%% This is `ksx1001.tex' written by koaunghi.un@student.uni-tuebingen.de.
%%
%% 이 파일은 Ω를 사용하여 KS X 1001 부호로 작성된 우리말 문서를 처리할 때
%% 필요한 환경 조성에 그 역할을 두고 있다.
%%
%% 저작권은 GNU General Public License에 준한다.
%%

\ProvidesFile{ksx1001.tex}[2000/02/15]

\ProcessOptions

\@namedef{ksx1001.tex}{\endinput}

%% 우리말 부호는 16진수로 ^^A1에서 ^^FE 범위에 있는 두 옥텟으로
%% 구성되며 이 범위의 모든 EUC 부호는 모두 평범한 글자 
%% (\catcode=11)로 처리된다.
\def\ksx@list{%
          \do\^^a1\do\^^a2\do\^^a3\do\^^a4\do\^^a5\do\^^a6\do\^^a7%
  \do\^^a8\do\^^a9\do\^^aa\do\^^ab\do\^^ac\do\^^ad\do\^^ae\do\^^af%
  \do\^^b0\do\^^b1\do\^^b2\do\^^b3\do\^^b4\do\^^b5\do\^^b6\do\^^b7%
  \do\^^b8\do\^^b9\do\^^ba\do\^^bb\do\^^bc\do\^^bd\do\^^be\do\^^bf%
  \do\^^c0\do\^^c1\do\^^c2\do\^^c3\do\^^c4\do\^^c5\do\^^c6\do\^^c7%
  \do\^^c8\do\^^c9\do\^^ca\do\^^cb\do\^^cc\do\^^cd\do\^^ce\do\^^cf%
  \do\^^d0\do\^^d1\do\^^d2\do\^^d3\do\^^d4\do\^^d5\do\^^d6\do\^^d7%
  \do\^^d8\do\^^d9\do\^^da\do\^^db\do\^^dc\do\^^dd\do\^^de\do\^^df%
  \do\^^e0\do\^^e1\do\^^e2\do\^^e3\do\^^e4\do\^^e5\do\^^e6\do\^^e7%
  \do\^^e8\do\^^e9\do\^^ea\do\^^eb\do\^^ec\do\^^ed\do\^^ee\do\^^ef%
  \do\^^f0\do\^^f1\do\^^f2\do\^^f3\do\^^f4\do\^^f5\do\^^f6\do\^^f7%
  \do\^^f8\do\^^f9\do\^^fa\do\^^fb\do\^^fc\do\^^fd\do\^^fe}
\def\do@ksxspecial#1{%
  \catcode`#1=11
  \lccode`#1=`#1
  \uccode`#1=`#1}
\let\do\do@ksxspecial\ksx@list

%% 조사 자동 처리 명령:
%%   \은/\는 \이/\가 \을/\를 \와/\과 \으로/\로 (\으로서/\로서 \으로써/\로써)
\DeclareRobustCommand*{\중@성}{\gdef\is@rieul{n}%
  \global\let\@조사\@firstoftwo}
\DeclareRobustCommand*{\종@성}{\gdef\is@rieul{n}%
  \global\let\@조사\@secondoftwo}
\DeclareRobustCommand*{\리@을}{\gdef\is@rieul{y}%
  \global\let\@조사\@secondoftwo}
\DeclareRobustCommand*{\ks@num}[1]{{\count@#1%
  \ifnum\count@<\z@ \count@-\count@ \fi\count2\count@
  \divide\count2 10 \multiply\count2 10 \advance\count@-\count2
  \ifcase\count@\종@성\or\리@을\or\중@성\or\종@성\or\중@성\or
  \중@성\or\종@성\or\리@을\or\리@을\or\중@성\fi}}
\def\은{\relax\@조사{는}{은}}
\let\는\은
\def\이{\relax\@조사{가}{이}}
\let\가\이
\def\을{\relax\@조사{를}{을}}
\let\를\을
\def\와{\relax\@조사{와}{과}}
\let\과\와
\def\로{\relax\if y\is@rieul\else\@조사{}{으}\fi 로}
\let\으로\로
\def\로서{\로 서}
\let\으로서\로서
\def\로써{\로 써}
\let\으로써\로써

