%	$Id: hlatex.ltx,v 1.3 1998/12/08 05:25:11 jccha Exp $
%
%	hlatex.ltx
%	Hangul (Korean) LaTeX2e (hLaTeXn or hLaTeXp)
%	1998/11/20 version
%	(LaTeX2e <1998/06/01> or later version is necessary)
%
%	Jae Choon Cha <jccha@knot.kaist.ac.kr>
%	Knot Theory Research Group
%	Department of Mathematics
%	Korea Advanced Institute of Science and Technology
%
%	Copyright (C) Jae Choon Cha. All Rights are reserved.
%	You are not allowed to change this file.
%	This file is part of hLaTeXp and hLaTeXn package. You are not allowed
%	to distribute this file alone. This file should be distributed as part
%	of hLaTeXp or hLaTeXn package of the author.
%	This file (and any derivation) cannot be sold or distributed with
%	any commercial product or used in any commercial organization without
%	additional agreement with the author.
%
%	For suggestions and bug reports of UNCHANGED version, send e-mail to
%	jccha@knot.kaist.ac.kr.
%

% Input original LaTeX2e, without dump operation.
\let\originaldump\dump \let\dump\relax
\input latex.ltx
\let\dump\originaldump
\makeatletter
%
% Check version of non-localized LaTeX2e.
\@ifl@t@r\fmtversion{1998/06/01}{}{%
  \GenericError{\space}%
  {hLaTeX Dump Error: Too old non-localized LaTeX2e}%
  {\space\space Non-localized (standard) LaTeX2e 1998/06/01 version (or later) is required.}%
  {To dump hLaTeX, you need a non-localized (standard) version of LaTeX2e.^^J%
   This version of hLaTeX requires LaTeX2e 1998/06/01 version (or later),^^J%
   But you tried with \fmtversion\space version.^^J}}%
%%
\DeclareRobustCommand{\hLaTeX}{h\LaTeX}
\DeclareRobustCommand{\hLaTeXn}{h\LaTeX n}
\DeclareRobustCommand{\hLaTeXp}{h\LaTeX p}
\DeclareRobustCommand{\hTeXn}{h\TeX n}
\DeclareRobustCommand{\hTeXp}{h\TeX p}
%%
%% Input hLaTeXn and hLaTeXp specific code.
%% (format name, 2-byte characters, modifications of NFSS2)
\input hlatexp.ltx
%%
%% Protect 2-byte characters.
\def\set@display@protect{\let\protect\string\makedbcharstring}
%
\long\def\protected@write#1#2#3{%
      \begingroup
       \let\thepage\relax
       \makedbcharstring #2%
       \let\protect\@unexpandable@protect
       \edef\reserved@a{\write#1{#3}}%
       \reserved@a%
      \endgroup
      \if@nobreak\ifvmode\nobreak\fi\fi
}
%
\def\@verbatim{\trivlist \item\relax
  \if@minipage\else\vskip\parskip\fi
  \leftskip\@totalleftmargin\rightskip\z@skip
  \parindent\z@\parfillskip\@flushglue\parskip\z@skip
  \@@par
  \@tempswafalse
  \def\par{%
    \if@tempswa
      \leavevmode \null \@@par\penalty\interlinepenalty
    \else
      \@tempswatrue
      \ifhmode\@@par\penalty\interlinepenalty\fi
    \fi}%
  \let\do\@makeother \dospecials \nohangulbreaking
  \obeylines \verbatim@font \@noligs
  \everypar \expandafter{\the\everypar \unpenalty}%
}
%
\def\verb{\relax\ifmmode\hbox\else\leavevmode\null\fi
  \bgroup
    \verb@eol@error \let\do\@makeother \dospecials
    \verbatim@font\@noligs
    \nohangulbreaking
    \@ifstar\@sverb\@verb}
