\def\filedate{2005/04/22}
\def\fileversion{1.0.1}

\ProvidesPackage{hangul}[\filedate\space Document Package for 한글LaTeX]
\typeout{한글 문서 꾸러미 `\filename' <\filedate>.}

%% 추가 선택 처리
%% --------------
%%%% 추가 선택 "hanja"는 단원의 이름들을 한자로 표시한다.
\newif\if@hanja\@hanjafalse
\DeclareOption{hanja}{\@hanjatrue}

%% 용지 규격
\DeclareOption{국반판}{%국반판(105x148)<105x148>
  \setlength\paperheight{148mm}
  \setlength\paperwidth {105mm}
  \@resetpapersize
}
\DeclareOption{국판}{%국판(148x210)<148x210>
  \setlength\paperheight{210mm}
  \setlength\paperwidth {148mm}
  \@resetpapersize
}
\DeclareOption{신국판}{%상하=20/25, 좌우=22.5/22.5,머리꼬리=0/0
  \setlength\paperheight{225mm}
  \setlength\paperwidth {152mm}
  \@resetpapersize
}
\DeclareOption{국배판}{%국배판(210x297)<210x297>
  \setlength\paperheight{297mm}
  \setlength\paperwidth {210mm}
  \@resetpapersize
}
\DeclareOption{사륙판}{%사륙판(128x188)<128x182>
  \setlength\paperheight{182mm}
  \setlength\paperwidth {128mm}
  \@resetpapersize
}
\DeclareOption{사륙배판}{%상하=25/30, 좌우=30/30 머리꼬리=15/0
  \setlength\paperheight{257mm}
  \setlength\paperwidth {182mm}
  \@resetpapersize
}
\DeclareOption{크라운판}{%크라운판(176x248)<176x248>
  \setlength\paperheight{248mm}
  \setlength\paperwidth {176mm}
  \@resetpapersize
}
\DeclareOption{신서판}{%신서판(삼륙판)(103x182)<103x182>
  \setlength\paperheight{182mm}
  \setlength\paperwidth {103mm}
  \@resetpapersize
}
\DeclareOption{삼륙판}{%삼륙판
  \setlength\paperheight{182mm}
  \setlength\paperwidth {103mm}
  \@resetpapersize
}
\DeclareOption{타블로이드판}{%<타블로이드>
  \setlength\paperheight{364mm}
  \setlength\paperwidth {257mm}
  \@resetpapersize
}
\DeclareOption{사륙반판}{%사륙반판%
  \setlength\paperheight{128mm}
  \setlength\paperwidth {94mm}
  \@resetpapersize
}
\DeclareOption{사륙배배판}{%사륙배배판
  \setlength\paperheight{374mm}
  \setlength\paperwidth {254mm}
  \@resetpapersize
}
\DeclareOption{대국전판}{%대국전판
  \setlength\paperheight{244mm}
  \setlength\paperwidth {172mm}
  \@resetpapersize
}
\DeclareOption{삼십절판}{%삼십절판
  \setlength\paperheight{205mm}
  \setlength\paperwidth {125mm}
  \@resetpapersize
}
\DeclareOption{삼오판}{%삼오판
  \setlength\paperheight{148mm}
  \setlength\paperwidth {84mm}
  \@resetpapersize
}
\def\@resetpapersize{
  \setlength\@tempdima{\paperwidth}
  \divide\@tempdima by9
  \if@twoside
    %% 제본 여백: 0.3\@tempdima
    \setlength\oddsidemargin{1.3\@tempdima}
    \setlength\evensidemargin{1.7\@tempdima}
  \else
    \setlength\oddsidemargin{1.5\@tempdima}
    \setlength\evensidemargin{1.5\@tempdima}
  \fi
  \setlength\marginparwidth{\evensidemargin}
  \addtolength{\marginparwidth}{-3\marginparsep}
  \setlength\textwidth{\paperwidth}
  \addtolength\textwidth{-3\@tempdima}
  \addtolength\oddsidemargin{-1in}
  \addtolength\evensidemargin{-1in}
  \setlength\topmargin{\paperheight}
  \divide\topmargin by9
  \setlength\headheight{12\p@}
%  \setlength\headsep{14.65pt}
  \setlength\headsep{25\p@}
  \addtolength\topmargin{-\headheight}
  \addtolength\topmargin{-\headsep}
  \setlength\textheight{\paperheight}
  \addtolength\textheight{-2\topmargin}
  \addtolength\textheight{-\headheight}
  \addtolength\textheight{-\headsep}
  \addtolength\textheight{-\footskip}
  \addtolength\topmargin{-1in}
}

\ProcessOptions

%% 우리말의 분철:
%% --------------
%% 우리말은 \hyphenchar가 없고 어느 곳에서나 分綴이 可能하다. 그러므로
%% 일단 글자체 자체에서 分綴을 억제하고 (\hyphenchar\font\m@ne)
%% 우리말 사이에 \hskip\hangul@skip을 揷入함으로써 分綴을 可能하게
%% 함과 동시에 \hangulskip으로 자간 간격을 조절을 할 수 있도록 한다.
%%
\newdimen\hangulskip
\newskip\hangul@skip
% 글자체가 바뀔 때마다 자간 간격을 새로 계산한다.
\def\set@hangulskip{%
  \@tempdima=\f@size\p@
  \multiply\@tempdima100
  \divide\@tempdima\p@
  \multiply\@tempdima\p@
  \hangul@skip=\hangulskip minus\hangulskip
  \multiply\hangul@skip by\strip@pt\@tempdima%
  \divide\hangul@skip by1000
}

%% 우리말 유니코드 부호는 16진수로 ^^80에서 ^^FF 범위에 있는
%% 세 옥텟으로 구성되며 이 범위의 모든 옥텟은 모두 평범한 글자 
%% (\catcode=11)로 처리된다.
\def\utf@list{%
  \do\^^80\do\^^81\do\^^82\do\^^83\do\^^84\do\^^85\do\^^86\do\^^87%
  \do\^^88\do\^^89\do\^^8a\do\^^8b\do\^^8c\do\^^8d\do\^^8e\do\^^8f%
  \do\^^90\do\^^91\do\^^92\do\^^93\do\^^94\do\^^95\do\^^96\do\^^97%
  \do\^^98\do\^^99\do\^^9a\do\^^9b\do\^^9c\do\^^9d\do\^^9e\do\^^9f%
  \do\^^a0\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\do\^^ff}
\def\do@utfspecial#1{%
  \catcode`#1=11
  \lccode`#1=`#1
  \uccode`#1=`#1}
\let\do\do@utfspecial\utf@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}}