\catcode`\^^^^e002=13
\catcode`\^^^^e003=13
\catcode`\^^^^e004=13
\let^^^^e002\중@성
\let^^^^e003\종@성
\let^^^^e004\리@을

%% 우리말 KS X 1001 부호(상징기호/한글/한자)와 영문자("00-"7F)는
%% "ksx1001.ocp"에서 유니코드로 변환된다.  이 때 각각의 글자들은
%% 앞에서 줄바꿈이 가능한 문자가 되고 글자 뒤에서는 이어지는 글자의
%% 줄바꿈 실행 여부를 정하게 된다.
\catcode`\^^^^e000=13
\catcode`\^^^^e001=13
\def^^^^e000{\ifhmode\ifnum\spacefactor=999\hskip\z@skip\fi\fi}
\def^^^^e001{\spacefactor=999\relax}
\ocp\KsxToUni=ksx1001
\ocplist\KsxToUniOCP=
\addbeforeocplist 1 \KsxToUni
\nullocplist
\pushocplist\KsxToUniOCP

%% Ω의 로고는 다음과 같이 정의한다.
\def\OMEGA{Ω}
\def\OTP{\OMEGA TP}

%% verbatim 환경에서 "! Missing number, treated as zero."의 착오를
%% 발생시키는 \unhbox 명령은 다음과 같이 해결한다.
\def\do@noligs#1{%
  \catcode`#1\active
  \begingroup
     \lccode`\~`#1\relax
     \lowercase{\endgroup\def~{\leavevmode\kern\z@{\clearocplists\char`#1}}}}

%% 우리말의 글자체 바꾸기:
%% -----------------------
%% 우리말의 글자체 가족은 "글자체 종류"에 따라 지정되고 글자체 바꿈
%% 모듬 명령은 "\text+글자체종류"나 "\글자체종류"로 형성된다.
%% 우리말 글자체 가족은 명조, 고딕, 타자의 세가지가 있고 다음과 같은
%% 등식이 성립한다. \rmfamily=\명조, \sffamily=\고딕, \ttfamily=\타자.
\DeclareRobustCommand\mjfamily
        {\not@math@alphabet\mjfamily\mathmj
         \fontfamily\mjdefault\selectfont}
\DeclareRobustCommand\gtfamily
        {\not@math@alphabet\gtfamily\mathgt
         \fontfamily\gtdefault\selectfont}
\DeclareRobustCommand\tzfamily
        {\not@math@alphabet\tzfamily\mathtz
         \fontfamily\tzdefault\selectfont\let^^^^e001\@}
\DeclareTextFontCommand{\textmj}{\mjfamily}
\DeclareTextFontCommand{\textgt}{\gtfamily}
\DeclareRobustCommand\texttz[1]{% \@italiccorr를 무자비하게 금지
  \ifmmode
    \nfss@text{\tzfamily#1}
  \else
    \leavevmode
    {\tzfamily#1}%
  \fi
}
\let\명조\mjfamily
\let\고딕\gtfamily
\let\타자\tzfamily

%% 영문의 글자체 바꿈 모듬 명령은 우리말 글자체 바꿈 명령과 일치시킨다.
\let\rmfamily\mjfamily
\let\sffamily\gtfamily
\let\ttfamily\tzfamily
\let\textrm\textmj
\let\textsf\textgt
\let\texttt\texttz

%% 편의상 다음과 같은 가족바꿈모듬명령도 제공된다. (그래픽, 궁서,
%% 필기, 외곽, 새명조, 목각, 옛글, 봄글씨 및 펜글씨)  이 모듬 명령들은
%% 없어질 잡동사니에 속하므로 되도록 쓰지 않도록 한다.
\def\그래픽{\fontfamily{gr}\selectfont}
\def\궁서{\fontfamily{gs}\selectfont}
\def\궁흘림{\fontfamily{gh}\selectfont}
\def\신문{\fontfamily{sh}\selectfont}
\def\필기{\fontfamily{pg}\selectfont}
\def\펜글씨{\fontfamily{pn}\selectfont}
\def\펜흘림{\fontfamily{ph}\selectfont}
\def\봄글씨{\fontfamily{bm}\selectfont}
\def\옛글{\fontfamily{yt}\selectfont}
\def\바다{\fontfamily{vd}\selectfont}
\def\자모명조{\fontfamily{jmj}\selectfont}
\def\자모고딕{\fontfamily{jgt}\selectfont}
\def\자모노벨{\fontfamily{jnv}\selectfont}
\def\자모소라{\fontfamily{jsr}\selectfont}
\let\목각\relax

%% 한글LaTeX 0.98판까지 사용되던 \새명조 명령들은 없앰므로써 사용을
%% 억제하고 자모 형태의 글자체 바꿈 명령들은 \fontfamily 로 선택하도록
%% 한다.
\DeclareTextFontCommand{\textgr}{\그래픽}
\DeclareTextFontCommand{\textgs}{\궁서}
\DeclareTextFontCommand{\textpg}{\필기}
\DeclareTextFontCommand{\textpn}{\펜글씨}
\DeclareTextFontCommand{\textph}{\펜흘림}
\DeclareTextFontCommand{\textbm}{\봄글씨}
\DeclareTextFontCommand{\textyt}{\옛글}

\let\textsm\textmj
\let\textmg\relax
\let\textol\relax

%% 호환성:
%% LaTeX을 쓸 때만 필요로 하는 명령들은 다음과 같이 대치시킨다.
\def\MapHangulFamily#1#2{\relax}
\DeclareRobustCommand\hfontfamily[1]{\fontfamily{#1}\selectfont\ignorespaces}
\let\make@josa\@gobble
\let\hbfdefault\bfdefault

%% LaTeX209식의 글자체 바꿈 모듬 명령은 기본 글자체만 제공한다.
\DeclareOldFontCommand{\mj}{\normalfont\mjfamily}{\@nomath\mj}
\DeclareOldFontCommand{\gt}{\normalfont\gtfamily}{\@nomath\gt}
\DeclareOldFontCommand{\tz}{\normalfont\tzfamily}{\@nomath\tz}

%% 우리말 글자체의 기본값은 다음과 같이 주어진다.
\def\mjdefault{mj}
\def\gtdefault{gt}
\def\tzdefault{tz}

\DeclareFontEncoding{UHC}{}{}
\DeclareErrorFont{UHC}{mj}{m}{n}{10}
\DeclareFontSubstitution{UHC}{mj}{m}{n}

\renewcommand{\encodingdefault}{UHC}
\renewcommand{\familydefault}{mj}
\renewcommand{\rmdefault}{mj}
\renewcommand{\sfdefault}{gt}
\renewcommand{\ttdefault}{tz}
\renewcommand{\bfdefault}{b}

%% ΩTP에 의해 문제를 일으키는 특수 문자들은 Ω의 번역 처리를 억제하고
%% OT1 부호화와 OMS 부호화에 의한 글자를 선택하도록 한다.
%% from ot1enc.def
\DeclareTextCommand{\textendash}{OT1}{{\clearocplists\char123}}
\DeclareTextCommand{\textquotedblleft}{OT1}{{\clearocplists\char92}}
\DeclareTextCommand{\AE}{OT1}{{\clearocplists\char29}}
\DeclareTextCommand{\OE}{OT1}{{\clearocplists\char30}}
\DeclareTextCommand{\O}{OT1}{{\clearocplists\char31}}
\DeclareTextCommand{\ae}{OT1}{{\clearocplists\char26}}
\DeclareTextCommand{\i}{OT1}{{\clearocplists\char16}}
\DeclareTextCommand{\j}{OT1}{{\clearocplists\char17}}
\DeclareTextCommand{\oe}{OT1}{{\clearocplists\char27}}
\DeclareTextCommand{\o}{OT1}{{\clearocplists\char28}}
\DeclareTextCommand{\ss}{OT1}{{\clearocplists\char25}}
\DeclareTextCommand{\textdollar}{OT1}{{\clearocplists%
   \ifdim \fontdimen\@ne\font >\z@
      \slshape
   \else
      \upshape
   \fi
   \char`\$}}
\DeclareTextCommand{\textsterling}{OT1}{{\clearocplists%
   \ifdim \fontdimen\@ne\font >\z@
      \itshape
   \else
      \fontshape{ui}\selectfont
   \fi
   \char`\$}}
\DeclareTextCompositeCommand{\r}{OT1}{A}
   {\leavevmode\setbox\z@\hbox{h}\dimen@\ht\z@\advance\dimen@-1ex%
    \rlap{\raise.67\dimen@\hbox{\clearocplists\char23}}A}
%% from omsenc.def
\DeclareTextCommand{\textcircled}{OMS}[1]{{\clearocplists%
   \ooalign{%
      \hfil \raise .07ex\hbox {\upshape#1}\hfil \crcr
      \char 13 % "0D
   }%
}}
\DeclareTextCommand{\textparagraph}{OMS}{{\clearocplists\char"7B}}
\DeclareTextCommand{\textperiodcentered}{UHC}{·}
% \DeclareTextCommand{\textperiodcentered}{OMS}{{\clearocplists\char"01}}
\DeclareTextCommand{\textasteriskcentered}{OMS}{{\clearocplists\char"03}}
\DeclareTextCommand{\textbullet}{OMS}{{\clearocplists\char"0F}}
%% from latex.ltx
\DeclareRobustCommand{\#}{{\clearocplists\char`\#}}
\DeclareRobustCommand{\%}{{\clearocplists\char`\%\relax}}
\DeclareRobustCommand{\&}{{\clearocplists\char`\&}}

%% hfont.sty은 여기서 끝난다.
\@nameuse{hfont.sty}

%% "한글LaTeX 길잡이"에 필요.
\begingroup
\def\gobble@zero#1{\expandafter\is@zero#1\relax}
\def\is@zero#1{\ifnum#1=0\relax\else#1\fi}
\def\d@t@#1/#2/#3\@nil{%
  \if@hanja #1年 \gobble@zero{#2}月 \gobble@zero{#3}日
  \else #1년 \gobble@zero{#2}월 \gobble@zero{#3}일\fi}
\xdef\HLaTeXdate{\expandafter\d@t@\HLaTeXdate\@nil}
\endgroup

%% 우리말문서 짜기
%% ---------------

%% 우리말 문서의 곳곳에서 사용될 이름들은 \ksnamedef 모듬으로 정의된다.
%%
%% 다른 꾸러미가 이 이름들을 다시 정하게 될 경우도 있으므로 아래의
%% 정의는 모든 꾸러미를 다 처리하고 난 후 \begin{document}가 나올 때
%% 효력을 갖도록 한다.  이런 이름들은 \begin{document} 앞에서
%% \renewcommand를 통해 변경할 수 있다.
\def\ksnamedef#1#2{\@namedef{#1}{#2}%
        \@namedef{ks#1}{\csname #1\endcsname}}  

\if@hanja
  \ksnamedef{today}{\number\year 年~\number\month 月~\number\day 日}
  \ksnamedef{enclname}{同封物}
  \ksnamedef{ccname}{寫本}% 사전에서
  \ksnamedef{headtoname}{受信人}%
  \ksnamedef{seename}{\을~參考}%
  \ksnamedef{contentsname}{目~次}% 錄}
  \ksnamedef{listfigurename}{그림~目次}% 錄}
  \ksnamedef{listtablename}{表~目次}% 錄}
  \ksnamedef{refname}{參考~文獻}% {參照~書籍}
  \ksnamedef{indexname}{索~引}
  \ksnamedef{tablename}{表}
  \ksnamedef{abstractname}{要~約}
  \ksnamedef{bibname}{著書~目錄}% 사전에서
  \ksnamedef{appendixname}{附錄}% 사전에서
  \ksnamedef{ksTHE}{第}
  \ksnamedef{partname}{篇}
  \ksnamedef{chaptername}{章}
  \ksnamedef{sectionname}{節}
  \ksnamedef{colorlayer}{幻燈版~色相}% 사전에서
  \ksnamedef{glossaryname}{語~彙}% 사전에서
\else
  \ksnamedef{today}{\number\year 년~\number\month 월~\number\day 일}
  \ksnamedef{enclname}{동봉물}
  \ksnamedef{ccname}{사본}%
  \ksnamedef{headtoname}{받는이}%
  \ksnamedef{seename}{\을~참고}% 조}%
  \ksnamedef{contentsname}{목~차}% 록}
  \ksnamedef{listfigurename}{그림~목차}% 록}
  \ksnamedef{listtablename}{표~목차}% 록}
  \ksnamedef{refname}{참고~문헌}% {참조~서적}
  \ksnamedef{indexname}{찾아보기}% 한자는 색~인
  \ksnamedef{tablename}{표}
  \ksnamedef{abstractname}{요~약}
  \ksnamedef{bibname}{저서~목록}% 사전에서
  \ksnamedef{appendixname}{부록}% 사전에서
  \ksnamedef{ksTHE}{제}%
  \ksnamedef{partname}{편}% 부
  \ksnamedef{chaptername}{장}%
  \ksnamedef{sectionname}{절}% 단락 - subsection 소단락
  \ksnamedef{colorlayer}{환등판~색깔}% 사전에서
  \ksnamedef{glossaryname}{용어~풀이}% 사전에서