%
\begingroup%
\catcode`\*=11 %
\catcode`\^^M\active%
\catcode`\^^L\active\let^^L\relax%
\catcode`\^^I\active%
\gdef\filecontents{\@tempswatrue\filec@ntents}%
\gdef\filecontents*{\@tempswafalse\filec@ntents}%
\gdef\filec@ntents#1{%
  \openin\@inputcheck#1 %
  \ifeof\@inputcheck%
    \@latex@warning@no@line%
        {Writing file `\@currdir#1'}%
    \chardef\reserved@c15 %
    \ch@ck7\reserved@c\write%
    \immediate\openout\reserved@c#1\relax%
  \else%
    \closein\@inputcheck%
    \@latex@warning@no@line%
            {File `#1' already exists on the system.\MessageBreak%
             Not generating it from this source}%
    \let\write\@gobbletwo%
    \let\closeout\@gobble%
  \fi%
  \if@tempswa%
    \immediate\write\reserved@c{%
      \@percentchar\@percentchar\space%
          \expandafter\@gobble\string\LaTeX2e file `#1'^^J%
      \@percentchar\@percentchar\space  generated by the %
        `\@currenvir' \expandafter\@gobblefour\string\newenvironment^^J%
      \@percentchar\@percentchar\space from source `\jobname' on %
         \number\year/\two@digits\month/\two@digits\day.^^J%
      \@percentchar\@percentchar}%
  \fi%
  \let\do\@makeother\dospecials\makedbcharother%
  \edef\E{\@backslashchar end\string{\@currenvir\string}}%
  \edef\reserved@b{%
    \def\noexpand\reserved@b%
         ####1\E####2\E####3\relax}%
  \reserved@b{%
    \ifx\relax##3\relax%
      \immediate\write\reserved@c{##1}%
    \else%
      \edef^^M{\noexpand\end{\@currenvir}}%
      \ifx\relax##1\relax%
      \else%
          \@latex@warning{Writing text `##1' before %
             \string\end{\@currenvir}\MessageBreak as last line of #1}%
        \immediate\write\reserved@c{##1}%
      \fi%
      \ifx\relax##2\relax%
      \else%
         \@latex@warning{%
           Ignoring text `##2' after \string\end{\@currenvir}}%
      \fi%
    \fi%
    ^^M}%
  \catcode`\^^L\active%
  \let\L\@undefined%
  \def^^L{\@ifundefined L^^J^^J^^J}%
  \catcode`\^^I\active%
  \let\I\@undefined%
  \def^^I{\@ifundefined I\space\space}%
  \catcode`\^^M\active%
  \edef^^M##1^^M{%
    \noexpand\reserved@b##1\E\E\relax}}%
\endgroup%
%
\DeclareRobustCommand*{\ref}[1]{\begingroup\makedbcharstring
  \expandafter\@setref\csname r@#1\endcsname\@firstoftwo{#1}\endgroup}
\DeclareRobustCommand*{\pageref}[1]{\begingroup\makedbcharstring
  \expandafter\@setref\csname r@#1\endcsname\@secondoftwo{#1}\endgroup}
\def\@newl@bel#1#2#3{\begingroup\makedbcharstring
  \@ifundefined{#1@#2}%
    \relax
    {\gdef \@multiplelabels {%
       \@latex@warning@no@line{There were multiply-defined labels}}%
     \@latex@warning@no@line{Label `#2' multiply defined}}%
  \global\@namedef{#1@#2}{#3}\endgroup}
%
\def\enddocument{%
   \@enddocumenthook
   \@checkend{document}%
   \clearpage
   \begingroup
     \if@filesw
       \immediate\closeout\@mainaux
       \let\@setckpt\@gobbletwo
       \let\@newl@bel\@testdef
       \@tempswafalse
       \makeatletter\makedbcharstring \input\jobname.aux \makedbcharactive
     \fi
     \@dofilelist
     \ifdim \font@submax >\fontsubfuzz\relax
       \@font@warning{Size substitutions with differences\MessageBreak
                  up to \font@submax\space have occured.\@gobbletwo}%
     \fi
     \@defaultsubs
     \@refundefined
     \if@filesw
       \ifx \@multiplelabels \relax
         \if@tempswa
           \@latex@warning@no@line{Label(s) may have changed.
               Rerun to get cross-references right}%
         \fi
       \else
         \@multiplelabels
       \fi
     \fi
   \endgroup
   \deadcycles\z@\@@end}
%
\def\@lbibitem[#1]#2{\item[\@biblabel{#1}\hfill]\if@filesw
      {\let\protect\noexpand\makedbcharstring
       \immediate
       \write\@auxout{\string\bibcite{#2}{#1}}}\fi\ignorespaces}
\def\@bibitem#1{\item\if@filesw {\makedbcharstring
  \immediate\write\@auxout
  {\string\bibcite{#1}{\the\value{\@listctr}}}}\fi\ignorespaces}
\def\bibcite{\@newl@bel b}
\def\@citex[#1]#2{%
  \let\@citea\@empty
  {\makedbcharstring \xdef\cite@list@temp{#2}}%
  \@cite{\@for\@citeb:=\cite@list@temp\do
    {\@citea\def\@citea{,\penalty\@m\ }%
     \edef\@citeb{\expandafter\@firstofone\@citeb\@empty}%
     \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
     \@ifundefined{b@\@citeb}{\mbox{\reset@font\bfseries ?}%
       \G@refundefinedtrue
       \@latex@warning
         {Citation `\@citeb' on page \thepage \space undefined}}%
       {\hbox{\csname b@\@citeb\endcsname}}}}{#1}}
%
\def\markboth#1#2{\gdef\@themark{{#1}{#2}}{%
     \let\protect\@unexpandable@protect \makedbcharnoexpand
     \let\label\relax \let\index\relax \let\glossary\relax
     \mark{\@themark}}\if@nobreak\ifvmode\nobreak\fi\fi}
\def\markright#1{{\let\protect\@unexpandable@protect \makedbcharnoexpand
     \let\label\relax \let\index\relax \let\glossary\relax
     \expandafter\@markright\@themark
     {#1}\mark{\@themark}}\if@nobreak\ifvmode\nobreak\fi\fi}
\makeatother
%% Now dump really.
\expandafter\everyjob\expandafter{\the\everyjob
\typeout{\hlatexfmtname\space<\hlatexfmtdate>}
\typeout{(C) Jae Choon Cha}
\typeout{\space\space\space\space Knot Theory Research Group, KAIST}}
\dump