%% 자동 조사 명령 뒤에 \space (2005/04/07)
\def\afterj@sa#1{\ifnum\catcode`#1=11\hspace{\spaceskip} \fi #1}%

%% \은=\는 \이=\가 \을=\를 \와=\과
\def\은{\relax\@조사{는}{은}\afterj@sa}\let\는\은
\def\이{\relax\@조사{가}{이}\afterj@sa}\let\가\이
\def\을{\relax\@조사{를}{을}\afterj@sa}\let\를\을
\def\와{\relax\@조사{와}{과}\afterj@sa}\let\과\와

%%% 매개모음 ``으'' (2005/04/07) {\ㅡ}
%%  \으로=\로 (\으로서=\로서 \으로써=\로써)
\def\ㅡ{\relax\if y\is@rieul\else\@조사{}{으}\fi}
\def\로{{\ㅡ}로\afterj@sa}
\let\으로\로
\def\로서{{\ㅡ}로서\afterj@sa}
\let\으로서\로서
\def\로써{{\ㅡ}로써\afterj@sa}
\let\으로써\로써

%%% 지정사 ``이'' (2005/04/07) {\ㅣ}
\def\ㅣ{{\relax\@조사{}{이}}}

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

%% 우리말의 분철
%%
\catcode`\^^^^e000=13
\catcode`\^^^^e001=13
\def^^^^e000{\ifhmode\ifnum\spacefactor=999\hskip\hangul@skip\fi\fi\hemph@size}
\def^^^^e001{\spacefactor=999\relax}

\def\no@ccent#1{#1}
\let\hemph@size\no@ccent

\expandafter\def\expandafter\selectfont\expandafter{\selectfont\set@hangulskip}