\fi
\ksnamedef{pagename}{쪽}
\ksnamedef{figurename}{그림}

%% 단원의 한글화
%% =============
%%
%% 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~}{}
    \def\thesection{\@Alph\c@section}}%
}{\@ifundefined{@chapapp}{}{% <report|book>
    \renewcommand\thesection{\@arabic\c@section}
    \renewcommand\appendix{\par
      \setcounter{chapter}{0}%
      \setcounter{section}{0}%
      \renewcommand\@chapapp{\appendixname}%
      \kscntformat{chapter}{\appendixname~}{}
      \renewcommand\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}%
        \typeout{\pre@chaptercnt\thechapter\post@chaptercnt}%
        \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{\bfseries\pre@chaptercnt\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{%
        \pre@sectioncnt\thesection\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}}
}

\@ifclassloaded{article}{%
  \renewcommand*\l@section[2]{%
    \ifnum \c@tocdepth >\z@
      \addpenalty{\@secpenalty}%
      \addvspace{1.0em \@plus\p@}%
      \setbox\z@=\hbox{\bfseries\pre@sectioncnt\post@sectioncnt}
      \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
      \endgroup
    \fi}
}{\@ifundefined{l@section}{}{%
    \renewcommand*\l@section{\@dottedtocline{1}{1em}{4em}}}%1.5em 2.3em
}

%% 다음은 \ps@headings과 \ps@myheadings를 한글에 맞게 수정한 것이다.
%% 각각의 class들이 서로 다른 방식으로 페이지 머리를 짜므로 우리는
%% 여기서 각각을 따로따로 정의해 주어야 한다.
\@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
    \renewcommand\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
}{}

