%%% file `kosections-euc.sty` ( a part of ko.TeX )
%%
%% (C) Copyright 2007 Koaunghi Un <koaunghi@kornet.net>
%%                    Dohyun Kim  <nomos@ktug.or.kr>
%%                    Kangsoo Kim <karnes@ktug.or.kr>
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%  http://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of LaTeX
%% version 2006/05/20 or later.
%%
%% Read LICENSE included in the package.
%%
%% �ܿ��� �ѱ�ȭ
%% =============
%%
%% Part I       --> �� I ��, � I ��
%% Chapter 1    --> �� 1 ��, � 1 ��   <book,report>
%% Section 1    --> �� 1 ��, � 1 �
%% Appendix A   --> �η�  A, ݾ��  A
%%
%% ���� ���� �ܿ��� �ѱ�ȭ�� ��(�)���� ������ ��ģ��. �׷��Ƿ� �츮��
%% ������ \subsubsection���� �ܿ��� ��ȣ�� �Բ� �������� �Ѵ�.
%% article������ �̹� 3���� �����Ǿ�����, �׿ܿ����� 2�� �����Ǿ�
%% \subsection������ ��ȣ�� ������ �������� �Ǿ� �ִ�.
\setcounter{secnumdepth}{\thr@@}

\@ifclassloaded{article}{% <article>
  \renewcommand{\appendix}{\par
    \setcounter{section}{0}%
    \setcounter{subsection}{0}%
    \def\@chapapp{\appendixname}% �η��� �ѱ�ȭ�� ���� �ʿ�.
    \kscntformat{section}{\appendixname~}{}
    \gdef\thesection{\@Alph\c@section}}%
}{\@ifundefined{@chapapp}{}{% <report|book>
    \renewcommand\thesection{\@arabic\c@section}
    \renewcommand\appendix{\par
      \setcounter{chapter}{0}%
      \setcounter{section}{0}%
      \gdef\@chapapp{\appendixname}%
      \kscntformat{chapter}{\appendixname~}{}
      \gdef\thechapter{\@Alph\c@chapter}}%
}}