%%% 드러냄표 (2005/04/10 koaunghi@kornet.net)
\def\circemph@size#1{\leavevmode%
  \setbox0\hbox{\fontencoding{OT1}\fontseries{m}\selectfont!}%
  \dimen@\ht0\advance\dimen@-.3ex%
  \rlap{\raise.7\dimen@\hbox{\fontencoding{OT1}\fontseries{m}\selectfont\rule{.3\dimen@}{0pt}\char'27}}#1}
\def\dotemph@size#1{\leavevmode%
  \setbox0\hbox{\fontencoding{OT1}\fontseries{m}\selectfont!}%
  \dimen@\ht0\advance\dimen@-.3ex%
  \rlap{\raise.7\dimen@\hbox{\fontencoding{OT1}\fontseries{m}\selectfont\rule{.7\dimen@}{0pt}\char'137}}#1}

\def\circem{\let\hemph@size\circemph@size}
\def\dotem#1{\let\hemph@size\dotemph@size}
\def\circemph#1{{\let\hemph@size\circemph@size #1}}
\def\dotemph#1{{\let\hemph@size\dotemph@size #1}}

%% 줄바꿈의 억제
% 우리말 음절은 어느 곳에서든지 줄바꿈이 가능하다.  줄바꿈을 억제할
% 때에 라텍의 \nolinebreak도 효과가 없다.  우리말 음절의 경계에서는
% 다음과 같이 줄바꿈을 억제한다.
\def\noHyphen{\spacefactor=1001\nolinebreak}

%% 2002.Apr.12: EUC-KR용의 ksx1001.ocp는 신정식님(jshin@mailaps.org)의
%% inuhc.otp와 hlatex.otp로 대체되어 윈도우즈 운영체계에서 사용되는
%% cp949 부호화 체계에 따른 한글 글자를 모두 사용할 수 있도록 하였고
%% hlatex.otp는 inutf8.otp와 함께 UTF-8 인코딩을 처리하는데 사용된다.
\ocp\OCPutf=inutf8
\ocp\OCPinHLaTeX=hlatex
\ocplist\OCPlistutf=\addbeforeocplist 1000 \OCPutf\nullocplist
\ocplist\OCPHLaTeXutf=\addbeforeocplist 1000 \OCPutf
                      \addbeforeocplist 1000 \OCPinHLaTeX\nullocplist
\pushocplist\OCPHLaTeXutf

%% 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

%% 편의상 다음과 같은 가족바꿈모듬명령도 제공된다. (그래픽, 궁서,
%% 필기, 외곽, 새명조, 목각, 옛글, 봄글씨, 펜글씨, 바다, 디나루,
%% 필기a)
\def\그래픽{\fontfamily{gr}\selectfont}
\def\궁서{\fontfamily{gs}\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{jmj}\selectfont}
\def\자모고딕{\fontfamily{jgt}\selectfont}
\def\자모노벨{\fontfamily{jnv}\selectfont}
\csname 자모소라\endcsname{\fontfamily{jsr}\selectfont}
\def\바다{\fontfamily{vd}\selectfont}
\def\디나루{\fontfamily{dn}\selectfont}
\def\필기a{\fontfamily{pga}\selectfont}

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

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

%% 우리말 문서의 곳곳에서 사용될 이름들은 \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{seealso}{도~參考}
  \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{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}{용어~풀이}
\fi
\ksnamedef{pagename}{쪽}
\ksnamedef{figurename}{그림}

%% 우리말숫자
\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}

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

%% 단원의 한글화
%% =============
%%
%% 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@}%
    \begingroup
    \parindent \z@ \rightskip \@pnumwidth
    \parfillskip -\@pnumwidth
    \leavevmode \bfseries
    \settowidth{\@tempdima}{\pre@sectioncnt\post@sectioncnt}
    \addtolength{\@tempdima}{1.5em}
    \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}{\pre@sectioncnt\post@sectioncnt}
      \addtolength{\@tempdima}{2.3em}
      \@dottedtocline{1}{1em}{\@tempdima}}}%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
    \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
}{}

%% 첫 줄 들여쓰기: 2배각
\settowidth{\parindent}{\reset@font 한글}

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