%% 우리말숫자
\def\jaso#1{\@jaso{\@nameuse{c@#1}}}
\def\@jaso#1{\ifcase#1\or ㄱ\or ㄴ\or ㄷ\or ㄹ\else\@ijaso{#1}\fi}
\def\@ijaso#1{\ifcase#1\or\or\or\or\or ㅁ\or ㅂ\or ㅅ\or ㅇ\or ㅈ\or
  ㅊ\or ㅋ\or ㅌ\or ㅍ\or ㅎ\else\@ctrerr\fi}
\def\gana#1{\@gana{\@nameuse{c@#1}}}
\def\@gana#1{\ifcase#1\or 가\or 나\or 다\or 라\else\@igana{#1}\fi}
\def\@igana#1{\ifcase#1\or\or\or\or\or 마\or 바\or 사\or 아\or 자\or
  차\or 카\or 타\or 파\or 하\else\@ctrerr\fi}
\def\ojaso#1{\@ojaso{\@nameuse{c@#1}}}
\def\@ojaso#1{\ifcase#1\or ㉠\or ㉡\or ㉢\or ㉣\else\@iojaso{#1}\fi}
\def\@iojaso#1{\ifcase#1\or\or\or\or\or ㉤\or ㉥\or ㉦\or ㉧\or ㉨\or
  ㉩\or ㉪\or ㉫\or ㉬\or ㉭\else\@ctrerr\fi}
