% \iffalse meta-comment
%
% Copyright 1989-2004 Johannes L. Braams and any individual authors
% listed elsewhere in this file.  All rights reserved.
% 
% This file is part of the Babel system.
% --------------------------------------
% 
% It may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% 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.3 or later is part of all distributions of LaTeX
% version 2003/12/01 or later.
% 
% This work has the LPPL maintenance status "maintained".
% 
% The Current Maintainer of this work is Johannes Braams.
% 
% The list of all files belonging to the LaTeX base distribution is
% given in the file `manifest.bbl. See also `legal.bbl' for additional
% information.
% 
% The list of derived (unpacked) files belonging to the distribution
% and covered by LPPL is defined by the unpacking scripts (with
% extension .ins) which are part of the distribution.
% \fi
% \CheckSum{1538}
% \iffalse
%    Tell the \LaTeX\ system who we are and write an entry on the
%    transcript.
%<*dtx>
\ProvidesFile{magyar.dtx}
%</dtx>
%<code>\ProvidesLanguage{magyar}
%\fi
%\ProvidesFile{magyar.dtx}
        [2004/03/06 v1.4i Magyar support from the babel system]
%\iffalse
%% File `magyar.dtx'
%% Babel package for LaTeX version 2e
%% Copyright (C) 1989 - 2004
%%           by Johannes Braams, TeXniek
%
%% Magyar Language Definition File
%% Copyright (C) 1989 - 2004
%%           by Johannes Braams, TeXniek
%%              \'Arp\'ad B\'IR\'O
%%              J\'ozsef B\'ERCES
%
% Please report errors to: J.L. Braams babel braams.cistron.nl
%
%    This file is part of the babel system, it provides the source
%    code for the Hungarian language definition file.  A contribution
%    was made by Attila Koppanyi (attila@cernvm.cern.ch).
%<*filedriver>
\documentclass{ltxdoc}
\newcommand*\TeXhax{\TeX hax}
\newcommand*\babel{\textsf{babel}}
\newcommand*\langvar{$\langle \it lang \rangle$}
\newcommand*\note[1]{}
\newcommand*\Lopt[1]{\textsf{#1}}
\newcommand*\file[1]{\texttt{#1}}
\begin{document}
 \DocInput{magyar.dtx}
\end{document}
%</filedriver>
%\fi
% \GetFileInfo{magyar.dtx}
%
% \changes{magyar-1.0a}{1991/07/15}{Renamed \file{babel.sty} in
%    \file{babel.com}}
% \changes{magyar-1.1}{1992/02/16}{Brought up-to-date with babel 3.2a}
% \changes{magyar-1.1d}{1994/02/08}{Further spelling corrections}
% \changes{magyar-1.1e}{1994/02/09}{Still more spelling corrections}
% \changes{magyar-1.2}{1994/02/27}{Update for \LaTeXe}
% \changes{magyar-1.3c}{1994/06/26}{Removed the use of \cs{filedate}
%    and moved identification after the loading of \file{babel.def}}
% \changes{magyar-1.3g}{1996/07/12}{Replaced \cs{undefined} with
%    \cs{@undefined} and \cs{empty} with \cs{@empty} for consistency
%    with \LaTeX}
% \changes{magyar-1.4a}{1998/06/04}{order inverting in
%    headings/titles/captions; definite article handling; active char
%    for special hyphenation}
% \changes{magyar-1.4d}{2001/11/15}{Corrected checksum}
%
%  \section{The Hungarian language}
%
%    The file option \file{\filename} defines all the
%    language definition macros for the Hungarian language.
%
%    The \babel{} support for the Hungarian language until file
%    version 1.3i was essentially changing the English document
%    elements to Hungarian ones, but because of the differences
%    between these too languages this was actually unusable (`Part I'
%    was transferred to `R\'esz I' which is not usable instead of `I.\
%    r\'esz'). To enhance the typesetting facilities for Hungarian
%    the following should be considered:
%    \begin{itemize}
%      \item In Hungarian documents there is a period after
%            the part, section, subsection \mbox{etc.} numbers.
%
%      \item In the part, chapter, appendix name the number
%            (or letter) goes before the name, so `Part I' translates to
%            `I.\ r\'esz'.
%
%       \item The same is true with captions
%             (`Table 2.1' goes to `2.1.\ t\'abl\'azat').
%
%       \item There is a period after the caption name instead of a colon.
%             (`Table 2.1:' goes to `2.1.\ t\'abl\'azat.')
%
%       \item There is a period at the end of the title in a run-in head
%             (when |afterskip<0| in |\@startsection|).
%
%       \item Special hyphenation rules must be applied
%             for the so-called long double consonants (ccs, ssz,\dots).
%
%       \item The opening quotation mark is like the German one
%             (the closing is the same as in English).
%
%       \item In Hungarian figure, table, \mbox{etc.}
%             referencing a definite article is also incorporated.
%             The Hungarian definite articles behave like the English
%             indefinite ones (`a/an'). `a' is used for words beginning
%             with a consonant and `az' goes for a vowel.
%             Since some numbers begin with a vowel some others
%             with a consonant some commands should be provided for
%             automatic definite article generation.
%    \end{itemize}
%
%    Until file version 1.3i\footnote{That file was
%    last revised on 1996/12/23 with a contribution by the next
%    authors: Attila Kopp\'anyi (\texttt{attila@cernvm.cern.ch}),
%    \'Arp\'ad B\'{\i}r\'o (\texttt{JZP1104@HUSZEG11.bitnet}),
%    Istv\'an Hamecz (\texttt{hami@ursus.bke.hu)} and
%    Dezs\H{o} Horv\'ath (\texttt{horvath@pisa.infn.it}).} 
%    the special typesetting rules of the Hungarian language
%    mentioned above were not taken into consideration.
%    This version (\fileversion)\footnote{It was written by J\'ozsef
%    B\'erces (\texttt{jozsi@docs4.mht.bme.hu}) with some help from
%    Ferenc Wettl (\texttt{wettl@math.bme.hu}) and an idea from David
%    Carlisle (\texttt{david@dcarlisle.demon.co.uk}).} 
%    enables \babel{} to typeset `good-looking' Hungarian texts.
%
% \DescribeMacro\ontoday
%    The |\ontoday| command works like |\today| but
%    produces a slightly different date format used in expressions such
%    as `on February 10th'.
%
% \DescribeMacro\Az
%    The commands |\Az#1| and |\az#1| write the correct
%    definite article for the argument and the argument itself
%    (separated with a |~|). The star-forms (|\Az*| and |\az*|)
%    produce the article only.
%
% \DescribeMacro\Azr
%    |\Azr#1| and |\azr#1| treat the argument as a label so expand
%    it then write the definite article for |\r@#1|, a non-breakable
%    space then the label expansion. The star-forms do not print
%    the label expansion. |\Azr(#1| and |\azr(#1| are used for
%    equation referencing with the syntax |\azr(|\textit{label}|)|.
%
% \DescribeMacro\Aref
%    There are two aliases |\Aref| and |\aref| for |\Azr| and |\azr|,
%    respectively. During the preparation of a document it is not
%    known in general, if the code `|a~\ref{|\textit{label}|}|' or the code
%    `|az~\ref{|\textit{label}|}|' is the grammatically correct one. Writing
%    `|\aref{|\textit{label}|}|' instead of the previous ones solves the 
%    problem.
%
% \DescribeMacro\Azp
%    |\Azp#1| and |\azp#1| also treat the argument as a label but
%    use the label's page for definite article determination.
%    There are star-forms giving only the definite article without
%    the page number. 
%
% \DescribeMacro\Apageref
%    There are aliases |\Apageref| and |\apageref| for |\Azp| and
%    |\azp|, respectively. The code |\apageref{|\textit{label}|}| 
%    is equivalent either to |a~\pageref{|\textit{label}|}| or 
%    to |az~\pageref{|\textit{label}|}|.
%
% \DescribeMacro\Azc
%    |\Azc| and |\azc| work like the |\cite| command but
%    (of course) they insert the definite article. There can be
%    several comma separated cite labels and in that case the
%    definite article is given for the first one.
%    They accept |\cite|'s optional argument.
%    There are star-forms giving the definite article only.
%
% \DescribeMacro\Acite
%    There are aliases |\Acite| and |\acite| for
%    |\Azc| and |\azc|, respectively. 
%
%    For this language the character |`| is made active.
%    Table~\ref{tab:hun-actives} shows the shortcuts.
%    The main reason for the activation of the |`| character
%    is to handle the special hyphenation of the long double
%    consonants.
%    \begin{table}
%      \begin{center}
%        \begin{tabular}{lp{45mm}p{47mm}}
%          shortcut & explanation & example \\
%          \hline
%          |``|        &  same as |\glqq| in \babel{}, or
%                         |\quotedblbase| in T1 
%                         (opening quotation mark, like ,,) 
%                        & |``id\'ezet''|$\longrightarrow$,,id\'ezet'{}' \\
%          |`c|, |`C|  &  ccs is hyphenated as cs-cs
%                        & |lo`ccsan|$\longrightarrow$locs-csan \\
%          |`d|, |`D|  &  ddz is hyphenated as dz-dz
%                        & |e`ddz\"unk|$\longrightarrow$edz-dz\"unk \\
%          |`g|, |`G|  &  ggy is hyphenated as gy-gy
%                        & |po`ggy\'asz|$\longrightarrow$pogy-gy\'asz \\
%          |`l|, |`L|  &  lly is hyphenated as ly-ly
%                        & |Kod\'a`llyal|$\longrightarrow$Kod\'aly-lyal \\
%          |`n|, |`N|  &  nny is hyphenated as ny-ny
%                        & |me`nnyei|$\longrightarrow$meny-nyei \\
%          |`s|, |`S|  &  ssz is hyphenated as sz-sz
%                        & |vi`ssza|$\longrightarrow$visz-sza \\
%          |`t|, |`T|  &  tty is hyphenated as ty-ty
%                        & |po`ttyan|$\longrightarrow$poty-tyan \\
%          |`z|, |`Z|  &  zzs is hyphenated as zs-zs
%                        & |ri`zzsel|$\longrightarrow$rizs-zsel \\
%        \end{tabular}
%        \caption{The shortcuts defined in \file{magyar.ldf}}
%        \label{tab:hun-actives}
%      \end{center}
%    \end{table}
%
%
% \StopEventually{}
%
%    The macro |\LdfInit| takes care of preventing that this file is
%    loaded more than once, checking the category code of the
%    \texttt{@} sign, etc.
% \changes{magyar-1.3h}{1996/11/03}{Now use \cs{LdfInit} to perform
%    initial checks}
%    \begin{macrocode}
%<*code>
\LdfInit{magyar}{caption\CurrentOption}
%    \end{macrocode}
%
%    When this file is read as an option, i.e. by the |\usepackage|
%    command, \texttt{magyar} will be an `unknown' language in which
%    case we have to make it known.  So we check for the existence of
%    |\l@magyar| or |\l@hungarian| to see whether we have to do
%    something here.
%
% \changes{magyar-1.0b}{1991/10/29}{Removed use of \cs{@ifundefined}}
% \changes{magyar-1.1}{1992/02/16}{Added a warning when no hyphenation
%    patterns were loaded.}
% \changes{magyar-1.3c}{1994/06/26}{Now use \cs{@nopatterns} to
%    produce the warning}
% \changes{magyar-1.4d}{2003/09/18}{The \cs{else} clause got outside
%    of the \cs{if} statement, breaking the Hungarian support}
% \changes{magyar-1.4g}{2003/10/07}{Further change to make it work
%    when neither \cs{l@magyar} nor \cs{l@hugarian} are defined}
%    \begin{macrocode}
\ifx\l@magyar\@undefined
  \ifx\l@hungarian\@undefined
    \@nopatterns{Magyar}
    \adddialect\l@magyar0
  \else
    \let\l@magyar\l@hungarian
  \fi
\fi
%    \end{macrocode}
%    The statement above makes sure that |\l@magyar| is always
%    defined; if |\l@hungarian| is still undefined we make it equal to
%    |\l@magyar|. 
%    \begin{macrocode}
\ifx\l@hungarian\@undefined
  \let\l@hungarian\l@magyar
\fi
%    \end{macrocode}
%
%    The next step consists of defining commands to switch to (and
%    from) the Hungarian language.
%
% \begin{macro}{\captionsmagyar}
%    The macro |\captionsmagyar| defines all strings used in the four
%    standard document classes provided with \LaTeX.
% \changes{magyar-1.1}{1992/02/16}{Added \cs{seename}, \cs{alsoname}
%    and \cs{prefacename}}
% \changes{magyar-1.1}{1993/07/15}{\cs{headpagename} should be
%    \cs{pagename}}
% \changes{magyar-1.1c}{1994/01/05}{Added translations, fixed typos}
% \changes{magyar-1.3e}{1995/07/04}{Added \cs{proofname} for
%    AMS-\LaTeX}
% \changes{magyar-1.3f}{1996/04/18}{translated Proof and replaced some
%    translations}
% \changes{magyar-1.4a}{1998/06/04}{the initial letter of fejezet,
%    t\'abl\'azat, r\'esz, l\'asd changed to lowercase}
%    \begin{macrocode}
\@namedef{captions\CurrentOption}{%
  \def\prefacename{El\H osz\'o}%
%    \end{macrocode}
%    For the list of references at the end of an article we have a
%    choice between two words, `Referenci\'ak' (a Hungarian version of
%    the English word) and `Hivatkoz\'asok'. The latter seems to
%    be in more widespread use.
%    \begin{macrocode}
  \def\refname{Hivatkoz\'asok}%
%    \end{macrocode}
%    If you have a document with a summary instead of an abstract you
%    might want to replace the word `Kivonat' with
%    `\"Osszefoglal\'o'.
%    \begin{macrocode}
  \def\abstractname{Kivonat}%
%    \end{macrocode}
%    The Hungarian version of `Bibliography' is `Bibliogr\'afia', but
%    a more natural word to use is `Irodalomjegyz\'ek'.
%    \begin{macrocode}
  \def\bibname{Irodalomjegyz\'ek}%
  \def\chaptername{fejezet}%
  \def\appendixname{F\"uggel\'ek}%
  \def\contentsname{Tartalomjegyz\'ek}%
  \def\listfigurename{\'Abr\'ak jegyz\'eke}%
  \def\listtablename{T\'abl\'azatok jegyz\'eke}%
  \def\indexname{T\'argymutat\'o}%
  \def\figurename{\'abra}%
  \def\tablename{t\'abl\'azat}%
  \def\partname{r\'esz}%
  \def\enclname{Mell\'eklet}%
  \def\ccname{K\"orlev\'el--c\'\i mzettek}%
  \def\headtoname{C\'\i mzett}%
  \def\pagename{oldal}%
  \def\seename{l\'asd}%
  \def\alsoname{l\'asd m\'eg}%
%    \end{macrocode}
%    Besides the Hungarian word for Proof, `Bizony\'\i t\'as' we can
%    also name Corollary (K\"ovetkezm\'eny), Theorem (T\'etel) and
%    Lemma (Lemma).
% \changes{magyar-1.4b}{2000/09/20}{Added \cs{glossaryname}}
% \changes{magyar-1.4h}{2003/11/20}{Inserted translation for Glossary} 
%    \begin{macrocode}
  \def\proofname{Bizony\'\i t\'as}%
  \def\glossaryname{Sz\'ojegyz\'ek}%
  }%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\datemagyar}
%    The macro |\datemagyar| redefines the command |\today| to produce
%    Hungarian dates.
% \changes{magyar-1.1d}{1994/02/08}{Rewritten to produce the correct
%    date format}
% \changes{magyar-1.4a}{1998/06/10}{Use \cs{number}\cs{day} instead of
%    \cs{ifcase} construct}
%    \begin{macrocode}
\@namedef{date\CurrentOption}{%
  \def\today{%
    \number\year.\nobreakspace\ifcase\month\or
    janu\'ar\or febru\'ar\or m\'arcius\or
    \'aprilis\or m\'ajus\or j\'unius\or
    j\'ulius\or augusztus\or szeptember\or
    okt\'ober\or november\or december\fi
    \space\number\day.}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ondatemagyar}
%    The macro |\ondatemagyar| produces Hungarian dates which have the
%    meaning `\emph{on this day}'.  It does not redefine the command
%    |\today|.
% \changes{magyar-1.1c}{1994/01/05}{The date number should not be
%    followed by a dot.}
% \changes{magyar-1.1d}{1994/02/08}{Renamed from \cs{datemagyar};
%    nolonger redefines \cs{today}.}
%    \begin{macrocode}
\@namedef{ondate\CurrentOption}{%
  \number\year.\nobreakspace\ifcase\month\or
  janu\'ar\or febru\'ar\or m\'arcius\or
  \'aprilis\or m\'ajus\or j\'unius\or
  j\'ulius\or augusztus\or szeptember\or
  okt\'ober\or november\or december\fi
    \space\ifcase\day\or
    1-j\'en\or  2-\'an\or  3-\'an\or  4-\'en\or  5-\'en\or
    6-\'an\or  7-\'en\or  8-\'an\or  9-\'en\or 10-\'en\or
   11-\'en\or 12-\'en\or 13-\'an\or 14-\'en\or 15-\'en\or
   16-\'an\or 17-\'en\or 18-\'an\or 19-\'en\or 20-\'an\or
   21-\'en\or 22-\'en\or 23-\'an\or 24-\'en\or 25-\'en\or
   26-\'an\or 27-\'en\or 28-\'an\or 29-\'en\or 30-\'an\or
   31-\'en\fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\extrasmagyar}
% \begin{macro}{\noextrasmagyar}
%    The macro |\extrasmagyar| will perform all the extra definitions
%    needed for the Hungarian language. The macro |\noextrasmagyar| is
%    used to cancel the actions of |\extrasmagyar|.
%
%    \begin{macrocode}
 \@namedef{extras\CurrentOption}{%
   \expandafter\let\expandafter\ontoday
     \csname ondate\CurrentOption\endcsname}
\@namedef{noextras\CurrentOption}{\let\ontoday\@undefined}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%    Now we redefine some commands included into \file{latex.ltx}.
%    The original form of a command is always saved with
%    |\babel@save| and the changes are added to |\extrasmagyar|.
%    This ensures that the Hungarian version of a macro is alive
%    \emph{only} if the Hungarian language is active.
%
% \begin{macro}{\fnum@figure}
% \begin{macro}{\fnum@table}
%    In figure and table captions the order of the figure/table
%    number and |\figurename|\hspace{0pt}/|\tablename| must be changed.
%    To achieve this |\fnum@figure| and |\fnum@table| are
%    redefined and added to |\extrasmagyar|.
% \changes{magyar-1.4i}{2004/02/20}{Use \cs{nobreakspace} instead of
%    tilde}
%    \begin{macrocode}
\expandafter\addto\csname extras\CurrentOption\endcsname{%
  \babel@save\fnum@figure
  \def\fnum@figure{\thefigure.\nobreakspace\figurename}}
\expandafter\addto\csname extras\CurrentOption\endcsname{%
  \babel@save\fnum@table
  \def\fnum@table{\thetable.\nobreakspace\tablename}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@makecaption}
%    The colon in a figure/table caption must be replaced by a dot
%    by redefining |\@makecaption|.
%    \begin{macrocode}
\expandafter\addto\csname extras\CurrentOption\endcsname{%
  \babel@save\@makecaption
  \def\@makecaption#1#2{%
    \vskip\abovecaptionskip
    \sbox\@tempboxa{#1. #2}%
    \ifdim \wd\@tempboxa >\hsize
      {#1. #2\csname par\endcsname}
    \else
      \global \@minipagefalse
      \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
    \fi
    \vskip\belowcaptionskip}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@caption}
%    There should be a dot after the figure/table number in lof/lot,
%    so |\@caption| is redefined.
%    \begin{macrocode}
\expandafter\addto\csname extras\CurrentOption\endcsname{%
  \babel@save\@caption
  \long\def\@caption#1[#2]#3{%
    \csname par\endcsname
    \addcontentsline{\csname ext@#1\endcsname}{#1}%
      {\protect\numberline{\csname the#1\endcsname.}{\ignorespaces #2}}%
    \begingroup
      \@parboxrestore
      \if@minipage
        \@setminipage
      \fi
      \normalsize
      \@makecaption{\csname fnum@#1\endcsname}%
          {\ignorespaces #3}\csname par\endcsname
    \endgroup}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@seccntformat}
%    In order to have a dot after the section number
%    |\@seccntformat| is redefined.
%    \begin{macrocode}
\expandafter\addto\csname extras\CurrentOption\endcsname{%
  \babel@save\@seccntformat
  \def\@seccntformat#1{\csname the#1\endcsname.\quad}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@sect}
%    Alas, |\@sect| must also be redefined to have that dot in toc too.
%    On the other hand, we include a dot after a run-in head.
%    \begin{macrocode}
\expandafter\addto\csname extras\CurrentOption\endcsname{%
  \babel@save\@sect
  \def\@sect#1#2#3#4#5#6[#7]#8{%
    \ifnum #2>\c@secnumdepth
      \let\@svsec\@empty
    \else
      \refstepcounter{#1}%
      \protected@edef\@svsec{\@seccntformat{#1}\relax}%
    \fi
    \@tempskipa #5\relax
    \ifdim \@tempskipa>\z@
      \begingroup
        #6{%
          \@hangfrom{\hskip #3\relax\@svsec}%
            \interlinepenalty \@M #8\@@par}%
      \endgroup
      \csname #1mark\endcsname{#7}%
      \addcontentsline{toc}{#1}{%
        \ifnum #2>\c@secnumdepth \else
          \protect\numberline{\csname the#1\endcsname.}%
        \fi
        #7}%
    \else
      \def\@svsechd{%
        #6{\hskip #3\relax
        \@svsec #8.}%
        \csname #1mark\endcsname{#7}%
        \addcontentsline{toc}{#1}{%
          \ifnum #2>\c@secnumdepth \else
            \protect\numberline{\csname the#1\endcsname.}%
          \fi
          #7}}%
    \fi
    \@xsect{#5}}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@ssect}
%    In order to have that dot after a run-in head when the star form of the
%    sectioning commands is used, we have to redefine |\@ssect|.
%    \begin{macrocode}
\expandafter\addto\csname extras\CurrentOption\endcsname{%
  \babel@save\@ssect
  \def\@ssect#1#2#3#4#5{%
    \@tempskipa #3\relax
    \ifdim \@tempskipa>\z@
      \begingroup
        #4{%
          \@hangfrom{\hskip #1}%
            \interlinepenalty \@M #5\@@par}%
      \endgroup
    \else
      \def\@svsechd{#4{\hskip #1\relax #5.}}%
    \fi
    \@xsect{#3}}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@begintheorem}
% \begin{macro}{\@opargbegintheorem}
%    Order changing and dot insertion in theorem by redefining
%    |\@begintheorem| and |\@opargbegintheorem|.
%    \begin{macrocode}
\expandafter\addto\csname extras\CurrentOption\endcsname{%
  \babel@save\@begintheorem
  \def\@begintheorem#1#2{\trivlist
    \item[\hskip \labelsep{\bfseries #2.\ #1.}]\itshape}
  \babel@save\@opargbegintheorem
  \def\@opargbegintheorem#1#2#3{\trivlist
    \item[\hskip \labelsep{\bfseries #2.\ #1\ (#3).}]\itshape}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%    The next step is to redefine some macros included into the
%    class files. It is determined which class file is loaded
%    then the original form of the macro is saved and the changes
%    are added to |\extrasmagyar|.
%
%    First we check if the \file{book.cls} is loaded.
%    \begin{macrocode}
\@ifclassloaded{book}{%
%    \end{macrocode}
% \begin{macro}{\ps@headings}
%    The look of the headings is changed: we have to insert some dots
%    and change the order of chapter number and |\chaptername|.
%    \begin{macrocode}
  \expandafter\addto\csname extras\CurrentOption\endcsname{%
    \babel@save\ps@headings}
  \expandafter\addto\csname extras\CurrentOption\endcsname{%
    \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
                \thechapter. \@chapapp. \ %
              \fi
            \fi
            ##1}}{}}%
        \def\sectionmark##1{%
          \markright {\MakeUppercase{%
            \ifnum \c@secnumdepth >\z@
              \thesection. \ %
            \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
                \thechapter. \@chapapp. \ %
              \fi
            \fi
            ##1}}}}
    \fi}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@part}
%    At the beginning of a part we need \mbox{eg.} `I.\ r\'esz'
%    instead of `Part I' (in toc too).
%    To achieve this |\@part| is redefined.
%    \begin{macrocode}
  \expandafter\addto\csname extras\CurrentOption\endcsname{%
    \babel@save\@part
    \def\@part[#1]#2{%
        \ifnum \c@secnumdepth >-2\relax
          \refstepcounter{part}%
          \addcontentsline{toc}{part}{\thepart.\hspace{1em}#1}%
        \else
          \addcontentsline{toc}{part}{#1}%
        \fi
        \markboth{}{}%
        {\centering
         \interlinepenalty \@M
         \normalfont
         \ifnum \c@secnumdepth >-2\relax
           \huge\bfseries \thepart.\nobreakspace\partname
           \csname par\endcsname
           \vskip 20\p@
         \fi
         \Huge \bfseries #2\csname par\endcsname}%
        \@endpart}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@chapter}
%    The same changes are made to chapter.
%    First the screen typeout and the toc are changed by
%    redefining |\@chapter|.
%    \begin{macrocode}
  \expandafter\addto\csname extras\CurrentOption\endcsname{%
    \babel@save\@chapter
    \def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
                           \if@mainmatter
                             \refstepcounter{chapter}%
                             \typeout{\thechapter.\space\@chapapp.}%
                             \addcontentsline{toc}{chapter}%
                                       {\protect\numberline{\thechapter.}#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}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@makechapterhead}
%    Then the look of the chapter-start is modified by redefining
%    |\@makechapterhead|.
%    \begin{macrocode}
  \expandafter\addto\csname extras\CurrentOption\endcsname{%
    \babel@save\@makechapterhead
    \def\@makechapterhead#1{%
      \vspace*{50\p@}%
      {\parindent \z@ \raggedright \normalfont
        \ifnum \c@secnumdepth >\m@ne
          \if@mainmatter
            \huge\bfseries \thechapter.\nobreakspace\@chapapp{}
            \csname par\endcsname\nobreak
            \vskip 20\p@
          \fi
        \fi
        \interlinepenalty\@M
        \Huge \bfseries #1\csname par\endcsname\nobreak
        \vskip 40\p@
      }}}%
%    \end{macrocode}
% \end{macro}
%    This the end of the book class modification.
%    \begin{macrocode}
}{}
%    \end{macrocode}
%
%    Now we check if \file{report.cls} is loaded.
%    \begin{macrocode}
\@ifclassloaded{report}{%
%    \end{macrocode}
% \begin{macro}{\ps@headings}
%    First the headings are modified just in case of the book class.
%    \begin{macrocode}
  \expandafter\addto\csname extras\CurrentOption\endcsname{%
    \babel@save\ps@headings}
  \expandafter\addto\csname extras\CurrentOption\endcsname{%
    \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
                \thechapter. \@chapapp. \ %
            \fi
            ##1}}{}}%
        \def\sectionmark##1{%
          \markright {\MakeUppercase{%
            \ifnum \c@secnumdepth >\z@
              \thesection. \ %
            \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
                \thechapter. \@chapapp. \ %
            \fi
            ##1}}}}
    \fi}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@chapter}
%    Chapter-start modification with |\@chapter|
%    \begin{macrocode}
  \expandafter\addto\csname extras\CurrentOption\endcsname{%
    \babel@save\@chapter
    \def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
                             \refstepcounter{chapter}%
                             \typeout{\thechapter.\space\@chapapp.}%
                             \addcontentsline{toc}{chapter}%
                                       {\protect\numberline{\thechapter.}#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}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@makechapterhead}
%    and |\@makechapterhead|.
%    \begin{macrocode}
  \expandafter\addto\csname extras\CurrentOption\endcsname{%
    \babel@save\@makechapterhead
    \def\@makechapterhead#1{%
      \vspace*{50\p@}%
      {\parindent \z@ \raggedright \normalfont
        \ifnum \c@secnumdepth >\m@ne
            \huge\bfseries \thechapter.\nobreakspace\@chapapp{}
            \csname par\endcsname\nobreak
            \vskip 20\p@
        \fi
        \interlinepenalty\@M
        \Huge \bfseries #1\csname par\endcsname\nobreak
        \vskip 40\p@
      }}}%
%    \end{macrocode}
% \end{macro}
%    End of report class modification.
%    \begin{macrocode}
}{}
%    \end{macrocode}
%
%    Checking if \file{article.cls} is loaded.
%    \begin{macrocode}
\@ifclassloaded{article}{%
%    \end{macrocode}
% \begin{macro}{\ps@headings}
%    Changing headings by redefining |\ps@headings|.
%    \begin{macrocode}
  \expandafter\addto\csname extras\CurrentOption\endcsname{%
    \babel@save\ps@headings}
  \expandafter\addto\csname extras\CurrentOption\endcsname{%
    \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\sectionmark##1{%
          \markboth {\MakeUppercase{%
            \ifnum \c@secnumdepth >\z@
              \thesection.\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
              \thesection.\quad
            \fi
            ##1}}}}
    \fi}%
%    \end{macrocode}
% \end{macro}
%    No more necessary changes specific to the article class.
%    \begin{macrocode}
}{}
%    \end{macrocode}
%
%    And now this is the turn of \file{letter.cls}.
%    \begin{macrocode}
\@ifclassloaded{letter}{%
%    \end{macrocode}
% \begin{macro}{\ps@headings}
%    In the headings the page number must be followed by a dot
%    and then |\pagename|.
%    \begin{macrocode}
  \expandafter\addto\csname extras\CurrentOption\endcsname{%
    \babel@save\ps@headings}
  \expandafter\addto\csname extras\CurrentOption\endcsname{%
    \if@twoside
      \def\ps@headings{%
          \let\@oddfoot\@empty\let\@evenfoot\@empty
          \def\@oddhead{\slshape\headtoname{:} \ignorespaces\toname
                        \hfil \@date
                        \hfil \thepage.\nobreakspace\pagename}%
          \let\@evenhead\@oddhead}
    \else
      \def\ps@headings{%
          \let\@oddfoot\@empty
          \def\@oddhead{\slshape\headtoname{:} \ignorespaces\toname
                        \hfil \@date
                        \hfil \thepage.\nobreakspace\pagename}}
    \fi}%
%    \end{macrocode}
% \end{macro}
%    End of letter class.
%    \begin{macrocode}
}{}
%    \end{macrocode}
%
%    After making the changes to the \LaTeX{}
%    macros we define some new ones to handle the problem
%    with definite articles.
% \begin{macro}{\az}
%    |\az| is a user-level command which decides if the next
%    character is a star. |\@az| is called for |\az*| and
%    |\az@| for |\az|.
%    \begin{macrocode}
\def\az{a\@ifstar{\@az}{\az@}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\Az}
%    |\Az| is used at the beginning of a sentence. Otherwise it behaves
%    the same as |\az|.
%    \begin{macrocode}
\def\Az{A\@ifstar{\@az}{\az@}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\az@}
%    |\az@| is called if there is no star after |\az| or |\Az|.
%    It calls |\@az| and writes |#1| separating with a non-breakable
%    space.
%    \begin{macrocode}
\def\az@#1{\@az{#1}\nobreakspace#1}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@az}
%    This macro calls |\hun@tempadef| to remove the accents from
%    the argument then calls |\@@az| that determines if a `z'
%    should be written after a/A (written by |\az|/|\Az|).
%    \begin{macrocode}
\def\@az#1{%
  \hun@tempadef{relax}{relax}{#1}%
  \edef\@tempb{\noexpand\@@az\@tempa\hbox!}%
  \@tempb}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hun@tempadef}
%    The macro |\hun@tempadef| has three tasks:
%    \begin{itemize}
%      \item Accent removal. Accented letters confuse
%            |\@@az|, the main definite article determinator
%            macro, so they must be changed to their non-accented
%            counterparts. Special letters must also be changed,
%            \mbox{eg.} \oe$\,\rightarrow\,$o.
%      \item Labels must be expanded.
%      \item To handle Roman numerals correctly, commands starting
%            with |\hun@| are defined for labels containing Roman
%            numbers with the Roman numerals
%            replaced by their Arabic representation.
%            This macro can check if there is a |\hun@| command.
%    \end{itemize}
%    There are three arguments:
%    \begin{enumerate}
%      \item The primary command that should be expanded if it exists.
%            This is usually the |\hun@| command for a label.
%      \item The secondary command which is used if the first one
%            is |\relax|. This is usually the original \LaTeX{}
%            command for a label.
%      \item This is used if the first two is |\relax|. For this one
%            no expansion is carried out but the accents are still
%            removed and special letters are changed.
%    \end{enumerate}
% \changes{magyar-1.4f}{2003/09/29}{Added
%    \cs{def}\cs{safe@activesfalse{}} as a fix for PR3426} 
%    \begin{macrocode}
\def\hun@tempadef#1#2#3{%
  \begingroup
    \def\@safe@activesfalse{}%
    \def\setbox ##1{}% to get rid of accents and special letters
    \def\hbox ##1{}%
    \def\accent ##1 ##2{##2}%
    \def\add@accent ##1##2{##2}%
    \def\@text@composite@x ##1##2{##2}%
    \def\i{i}\def\j{j}%
    \def\ae{a}\def\AE{A}\def\oe{o}\def\OE{O}%
    \def\ss{s}\def\L{L}%
    \def\d{}\def\b{}\def\c{}\def\t{}%
    \expandafter\ifx\csname #1\endcsname\relax
      \expandafter\ifx\csname #2\endcsname\relax
        \xdef\@tempa{#3}%
      \else
        \xdef\@tempa{\csname #2\endcsname}%
      \fi
    \else
      \xdef\@tempa{\csname #1\endcsname}%
    \fi
  \endgroup}
%    \end{macrocode}
% \end{macro}
%
%    The following macros are used to determine the definite
%    article for a label's expansion.
% \begin{macro}{\aref}
%    |\aref| is an alias for |\azr|.
%    \begin{macrocode}
\def\aref{\azr}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\Aref}
%    |\Aref| is an alias for |\Azr|.
%    \begin{macrocode}
\def\Aref{\Azr}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\azr}
%    |\azr| calls |\@azr| if the next character is a star,
%    otherwise it calls |\azr@|.
%    \begin{macrocode}
\def\azr{a\@ifstar{\@azr}{\azr@}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\Azr}
%    |\Azr| is the same as |\azr| except that it writes `A'
%    instead of `a'.
%    \begin{macrocode}
\def\Azr{A\@ifstar{\@azr}{\azr@}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\azr@}
%    |\azr@| decides if the next character is |(| and
%    in that case it calls |\azr@@@| which writes an extra |(|
%    for equation referencing. Otherwise |\azr@@| is called.
%    \begin{macrocode}
\def\azr@{\@ifnextchar ({\azr@@@}{\azr@@}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\azr@@}
%    Calls |\@azr| then writes the label's expansion preceded by
%    a non-breakable space.
%    \begin{macrocode}
\def\azr@@#1{\@azr{#1}\nobreakspace\ref{#1}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\azr@@@}
%    Same as |\azr@@| but inserts a |(| between the
%    non-breakable space and the label expansion.
%    \begin{macrocode}
\def\azr@@@(#1{\@azr{#1}\nobreakspace(\ref{#1}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@azr}
%    Calls |\hun@tempadef| to choose between the label's
%    |\hun@| or original \LaTeX{} command and to expand
%    it with accent removal and special letter substitution.
%    Then calls |\@@az|, the core macro of definite article handling.
%    \begin{macrocode}
\def\@azr#1{%
  \hun@tempadef{hun@r@#1}{r@#1}{}%
  \ifx\@tempa\empty
  \else
    \edef\@tempb{\noexpand\@@az\expandafter\@firstoftwo\@tempa\hbox!}%
    \@tempb
  \fi
}
%    \end{macrocode}
% \end{macro}
%
%    The following commands are used to generate the definite article
%    for the page number of a label.
% \begin{macro}{\apageref}
%    |\apageref| is an alias for |\azp|.
%    \begin{macrocode}
\def\apageref{\azp}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\Apageref}
%    |\Apageref| is an alias for |\Azp|.
%    \begin{macrocode}
\def\Apageref{\Azp}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\azp}
%    Checks if the next character is |*| and calls
%    |\@azp| or |\azp@|.
%    \begin{macrocode}
\def\azp{a\@ifstar{\@azp}{\azp@}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\Azp}
%    Same as |\azp| except that it writes `A' instead of `a'.
%    \begin{macrocode}
\def\Azp{A\@ifstar{\@azp}{\azp@}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\azp@}
%    Calls |\@azp| then writes the label's page preceded by
%    a non-breakable space.
%    \begin{macrocode}
\def\azp@#1{\@azp{#1}\nobreakspace\pageref{#1}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@azp}
%    Calls |\hun@tempadef| then takes the label's page and passes
%    it to |\@@az|.
%    \begin{macrocode}
\def\@azp#1{%
  \hun@tempadef{hun@r@#1}{r@#1}{}%
  \ifx\@tempa\empty
  \else
    \edef\@tempb{\noexpand\@@az\expandafter\@secondoftwo\@tempa\hbox!}%
    \@tempb
  \fi
}
%    \end{macrocode}
% \end{macro}
%
%    The following macros are used to give the definite article to
%    citations.
% \begin{macro}{\acite}
%    This is an alias for |\azc|.
%    \begin{macrocode}
\def\acite{\azc}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\Acite}
%    This is an alias for |\Azc|.
%    \begin{macrocode}
\def\Acite{\Azc}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\azc}
%    Checks if the next character is a star and
%    calls |\@azc| or |\azc@|.
%    \begin{macrocode}
\def\azc{a\@ifstar{\@azc}{\azc@}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\Azc}
%    Same as |\azc| but used at the beginning of sentences.
%    \begin{macrocode}
\def\Azc{A\@ifstar{\@azc}{\azc@}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\azc@}
%    If there is no star we accept an optional argument,
%    just like the |\cite| command.
%    \begin{macrocode}
\def\azc@{\@ifnextchar [{\azc@@}{\azc@@[]}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\azc@@}
%    First calls |\@azc| then |\cite|.
%    \begin{macrocode}
\def\azc@@[#1]#2{%
  \@azc{#2}\nobreakspace\def\@tempa{#1}%
    \ifx\@tempa\@empty\cite{#2}\else\cite[#1]{#2}\fi}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@azc}
%    This is an auxiliary macro to get the first cite label
%    from a comma-separated list.
%    \begin{macrocode}
\def\@azc#1{\@@azc#1,\hbox!}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@@azc}
%    This one uses only the first argument, that is the first
%    element of the comma-separated list of cite labels.
%    Calls |\hun@tempadef| to expand the cite label with accent
%    removal and special letter replacement.
%    Then |\@@az|, the core macro, is called.
%    \begin{macrocode}
\def\@@azc#1,#2\hbox#3!{%
  \hun@tempadef{hun@b@#1}{b@#1}{}%
  \ifx\@tempa\empty
  \else
    \edef\@tempb{\noexpand\@@az\@tempa\hbox!}%
    \@tempb
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hun@number@lehgth}
%    This macro is used to count the number of digits in its
%    argument until a non-digit character is found or
%    the end of the argument is reached.
%    It must be called as
%    |\hun@number@lehgth|\textit{arg}|\hbox\hbox!| and
%    |\count@| must be zeroed.
%    It is called by |\@@az|.
%    \begin{macrocode}
\def\hun@number@lehgth#1#2\hbox#3!{%
  \ifcat\noexpand#11%
    \ifnum\expandafter`\csname#1\endcsname>47
      \ifnum\expandafter`\csname#1\endcsname<58
        \advance\count@ by \@ne
        \hun@number@lehgth#2\hbox\hbox!\fi\fi\fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hun@alph@lehgth}
%    This is used to count the number of letters until a
%    non-letter is found or the end of the argument is reached.
%    It must be called as
%    |\hun@alph@lehgth|\textit{arg}|\hbox\hbox!| and
%    |\count@| must be set to zero.
%    It is called by |\@@az@string|.
%    \begin{macrocode}
\def\hun@alph@lehgth#1#2\hbox#3!{%
  \ifcat\noexpand#1A%
    \advance\count@ by \@ne
    \hun@alph@lehgth#2\hbox\hbox!\fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@az@string}
%    This macro is called by |\@@az| if the argument begins
%    with a letter.
%    The task of |\@@az@string| is to determine if the argument
%    starts with a vowel and in that case |\let\@tempa\@tempb|.
%    After checking if the first letter is A, E, I, O, or U,
%    |\hun@alph@lehgth| is called
%    to determine the length of the argument. If it gives 1
%    (that is the argument is a single-letter one or the second
%    character is not letter) then the letters L, M, N, R, S, X, and Y
%    are also considered as a vowel since their Hungarian pronounced
%    name starts with a vowel.
%    \begin{macrocode}
\def\@@az@string#1#2{%
  \ifx#1A%
    \let\@tempa\@tempb
  \else\ifx#1E%
    \let\@tempa\@tempb
  \else\ifx#1I%
    \let\@tempa\@tempb
  \else\ifx#1O%
    \let\@tempa\@tempb
  \else\ifx#1U%
    \let\@tempa\@tempb
  \fi\fi\fi\fi\fi
  \ifx\@tempa\@tempb
  \else
    \count@\z@
    \hun@alph@lehgth#1#2\hbox\hbox!%
    \ifnum\count@=\@ne
      \ifx#1F%
        \let\@tempa\@tempb
      \else\ifx#1L%
        \let\@tempa\@tempb
      \else\ifx#1M%
        \let\@tempa\@tempb
      \else\ifx#1N%
        \let\@tempa\@tempb
      \else\ifx#1R%
        \let\@tempa\@tempb
      \else\ifx#1S%
        \let\@tempa\@tempb
      \else\ifx#1X%
        \let\@tempa\@tempb
      \else\ifx#1Y%
        \let\@tempa\@tempb
      \fi\fi\fi\fi\fi\fi\fi\fi
    \fi
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@az}
%    This macro is the core of definite article handling.
%    It determines if the argument needs `az' or `a' definite
%    article by setting |\@tempa| to `z' or |\@empty|.
%    It sets |\@tempa| to `z' if
%    \begin{itemize}
%      \item the first character of the argument is 5; or
%      \item the first character of the argument is 1 and
%            the $\mathit{length\ of\ the\ number} \pmod 3 = 1$
%            (one--egy, thousand--ezer, million--egymilli\'o,\dots); or
%      \item the first character of the argument is
%            a, A, e, E, i, I, o, O, u, or U; or
%      \item the first character of the argument is
%            l, L, m, M, n, N, r, R, s, S, x, X, y, or Y
%            and the length of the argument is 1 or the second
%            character is a non-letter.
%    \end{itemize}
%    At the end it calls |\@tempa|, that is, it either typesets a `z'
%    or nothing.
%    \begin{macrocode}
\def\@@az#1#2\hbox#3!{%
  \let\@tempa\@empty
  \def\@tempb{z}%
  \uppercase{%
    \ifx5#1%
      \let\@tempa\@tempb
    \else\ifx1#1%
      \count@\@ne
      \hun@number@lehgth#2\hbox\hbox!%
      \loop
      \ifnum\count@>\thr@@
        \advance\count@-\thr@@
      \repeat
      \ifnum\count@=\@ne
        \let\@tempa\@tempb
      \fi
    \else
      \@@az@string{#1}{#2}%
    \fi\fi
  }%
  \@tempa}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\refstepcounter}
%    |\refstepcounter| must be redefined in order to keep
%    |\@currentlabel| unexpanded. This is necessary to enable
%    the |\label| command to write a |\hunnewlabel| command
%    to the aux file with the Roman numerals substituted by
%    their Arabic representations.
%    Of course, the original definition of |\refstepcounter| is
%    saved and restored if the Hungarian language is switched off.
%    \begin{macrocode}
\expandafter\addto\csname extras\CurrentOption\endcsname{%
  \babel@save\refstepcounter
  \def\refstepcounter#1{\stepcounter{#1}%
    \def\@currentlabel{\csname p@#1\endcsname\csname the#1\endcsname}}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\label}
%    |\label| is redefined to write another line into the aux
%    file: |\hunnewlabel{ }{ }| where the Roman numerals
%    are replaced their Arabic representations.
%    The original definition of |\label| is saved into
%    |\old@label| and it is also called by |\label|.
%    On leaving the Hungarian typesetting mode |\label|'s
%    original is restored since it is added to |\noextrasmagyar|.
%    \begin{macrocode}
\expandafter\addto\csname extras\CurrentOption\endcsname{%
  \let\old@label\label
  \def\label#1{\@bsphack
    \old@label{#1}%
    \begingroup
      \let\romannumeral\number
      \def\@roman##1{\number ##1}%
      \def\@Roman##1{\number ##1}%
      {\toks0={\noexpand\noexpand\noexpand\number}%
        \def\number##1{\the\toks0 ##1}\xdef\tempb@{\thepage}}%
      \edef\@tempa##1{\noexpand\protected@write\@auxout{}%
           {\noexpand\string\noexpand\hunnewlabel
           {##1}{{\@currentlabel}{\tempb@}}}}%
      \@tempa{#1}%
    \endgroup
  \@esphack}%
}
\expandafter\addto\csname noextras\CurrentOption\endcsname{%
  \let\label\old@label
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hunnewlabel}
%    Finally, |\hunnewlabel| is defined.
%    It checks if the label's expansion (|#2|) differs from that
%    one given in the |\newlabel| command. If yes
%    (that is, the label contains some Roman numerals),
%    it defines the macro |\hun@r@|\textit{label},
%    otherwise it does nothing.
%    \begin{macrocode}
\def\hunnewlabel#1#2{%
  \def\@tempa{#2}%
  \expandafter\ifx\csname r@#1\endcsname\@tempa
    \relax% \message{No need for def: #1}%
  \else
    \global\expandafter\let\csname hun@r@#1\endcsname\@tempa%
  \fi
}
%    \end{macrocode}
% \end{macro}
%
%    For Hungarian the |`| character is made active.
% \changes{magyar-1.4c}{2001/03/05}{Make sure that the grave accent
%    has catcode 12 \emph{before} it is made \cs{active}}
%    \begin{macrocode}
\AtBeginDocument{%
  \if@filesw\immediate\write\@auxout{\catcode096=12}\fi}
\initiate@active@char{`}
\expandafter\addto\csname extras\CurrentOption\endcsname{%
  \languageshorthands{magyar}%
  \bbl@activate{`}}
\expandafter\addto\csname noextras\CurrentOption\endcsname{%
  \bbl@deactivate{`}}
%    \end{macrocode}
%
%    The character sequence |``| is declared as a shorthand
%    in order to produce
%    the opening quotation sign appropriate for Hungarian.
%    \begin{macrocode}
\declare@shorthand{magyar}{``}{\glqq}
%    \end{macrocode}
%
% In Hungarian there are some long double consonants which
% must be hyphenated specially.
% For all these long double consonants (except dzzs, that is
% extremely very-very rare) a shortcut is defined.
%    \begin{macrocode}
\declare@shorthand{magyar}{`c}{\textormath{\bbl@disc{c}{cs}}{c}}
\declare@shorthand{magyar}{`C}{\textormath{\bbl@disc{C}{CS}}{C}}
\declare@shorthand{magyar}{`d}{\textormath{\bbl@disc{d}{dz}}{d}}
\declare@shorthand{magyar}{`D}{\textormath{\bbl@disc{D}{DZ}}{D}}
\declare@shorthand{magyar}{`g}{\textormath{\bbl@disc{g}{gy}}{g}}
\declare@shorthand{magyar}{`G}{\textormath{\bbl@disc{G}{GY}}{G}}
\declare@shorthand{magyar}{`l}{\textormath{\bbl@disc{l}{ly}}{l}}
\declare@shorthand{magyar}{`L}{\textormath{\bbl@disc{L}{LY}}{L}}
\declare@shorthand{magyar}{`n}{\textormath{\bbl@disc{n}{ny}}{n}}
\declare@shorthand{magyar}{`N}{\textormath{\bbl@disc{N}{NY}}{N}}
\declare@shorthand{magyar}{`s}{\textormath{\bbl@disc{s}{sz}}{s}}
\declare@shorthand{magyar}{`S}{\textormath{\bbl@disc{S}{SZ}}{S}}
\declare@shorthand{magyar}{`t}{\textormath{\bbl@disc{t}{ty}}{t}}
\declare@shorthand{magyar}{`T}{\textormath{\bbl@disc{T}{TY}}{T}}
\declare@shorthand{magyar}{`z}{\textormath{\bbl@disc{z}{zs}}{z}}
\declare@shorthand{magyar}{`Z}{\textormath{\bbl@disc{Z}{ZS}}{Z}}
%    \end{macrocode}
%
%    The macro |\ldf@finish| takes care of looking for a
%    configuration file, setting the main language to be switched on
%    at |\begin{document}| and resetting the category code of
%    \texttt{@} to its original value.
% \changes{magyar-1.3h}{1996/10/30}{Now use \cs{ldf@finish} to wrap up}
%    \begin{macrocode}
\ldf@finish\CurrentOption
%</code>
%    \end{macrocode}
%
% \Finale
%%
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%%
\endinput