%% ���Ͱ��� �����Ƿ� ������ ���� ������ �߻��Ѵ�.
%% 1. \part�� \partname~\thepart�� ������ �ȴ�. ��~I
%% 2. \chapter�� \@chapapp{} \thechapter��. ��~1
%% 3. \section�� \sectionname~\thesection����. ��~1
%% 4. �����ۼ��� �鿩���Ⱑ �츮�� ȯ�濡 �������� �ʴ�.
%% 5. ������ heading�� ����ü�� \slshape���� �ٲ����μ� �츮����
%%    �Ҿ���������.
%%
%% �̷� ������ �����ϱ� ���� �ܿ��� �Ϸù�ȣ�� �հ� �ڿ� ��������
%% ����� ������ ���� �����Ѵ�.
\def\kscntformat#1#2#3{\@namedef{pre@#1cnt}{#2}
                       \@namedef{post@#1cnt}{#3}}
\kscntformat{part}{\ksTHE~}{~\partname}
\kscntformat{chapter}{\ksTHE~}{~\chaptername}
\kscntformat{section}{\ksTHE~}{~\sectionname}

\@ifclassloaded{article}{% <article>
  \def\@part[#1]#2{%
    \ifnum \c@secnumdepth >\m@ne
      \refstepcounter{part}%
      \addcontentsline{toc}{part}%
        {\pre@partcnt\thepart\post@partcnt\hspace{1em}#1}%
    \else
      \addcontentsline{toc}{part}{#1}%
    \fi
    {\parindent \z@ \raggedright
     \interlinepenalty \@M
     \normalfont
     \ifnum \c@secnumdepth >\m@ne
       \Large\bfseries \pre@partcnt\thepart\post@partcnt
       \par\nobreak
     \fi
     \huge \bfseries #2%
     \markboth{}{}\par}%
   \nobreak
   \vskip 3ex
   \@afterheading}
}{% <report|book>
  \@ifundefined{@part}{}{%
    \def\@part[#1]#2{%
      \ifnum \c@secnumdepth >-2\relax
        \refstepcounter{part}%
        \addcontentsline{toc}{part}%
          {\pre@partcnt\thepart\post@partcnt\hspace{1em}#1}%
      \else
        \addcontentsline{toc}{part}{#1}%
      \fi
      \markboth{}{}%
      {\centering
       \interlinepenalty \@M
       \normalfont
       \ifnum \c@secnumdepth >-2\relax
         \huge\bfseries \pre@partcnt\thepart\post@partcnt
         \par
         \vskip 20\p@
       \fi
       \Huge \bfseries #2\par}%
     \@endpart}
  }
}

\@ifclassloaded{book}{%
  \def\@chapter[#1]#2{%
    \ifnum \c@secnumdepth >\m@ne
      \if@mainmatter
        \refstepcounter{chapter}%
        \begingroup
        \let\protect\string
        \edef\reserved@a{\pre@chaptercnt\thechapter\post@chaptercnt}
        \typeout{\expandafter\strip@prefix\meaning\reserved@a}%
        \endgroup
        \addcontentsline{toc}{chapter}%
          {\protect\numberline{%
             \pre@chaptercnt\thechapter\post@chaptercnt}#1}%
      \else
        \addcontentsline{toc}{chapter}{#1}%
      \fi
    \else
      \addcontentsline{toc}{chapter}{#1}%
    \fi
    \chaptermark{#1}%
    \addtocontents{lof}{\protect\addvspace{10\p@}}%
    \addtocontents{lot}{\protect\addvspace{10\p@}}%
    \if@twocolumn
      \@topnewpage[\@makechapterhead{#2}]%
    \else
      \@makechapterhead{#2}%
      \@afterheading
    \fi}
  \def\@makechapterhead#1{%
    \vspace*{50\p@}%
    {\parindent \z@ \raggedright \normalfont
     \ifnum \c@secnumdepth >\m@ne
       \if@mainmatter
         \huge\bfseries
         \pre@chaptercnt\thechapter\post@chaptercnt
         \par\nobreak
         \vskip 20\p@
       \fi
     \fi
     \interlinepenalty\@M
     \Huge \bfseries #1\par\nobreak
     \vskip 40\p@
     }}}{}%
\@ifclassloaded{report}{%
  \def\@chapter[#1]#2{%
    \ifnum \c@secnumdepth >\m@ne
      \refstepcounter{chapter}%
      \typeout{\pre@chaptercnt\thechapter\post@chaptercnt}
      \addcontentsline{toc}{chapter}%
        {\protect\numberline{%
           \pre@chaptercnt\thechapter\post@chaptercnt}#1}%
    \else
      \addcontentsline{toc}{chapter}{#1}%
    \fi
    \chaptermark{#1}%
    \addtocontents{lof}{\protect\addvspace{10\p@}}%
    \addtocontents{lot}{\protect\addvspace{10\p@}}%
    \if@twocolumn
      \@topnewpage[\@makechapterhead{#2}]%
    \else
      \@makechapterhead{#2}%
      \@afterheading
    \fi}
  \def\@makechapterhead#1{%
    \vspace*{50\p@}%
    {\parindent \z@ \raggedright \normalfont
      \ifnum \c@secnumdepth >\m@ne
        \huge\bfseries
        \pre@chaptercnt\thechapter\post@chaptercnt
        \par\nobreak
        \vskip 20\p@
      \fi
      \interlinepenalty\@M
      \Huge \bfseries #1\par\nobreak
      \vskip 40\p@
    }}}{}

\@ifundefined{chapter}{}{%
  \renewcommand*\l@chapter[2]{%
    \ifnum \c@tocdepth >\m@ne
      \addpenalty{-\@highpenalty}%
      \vskip 1.0em \@plus\p@%
      \setbox\z@=\hbox{\c@chapter=1\relax\bfseries\pre@chaptercnt\thechapter\post@chaptercnt~}
      \setlength\@tempdima{1.5em}
      \advance\@tempdima\wd\z@
      \begingroup
        \parindent \z@ \rightskip \@pnumwidth
        \parfillskip -\@pnumwidth
        \leavevmode \bfseries
        \advance\leftskip \@tempdima
        \hskip -\leftskip
        #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
        \penalty\@highpenalty
      \endgroup
    \fi}}

\@ifundefined{section}{}{%
  \def\section{%
    \if@noskipsec \leavevmode \fi
    \par
    \@afterindentfalse
    \if@nobreak
      \everypar{}%
    \else
      \addpenalty\@secpenalty\addvspace{3.5ex \@plus 1ex \@minus .2ex\relax}
    \fi
    \secdef\ks@sect\ks@ssect}
  \def\ks@sect[#1]#2{%
    \ifnum \c@secnumdepth<1
      \let\@svsec\@empty
    \else
      \refstepcounter{section}%
      \protected@edef\@svsec{%
        \noexpand\pre@sectioncnt\thesection\noexpand\post@sectioncnt
        \quad\relax}%
    \fi
    \begingroup
      \normalfont\Large\bfseries{%
        \@hangfrom{\hskip \z@\relax\@svsec}%
        \interlinepenalty \@M #2\@@par}%
    \endgroup
    \sectionmark{#1}%
    \addcontentsline{toc}{section}{%
      \ifnum\c@secnumdepth<1 \else
        \protect\numberline{\pre@sectioncnt\thesection\post@sectioncnt}%
      \fi
      #1}
    \@xsect{2.3ex \@plus.2ex}}
  \def\ks@ssect#1{%
    \begingroup
      \normalfont\Large\bfseries{%
        \@hangfrom{\hskip \z@}%
        \interlinepenalty \@M #1\@@par}%
    \endgroup
    \@xsect{2.3ex \@plus.2ex}}
}

\def\@startsection#1#2#3#4#5#6{%
  \if@noskipsec \leavevmode \fi
  \par
  \@tempskipa #4\relax
  \@afterindenttrue
  \ifdim \@tempskipa <\z@
    \@tempskipa -\@tempskipa \@afterindentfalse
  \fi
  \if@nobreak
    \everypar{}%
  \else
    \addpenalty\@secpenalty\addvspace\@tempskipa
  \fi
  \@ifstar
    {\@ssect{#3}{#4}{#5}{#6}}%
    {\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}}

\@ifclassloaded{article}{%
  \renewcommand*\l@section[2]{%
    \ifnum \c@tocdepth >\z@
      \addpenalty{\@secpenalty}%
      \addvspace{1.0em \@plus\p@}%
      \settowidth{\@tempdima}{\bfseries\pre@sectioncnt\post@sectioncnt}
      \addtolength{\@tempdima}{1.5em}
      \begingroup
        \parindent \z@ \rightskip \@pnumwidth
        \parfillskip -\@pnumwidth
        \leavevmode \bfseries
        \advance\leftskip\@tempdima
        \hskip -\leftskip
        #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
      \endgroup
    \fi}
}{\@ifundefined{l@section}{}{%
    \renewcommand*\l@section{%
      \settowidth{\@tempdima}{\bfseries\pre@sectioncnt\post@sectioncnt}
      \addtolength{\@tempdima}{2.3em}
      \@dottedtocline{1}{1em}{\@tempdima}}}%1.5em 2.3em
}

%% ������ \ps@headings�� \ps@myheadings�� �ѱۿ� �°� ������ ���̴�.
%% ������ class���� ���� �ٸ��� �� �Ӹ��� ���� ¥�Ƿ� �츮��
%% ���⼭ ������ ���ε��� ������ �־�� �Ѵ�.
%% \LaTeXe�� ���� ���Ե� \MakeUpperCase�� 8��Ʈ ���ڸ� ����
%% iso-latin�� ���� �ٸ� �ٷ��̸� ����� �� �����ϴ�. -- ����
%% ��-�����̹Ƿ� �ܼ��� \uppercase�� ��ġ�Ѵ�.
\DeclareRobustCommand{\MakeUppercase}[1]{\uppercase{#1}}
\DeclareRobustCommand{\MakeLowercase}[1]{\lowercase{#1}}

\@ifclassloaded{article}{%
  \if@twoside
    \renewcommand\ps@headings{%
      \let\@oddfoot\@empty\let\@evenfoot\@empty
      \def\@evenhead{\thepage\hfil\slshape\leftmark}%
      \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
      \let\@mkboth\markboth
      \def\sectionmark##1{%
        \markboth {\MakeUppercase{%
          \ifnum \c@secnumdepth >\z@
            \pre@sectioncnt\thesection\post@sectioncnt\quad
          \fi
          ##1}}{}}%
      \def\subsectionmark##1{%
        \markright {%
          \ifnum \c@secnumdepth >\@ne
            \thesubsection\quad
          \fi
          ##1}}}
  \else
    \def\ps@headings{%
      \let\@oddfoot\@empty
      \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
      \let\@mkboth\markboth
      \def\sectionmark##1{%
        \markright {\MakeUppercase{%
          \ifnum \c@secnumdepth >\m@ne
            \pre@sectioncnt\thesection\post@sectioncnt\quad
          \fi
          ##1}}}}
  \fi
}{}

\@ifclassloaded{book}{%
  \if@twoside
    \def\ps@headings{%
      \let\@oddfoot\@empty\let\@evenfoot\@empty
      \def\@evenhead{\thepage\hfil\slshape\leftmark}%
      \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
      \let\@mkboth\markboth
      \def\chaptermark##1{%
        \markboth {\MakeUppercase{%
            \ifnum \c@secnumdepth >\m@ne
              \if@mainmatter
                 \pre@chaptercnt\thechapter\post@chaptercnt\quad%
              \fi
            \fi
            ##1}}{}}%
      \def\sectionmark##1{%
        \markright {\MakeUppercase{%
            \ifnum \c@secnumdepth >\z@
              \pre@sectioncnt\thesection\post@sectioncnt\quad%
            \fi
            ##1}}}}
  \else
    \def\ps@headings{%
      \let\@oddfoot\@empty
      \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
      \let\@mkboth\markboth
      \def\chaptermark##1{%
        \markright {\MakeUppercase{%
          \ifnum \c@secnumdepth >\m@ne
            \if@mainmatter
              \pre@chaptercnt\thechapter\post@chaptercnt\quad%
            \fi
          \fi
          ##1}}}}
  \fi
  \pagestyle{headings}
  }{}

\@ifclassloaded{report}{%
  \if@twoside
    \def\ps@headings{%
      \let\@oddfoot\@empty\let\@evenfoot\@empty
      \def\@evenhead{\thepage\hfil\slshape\leftmark}%
      \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
      \let\@mkboth\markboth
      \def\chaptermark##1{%
        \markboth {\MakeUppercase{%
          \ifnum \c@secnumdepth >\m@ne
            \pre@chaptercnt\thechapter\post@chaptercnt\quad%
          \fi
          ##1}}{}}%
      \def\sectionmark##1{%
        \markright {\MakeUppercase{%
          \ifnum \c@secnumdepth >\z@
            \pre@sectioncnt\thesection\post@sectioncnt\quad%
          \fi
          ##1}}}}
  \else
    \def\ps@headings{%
      \let\@oddfoot\@empty
      \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
      \let\@mkboth\markboth
      \def\chaptermark##1{%
        \markright {\MakeUppercase{%
          \ifnum \c@secnumdepth >\m@ne
            \pre@chaptercnt\thechapter\post@chaptercnt\quad%
          \fi
          ##1}}}}
  \fi
}{}

%% �����ۼ��� makeidx.sty�� ���� \see�� \seealso�� ���ǵȴ�.
\AtBeginDocument{%
  \@ifundefined{see}{}{%
    \renewcommand*\see[2]{#1\emph{\seename}}
    \providecommand*\seealso[2]{#1\emph{\alsoname}}}
}

%% �ѱ�LaTeX�� logo�� �̷���.
\DeclareRobustCommand{\HLaTeX}{��\kern-.4ex\lower.3ex\hbox{��}\kern-.4ex\LaTeX}

%% \LaTeX�� �ѱ�ȭ:
%% ----------------
%% suppress this part. 2007/11/29. karnes.
%%% From File: ltbibl.dtx
%\def\@lbibitem[#1]#2{\item[\@biblabel{#1}\hfill]\if@filesw
%      {\let\protect\noexpand
%       \immediate
%       \write\@auxout{\string\bibcite{#2}%
%        {#1}}}\fi\ignorespaces}
%\def\@bibitem#1{\item\if@filesw
%       {\let\protect\noexpand\immediate\write\@auxout
%        {\string\bibcite{#1}{\the\value{\@listctr}%
%         \string\ks@num{\the\value{\@listctr}}}}}\fi\ignorespaces}
%\def\bibcite{\let\protect\string\@newl@bel b}
%\def\@citex[#1]#2{\let\protect\string%
%  \let\@citea\@empty
%  \@cite{\@for\@citeb:=#2\do
%    {\@citea\def\@citea{,\penalty\@m\ }%
%     \edef\@citeb{\expandafter\@firstofone\@citeb\@empty}%
%     \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
%     \let\protect\@typeset@protect
%     \@ifundefined{b@\@citeb}{\mbox{\reset@font\bfseries ?}%
%       \G@refundefinedtrue
%       \@latex@warning
%         {Citation `\@citeb' on page \thepage \space undefined}}%
%       {\@cite@ofmt{\csname b@\@citeb\endcsname}}}}{#1}
%       \let\protect\@typeset@protect}
%\def\nocite#1{\@bsphack\let\protect\string%
%  \@for\@citeb:=#1\do{%
%    \edef\@citeb{\expandafter\@firstofone\@citeb\@empty}%
%    \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
%    \let\protect\relax
%    \@ifundefined{b@\@citeb}{\G@refundefinedtrue
%        \@latex@warning{Citation `\@citeb' undefined}}{}}%
%  \@esphack}

\endinput