\def\ogana#1{\@ogana{\@nameuse{c@#1}}}
\def\@ogana#1{\ifcase#1\or ㉮\or ㉯\or ㉰\or ㉱\else\@iogana{#1}\fi}
\def\@iogana#1{\ifcase#1\or\or\or\or\or ㉲\or ㉳\or ㉴\or ㉵\or ㉶\or
  ㉷\or ㉸\or ㉹\or ㉺\or ㉻\else\@ctrerr\fi}
\def\pjaso#1{\@pjaso{\@nameuse{c@#1}}}
\def\@pjaso#1{\ifcase#1\or ㈀\or ㈁\or ㈂\or ㈃\else\@ipjaso{#1}\fi}
\def\@ipjaso#1{\ifcase#1\or\or\or\or\or ㈄\or ㈅\or ㈆\or ㈇\or ㈈\or
  ㈉\or ㈊\or ㈋\or ㈌\or ㈍\else\@ctrerr\fi}
\def\pgana#1{\@pgana{\@nameuse{c@#1}}}
\def\@pgana#1{\ifcase#1\or ㈎\or ㈏\or ㈐\or ㈑\else\@ipgana{#1}\fi}
\def\@ipgana#1{\ifcase#1\or\or\or\or\or ㈒\or ㈓\or ㈔\or ㈕\or ㈖\or
  ㈗\or ㈘\or ㈙\or ㈚\or ㈛\else\@ctrerr\fi}
\def\onum#1{\@onum{\@nameuse{c@#1}}}
\def\@onum#1{\ifcase#1\or ①\or ②\or ③\or ④\else\@ionum{#1}\fi}
\def\@ionum#1{\ifcase#1\or\or\or\or\or ⑤\or ⑥\or ⑦\or ⑧\or ⑨\or
  ⑩\or ⑪\or ⑫\or ⑬\or ⑭\or ⑮\else\@ctrerr\fi}
\def\pnum#1{\@pnum{\@nameuse{c@#1}}}
\def\@pnum#1{\ifcase#1\or ⑴\or ⑵\or ⑶\or ⑷\else\@ipnum{#1}\fi}
\def\@ipnum#1{\ifcase#1\or\or\or\or\or ⑸\or ⑹\or ⑺\or ⑻\or ⑼\or
  ⑽\or ⑾\or ⑿\or ⒀\or ⒁\or ⒂\else\@ctrerr\fi}
\def\oeng#1{\@oeng{\@nameuse{c@#1}}}
\def\@oeng#1{\ifcase#1\or ⓐ\or ⓑ\or ⓒ\or ⓓ\else\@ioeng{#1}\fi}
\def\@ioeng#1{\ifcase#1\or\or\or\or\or ⓔ\or ⓕ\or ⓖ\or ⓗ\or ⓘ\or
  ⓙ\or ⓚ\or ⓛ\or ⓜ\or ⓝ\or ⓞ\or ⓟ\or ⓠ\or ⓡ\or ⓢ\or ⓣ\or
  ⓤ\or ⓥ\or ⓦ\or ⓧ\or ⓨ\or ⓩ\else\@ctrerr\fi}
\def\peng#1{\@peng{\@nameuse{c@#1}}}
\def\@peng#1{\ifcase#1\or ⒜\or ⒝\or ⒞\or ⒟\else\@ipeng{#1}\fi}
\def\@ipeng#1{\ifcase#1\or\or\or\or\or ⒠\or ⒡\or ⒢\or ⒣\or ⒤\or
  ⒥\or ⒦\or ⒧\or ⒨\or ⒩\or ⒪\or ⒫\or ⒬\or ⒭\or ⒮\or ⒯\or
  ⒰\or ⒱\or ⒲\or ⒳\or ⒴\or ⒵\else\@ctrerr\fi}
\def\hnum#1{\@hnum{\@nameuse{c@#1}}}
\def\@hnum#1{\ifcase#1\or 하나\or 둘\or 셋\or 넷\or\@ihnum{#1}\fi}
\def\@ihnum#1{\ifcase#1\or\or\or\or\or 다섯\or 여섯\or 일곱\or 여덟\or
  아홉\or 열\or 열하나\or 열둘\or 열셋\or 열넷\or 열다섯\or 열여섯\or
  열일곱\or 열여덟\or 열아홉\or 스물\or 스물하나\or 스물둘\or
  스물셋\or 스물넷\else\@ctrerr\fi}
\def\Hnum#1{\@Hnum{\@nameuse{c@#1}}}
\def\@Hnum#1{\ifcase#1\or 첫\or 둘\or 세\or 네\or\@iHnum{#1}\fi 째}
\def\@iHnum#1{\ifcase#1\or\or\or\or\or 다섯\or 여섯\or 일곱\or 여덟\or
  아홉\or 열\or 열하나\or 열둘\or 열셋\or 열넷\or 열다섯\or 열여섯\or
  열일곱\or 열여덟\or 열아홉\or 스물\or 스물하나\or 스물둘\or 스물셋\or
  스물넷\else\@ctrerr\fi}

%% 색인작성시 makeidx.sty을 쓰면 \see가 정의된다.
\@ifundefined{see}{}{%
  \AtBeginDocument{%
    \renewcommand*\see[2]{#1\emph{\make@josa{#1}\seename}}}
}

%% hind.ist를 사용하여 색인을 작성할 때, 다음의 모듬명령은 우리말의
%% 자소 집단을 알맞게 분리한다.
\begingroup
\if@hanja\gdef\hj@head{漢字}\else\gdef\hj@head{한자}\fi
\gdef\KSitem #1\endKS{\@tempcnta\expandafter`\@car#1\@nil\relax
  \ifnum\@tempcnta>"0A0
    \ifnum\@tempcnta<"0B0\let\hitem\item
      \expandafter\ifx\csname I|4\endcsname\relax
        \indexspace\hindexhead{심벌}\nopagebreak
        \global\expandafter\let\csname I|4\endcsname\@empty\fi
    \else\ifnum\@tempcnta<"0CA\advance\@tempcnta-"0B0
      \gdef\hitem{\@ifnextchar#1{\@nameuse{I-\number\@tempcnta}}%
        {\def\reserved@f{#1}\expandafter\KS@item}}
    \else\let\hitem\item
      \expandafter\ifx\csname I|5\endcsname\relax
        \indexspace\hindexhead{\hj@head}\nopagebreak
        \global\expandafter\let\csname I|5\endcsname\@empty\fi\fi\fi
  \else\indexspace\hindexhead{#1}\nopagebreak\fi}
\gdef\KS@item#1#2{%
  \expandafter\ifx\reserved@f#1%
    \@tempcnta`#1\advance\@tempcnta-"0B0
    \@nameuse{I-\number\@tempcnta} #1#2%
  \else\ifx\protect#1\expandafter\KS@item#2
  \else\item #1#2\fi\fi}
\gdef\hindexhead#1{【{\bfseries#1}】\hfil}
\def\^^a0#1#2{\count@`#1\advance\count@-"0B0
  \@tempcnta`#2\advance\@tempcnta-"0A1
  \expandafter\xdef\csname I-\number\count@\endcsname ##1##2{%
    \noexpand\expandafter\noexpand\ifx\noexpand\csname
    I|\number\@tempcnta\noexpand\endcsname\relax
      \noexpand\indexspace\noexpand\hindexhead{\noexpand ^^a4\noexpand#2}
      \noexpand\nopagebreak 
      \noexpand\global\noexpand\expandafter\let\noexpand\csname
      I|\number\@tempcnta\noexpand\endcsname\noexpand\@empty
    \noexpand\fi
    \noexpand\item ##1##2}}
\def\^^ff#1#2#3#4{\count@`#1\advance\count@-"0B0
  \@tempcnta`#3\advance\@tempcnta-"0A1\@tempcntb\@tempcnta
  \ifnum\@tempcnta=1\advance\@tempcntb2\else
  \ifnum\@tempcnta=3\advance\@tempcntb3\else
  \ifnum\@tempcnta=8\advance\@tempcntb8\else
  \ifnum\@tempcnta=18\advance\@tempcntb2
  \else\advance\@tempcntb1\fi\fi\fi\fi
  \expandafter\xdef\csname I-\number\count@\endcsname ##1##2{%
    \noexpand\ifnum`##2<#2
      \noexpand\expandafter\noexpand\ifx\noexpand\csname
      I|\number\@tempcnta\noexpand\endcsname\relax
        \noexpand\indexspace\noexpand\hindexhead{\noexpand ^^a4\noexpand#3}
        \noexpand\nopagebreak
        \noexpand\global\noexpand\expandafter\let\noexpand\csname
        I|\number\@tempcnta\noexpand\endcsname\noexpand\@empty
      \noexpand\fi
    \noexpand\else
      \noexpand\expandafter\noexpand\ifx\noexpand\csname
      I|\number\@tempcntb\noexpand\endcsname\relax
        \noexpand\indexspace\noexpand\hindexhead{\noexpand ^^a4\noexpand#4}
        \noexpand\nopagebreak
        \noexpand\global\noexpand\expandafter\let\noexpand\csname
        I|\number\@tempcntb\noexpand\endcsname\noexpand\@empty
      \noexpand\fi
    \noexpand\fi
    \noexpand\item ##1##2}}
\^^a0{^^b0}{^^a1}             \^^ff{^^b1}{"0EE}{^^a1}{^^a2}
\^^a0{^^b2}{^^a2}             \^^ff{^^b3}{"0AA}{^^a2}{^^a4}
\^^ff{^^b4}{"0D9}{^^a4}{^^a7} \^^ff{^^b5}{"0FB}{^^a7}{^^a8}
\^^ff{^^b6}{"0F3}{^^a8}{^^a9} \^^a0{^^b7}{^^a9}
\^^ff{^^b8}{"0B6}{^^a9}{^^b1} \^^ff{^^b9}{"0D9}{^^b1}{^^b2}
\^^ff{^^ba}{"0FC}{^^b2}{^^b3} \^^ff{^^bb}{"0E7}{^^b3}{^^b5}
\^^a0{^^bc}{^^b5}             \^^ff{^^bd}{"0CE}{^^b5}{^^b6}
\^^ff{^^be}{"0C6}{^^b6}{^^b7} \^^a0{^^bf}{^^b7}
\^^ff{^^c0}{"0DA}{^^b7}{^^b8} \^^a0{^^c1}{^^b8}
\expandafter\gdef\csname I-18\endcsname #1#2{%
  \ifnum`#2<"0A5
    \expandafter\ifx\csname I|23\endcsname\relax
      \indexspace\hindexhead{ㅈ}\nopagebreak
      \global\expandafter\let\csname I|23\endcsname\@empty
    \fi
  \else\ifnum`#2<"0F7
    \expandafter\ifx\csname I|24\endcsname\relax
      \indexspace\hindexhead{ㅉ}\nopagebreak
      \global\expandafter\let\csname I|24\endcsname\@empty
    \fi
  \else
    \expandafter\ifx\csname I|25\endcsname\relax
      \indexspace\hindexhead{ㅊ}\nopagebreak
      \global\expandafter\let\csname I|25\endcsname\@empty
    \fi
  \fi\fi
  \item #1#2}
\^^a0{^^c3}{^^ba}             \^^ff{^^c4}{"0AB}{^^ba}{^^bb}
\^^ff{^^c5}{"0B8}{^^bb}{^^bc} \^^ff{^^c6}{"0C4}{^^bc}{^^bd}
\^^ff{^^c7}{"0CF}{^^bd}{^^be} \^^a0{^^c8}{^^be}
\endgroup

%% 어휘집을 만들 때 다음과 같은 환경의 정의가 필요하다.
\let\gloitem\@idxitem
\def\glopage{\hfill}
\newenvironment{theglossary}
               {\if@twocolumn
                  \@restonecolfalse
                \else
                  \@restonecoltrue
                \fi
                \columnseprule \z@
                \columnsep 35\p@
                \twocolumn[\section*{\glossaryname}]%
                \@mkboth{\MakeUppercase{\glossaryname}}%
                        {\MakeUppercase{\glossaryname}}%
                \thispagestyle{plain}\parindent\z@
                \parskip\z@ \@plus .3\p@\relax
                \let\item\gloitem}
               {\if@restonecol\onecolumn\else\clearpage\fi}
\newcommand\printglossary{\@input@{\jobname.gls}}

%% 한글LaTeX의 logo는 이렇게.
\DeclareRobustCommand{\HLaTeX}{한\kern-.4ex\lower.3ex\hbox{글}\kern-.4ex\LaTeX}

%%% End of file `ksx1001.tex'.
