%
% magyar.ldf -- LaTeX Language Definition for `magyar' (Hungarian), v1.5b
% written and copyright (C) by P\'eter SZAB\'O <pts@fazekas.hu>
% (version 1.5 -- Early October 2003 -- February 2004 --)
%
% The newest version of this magyar.ldf is part of MagyarLaTeX, available from
% http://www.math.bme.hu/latex/ . The web page is in Hungarian language, but
% it is easy to figure out how to download the newest magyar.ldf. Please
% bookmark this link as the definitive source of the newest version.
%
% This program is free software. There is NO WARRANTY. Use at your own risk!
% You can choose any of these licenses: GNU GPL, LaTeX's license,
% Babel's license.
%
% When will magyar.ldf 1.5 be part of mainstream LaTeX / Babel? I have no
% idea, ask the maintainer of Babel. magyar.ldf 1.5 has ptebeen converted to
% magyar.dtx on June 27, 2004. That version has been submitted to the
% maintainer of the Babel package. No reply from him since then.
%
% Should magyar.ldf 1.5 be part of tetex, or should it be available as a
% supplementary package in TeX distributions? Yes, but this is the task of the
% creators of those distributions. The Debian package ``magyarlatex'',
% which supplements the teTeX shipped with Debian Woody, Sarge and Sid,
% is available from http://www.math.bme.hu/latex/dl
% (file magyarlatex-latest.deb).
%
% The author of magyar.ldf 1.5 has uploaded it to CTAN
% (http://www.ctan.org), but he doesn't re-upload regularly, because he
% doesn't have time to maintain it and re-upload it after each bugfix. If
% you think that magyar.ldf 1.5 should be on CTAN, feel free to upload a
% snapshot, since it is free software.
%
% magyar.ldf 1.5 is based on magyar.ldf 1.4. However, it has been totally
% rewritten and extended (just compare the file sizes), and it doesn't share
% code from the earlier versions anymore. However, its default configuration
% tries to be compatible with older versions.
%
% Earlier versions of file `magyar.dtx' Babel package for LaTeX version 2e
%   Copyright (C) 1989--2004 by Johannes Braams, TeXniek
%   Copyright (C) 1989--2004 by
%   \'Arp\'ad B\'IR\'O
%   J\'ozsef B\'ERCES (version 1.4c -- 2001; contains a lot of work of him)
%
% To typeset text in Hungarian, please
%
% 1. Include `magyar huhyph.tex' in language.dat, re-run initex(1) (initex
%    'latex.ini \dump') or pdfinitex(1), verify that running latex(1) displays
%    the word `magyar' in the line containing `hyphenation patterns' in its
%    console output.
%
% 2. In the document preamble, use
%
%      \def\magyarOptions{defaults=hu-min}
%      \usepackage[magyar]{babel}
%      \usepackage{t1enc}% for automatic hyphenation of accented chars
%      \usepackage[latin2]{inputenc}% for typing chars
%
% This file is quite long, because it implements a lot of parametric features
% related to typesetting Hungarian text with \LaTeX. Sorry.
%
% Motto: ``There is a lot to do in the future'' -- by Gyöngyi Bujdosó and
% Ferenc Wettl in their conference proceedings article ``On the localization
% of TeX in Hungary'', presented at EuroBachoTeX 2002.
%
% Most of the code and comments in this file are written by P\'eter Szab\'o.
% The newest version is available from http://www.math.bme.hu/latex/
%
% The version of this file is 1.5, even when new releases come out. Please see
% the \expandafter\ProvidesLanguage line for the release date.
%

\expandafter\ifx\csname CurrentOption\endcsname\relax
  \def\CurrentOption{magyar}%
\fi
%** So `\input magyar.ldf' will work as well.
\expandafter\ifx\csname ver@babel.sty\endcsname\relax
  \csname fi\endcsname
  \endinput \expandafter\RequirePackage\expandafter[\CurrentOption]{babel}
\fi

%\ProvidesFile{magyar.ldf}[1996/12/23 v1.3h Magyar support from the babel system]
%\ProvidesLanguage{magyar}[2001/03/05 v1.4c Magyar support from the babel system]
% vvv for Babel v3.7
\expandafter\ProvidesLanguage\expandafter{\CurrentOption}[2007/10/19 v1.5  Magyar support from the babel v3.7 system]

% Possibly do \endinput if .ldf already loaded
\expandafter\LdfInit\expandafter{\CurrentOption}{captions\CurrentOption}%

% Fix \catcodes{} possibly screwed up by other Babel languages.
% Dat: \string`\string! could have been written as \string`!
\edef\@@magyar@restcats{%
  \catcode\string`\string`\the\catcode\string``\space\space
  \catcode\string`\string!\the\catcode\string`!\space\space
  \catcode\string`\string*\the\catcode\string`*\space\space
  \catcode\string`\string+\the\catcode\string`+\space\space
  \catcode\string`\string-\the\catcode\string`-\space\space
  \catcode\string`\string=\the\catcode\string`=\space\space
  \catcode\string`\string|\the\catcode\string`|\space\space
  \catcode\string`\string;\the\catcode\string`;\space\space
  \catcode\string`\string:\the\catcode\string`:\space\space
  \catcode\string`\string'\the\catcode\string`'\space\space
  \catcode\string`\string"\the\catcode\string`"\space\space
  \catcode\string`\string?\the\catcode\string`?\space\space
  \catcode\string`\string/\the\catcode\string`/\space\space
  \let\noexpand\@@magyar@restcats\noexpand\@undefined
}
\catcode\string``12       \catcode`!12 \catcode`*12 \catcode`+12 \catcode`-12
\catcode`=12 \catcode`|12 \catcode`;12 \catcode`:12 \catcode`'12 \catcode`"12
\catcode`?12 \catcode`/12

%** Expand \CurrentOption early.
\edef\@@magyar@error#1{\noexpand\PackageError{\CurrentOption.ldf}{#1}\noexpand\@ehc}

% --- Declare options.
%
% Dat: \languageattribute{magyar}{...} and \bbl@declare@ttribute{magyar}{foo}{...}
% isn't enough for us, because it is processed
% after \usepackage[magyar]{babel}, but we need the options information
% earlier. And also it cannot contain `='.
% 

%** `\dMf foo-bar {...}' is `\def\foo-bar{...}' where `-' is a letter
\def\dMf#1 {\expandafter\def\csname#1\endcsname}
\def\magyar@@unchanged{unchanged}
\def\magyar@enumarg#1#2{%
  \expandafter\ifx\csname magyar@opt@#1@@#2\endcsname\relax
    \@@magyar@error{Invalid arg for option: #1 = #2}%
  \else
    \csname magyar@opt@#1@@#2\endcsname
  \fi
}
\def\@@magyar@argw@no  {0}%
\def\@@magyar@argw@weak{1}%
\def\@@magyar@argw@yes {2}%
\def\magyar@yesweaknoarg#1#2{%
  \expandafter\ifx\csname @@magyar@argw@#2\endcsname\relax
    \@@magyar@error{Invalid arg for option: #1 = #2\MessageBreak Must be =no, =yes or =weak}%
  \else
    \expandafter\edef\csname magyar@opt@@#1\endcsname{\csname @@magyar@argw@#2\endcsname}%
  \fi
}

% Declare defaults.

%** These defaults load most of the new functionality, but try not to
%** introduce visible typographical changes over magyar.ldf v1.4. These
%** are the ovarall defaults of magyar.ldf v1.5, in case of
%** \def\magyarOptions{} (or if is missing).
%**
%** These are the defaults: (over-1.4)
%**   \def\magyarOptions{
%**     accents=defaulthigh,       % or =high or =low
%**     active=safe,               % or =problematic or =none or =onlycs
%**     activeprefix=babelopt2,    % or =none or =babelopt3 or =grave or =acute or =quotedbl
%**     activespace=none,          % or =safe or =problematic
%**     afterindent=unchanged,     % or =force-no or =force-yes
%**     amslevelfix=fix-ams,       % or =unchanged or =fix-all
%**     amsuppercasefix=fix-ams,   % or =unchanged or =fix-all
%**     amstocnumskip=\enskip,     % TeX code or --empty--
%**     amstocnumlang=all,         % or =hu
%**     amspostsectiondot=no,      % or =unchanged
%**     appendixdot=yes,           % or =no % !! dokumentálni
%**     az=weak,                   % or =yes or =no
%**     babelmarkfix=yes,          % or =unchanged
%**     captionfix=yes,            % or =unchanged
%**     captions=hu,               % or =unchanged
%**     chapterhead=yes,           % or =unchanged(=no)
%**     chapternumber=unchanged,   % see partnumber=
%**     cjhebrewfix=yes,           % or =unchanged or =onlyouter
%**     classmod=yes,              % or =unchanged(=no) or TeX class name
%**     %defaults=over-1.4,        % or =compat-1.4 or =safest or =prettiest
%**     dottedtocline=fix,         % or =unchanged
%**     emitdate=weak,             % or =no or =yes
%**     extras=yes,                % or =no
%**     fancyhdr=hu,               % or =unchanged
%**     figurecaptions=hu,         % or =us or =unchanged
%**     frenchspacing=unchanged,   % or =no or =yes
%**     hang=weak,                 % or =no or =yes
%**     hunnewlabel=yes,           % or =no or =only-hu
%**     hunumbers=yes,             % or =no
%**     hutoday=yes,               % or =no
%**     hyphenmins=22,             % or =unchanged or two chars: \lefthyphenmin\righthyphenmin
%**     hyphenation=huhyph3,       % or =none or =composite or =phonetic or =huhyphn
%**     hynumberline=unchanged,    % or =hu
%**     labelenums=unchanged,      % or =hu-a or =hu-A or =hu-d
%**     labelitems=unchanged,      % or =hu
%**     longcaption=justified,     % or =centered or =centernewline or =none (=unchanged)
%**     mathbrk=define,            % or =unchanged or =fix
%**     mathhucomma=define,        % or =unchanged or =fix
%**     mathfactorial=define,      % or =unchanged or =fix
%**     mathmuskips=unchanged,     % or =latex or =hu
%**     mathreal=weak,             % or =no or =yes
%**     mond=weak,                 % or =no or =yes
%**     ntheoremfix=yes,           % or =unchanged
%**     openqq=maybedown,          % or =up or =down or =unchanged
%**     partnumber=unchanged,      % or =huordinal or =Huordinal
%**     postdescription=unchanged, % see postpara=
%**     postpara=unchanged,        % or =bfdot or =dot or =quad or =diamond or =enskip or =quad or =em or =empty ... (\magyar@post@...)
%**     postsubpara=unchanged,     % see postpara=
%**     refstruc=weak,             % or =no or =yes
%**     %safest=no,                % or =yes (safest=no has no effect, safest=yes is equivalent to defaults=safest)
%**     sectiondot=safe,           % or =none or =problematic
%**     shorthandcs=\shu,          % or =none or a csname or a \cs, e.g shorthandcs=\shu
%**     shortrefcmds=yes,          % or =no
%**     showfix=yes,               % or =unchanged
%**     suggestions=yes,           % or =no
%**     tablecaptions=hu,          % or =us or =unchanged
%**     textqq=weak,               % or =no or =yes
%**     theoremtitle=hu,           % or =unchanged
%**     footnote=yes,              % or =unchanged or =huplain or =starplain
%**     titles=\enskip,            % TeX code: =unchanged, =\quad or other
%**     toclang=good,              % or =badfloat or =badall or =unchanged
%**     told=weak,                 % or =no or =yes
%**     varioref=hu,               % or =unchanged
%**   }\usepackage[magyar]{babel}
\dMf magyar@opt@defaults@@over-1.4 {%
  \magyar@opt@accents@@defaulthigh
  \magyar@opt@active@@safe
  \magyar@opt@activeprefix{activeprefix}{babelopt2}%
  \magyar@opt@activespace@@none
  \magyar@opt@afterindent@@unchanged
  \magyar@opt@amslevelfix{amslevelfix}{fix-ams}%
  \magyar@opt@amsuppercasefix{amsuppercasefix}{fix-ams}%
  \magyar@opt@amspostsectiondot@@no% change over 1.4
  \magyar@opt@amstocnumlang@@all
  \magyar@opt@amstocnumskip{amstocnumskip}{\enskip}% change over 1.4
  \magyar@opt@appendixdot@@yes
  \magyar@opt@babelmarkfix@@yes
  \magyar@opt@az{az}{weak}%
  \magyar@opt@captionfix@@yes
  \magyar@opt@captions@@hu
  \magyar@opt@chapternumber@@unchanged
  \magyar@opt@classmod@@yes
  \magyar@opt@dottedtocline@@fix
  \magyar@opt@emitdate{emitdate}{weak}%
  \magyar@opt@extras@@yes
  \magyar@opt@chapterhead@@yes
  \magyar@opt@fancyhdr@@hu% change over 1.4
  \magyar@opt@figurecaptions@@hu
  \magyar@opt@footnote@@yes
  \magyar@opt@frenchspacing@@unchanged
  \magyar@opt@hang{hang}{weak}%
  \magyar@opt@hunnewlabel@@yes
  \magyar@opt@hunumbers@@yes
  \magyar@opt@hutoday@@yes
  \magyar@opt@hyphenation{hyphenation}{huhyph3-or-any}%
  \magyar@opt@hyphenmins{hyphenmins}{22}% change over 1.4 Dat: Default LaTeX is {23}
  \magyar@opt@labelenums@@unchanged
  \magyar@opt@labelitems@@unchanged
  \magyar@opt@longcaption@@justified
  \magyar@opt@mathbrk@@define
  \magyar@opt@mathfactorial@@define
  \magyar@opt@mathhucomma@@define
  \magyar@opt@mathmuskips@@unchanged
  \magyar@opt@hynumberline@@unchanged
  \magyar@opt@mathreal{mathreal}{weak}%
  \magyar@opt@mond{mond}{weak}%
  \magyar@opt@ntheoremfix@@yes
  \magyar@opt@openqq@@maybedown
  \magyar@opt@partnumber@@unchanged
  \magyar@opt@postpara{}{unchanged}%
  \magyar@opt@postsubpara{}{unchanged}%
  \magyar@opt@refstruc{refstruc}{weak}%
  \magyar@opt@sectiondot@@safe
  \magyar@opt@shorthandcs{shorthandcs}{\shu}%
  \magyar@opt@shortrefcmds@@yes
  \magyar@opt@showfix@@yes
  \magyar@opt@suggestions@@yes
  \magyar@opt@tablecaptions@@hu
  \magyar@opt@textqq{textqq}{weak}%
  \magyar@opt@theoremtitle@@hu
  \magyar@opt@titles{}{\enskip}% change over 1.4
  \magyar@opt@toclang@@good
  \magyar@opt@told{told}{weak}%
  \magyar@opt@varioref@@hu
  \magyar@opt@cjhebrewfix@@yes
}

%** These defaults try to be compatible with magyar.ldf v1.4 as much as
%** possible -- but avoids stupid, problematic, dangerous implementation
%** mistakes that would make magyar.ldf incompatible with many LaTeX
%** packages. The purpose of compat-1.4 is to make the document compilable:
%** if a fix would produce better results, but documents are compilable
%** without the fix, the fix will not be applied in compat-1.4.
%** Some very useful fixes are not applied here -- please use
%** defaults=over-1.4 to have them. Also some very nice features such
%** as \emitdate and \told are not available here.
\dMf magyar@opt@defaults@@compat-1.4 {%
  \magyar@opt@accents@@defaulthigh% OK
  \magyar@opt@active@@safe% we don't want =problematic
  \magyar@opt@activeprefix@@grave% OK
  \magyar@opt@activespace@@none% OK
  \magyar@opt@afterindent@@unchanged% OK
  \magyar@opt@amslevelfix@@unchanged% OK
  \magyar@opt@amsuppercasefix@@unchanged% OK
  \magyar@opt@amspostsectiondot@@unchanged% OK
  \magyar@opt@amstocnumlang@@all% OK, irrelevant
  \magyar@opt@amstocnumskip{amstocnumskip}{}% OK
  \magyar@opt@appendixdot@@yes
  \magyar@opt@babelmarkfix@@unchanged
  \magyar@opt@az{az}{yes}% OK
  \magyar@opt@captionfix@@unchanged
  \magyar@opt@captions@@hu% OK
  \magyar@opt@chapterhead@@yes% OK
  \magyar@opt@chapternumber@@unchanged% OK
  \magyar@opt@classmod@@yes% OK
  \magyar@opt@dottedtocline@@unchanged% OK
  \magyar@opt@emitdate{emitdate}{no}% OK
  \magyar@opt@extras@@yes% OK
  \magyar@opt@fancyhdr@@unchanged% OK
  \magyar@opt@figurecaptions@@hu% OK
  \magyar@opt@footnote@@unchanged% OK
  \magyar@opt@frenchspacing@@unchanged% OK
  \magyar@opt@hang{hang}{no}% OK
  \magyar@opt@hunnewlabel@@yes% OK
  \magyar@opt@hunumbers@@no% OK
  \magyar@opt@hutoday@@yes% OK
  \magyar@opt@hyphenation{hyphenation}{huhyph3-or-any}% OK
  \magyar@opt@hyphenmins{hyphenmins}{unchanged}%
  \magyar@opt@labelenums@@unchanged% OK
  \magyar@opt@labelitems@@unchanged% OK
  \magyar@opt@longcaption@@justified% OK
  \magyar@opt@mathbrk@@unchanged% OK
  \magyar@opt@mathhucomma@@unchanged% OK
  \magyar@opt@mathfactorial@@unchanged% OK
  \magyar@opt@mathmuskips@@unchanged% OK
  \magyar@opt@hynumberline@@unchanged% OK
  \magyar@opt@mathreal{mathreal}{no}%
  \magyar@opt@mond{mond}{no}% OK
  \magyar@opt@ntheoremfix@@yes% OK
  \magyar@opt@openqq@@maybedown% OK
  \magyar@opt@partnumber@@unchanged% OK
  \magyar@opt@postpara{}{unchanged}% OK
  \magyar@opt@postsubpara{}{unchanged}% OK
  \magyar@opt@refstruc{refstruc}{no}% OK
  \magyar@opt@sectiondot@@safe% we don't want =problematic
  \magyar@opt@shorthandcs{shorthandcs}{none}% OK
  \magyar@opt@shortrefcmds@@yes% OK
  \magyar@opt@showfix@@yes% OK
  \magyar@opt@suggestions@@no% OK -- user has explicity requested defaults=compat-1.4
  \magyar@opt@tablecaptions@@hu% OK
  \magyar@opt@textqq{textqq}{no}% OK
  \magyar@opt@theoremtitle@@hu% OK
  \magyar@opt@titles{}{\quad}% OK -- ugly, but compatible
  \magyar@opt@toclang@@good% we don't want weird errors and mischosen languages (would be =badall)
  \magyar@opt@told{told}{no}% OK
  \magyar@opt@varioref@@hu% was =unchanged, but varioref.sty (2000) is buggy
  \magyar@opt@cjhebrewfix@@yes
}

%** These defaults turn of most features -- the effect is similar to as if
%** magyar.ldf hasn't been loaded at all. Useful for debugging purposes.
\def\magyar@opt@defaults@@safest{%
  \magyar@opt@accents@@defaulthigh
  \magyar@opt@active@@none
  \magyar@opt@activeprefix@@none
  \magyar@opt@activespace@@none
  \magyar@opt@afterindent@@unchanged
  \magyar@opt@amslevelfix@@unchanged
  \magyar@opt@amsuppercasefix{amsuppercasefix}{fix-ams}%
  \magyar@opt@amspostsectiondot@@unchanged
  \magyar@opt@amstocnumlang@@all% OK, irrelevant
  \magyar@opt@amstocnumskip{amstocnumskip}{}%
  \magyar@opt@appendixdot@@yes
  \magyar@opt@az{az}{no}%
  \magyar@opt@babelmarkfix@@yes
  \magyar@opt@captionfix@@yes
  \magyar@opt@captions@@unchanged
  \magyar@opt@chapternumber@@unchanged
  \magyar@opt@classmod@@unchanged
  \magyar@opt@dottedtocline@@unchanged
  \magyar@opt@emitdate{emitdate}{no}%
  \magyar@opt@extras@@no
  \magyar@opt@chapterhead@@no
  \magyar@opt@fancyhdr@@unchanged
  \magyar@opt@figurecaptions@@unchanged
  \magyar@opt@footnote@@unchanged
  \magyar@opt@frenchspacing@@unchanged
  \magyar@opt@hang{hang}{no}%
  \magyar@opt@hunnewlabel@@no
  \magyar@opt@hunumbers@@no
  \magyar@opt@hutoday@@no
  \magyar@opt@hyphenation{hyphenation}{huhyph3-or-any}%
  \magyar@opt@hyphenmins{hyphenmins}{unchanged}%
  \magyar@opt@labelenums@@unchanged
  \magyar@opt@labelitems@@unchanged
  \magyar@opt@longcaption@@unchanged
  \magyar@opt@mathbrk@@unchanged
  \magyar@opt@mathhucomma@@unchanged
  \magyar@opt@mathfactorial@@unchanged
  \magyar@opt@mathmuskips@@unchanged
  \magyar@opt@hynumberline@@unchanged
  \magyar@opt@mathreal{mathreal}{no}%
  \magyar@opt@mond{mond}{no}%
  \magyar@opt@ntheoremfix@@unchanged
  \magyar@opt@openqq@@unchanged
  \magyar@opt@partnumber@@unchanged
  \magyar@opt@postpara{}{unchanged}%
  \magyar@opt@postsubpara{}{unchanged}%
  \magyar@opt@refstruc{refstruc}{no}%
  \magyar@opt@sectiondot@@none
  \magyar@opt@shorthandcs{shorthandcs}{none}%
  \magyar@opt@shortrefcmds@@no
  \magyar@opt@showfix@@unchanged
  \magyar@opt@suggestions@@yes
  \magyar@opt@tablecaptions@@unchanged
  \magyar@opt@textqq{textqq}{no}%
  \magyar@opt@theoremtitle@@unchanged
  \magyar@opt@titles{}{unchanged}%
  \magyar@opt@toclang@@unchanged
  \magyar@opt@told{told}{no}%
  \magyar@opt@varioref@@unchanged
  \magyar@opt@cjhebrewfix@@unchanged
}

%** These defaults load almost all features, and try to do their best to make
%** the document comply to the Hungarian typography standards. Full compliance
%** is not achieved yet, and as new features are implemented, they will be
%** added to these defaults.
\def\magyar@opt@defaults@@prettiest{%
  \magyar@opt@accents@@defaulthigh% {low} would have no effect with \usepackage{t1enc}
  \magyar@opt@active@@safe
  \magyar@opt@activeprefix{activeprefix}{babelopt2}%
  \magyar@opt@activespace@@safe
  \magyar@opt@afterindent@@unchanged% keep =force-no
  \magyar@opt@amslevelfix{amslevelfix}{fix-ams}%
  \magyar@opt@amsuppercasefix{amsuppercasefix}{fix-ams}%
  \magyar@opt@amspostsectiondot@@no
  \magyar@opt@amstocnumlang@@all
  \magyar@opt@amstocnumskip{amstocnumskip}{\enskip}%
  \magyar@opt@appendixdot@@no
  \magyar@opt@az{az}{yes}%
  \magyar@opt@babelmarkfix@@yes
  \magyar@opt@captionfix@@yes
  \magyar@opt@captions@@hu
  \magyar@opt@chapternumber@@unchanged
  \magyar@opt@classmod@@yes
  \magyar@opt@dottedtocline@@fix
  \magyar@opt@emitdate{emitdate}{yes}%
  \magyar@opt@extras@@yes
  \magyar@opt@chapterhead@@yes
  \magyar@opt@fancyhdr@@hu
  \magyar@opt@figurecaptions@@hu
  \magyar@opt@footnote@@yes
  \magyar@opt@frenchspacing@@yes
  \magyar@opt@hang{hang}{yes}%
  \magyar@opt@hunnewlabel@@yes
  \magyar@opt@hunumbers@@yes
  \magyar@opt@hutoday@@yes
  \magyar@opt@hyphenation{hyphenation}{composite-or-any}%
  \magyar@opt@hyphenmins{hyphenmins}{22}% Dat: Default LaTeX is {23}
  \magyar@opt@labelenums{labelenums}{hu-a}%
  \magyar@opt@labelitems@@hu
  \magyar@opt@longcaption@@centered
  \magyar@opt@mathbrk@@fix
  \magyar@opt@mathhucomma@@fix
  \magyar@opt@mathfactorial@@fix
  \magyar@opt@mathmuskips@@hu
  \magyar@opt@hynumberline@@hu
  \magyar@opt@mathreal{mathreal}{yes}%
  \magyar@opt@mond{mond}{yes}%
  \magyar@opt@ntheoremfix@@yes
  \magyar@opt@openqq@@maybedown
  \magyar@opt@partnumber@@Huordinal
  \magyar@opt@postdescription{}{dot}%
  \magyar@opt@postpara{}{diamond}%
  \magyar@opt@postsubpara{}{star}%
  \magyar@opt@refstruc{refstruc}{yes}%
  \magyar@opt@sectiondot@@safe
  \magyar@opt@shorthandcs{shorthandcs}{\shu}%
  \magyar@opt@shortrefcmds@@no
  \magyar@opt@showfix@@yes
  \magyar@opt@suggestions@@yes
  \magyar@opt@tablecaptions@@hu
  \magyar@opt@textqq{textqq}{yes}%
  \magyar@opt@theoremtitle@@hu
  \magyar@opt@titles{}{\enskip}%
  \magyar@opt@toclang@@good
  \magyar@opt@told{told}{yes}%
  \magyar@opt@varioref@@hu
  \magyar@opt@cjhebrewfix@@yes
}

%** Expands to the \magyarOptions changes defaults=hu-min makes over
%** defaults=safest.
\def\magyar@@humin@options{%
  active=safe,
  activeprefix=babelopt2,
  activespace=safe,
  amslevelfix=fix-ams,
  amspostsectiondot=no,
  amstocnumlang=all,
  amstocnumskip=\enskip,
  appendixdot=no,
  az=weak,
  captions=hu,
  chapterhead=yes,
  cjhebrewfix=yes,
  classmod=yes,
  classmod=yes,
  dottedtocline=fix,
  emitdate=weak,
  extras=yes,
  fancyhdr=hu,
  figurecaptions=hu,
  footnote=huplain,
  frenchspacing=yes,
  hang=weak,
  hunnewlabel=yes,
  hunumbers=yes,
  hutoday=yes,
  hynumberline=hu,
  hyphenmins=22,
  labelenums=hu-d,
  labelitems=hu,
  longcaption=centered,
  mathbrk=define,
  mathbrk=fix,
  mathfactorial=define,
  mathhucomma=fix,
  mathreal=weak,
  mond=weak,
  ntheoremfix=yes,
  openqq=maybedown,
  postdescription=dot,
  postpara=diamond,
  postsubpara=star,
  refstruc=weak,
  sectiondot=safe,
  shorthandcs=\shu,
  shortrefcmds=yes,
  showfix=yes,
  tablecaptions=hu,
  textqq=weak,
  theoremtitle=hu,
  titles=\enskip,
  toclang=good,
  told=weak,
  varioref=hu,
}

%** Matches Hungarian typographic rules most closely -- and most
%** simplistically (minimally).
\dMf magyar@opt@defaults@@hu-min {%
  %\csname magyar@opt@defaults@@over-1.4\endcsname
  \csname magyar@opt@defaults@@safest\endcsname
  % Dat: no openqq=unchanged (!)
  \expandafter\magyar@doopt\magyar@@humin@options\hfuzz,%
}

\def\magyarDumpHuMin{%
  \begingroup
  \typeout{}
  \typeout{\expandafter\@gobble\string\% for defaults=hu-min}%
  \typeout{\string\def\string\magyarOptions\expandafter\@gobble\string\{}%
  \typeout{ \space defaults=safest,}%
  \typeout{ \space\expandafter\@gobble\string\%}%
  \def\magyar@applyopt##1##2{%
    \def\reserved@a{##1=##2,}%
    \typeout{ \space\expandafter\strip@prefix\meaning\reserved@a}%
  }%
  \expandafter\magyar@doopt\magyar@@humin@options\hfuzz,%
  \typeout{\expandafter\@gobble\string\}}%
  \typeout{\string\usepackage[magyar]{babel}}%
  \typeout{}%
  \endgroup
}

\let\magyar@opt@defaults\magyar@enumarg
\def\magyar@opt@safest@@yes{\magyar@opt@defaults@@safest}
\def\magyar@opt@safest@@no{}
\let\magyar@opt@safest\magyar@enumarg

% Declare normal options.

\def\magyar@opt@titles#1#2{\def\magyar@opt@@titleskip{#2}}
\def\@@magyar@twodigitcheck#1#2#3\hfuzz#4#5{%
  \csname if\ifnum0<0\string#1 \ifnum0<0\string#2 false\else true\fi\else true\fi\endcsname
    \@@magyar@error{Option #4 needs [1-9][1-9], got #1#2}%
  \fi
}
\def\magyar@opt@hyphenmins#1#2{%
  \def\reserved@a{#2}%
  \ifx\reserved@a\magyar@@unchanged
    \let\magyar@opt@@hyphenmins\@empty
  \else
    \@@magyar@twodigitcheck#2..\hfuzz{#1}{#2}%
    \def\magyar@opt@@hyphenmins{#2}%
  \fi
}

\def\magyar@opt@amstocnumskip#1#2{\def\magyar@opt@@amstocnumskip{#2}}
\def\magyar@opt@amstocnumlang@@all{\def\magyar@opt@@amstocnumlang{2}}
\def\magyar@opt@amstocnumlang@@hu {\def\magyar@opt@@amstocnumlang{1}}
\let\magyar@opt@amstocnumlang\magyar@enumarg
\def\magyar@opt@active@@none{\def\magyar@opt@@active{0}}
\def\magyar@opt@active@@onlycs{\def\magyar@opt@@active{1}}
\def\magyar@opt@active@@safe{\def\magyar@opt@@active{2}}
\def\magyar@opt@active@@problematic{\def\magyar@opt@@active{3}}
\let\magyar@opt@active\magyar@enumarg
\def\magyar@opt@activeprefix@@none    {\let\magyar@opt@@activeprefix\relax}
\def\magyar@opt@activeprefix@@acute   {\def\magyar@opt@@activeprefix{'}}
\def\magyar@opt@activeprefix@@grave   {\def\magyar@opt@@activeprefix{`}}
\def\magyar@opt@activeprefix@@quotedbl{\def\magyar@opt@@activeprefix{"}}
\dMf magyar@opt@activeprefix@@babelopt2 {%
  \@ifpackagewith{babel}{activeacute}% Dat: not expandable
    {\def\magyar@opt@@activeprefix{'}}%
    {\def\magyar@opt@@activeprefix{`}}%
}
\dMf magyar@opt@activeprefix@@babelopt3 {%
  \@ifpackagewith{babel}{activeacute}%
    {\def\magyar@opt@@activeprefix{'}}%
 {\@ifpackagewith{babel}{activegrave}%
    {\def\magyar@opt@@activeprefix{`}}%
    {\def\magyar@opt@@activeprefix{"}}}%
}
\let\magyar@opt@activeprefix\magyar@enumarg
\def\magyar@opt@activespace@@none{\def\magyar@opt@@activespace{0}}
\def\magyar@opt@activespace@@safe{\def\magyar@opt@@activespace{2}}
\def\magyar@opt@activespace@@problematic{\def\magyar@opt@@activespace{3}}
\let\magyar@opt@activespace\magyar@enumarg
\def\magyar@opt@amspostsectiondot@@no       {\def\magyar@opt@@amspostsectiondot{1}}
\def\magyar@opt@amspostsectiondot@@unchanged{\def\magyar@opt@@amspostsectiondot{0}}
\let\magyar@opt@amspostsectiondot\magyar@enumarg
\let\magyar@opt@hyphenation\magyar@enumarg
\def\magyar@opt@hyphenation@@huhyphf  {\magyar@opt@hyphenation@@phonetic}
\def\magyar@opt@hyphenation@@huhyphc  {\magyar@opt@hyphenation@@composite}
\expandafter\ifx\csname @OFWO\endcsname\relax
% Imp: fix --:hyphenation= reporting above
\def\magyar@opt@hyphenation@@none              {\def\magyar@opt@@hyphenation{}}
\dMf magyar@opt@hyphenation@@huhyph3           {\def\magyar@opt@@hyphenation{3rN}}
\dMf magyar@opt@hyphenation@@huhyph3-or-any    {\def\magyar@opt@@hyphenation{3CmhwN}}
\def\magyar@opt@hyphenation@@huhyphn           {\def\magyar@opt@@hyphenation{nrN}}
\def\magyar@opt@hyphenation@@composite         {\def\magyar@opt@@hyphenation{crN}}
\dMf magyar@opt@hyphenation@@composite-or-any  {\def\magyar@opt@@hyphenation{cCmhwN}}
\def\magyar@opt@hyphenation@@any               {\def\magyar@opt@@hyphenation{CmhwN}}
\def\magyar@opt@hyphenation@@phonetic          {\def\magyar@opt@@hyphenation{frN}}
\else% report to lafmtgen.pl
  \typeout{--:hyphenation-=\CurrentOption}
  \def\magyar@opt@@hyphenation{}%
  \def\magyar@opt@hyphenation@@none     {\def\magyar@opt@@hypr{}}
  \dMf magyar@opt@hyphenation@@huhyph3  {\def\magyar@opt@@hypr{\typeout{--:hyphenation=magyar3}\typeout{--:hyphenation=magyar}}} % install both for safety
  \def\magyar@opt@hyphenation@@huhyphn  {\def\magyar@opt@@hypr{\typeout{--:hyphenation=magyarn}\typeout{--:hyphenation=magyar}}}
  \def\magyar@opt@hyphenation@@composite{\def\magyar@opt@@hypr{\typeout{--:hyphenation=magyarc}\typeout{--:hyphenation=magyar}}}
  \def\magyar@opt@hyphenation@@phonetic {\def\magyar@opt@@hypr{\typeout{--:hyphenation=magyarf}}}
\fi
\def\magyar@opt@sectiondot@@none{\def\magyar@opt@@sectiondot{0}}
\def\magyar@opt@sectiondot@@safe{\def\magyar@opt@@sectiondot{1}}
\def\magyar@opt@sectiondot@@problematic{\def\magyar@opt@@sectiondot{2}}
\let\magyar@opt@sectiondot\magyar@enumarg
\def\magyar@opt@captions@@unchanged{\def\magyar@opt@@captions{0}}
\def\magyar@opt@captions@@hu{\def\magyar@opt@@captions{1}}
\let\magyar@opt@captions\magyar@enumarg
\def\magyar@opt@varioref@@unchanged{\def\magyar@opt@@varioref{0}}
\def\magyar@opt@varioref@@hu{\def\magyar@opt@@varioref{1}}
\let\magyar@opt@varioref\magyar@enumarg
\def\magyar@opt@cjhebrewfix@@unchanged{\def\magyar@opt@@cjhebrewfix{0}}
\def\magyar@opt@cjhebrewfix@@onlyouter{\def\magyar@opt@@cjhebrewfix{1}}
\def\magyar@opt@cjhebrewfix@@yes{\def\magyar@opt@@cjhebrewfix{2}}
\let\magyar@opt@cjhebrewfix\magyar@enumarg
\def\magyar@opt@fancyhdr@@unchanged{\def\magyar@opt@@fancyhdr{0}}
\def\magyar@opt@fancyhdr@@hu{\def\magyar@opt@@fancyhdr{1}}
\let\magyar@opt@fancyhdr\magyar@enumarg
\def\magyar@opt@ntheoremfix@@unchanged{\def\magyar@opt@@ntheoremfix{0}}
\def\magyar@opt@ntheoremfix@@yes{\def\magyar@opt@@ntheoremfix{1}}
\let\magyar@opt@ntheoremfix\magyar@enumarg
\def\magyar@opt@figurecaptions@@unchanged{\def\magyar@opt@@figurecaptions{0}}
\def\magyar@opt@figurecaptions@@hu{\def\magyar@opt@@figurecaptions{1}}
\def\magyar@opt@figurecaptions@@us{\def\magyar@opt@@figurecaptions{2}}
\let\magyar@opt@figurecaptions\magyar@enumarg
\def\magyar@opt@tablecaptions@@unchanged{\def\magyar@opt@@tablecaptions{0}}
\def\magyar@opt@tablecaptions@@hu{\def\magyar@opt@@tablecaptions{1}}
\def\magyar@opt@tablecaptions@@us{\def\magyar@opt@@tablecaptions{2}}
\let\magyar@opt@tablecaptions\magyar@enumarg
\def\magyar@opt@toclang@@unchanged{\def\magyar@opt@@toclang{0}}% same as =badall
\def\magyar@opt@toclang@@badall{\def\magyar@opt@@toclang{0}}
\def\magyar@opt@toclang@@badfloat{\def\magyar@opt@@toclang{1}}
\def\magyar@opt@toclang@@good{\def\magyar@opt@@toclang{2}}
\let\magyar@opt@toclang\magyar@enumarg
\def\magyar@opt@mathbrk@@unchanged{\def\magyar@opt@@mathbrk{0}}
\def\magyar@opt@mathbrk@@define{\def\magyar@opt@@mathbrk{1}}
\def\magyar@opt@mathbrk@@fix{\def\magyar@opt@@mathbrk{2}}
\let\magyar@opt@mathbrk\magyar@enumarg
\def\magyar@opt@mathfactorial@@unchanged{\def\magyar@opt@@mathfactorial{0}}
\def\magyar@opt@mathfactorial@@define{\def\magyar@opt@@mathfactorial{1}}
\def\magyar@opt@mathfactorial@@fix{\def\magyar@opt@@mathfactorial{2}}
\let\magyar@opt@mathfactorial\magyar@enumarg
\def\magyar@opt@mathhucomma@@unchanged{\def\magyar@opt@@mathhucomma{0}}
\def\magyar@opt@mathhucomma@@define{\def\magyar@opt@@mathhucomma{1}}
\def\magyar@opt@mathhucomma@@fix{\def\magyar@opt@@mathhucomma{2}}
\let\magyar@opt@mathhucomma\magyar@enumarg
\def\magyar@opt@mathmuskips@@unchanged{\def\magyar@opt@@mathmuskips{0}}
\def\magyar@opt@mathmuskips@@latex{\def\magyar@opt@@mathmuskips{1}}
\def\magyar@opt@mathmuskips@@hu{\def\magyar@opt@@mathmuskips{2}}
\let\magyar@opt@mathmuskips\magyar@enumarg
\def\magyar@opt@hynumberline@@unchanged{\def\magyar@opt@@hynumberline{0}}
\def\magyar@opt@hynumberline@@latex{\def\magyar@opt@@hynumberline{1}}
\def\magyar@opt@hynumberline@@hu{\def\magyar@opt@@hynumberline{2}}
\let\magyar@opt@hynumberline\magyar@enumarg
\def\magyar@opt@hunnewlabel@@no {\def\magyar@opt@@hunnewlabel{0}}
\dMf magyar@opt@hunnewlabel@@only-hu {\def\magyar@opt@@hunnewlabel{1}}
\def\magyar@opt@hunnewlabel@@yes{\def\magyar@opt@@hunnewlabel{2}}
\let\magyar@opt@hunnewlabel\magyar@enumarg
\def\magyar@opt@partnumber@@unchanged{\def\magyar@opt@@partnumber{0}}
\def\magyar@opt@partnumber@@huordinal{\def\magyar@opt@@partnumber{1}}
\def\magyar@opt@partnumber@@Huordinal{\def\magyar@opt@@partnumber{2}}
\let\magyar@opt@partnumber\magyar@enumarg
\def\magyar@opt@chapternumber@@unchanged{\def\magyar@opt@@chapternumber{0}}
\def\magyar@opt@chapternumber@@huordinal{\def\magyar@opt@@chapternumber{1}}
\def\magyar@opt@chapternumber@@Huordinal{\def\magyar@opt@@chapternumber{2}}
\let\magyar@opt@chapternumber\magyar@enumarg
\def\magyar@opt@accents@@high{\def\magyar@opt@@umlaut{\umlauthigh}}
\def\magyar@opt@accents@@low{\def\magyar@opt@@umlaut{\umlautlow\umlautelow}}
\def\magyar@opt@accents@@defaulthigh{\let\magyar@opt@@umlaut\@empty}
\let\magyar@opt@accents\magyar@enumarg
\def\magyar@opt@longcaption@@centered{\def\magyar@caption@centering{\centering}\def\magyar@caption@newline{\ }}
\def\magyar@opt@longcaption@@justified{\def\magyar@caption@centering{\relax}\def\magyar@caption@newline{\ }}
\def\magyar@opt@longcaption@@centernewline{\def\magyar@caption@centering{\centering}\def\magyar@caption@newline{\\\relax}}
\def\magyar@opt@longcaption@@none{\let\magyar@caption@centering\@empty}
\def\magyar@opt@longcaption@@unchanged{\let\magyar@caption@centering\@empty}
\let\magyar@opt@longcaption\magyar@enumarg
\def\magyar@opt@suggestions@@no {\def\magyar@opt@@suggestions{0}}
\def\magyar@opt@suggestions@@yes{\def\magyar@opt@@suggestions{1}}
\let\magyar@opt@suggestions\magyar@enumarg
\def\magyar@opt@appendixdot@@no {\def\@@magyar@appendixname{\appendixname}}
\def\magyar@opt@appendixdot@@yes{\def\@@magyar@appendixname{}}
\let\magyar@opt@appendixdot\magyar@enumarg
\def\magyar@opt@extras@@no {\def\magyar@opt@@extras{0}}
\def\magyar@opt@extras@@yes{\def\magyar@opt@@extras{1}}
\let\magyar@opt@extras\magyar@enumarg
\def\magyar@opt@chapterhead@@unchanged{\def\magyar@opt@@chapterhead{0}}
\def\magyar@opt@chapterhead@@no{\def\magyar@opt@@chapterhead{0}}
\def\magyar@opt@chapterhead@@yes{\def\magyar@opt@@chapterhead{1}}
\let\magyar@opt@chapterhead\magyar@enumarg
\def\magyar@opt@classmod@@no       {\let\magyar@opt@@classmod\relax}
\def\magyar@opt@classmod@@unchanged{\let\magyar@opt@@classmod\relax}
\def\magyar@opt@classmod@@yes      {\let\magyar@opt@@classmod\@empty}
\def\magyar@opt@classmod#1#2{%
  \expandafter\ifx\csname magyar@opt@#1@@#2\endcsname\relax
    \@namedef{magyar@opt@@#1}{#2}%
  \else
    \csname magyar@opt@#1@@#2\endcsname
  \fi
}
\def\magyar@opt@shorthandcs#1#2{%
  \def\reserved@a{#2}%
  \def\reserved@b{none}%
  \ifx\reserved@a\reserved@b
    \def\magyar@opt@@shorthandcs{0}% overridable
  \else
    \def\magyar@opt@@shorthandcs{1}%
    \ifcat\hfuzz\noexpand#2\relax% #2 is \shu  \shu`tty is `tty
      \def#2##1{\protect\@@magyar@shorthand}% Dat: ##1 is usually `_12
    \else
      \@namedef{#2}{\protect\@@magyar@shorthand}%
    \fi
  \fi
}
\def\magyar@opt@hunumbers@@no{\def\magyar@opt@@hunumbers{0}}
\def\magyar@opt@hunumbers@@yes{\def\magyar@opt@@hunumbers{1}}
\let\magyar@opt@hunumbers\magyar@enumarg
\let\magyar@opt@az\magyar@yesweaknoarg
\let\magyar@opt@told\magyar@yesweaknoarg
\let\magyar@opt@textqq\magyar@yesweaknoarg
\let\magyar@opt@emitdate\magyar@yesweaknoarg
\let\magyar@opt@mathreal\magyar@yesweaknoarg
\let\magyar@opt@refstruc\magyar@yesweaknoarg
\let\magyar@opt@mond\magyar@yesweaknoarg
\let\magyar@opt@hang\magyar@yesweaknoarg
\def\magyar@opt@theoremtitle@@unchanged{\def\magyar@opt@@theoremtitle{0}}
\def\magyar@opt@theoremtitle@@hu{\def\magyar@opt@@theoremtitle{1}}
\let\magyar@opt@theoremtitle\magyar@enumarg
\def\magyar@opt@footnote@@unchanged{\def\magyar@opt@@footnote{0}}
\def\magyar@opt@footnote@@yes{\def\magyar@opt@@footnote{1}}
\def\magyar@opt@footnote@@huplain{\def\magyar@opt@@footnote{2}}
\def\magyar@opt@footnote@@starplain{\def\magyar@opt@@footnote{3}}
\let\magyar@opt@footnote\magyar@enumarg
\def\magyar@opt@hutoday@@no{\def\magyar@opt@@hutoday{0}}
\def\magyar@opt@hutoday@@yes{\def\magyar@opt@@hutoday{1}}
\let\magyar@opt@hutoday\magyar@enumarg
\def\magyar@opt@shortrefcmds@@no{\def\magyar@opt@@shortrefcmds{0}}
\def\magyar@opt@shortrefcmds@@yes{\def\magyar@opt@@shortrefcmds{1}}
\let\magyar@opt@shortrefcmds\magyar@enumarg
\def\magyar@opt@dottedtocline@@fix{\def\magyar@opt@@dottedtocline{1}}
\def\magyar@opt@dottedtocline@@unchanged{\def\magyar@opt@@dottedtocline{0}}
\let\magyar@opt@dottedtocline\magyar@enumarg
\let\magyar@opt@amslevelfix\magyar@enumarg
\def\magyar@opt@amslevelfix@@unchanged{\def\magyar@opt@@amslevelfix{0}}
\dMf magyar@opt@amslevelfix@@fix-ams  {\def\magyar@opt@@amslevelfix{1}}
\dMf magyar@opt@amslevelfix@@fix-all  {\def\magyar@opt@@amslevelfix{2}}
\let\magyar@opt@amsuppercasefix\magyar@enumarg
\def\magyar@opt@amsuppercasefix@@unchanged{\def\magyar@opt@@amsuppercasefix{0}}
\dMf magyar@opt@amsuppercasefix@@fix-ams  {\def\magyar@opt@@amsuppercasefix{1}}
\dMf magyar@opt@amsuppercasefix@@fix-all  {\def\magyar@opt@@amsuppercasefix{2}}
\let\magyar@opt@captionfix\magyar@enumarg
\def\magyar@opt@captionfix@@unchanged{\def\magyar@opt@@captionfix{0}}
\def\magyar@opt@captionfix@@yes      {\def\magyar@opt@@captionfix{1}}
\let\magyar@opt@babelmarkfix\magyar@enumarg
\def\magyar@opt@babelmarkfix@@unchanged{\def\magyar@opt@@babelmarkfix{0}}
\def\magyar@opt@babelmarkfix@@yes      {\def\magyar@opt@@babelmarkfix{1}}
\let\magyar@opt@showfix\magyar@enumarg
\def\magyar@opt@showfix@@unchanged{\def\magyar@opt@@showfix{0}}
\def\magyar@opt@showfix@@yes      {\def\magyar@opt@@showfix{1}}
\def\magyar@opt@labelenums@@unchanged{\def\magyar@opt@@labelenums{0}}
\dMf magyar@opt@labelenums@@hu-a     {\def\magyar@opt@@labelenums{1}}
\dMf magyar@opt@labelenums@@hu-A     {\def\magyar@opt@@labelenums{2}}
\dMf magyar@opt@labelenums@@hu-d     {\def\magyar@opt@@labelenums{3}}
\let\magyar@opt@labelenums\magyar@enumarg
\def\magyar@opt@labelitems@@unchanged{\def\magyar@opt@@labelitems{0}}
\def\magyar@opt@labelitems@@hu       {\def\magyar@opt@@labelitems{1}}
\let\magyar@opt@labelitems\magyar@enumarg
\def\magyar@opt@openqq@@unchanged{\def\magyar@opt@@openqq{0}}
\def\magyar@opt@openqq@@up{\def\magyar@opt@@openqq{1}}
\def\magyar@opt@openqq@@down{\def\magyar@opt@@openqq{2}}
\def\magyar@opt@openqq@@maybedown{\def\magyar@opt@@openqq{3}}
\let\magyar@opt@openqq\magyar@enumarg
\def\magyar@opt@frenchspacing@@unchanged{\def\magyar@opt@@frenchspacing{0}}% same as =no
\def\magyar@opt@frenchspacing@@no {\def\magyar@opt@@frenchspacing{1}}
\def\magyar@opt@frenchspacing@@yes{\def\magyar@opt@@frenchspacing{2}}
\let\magyar@opt@frenchspacing\magyar@enumarg
\dMf magyar@opt@afterindent@@force-no {\def\magyar@opt@@afterindent{0}}
\dMf magyar@opt@afterindent@@force-yes {\def\magyar@opt@@afterindent{1}}
\dMf magyar@opt@afterindent@@unchanged {\def\magyar@opt@@afterindent{9}}
\let\magyar@opt@afterindent\magyar@enumarg
\def\magyar@opt@postpara#1#2{%
  \def\reserved@a{#2}%
  \ifx#2\magyar@@unchanged
    \let\magyar@opt@@paragraphs\@undefined
  \else
    \expandafter\def\csname magyar@opt@@#1\endcsname{#2}%
    \let\magyar@opt@@paragraphs\@empty
  \fi
}
\let\magyar@opt@postsubpara\magyar@opt@postpara
\let\magyar@opt@postdescription\magyar@opt@postpara

% --- Option processing code of \magyarOptions
%
% Example: \def\magyarOptions{titles=\quad,active=safe} \usepackage[magyar]{babel}
% Dat: Babel has \languageoptions, but it is quite weak and it's too late
% Dat: this is a complete rewrite based on examplep.sty

%** @param #1 to gobble a space token
%** @usage \magyar@doopt foo=bar,foo2=bar2,\hfuzz,%
\def\magyar@doopt#1,{%
  \if,\noexpand#1,% ignore multiple commas (#1 is empty)
    \expandafter\magyar@doopt
  \else
    \csname fi\endcsname% don't count as `\fi' when being skipped
    \magyar@doopt@low#1,=,%
  \fi
}
\@gobble\iftrue% \def\magyar@doopt@low contains `\fi'. Make it skippable.
\def\magyar@applyopt#1#2{\csname magyar@opt@#1\endcsname{#1}{#2}}%
%** @param #1 is here for gobbling space tokens
\def\magyar@doopt@low#1#2=#3,#4\fi{%
  % Dat: Normal case: #1#2 is key, #3 is value, #4 is `=,'
  % Dat: MissingArg case: #1#2 is `key,', #3 is empty, #4 is empty
  % Dat: Terminator case: #1#2 is `\hfuzz,', #3 is empty, #4 is empty
  % Dat: OnlySpace case: #1 is `,', #2 is empty, #3 is empty, #4 is empty
  \ifx\relax#4\relax% MissingArg or Terminator
    \ifx#1\hfuzz% Terminator
    \else
      \if,\noexpand#1\else% OnlySpace case
        \if=\noexpand#1\magyar@doopt@missingkey#2% #2 already contains comma at end
        \else          \magyar@doopt@missingval#1#2\fi
      \fi
      \expandafter\expandafter\expandafter\magyar@doopt
    \fi
  \else% Normal
    \expandafter\ifx\csname magyar@opt@#1#2\endcsname\relax
      \@@magyar@error{Unknown option: #1#2 (= #3)}%
    \else
      \magyar@applyopt{#1#2}{#3}%
    \fi
    \expandafter\magyar@doopt
  \fi
}
\def\magyar@doopt@missingkey#1,{%
  \@@magyar@error{Key missing for value: #1}%
}
\def\magyar@doopt@missingval#1,{%
  \@@magyar@error{Value (=) missing for option: #1}%
}
%** Dat: Spaces and newlines at end of #1 are not ignored, so please prefix
%**      them with a comma, e.g \magyar@doopts{foo=bar, }
%** @param #1 comma-separated optoinname=value pairs
%\def\magyar@doopts#1{\magyar@doopt #1,\hfuzz,}%

\def\magyar@dooptions{%
  \expandafter\ifx\csname opt@\CurrentOption.ldf.sty\endcsname\relax\else
    % Usage: \PassOptionsToPackage{foo=bar}{magyar.ldf}
    \expandafter\expandafter\expandafter
    \magyar@doopt\csname opt@\CurrentOption.ldf.sty\endcsname,\hfuzz,%
   \expandafter\let\csname opt@\CurrentOption.ldf.sty\endcsname\relax
  \fi
  \expandafter\ifx\csname \CurrentOption Options\endcsname\relax\else% \magyarOptions
    \expandafter\expandafter\expandafter
    \magyar@doopt\csname\CurrentOption Options\endcsname,\hfuzz,%
    \expandafter\let\csname \CurrentOption Options\endcsname\relax
  \fi
}
\def\magyar@do@option@low#1#2=#3=,\vfuzz{%
  \ifx#1\hfuzz\else
    %%\typeout{(#1#2)=(#3)}%
    % vvv wastes some heap (\csname), but never mind
  \fi    
}


\magyar@opt@defaults{defaults}{over-1.4}  % defaults=over-1.4 by default
\def\magyar@opt@@hdrtitleskip{\enskip}% !! option for that
\magyar@dooptions% in \magyarOptions
\ifnum\magyar@opt@@openqq=3 % =maybedown
  \ifnum\magyar@opt@@active=0
    \def\magyar@opt@@openqq{0}% =unchanged
  \else
    \def\magyar@opt@@openqq{2}% =down
  \fi
\fi
\ifnum\magyar@opt@@partnumber   >0 \let\magyar@needopt@hunumbers\@empty \fi
\ifnum\magyar@opt@@chapternumber>0 \let\magyar@needopt@hunumbers\@empty \fi
\expandafter\ifx\csname magyar@needopt@hunumbers\endcsname\relax\else
  \ifnum\magyar@opt@@hunumbers=0
    \@@magyar@error{(chapter|part)number=... needs hunumbers=yes}%
    \magyar@opt@@hunumbers1
  \fi
  \def\magyar@hunumbers@noclassmod{%
    \@@magyar@error{unsupported \string\documentclass,\MessageBreak
      hunumbers=yes,chapternumber=,partnumber= disabled}%
  }%
  \def\magyar@hunumbers@errmsg{\magyar@hunumbers@noclassmod}%
  \AtBeginDocument\magyar@hunumbers@errmsg
\fi
\if0\magyar@opt@@shorthandcs\else
  \if\magyar@opt@@active0%
    \@@magyar@error{active=none implies shorthandcs=none}%
    \magyar@opt@@active2 % active=safe
  \fi
\fi
% Imp: undef \magyar\@opt@* to save memory

\@gobble\iftrue
%** Usage: `\if...\else\@@magyar@skiplong\fi ... \@gobble{^}', where {^} is in
%** its own line
\def\@@magyar@skiplong#1{%
  \fi
  %\typeout{--skipfrom:\the\inputlineno}
  \bgroup% so ^} would close it
  \catcode\string`^13 \lccode\string`~=\string`^
  \lowercase{\let~\fi}% \lowercase because catcode of ^ in \let^ would have been already assigned
  %\lowercase{\def~{\typeout{--skipto:\inputlineno}\fi}}%
  \catcode\string`\\14 % comment -- avoid using hash memory
  \catcode\string`$14 % %$
  \iffalse
}
\@gobble\fi

\@namedef{extras\CurrentOption}{}%

% --- hyphenation=

\csname magyar@opt@@hypr\endcsname
\let\magyar@sugg@pa\@gobble
%\show\magyar@opt@@hyphenation
\ifx\magyar@opt@@hyphenation\@empty
  % Hungarian words won't be hyphenated automatically
  \expandafter\chardef\csname l@\CurrentOption\endcsname255
  \@@magyar@skiplong\fi
% Define a warning, will be printed later.
\def\@@magyar@suggpa@req@def{%
  \def\magyar@sugg@pa##1{%
  \PackageWarningNoLine{##1.ldf}{%
    Requested Hungarian hyphenation= patterns missing.\MessageBreak
    To make LaTeX hyphenate Hungarian words, please\MessageBreak
    modify language.dat and rerun initex or texconfig}}}%
% Define a warning, will be printed later.
\def\@@magyar@suggpa@all@def{%
  \def\magyar@sugg@pa##1{%
  \PackageWarningNoLine{##1.ldf}{%
    All Hungarian hyphenation= patterns missing.\MessageBreak
    To make LaTeX hyphenate Hungarian words, please\MessageBreak
    modify language.dat and rerun initex or texconfig}}}%
\def\@@magyar@hyphenation@last#1\@@magyar@hyphenation@next#2\hfuzz{#1}%
\def\@@magyar@hyphenation@defcs#1#2{\ifx#1#2\else\chardef#1#2\fi}% Dat: \chardef\foo\foo doesn't work
\def\@@magyar@hyphenation@def#1{%
  \expandafter\ifx\csname l@#1\endcsname\relax\else
    \expandafter\expandafter\expandafter\@@magyar@hyphenation@defcs
      \expandafter\expandafter\csname l@\CurrentOption\endcsname
      \csname l@#1\endcsname
    \@@magyar@hyphenation@last\fi}%
\def\@@magyar@hyphenation@next#1{%
  \ifx#1\hfuzz
  \else\if#1N% none
    % Turn of hyphenation.
    \expandafter\chardef\csname l@\CurrentOption\endcsname255
    \@@magyar@hyphenation@last
  \else\if#1C% use l@\CurrentOption if defined
    \expandafter\ifx\csname l@\CurrentOption\endcsname\relax\else
      \@@magyar@hyphenation@last
    \fi
  \else\if#1w% print the all-missing-warning
    \@@magyar@suggpa@all@def
  \else\if#1r% print the req-missing-warning
    \@@magyar@suggpa@req@def
  \else\if#1h\@@magyar@hyphenation@def{hungarian}%
  \else\if#1m\@@magyar@hyphenation@def{magyar}%
  \else\if#13\@@magyar@hyphenation@def{magyar3}%
  \else\if#1c\@@magyar@hyphenation@def{magyarc}%
  \else\if#1f\@@magyar@hyphenation@def{magyarf}%
  \else\if#1n\@@magyar@hyphenation@def{magyarn}%
  \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\@@magyar@hyphenation@next
  % Dat: no \adddialect\l@magyar... - it's only a chardef
}%

%\tracingmacros1 \show\magyar@opt@@hyphenation
\expandafter\@@magyar@hyphenation@next\magyar@opt@@hyphenation\hfuzz
%\show\l@magyar
%\tracingmacros0
\expandafter\ifx\csname l@\CurrentOption\endcsname\relax
  \expandafter\newcount\csname l@\CurrentOption\endcsname
  % ^^^ BUGFIX at Tue Oct 12 14:13:54 CEST 2004
\fi
\let\@@magyar@suggpa@all@def\@undefined
\let\@@magyar@suggpa@req@def\@undefined
\@gobble
{^}

% --- accents=

\ifx\magyar@opt@@umlaut\@empty\else% !! test this
  % Dat: this only affects \"
  \expandafter\addto\csname extras\CurrentOption\endcsname{%
    \babel@save\"\umlautlow \magyar@opt@@umlaut}
\fi

% --- theorem title number ordering and the dot; theoremtitle=
%
% Dat: \ref{mytheorem} never appends a dot

\if0\magyar@opt@@theoremtitle \@@magyar@skiplong\fi
% for theorem.sty and ntheorem.sty
% Define your \newtheorem commands in the preamble, before \theoremstyle
\def\magyar@th@magyar{%
  \def\@begintheorem##1##2{%
    \item[\hskip \labelsep{\theorem@headerfont ##2.\ ##1.}]}%
  \def\@opargbegintheorem##1##2##3{%
    \item[\hskip \labelsep{\theorem@headerfont ##2.\ ##1\ (##3).}]}%
}

% vvv Dat: theorem.sty needs \th@magyar-plain when \theoremstyle{...}
%     is called, so we have to define it early (even if theorem.sty is not
%     loaded).
\expandafter\let\csname th@\CurrentOption-plain\endcsname\magyar@th@magyar% Dat: moved to earlier
% !! now \usepackage{theorem}
%        \usepackage[magyar]{babel}
%        \theoremstyle{magyar-plain}% % Dat: must be put before \new
%        \newtheorem{Def}{Defin\'{i}ci\'o}

%** @param #1 magyar
\def\@@magyar@setup@theoremstyle#1{%
  \expandafter\ifx\csname theorem@headerfont\endcsname\relax
    \let\magyar@th@magyar\@undefined
  \else
    %\expandafter\let\csname th@#1-plain\endcsname\magyar@th@magyar% Dat: moved to earlier
    % vvv Dat: activate the Hungarian theorem style by default.
    \def\theorem@headerfont{\bf}%
    \edef\reserved@a{\the\theorem@style}%
    \def\reserved@b{plain}%
    \ifx\reserved@a\reserved@b
      \expandafter\theorem@style\expandafter{#1-plain}%
    \fi
  \fi
}

% Do this quite late in case theorem.sty or ntheorem.sty is loaded late.
\expandafter\AtBeginDocument\expandafter{\expandafter
  \@@magyar@setup@theoremstyle\expandafter{\CurrentOption}}

\expandafter\addto\csname extras\CurrentOption\endcsname{%
  %%\show\theorem@headerfont
  \expandafter\ifx\csname thm@swap\endcsname\relax
    \expandafter\ifx\csname theorem@headerfont\endcsname\relax% no theorem.sty
      \babel@save\@begintheorem
      % Dat: amsart.cls: \def\@begintheorem#1#2[#3]{}%
      \def\@begintheorem#1#2{\trivlist
	\item[\hskip \labelsep{\bfseries #2.\ #1.}]\itshape}% old: \slshape
      \babel@save\@opargbegintheorem
      \def\@opargbegintheorem#1#2#3{\trivlist
	\item[\hskip \labelsep{\bfseries #2.\ #1\ (#3).}]\itshape}% old: \slshape
    \else% theorem.sty or ntheorem.sty
      % Nothing -- style already set up in the preamble.
    \fi
  \else% amsthm.sty
    \babel@save\thmhead
    \babel@save\swappedhead
    %** \swapnumbers. \newtheorem{...}{...} already inserts the trailing dot
    % \def\thm@swap{S}% no effect :-(
    %** overrides amsart.cls
    \def\thmhead#1#2#3{%
      \thmnumber{\@upn{#2}\@ifnotempty{#1}{.~}}%
      \thmname{#1}%
      \thmnote{ {\the\thm@notefont(#3)}}%
    }%
    \let\swappedhead\thmhead
  \fi
}%
\@gobble
{^}%

% --- Quotation marks with \textqq
%
% Symbols of Hungarian quoting: unquoted ,,outer >>middle 'inner'<<''
% Equivalent: unquoted \quotedblbase outer \guillemotright middle
%   \textquoteright inner\textquoteright\guillemotleft\textquotedblright
% With magyar.ldf: unquoted \textqq{outer \textqq{middle \textqq{inner}}}
% Typing this with magyar.ldf works for outer: \textqq{foo}
% Typing this works with T1 and OT1 for outer: \glqq foo''
% Typing this works in T1, but not in OT1 for outer: ,,foo''
%

\if0\magyar@opt@@textqq \@@magyar@skiplong\fi
\def\magyar@textqq@level{0}
%** Provide a placeholder for language-unspecific \textqq
\def\@@magyar@textqq@nolang#1{%
  \ifcase\magyar@textqq@level
    \def\magyar@textqq@level{1}%
    \textquotedblleft#1\textquotedblright
    \def\magyar@textqq@level{0}%
  \or
    \textquoteleft#1\textquoteright
  \fi
}
\def\@@magyar@textqq@hu#1{\ifmmode\expandafter\mbox\fi{%
  % Imp: \textqq{\textqq{foo}} -> \textqq{\textqq{foo}\,}
  % Dat: \showhyphens{\textqq{hello bello}} --> hel-lo bel-lo
  % Dat: \guillemotleft is provided by babel.def even for the OT1 encoding
  \ifcase\magyar@textqq@level
    \def\magyar@textqq@level{1}%
    % Dat: \hskip instead of \kern to allow hyphenation
    % \nobreak\hskip-.06em adds a non-breakable skip and allows hyphenation
    % of the following word.
    \quotedblbase\nobreak\hskip-.06em\relax#1\kern\z@\textquotedblright% skip OK for the CM and EC fonts
    \def\magyar@textqq@level{0}%
  \or
    \def\magyar@textqq@level{2}%
    \guillemotright\nobreak\hskip-.07em\relax#1\kern-0.05em\guillemotleft% skip OK for CM and EC fonts
    \def\magyar@textqq@level{1}%
  \or
    \def\magyar@textqq@level{3}%
    \textquoteright\nobreak\hskip\z@\relax#1\kern\z@\textquoteright
    \def\magyar@textqq@level{2}%
  \else
    \quotedblbase\nobreak\hskip-.06em\relax#1\kern\z@\textquotedblright% skip OK for the CM and EC fonts
  \fi
}}%

\catcode`\ =11\relax% make space a letter
\ifnum\magyar@opt@@textqq\expandafter\ifx\csname\@gobble.textqq\endcsname\relax1\fi>1\relax% 21, 2, 11, 1
\def\textqq{\protect\textqq }% \MakeRobust
\def\@@magyar@textqq{\protect\textqq }%
\let\textqq \@@magyar@textqq@nolang%
\expandafter\addto\csname\@gobble.extras\CurrentOption\endcsname%
{\babel@save\textqq \let\textqq \@@magyar@textqq@hu}%
\else%
\def\@@magyar@textqq{\protect\@@magyar@textqq }% \MakeRobust
\let\@@magyar@textqq \@@magyar@textqq@nolang%
\expandafter\addto\csname\@gobble.extras\CurrentOption\endcsname%
{\babel@save\@@magyar@textqq \let\@@magyar@textqq \@@magyar@textqq@hu}%
\fi%
\catcode`\ =10\relax% back to space again
\@gobble
{^}%

% --- Definite articles (\az, \pageref -> \apageref etc.)

\if0\magyar@opt@@az \@@magyar@skiplong\fi

\makeatletter

%** modified by pts at Fri Oct  3 22:19:13 CEST 2003
%** @param #1 tokens, will be \edef\vfuzz'ed
\def\@@magyar@az@vfuzzedef#1{%
  \begingroup
  \@safe@activestrue% allow active `:' inside labels; 
  \def\hyper@@link[##1]##2##3##4{##4}% Dat: \def\b@abook{\hyper@@link [cite]{}{cite.sokt}{2}}% with hyperref.sty
  \let\romannumeral\number% by pts@fazekas.hu at Mon Oct 27 23:44:06 CET 2003
  % Dat: deliberately no \autoref for hyperref.sty !! (why??)
  \let\ref\@@magyar@zeroref \let\pageref\@@magyar@zeropageref
  \let\cite\@@magyar@zerocite \let\eqref\@@magyar@zeroeqref
  % ^^^ fix so \az{\ref{...}} works
  \let\refstruc\@@magyar@zerorefplus
  \let\refstrucparen\@@magyar@zerorefplus
  \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{}% Dat: no need to redefine \H and \.
  % Dat: no need to remove \textsf or \mdseries, because they are
  % handled properly by \protect == \string here.
  \let\@safe@activestrue\@empty% babel puts these inside \b@...: % Dat: \def\b@abook{\@safe@activesfalse 2}% (what is \@safe@actives??)
  \let\@safe@activesfalse\@empty
  \edef\vfuzz{\noexpand\def\noexpand\vfuzz{#1}}%
  \expandafter\endgroup\vfuzz
}

%** Makes \az etc. not emit the definite article.
%** Unused.
\def\@@magyar@noaz{%
  \def\@@magyar@az@lowt{\@ifstar\@gobble\@firstofone}%
  \def\az{\@@magyar@az@lowt}%
  \let\Az\az
  \def\aref{\@ifstar\@gobble\@@magyar@az@lowa}%
  \let\Aref\aref
  \def\apageref{\@ifstar\@gobble\firstoftwo}%
  \let\Apageref\apageref
  \def\acite{\@ifstar\@gobble\cite}%
  \let\Acite\acite
}

%** Usage: \az{alma} -> `az alma'; \Az*{alma} -> `az'
%** Usage: \az+\ref{foo} is equivalent to \az{\ref{foo}}
\def\@@magyar@az@lowt{\@ifstar{\@@magyar@az@lowy}{\@ifnextchar+\@@magyar@az@lowz\@@magyar@az@lowx}}
\def\@@magyar@az@lowz#1#2#3{\@@magyar@az@lowy{#2{#3}}~#2{#3}}
%** Used by new varioref.sty
\def\@@magyar@az@lowxu{\unskip\@@magyar@az@lowx}%
\def\@@magyar@az@lowx#1{\@@magyar@az@lowy{#1}~#1}
\def\@@magyar@az@lowy#1{{%
  \begingroup
  %\def\protect{\noexpand\protect\noexpand}%
  \set@display@protect% screws up \r
  \@@magyar@az@vfuzzedef{#1}%
  %%\show\vfuzz
  \expandafter\endgroup\expandafter
    \set@display@protect\expandafter% fixes \r; why??
    \@@magyar@az@set\expandafter{\vfuzz}\hbox$%
}}

\def\@@magyar@firstarg#1#2\hbox${#1}%

%** \Aref({e:foo}) -> `az~(5)'; \aref*{e:foo}: `az'
\def\@@magyar@az@lowa{\@ifnextchar({\@@magyar@az@lowb}{\@@magyar@az@lowb\@empty}}
\def\@@magyar@az@lowb#1#2{\@@magyar@az@ref\@firstoftwo{#2}~#1\ref{#2}}
%** @param #1 \@firstoftwo (for \ref) or \@secondoftwo (for \pageref)
%**           everything which is not \@secondoftwo is treated is \@firstoftwo
%** @param #2 for \csname r@#2\endcsname
\def\@@magyar@az@ref#1#2{%
  \begingroup
  % Dat: this works when turning on hyperref.sty for the 1st time (1st .aux file) -- but the original \ref doesn't work (\@fifthoffive)
  % Dat: #2 might contain an active : ; ! ? in case
  %      \def\magyarOptions{activespace=safe}
  \begingroup\lccode`~`: \lowercase{\endgroup\edef~{\string~}}%
  \begingroup\lccode`~`; \lowercase{\endgroup\edef~{\string~}}%
  \begingroup\lccode`~`! \lowercase{\endgroup\edef~{\string~}}%
  \begingroup\lccode`~`? \lowercase{\endgroup\edef~{\string~}}%
  \@ifundefined{@@magyar@r@#2}{%
    \@ifundefined{r@#2}{\let\reserved@a\@empty}{\expandafter\let\expandafter\reserved@a\csname r@#2\endcsname}%
  }{\expandafter\let\expandafter\reserved@a\csname @@magyar@r@#2\endcsname}%
  \ifx\reserved@a\@empty\endgroup\else% a speed boost
    \ifx#1\@secondoftwo\relax % Dat: remove the 1st {...} arg inside \reserved@a
      \expandafter\expandafter\expandafter\def\expandafter\expandafter
        \expandafter\reserved@a\expandafter\expandafter\expandafter{%
        \expandafter\expandafter\expandafter\@gobble\reserved@a{}}%
    \fi
    % vvv keep only the 1st arg (w/o braces) of \vbox, without expansion.
    %     This is to have hyperref.sty with `\newlabel{tab}{{1}{2}{\texorpdfstring {\textit {bg}}{asd}\relax }{section.1}{}}'
    %     right, and \texorpdfstring not expanded in the \edef below.
    \expandafter\expandafter\expandafter\def\expandafter\expandafter
      \expandafter\reserved@a\expandafter\expandafter\expandafter{%
      \expandafter\expandafter\expandafter\@@magyar@firstarg\reserved@a{}\hbox$}%
    \expandafter\@@magyar@az@vfuzzedef\expandafter{\reserved@a}%
    \expandafter\endgroup\expandafter\@@magyar@az@set\expandafter{\vfuzz}\hbox$%
  \fi
}

\def\@@magyar@az@lowd#1{\@@magyar@az@ref\@secondoftwo{#1}~\pageref{#1}}

\def\@@magyar@acite@lowb{\@ifnextchar [{\@@magyar@acite@lowa}{\@@magyar@acite@lowa[]}}
\def\@@magyar@acite@lowa[#1]#2{%
  \@@magyar@acite@lowd{#2}~%
  \ifx\vfuzz#1\vfuzz\cite{#2}\else\cite[#1]{#2}\fi
}
\def\@@magyar@acite@lowd#1{\@@magyar@acite@lowc#1,\hbox$}
\def\@@magyar@acite@lowc#1,#2\hbox#3${%
  \begingroup
  \@ifundefined{@@magyar@b@#1}{%
    \@ifundefined{b@#1}{\def\vfuzz{}}{%
      \@@magyar@az@vfuzzedef{%
        \expandafter\expandafter\expandafter\@@magyar@b@number
        \expandafter\expandafter\expandafter{\csname b@#1\endcsname}}}%
  }  {\@@magyar@az@vfuzzedef{\csname @@magyar@b@#1\endcsname}}%
  \expandafter\endgroup\expandafter
    \@@magyar@az@set\expandafter{\vfuzz}\hbox$%
}

% The original version of the \@az macros below were written by
% David Carlisle, but they have been completely rewritten by pts.

%** Adds definite article for a word #1#2#3 if #1 is in [A..Z]. Spaces
%** between #1, #2 and #3 can be -- fortunately -- ignored.
%** This is used to distinguish single-letter labels from text labels.
%** Dat: by pts: `\Az{Sz} betű' emits `Az Sz betű'; `\az{szólam}' is also OK
%** @param #1#2#3 doesn't contain \hbox (but may contain space)
%** @param #1 #2 #3 never lower case
\def\@@magyar@azuc#1#2#3{%
  \if\noexpand#1Az%
  \else\if\noexpand#1Ez%
  \else\if\noexpand#1F\ifnum11=\the\catcode\string`#2\else z\fi
  \else\if\noexpand#1Iz%
  \else\if\noexpand#1L\ifnum11=\the\catcode\if\noexpand#2Y\string`#3\else\string`#2\fi\else z\fi
  \else\if\noexpand#1M\ifnum11=\the\catcode\string`#2\else z\fi
  \else\if\noexpand#1N\ifnum11=\the\catcode\if\noexpand#2Y\string`#3\else\string`#2\fi\else z\fi
  \else\if\noexpand#1Oz%
  \else\if\noexpand#1S\ifnum11=\the\catcode\if\noexpand#2Z\string`#3\else\string`#2\fi\else z\fi
  \else\if\noexpand#1R\ifnum11=\the\catcode\string`#2\else z\fi
  \else\if\noexpand#1Uz%
  \else\if\noexpand#1X\ifnum11=\the\catcode\string`#2\else z\fi
  \else\if\noexpand#1Y\ifnum11=\the\catcode\string`#2\else z\fi
  \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
}
\def\@@magyar@azuc@pre#1#2#3#4\hbox${%
  \uppercase{\@@magyar@azuc#1#2#3}% Dat: we map a..z -> A..Z
}

%** Also defined elsewhere.
%** @param #2 \else...\else...\fi...\fi etc.
\def\@@magyar@swaprelax#1#2\relax{#2#1}
\def\@@magyar@ignorehbox@pre#1\hbox${}%
%** Counts the number of digits until a nondigit is found, and insert `z' if
%** appropriate (divisible by 3).
%** We need this to properly handle \aref for eg. 1.3.12 (subsec number)
%** or 3-45 (pagenumber preceeded by chapter number).
\def\@@magyar@eatddd#1#2#3#4{%
  % Wizardry: \@@magyar@eatddd throws away #1 (\@@magyar@ignorehbox@pre)
  \ifnum9<1\string#2 \ifnum9<1\string#3 \ifnum9<1\string#4 % test for digits
  \@@magyar@swaprelax\@@magyar@eatddd\fi\fi\else z\fi
  \relax\@@magyar@ignorehbox@pre
}

% vvv Wizardry: ignore everything (second number?) after first space
\def\@@magyar@eatddd@pre#1 #2\hbox${\@@magyar@eatddd.#1[][]\hbox$}%

\@gobble\iftrue
\def\@@magyar@azrb@stop#1#2\fi{#1}%
%** Strips spaces and braces automatically
%** @expands to `z' or nothing (last char of definite article)
%** @example \message{R:\removebraces {{foo}{{}{b}{{{{a\fi}}}}r}}\hfuzz;}
\def\@@magyar@azrb#1{%
  \ifx\hfuzz#1\@@magyar@azrb@stop\fi
  \expandafter\@@magyar@azrb\expandafter{%
  \ifcat{\noexpand#1\hfuzz\iffalse}\fi\expandafter
    \@@magyar@azrb\else\hfuzz}\@@magyar@azrb@nob{#1}\fi}
\def\@@magyar@azrb@nob#1#2{#2% #2 is \fi
  \ifx\hfuzz#1\hfuzz\expandafter\@firstoftwo
    \expandafter\@@magyar@azrb\fi\@@magyar@azrb@nobone#1}
\def\@@magyar@azrb@nobone#1{\noexpand#1\@@magyar@azrb}%

\def\@@magyar@aznospace#1{%
  \if\hfuzz\noexpand#1\expandafter\@@magyar@aznospace\else % a \cs, ignored -- may be \relax
    \expandafter\@@magyar@aznospace@short\expandafter#1%
  \fi
}

%** @param #1 might not be \cs -- and isn't empty
\def\@@magyar@aznospace@short#1{%
  \if5\noexpand#1z% Dat: emit `az 5'
    \@@magyar@swaprelax\@@magyar@ignorehbox@pre
  \else\if1\noexpand#1%
    % Dat: properly handle `az 1001 éjszaka', `az 1234567 éves bolygó'
    \@@magyar@swaprelax\@@magyar@eatddd@pre
  \else\ifnum1<1\noexpand#1 % a different digit, emit `a '
    \@@magyar@swaprelax\@@magyar@ignorehbox@pre
  \else\if-\noexpand#1% \az{-5} yields `a~-5'
    \@@magyar@swaprelax\@@magyar@ignorehbox@pre
  \else\ifcat\string*\noexpand#1% ignore non-digit (non-letter) `other' char
    % Wizardary: (undocumented)
    % This is a really smart way to ignore control sequence chars resulting
    % from \string\textrm etc. Fortunately, most control sequences don't
    % contain digits.
    \@@magyar@swaprelax\@@magyar@aznospace
  \else
    \@@magyar@swaprelax{\@@magyar@azuc@pre#1}% safe to call, no \cs
  \fi\fi\fi\fi\fi\relax
}

%** Typesets `z' or nothing (last char of definite article). Is _not_
%** expandable.
%** @param #1 may contain space(_10) tokens, but mustn't contain expandable
%**   tokens.
\def\@@magyar@az@set#1#2\hbox${% by pts
  % ^^^ Dat: we have `$' instead of `!' because of catcode changes (shouldn't affect)
  \edef\reserved@a{\@@magyar@azrb#1\hfuzz}%
  \expandafter\@@magyar@aznospace\reserved@a[b][][] \hbox$%
  % ^^^ Wizardry: [b][][] is a smart sentinel for \@@magyar@azuc and `b' for
  %	\@@magyar@aznospace@short. First `[' is there for aesthetics. Space
  %     is there for \@@magyar@eatddd@pre. \hbox$ is something that will not
  %     occur in normal text.
}

\ifnum\magyar@opt@@az \expandafter\ifx\csname az\endcsname\relax1\fi>1 % 21, 2, 11, 1
  \DeclareRobustCommand\az{a\@@magyar@az@lowt}\fi
\ifnum\magyar@opt@@az \expandafter\ifx\csname Az\endcsname\relax1\fi>1 % 21, 2, 11, 1
  \DeclareRobustCommand\Az{A\@@magyar@az@lowt}\fi
\ifnum\magyar@opt@@az \expandafter\ifx\csname aref\endcsname\relax1\fi>1 % 21, 2, 11, 1
  \DeclareRobustCommand\aref{a\@ifstar{\@@magyar@az@ref\@firstoftwo}{\@@magyar@az@lowa}}\fi
\ifnum\magyar@opt@@az \expandafter\ifx\csname Aref\endcsname\relax1\fi>1 % 21, 2, 11, 1
  \DeclareRobustCommand\Aref{A\@ifstar{\@@magyar@az@ref\@firstoftwo}{\@@magyar@az@lowa}}\fi
\ifnum\magyar@opt@@az \expandafter\ifx\csname apageref\endcsname\relax1\fi>1 % 21, 2, 11, 1
  \DeclareRobustCommand\apageref{a\@ifstar{\@@magyar@az@ref\@secondoftwo}{\@@magyar@az@lowd}}\fi
\ifnum\magyar@opt@@az \expandafter\ifx\csname Apageref\endcsname\relax1\fi>1 % 21, 2, 11, 1
  \DeclareRobustCommand\Apageref{A\@ifstar{\@@magyar@az@ref\@secondoftwo}{\@@magyar@az@lowd}}\fi
\ifnum\magyar@opt@@az \expandafter\ifx\csname acite\endcsname\relax1\fi>1 % 21, 2, 11, 1
  \DeclareRobustCommand\acite{a\@ifstar{\@@magyar@acite@lowd}{\@@magyar@acite@lowb}}\fi
\ifnum\magyar@opt@@az \expandafter\ifx\csname Acite\endcsname\relax1\fi>1 % 21, 2, 11, 1
  \DeclareRobustCommand\Acite{A\@ifstar{\@@magyar@acite@lowd}{\@@magyar@acite@lowb}}\fi

\@gobble
{^}

% --- hunnewlabel=

\if0\magyar@opt@@hunnewlabel
  \let\hunnewlabel\@gobbletwo
  % ^^^ with this the user would be able to switch from hunnewlabel=yes
  %     to hunnewlabel=no without removing the .aux file. But now I have a
  %     better solution to that. (??) !!
  \@@magyar@skiplong\fi

% [pts] Done properly by pts@fazekas.hu at Mon Mar  2 21:53:30 CET 2009
%
% \label will be redefined to write another line to .aux file:
% \hunnewlabel{...}{...}: similar to \newlabel{sectionStructNr}{pageNr},
% where the roman numerals are replaced by their arabic representations, so
% \aref and \apageref will work (`a II. rész'). The name \hunnewlabel is a
% legacy.
%
% We have to redefine \refstepcounter, which defines \@currentlabel, so we
% can define \magyar@@currentlabel@arabic, wich is the same as \@currentlabel,
% but it contains the number in arabic instead of roman. Without
% \magyar@@currentlabel@arabic, \label would have no clue that a roman number
% was involved. hyperref.sty also redefines \refstepcounter, but we are
% agnostic to that: it doesn't matter if we are first.

\let\magyar@@orig@refstepcounter\refstepcounter
% \relax, or {currentlabel}{pagenumber}
\let\magyar@@currentlabel@intact\relax
% \relax, or {currentlabel-in-arabic}{pagenumber-in-arabic}
\let\magyar@@currentlabel@arabic\relax

\def\@@magyar@setup@romantoarabic{%
  \let\romannumeral\number
  \let\@Roman\@roman  % avoid uppercasing
}

\def\refstepcounter#1{%
  \magyar@@orig@refstepcounter{#1}%
  \begingroup
    % Imp: wait till \shipout before expanding \thepage, in case of
    % \pagenumbering{roman}.
    % \c@page might be wrong (it's correcy at \shipout only), se we fake it.
    \c@page\@m
    \edef\reserved@b{{\thepage}}%
    \let\reserved@a\@currentlabel
    % Wrap \reserved@a in {...}, and then append \reserved@b to \reserved@a.
    \expandafter\expandafter\expandafter\def
      \expandafter\expandafter\expandafter\reserved@a%
      \expandafter\expandafter\expandafter{%
      \expandafter\expandafter\expandafter{%
      \expandafter\reserved@a\expandafter}\reserved@b}%
    \expandafter\def\expandafter\reserved@b\expandafter{%
      \expandafter\def\expandafter\magyar@@currentlabel@intact\expandafter{%
	\reserved@a}}%
  \expandafter\endgroup\reserved@b
  \begingroup
    \c@page\@m
    \@@magyar@setup@romantoarabic
    % This \protected@edef is from the \refstepcounter code.
    \protected@edef\reserved@a{%
      {\csname p@#1\endcsname\csname the#1\endcsname}{\thepage}}%
    \let\reserved@b\@empty
    \ifx\reserved@a\@currentlabel\else
      \expandafter\def\expandafter\reserved@b\expandafter{%
        \expandafter\def\expandafter\magyar@@currentlabel@arabic\expandafter{%
	  \reserved@a}}%
    \fi
  \expandafter\endgroup\reserved@b
}

%** Make its expansion short so \ifx would be fast down in noextras...
\def\@@magyar@labela{\@@magyar@labelb}%
\def\@@magyar@labelb#1{%
  \@@magyar@orig@label{#1}% output \newlabel to \@auxout
  \begingroup
    \c@page\@m
    \edef\reserved@b{{\thepage}}%
    \let\reserved@a\@currentlabel
    % Wrap \reserved@a in {...}, and then append \reserved@b to \reserved@a.
    \expandafter\expandafter\expandafter\def
      \expandafter\expandafter\expandafter\reserved@a%
      \expandafter\expandafter\expandafter{%
      \expandafter\expandafter\expandafter{%
      \expandafter\reserved@a\expandafter}\reserved@b}%
    \ifx\reserved@a\magyar@@currentlabel@intact
      % \@currentlabel created by our overridden \refstepcounter.
      \ifx\magyar@@currentlabel@arabic\magyar@@currentlabel@intact\else
	\expandafter\@@magyar@labelc\magyar@@currentlabel@arabic{#1}%
      \fi
    \else
      % \@currentlabel from unknown origin.
      % Emit \hunnewlabel if \thepage is roman.
      \@@magyar@setup@romantoarabic
      \edef\reserved@c{{\thepage}}%
      \ifx\reserved@b\reserved@c\else % \thepage is roman
        \@@magyar@labelc\@currentlabel{}{#1}%
      \fi
    \fi
  \endgroup
}
% @param #1 \@currentlabel (maybe expanded) as roman converted to arabic
% @param #2 any page number in any format; ignored
% @param #3 name of the label
\def\@@magyar@labelc#1#2#3{%
  % We have \noexpand\number below to prevent the \edef in \protected@write
  % from expanding the page number. It will be expanded at \shipout.
  \protected@write\@auxout{}{%
    \string\hunnewlabel{#3}{{#1}{\noexpand\number\c@page}}}%
}

\expandafter\addto\csname extras\CurrentOption\endcsname{%
  %%\message{--EXTRAS--}\show\label
  \ifx\label\@@magyar@labela\else
    \let\@@magyar@orig@label\label
    \let\label\@@magyar@labela
  \fi
}
\expandafter\addto\csname noextras\CurrentOption\endcsname{%
  %%\message{--NO--}%
  \ifx\label\@@magyar@labela
    % The trick here is not to restore the ``original'' label command if
    % somebody has changed it since the previous save in \extrasmagyar. This
    % adds compatibility with hyperref.sty, because it loads nameref.sty which
    % changes \label after babel.sty and magyar.ldf has been loaded.
    % 1. \usepackage[magyar]{babel}% \AtBeginDocument{\select@language{magyar}}
    % 2. \usepackage{hyperref}% \AtBeginDocument{\RequirePackage{nameref}}
    % 3. \begin{document}:
    % 4. \input \jobname.aux
    % 5. \AtBeginDocument hooks:
    % 6. \select@language{magyar}
    % 7. \extrasmagyar
    % 8. \let\@@magyar@orig@label\label
    % 9. \RequirePackage{nameref}:
    % 10. \def\label#1{...}
    \if1\magyar@opt@@hunnewlabel % only hunnewlabel=only-hu
      \let\label\@@magyar@orig@label
    \fi
  \fi
  % \let\@@magyar@orig@label\relax % Dat: commenting out this makes it possible to load magyar.ldf twice
}
\def\hunnewlabel#1#2{%
  \def\reserved@a{#2}%
  \expandafter\ifx\csname r@#1\endcsname\reserved@a% hun and normal labels are the same
    \relax% \message{No need for def: #1}%
  \else
    \global\expandafter\let\csname @@magyar@r@#1\endcsname\reserved@a%
  \fi
}

\@gobble
{^}

% --- captions=

\if0\magyar@opt@@captions\@@magyar@skiplong\fi
\@namedef{captions\CurrentOption}{%
  % Dat: inputenc isn't known, so we just use the safe \'a for accented letters 
  \def\prefacename{El\H osz\'o}%
  \def\refname{Hivatkoz\'asok}%
  \def\abstractname{Kivonat}%
  \def\bibname{Irodalomjegyz\'ek}%
  \def\appendixname{f\"uggel\'ek}% BUGFIX at Sun Feb 29 22:02:51 CET 2004
  \def\contentsname{Tartalomjegyz\'ek}%
  \def\listfigurename{\'Abr\'ak jegyz\'eke}%
  \def\listtablename{T\'abl\'azatok jegyz\'eke}%
  \def\indexname{T\'argymutat\'o}%
  \def\enclname{Mell\'eklet}%
  \def\ccname{K\"orlev\'el--c\'\i mzettek}% ??
  \def\headtoname{C\'\i mzett}%
  \def\proofname{Bizony\'\i t\'as}% AMS-\LaTeX
  \def\glossaryname{Sz\'ojegyz\'ek}% glosszárium, (magyarázatos) szójegyzék
  % vvv All these are start with a small letter
  \def\figurename{\'abra}%
  \def\chaptername{fejezet}%
  \def\tablename{t\'abl\'azat}%
  \def\notesname{Jegyzetek}% endnotes.sty
  \def\partname{r\'esz}%
  \def\pagename{oldal}%
  \def\seename{l\'asd}%
  \def\alsoname{l\'asd m\'eg}%
}
\@gobble
{^}

% --- Changing the order of the table numbers; tablecaptions=

\if0\magyar@opt@@tablecaptions\@@magyar@skiplong\fi
  % Wee need `1. táblázat' instead of `Table 1'
  \if1\magyar@opt@@tablecaptions
        \def\@@magyar@fnum@table{\thetable.~\tablename}%
  \else \def\@@magyar@fnum@table{\tablename\nobreakspace\thetable}\fi
  \expandafter\addto\csname extras\CurrentOption\endcsname{%
    \babel@save\fnum@table\let\fnum@table\@@magyar@fnum@table}
  \@gobble
{^}

% --- Changing the order of the figure numbers; figurecaptions=

\if0\magyar@opt@@figurecaptions\@@magyar@skiplong\fi
  \if1\magyar@opt@@figurecaptions
        \def\@@magyar@fnum@figure{\thefigure.~\figurename}%
  \else \def\@@magyar@fnum@figure{\figurename\nobreakspace\thefigure}\fi
  \expandafter\addto\csname extras\CurrentOption\endcsname{%
    \babel@save\fnum@figure\let\fnum@figure\@@magyar@fnum@figure}
  \@gobble
{^}

% --- dottedtocline=

\if0\magyar@opt@@dottedtocline\@@magyar@skiplong\fi
  % Dat: It is quite safe to re-define \@dottedtocline, because it isn't
  % redefined in standard packages of teTeX 1.
  %** Overrides latex.ltx. Allows the page number extend beyond \@pnumwidth.
  \def\@dottedtocline#1#2#3#4#5{%
    \ifnum #1>\c@tocdepth \else
      \vskip \z@ \@plus.2\p@
      {\leftskip #2\relax \rightskip \@tocrmarg \parfillskip -\rightskip
       \parindent #2\relax\@afterindenttrue
       \interlinepenalty\@M
       \leavevmode
       \@tempdima #3\relax
       \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
       {#4}\nobreak
       \leaders\hbox{\(\m@th
          \mkern \@dotsep mu\hbox{.}\mkern \@dotsep
          mu\)}\hfill
       \nobreak
       \setbox\@tempboxa\hbox{\normalfont \normalcolor #5}% ****pts****
       \ifdim\wd\@tempboxa<\@pnumwidth\setbox\@tempboxa\hb@xt@\@pnumwidth{\hfil\unhbox\@tempboxa}\fi
       \box\@tempboxa
       \par}%
    \fi}
  \@gobble
{^}%

% --- amslevelfix=

% detect ams{ldoc,dtx,art,book,proc}.sty
\ifnum1<0%
  \magyar@opt@@amslevelfix
  \expandafter\ifx\csname setTrue\endcsname\relax\else 1\fi
  \expandafter\ifx\csname allowttyhyphens\endcsname\relax\else 1\fi
\space\else\@@magyar@skiplong\fi
  % Fix amsart.cls etc. so no Overfull \hbox occurs in the \listoffigures.
  % Changes \@tocline{0}{3pt plus2pt}{0pt}{}{} to \@tocline{0}{3pt plus2pt}{0pt}{\parindent}{}
  \def\magyar@amslevelfix#1#2#3#4#5#6#7\vfuzz{%
    \def\reserved@a{#6}%
    \ifx\@tocline#2\ifx\reserved@a\@empty%
      \def#1{\@tocline{#3}{#4}{#5}{\parindent}{}}%
    \fi\fi
  }
  \expandafter\magyar@amslevelfix\expandafter\l@table \l@table ,,,,,,,\vfuzz
  \expandafter\magyar@amslevelfix\expandafter\l@figure\l@figure,,,,,,,\vfuzz
  \@gobble
{^}%

% --- amsuppercasefix=

% Fix for small \'\i in capitalized title (no fix needed for \'i and í):
%   \documentlcass{amsart} % amsart.cls
%   \usepackage{t1enc}
%   \usepackage[latin2]{inputenc}
%   \author{author Anal{\'\i}{\'i}zis}
%   \title {title  Anal{\'\i}{\'i}zis}
%   \begin{document} \maketitle a\newpage b\newpage c \end{document}
% This bug is a general amsart.cls bug, not specific to magyar.ldf.
\ifnum1<0%
  \magyar@opt@@amsuppercasefix
  \expandafter\ifx\csname altucnm\endcsname\relax\else 1\fi
\space\else\@@magyar@skiplong\fi
  % textcase.sty is not available by default (Ubuntu 8.04 TeX Live), and
  % newer amsart.cls doesn't have this bug (\'\i gets capitalized properly)
  \AtEndOfPackage{\IfFileExists{textcase.sty}{\RequirePackage{textcase}}{}}
  \@gobble
{^}%

% --- babelmarkfix=

% Fix the language name (\foreignlanguage{\languagename}}) appearing in
% \@evenhead. Reason: both amsart.cls and babel.def 3.8 redefine \markboth.
% (There is no problem in Babel 3.7.)
%   This bug is a general Babel 3.8 + amsart.cls bug, not specific to
% magyar.ldf.
%
% Dat: amsart.cls redefines \markboth defined in latex.ltx
\ifnum0<0%
  \magyar@opt@@babelmarkfix\relax
\space\else\@@magyar@skiplong\fi
  \begingroup
  %\def\foreignlanguage{\fffffff} % Dat: not called here
  % Dat: usually called: \mark{\the\@temptokena}
  %\def\mark#1{\showthe\@temptokena{\toks@{B#1}\global\edef\@@magyar@@marktest{\the\toks@}}}
  %\def\mark#1{\global\def\@@magyar@@marktest{#1}}
  \def\mark#1{\global\edef\@@magyar@@marktest{#1}}
  \let\if@nobreak\iffalse \@gobble\fi\@gobble\fi % Dat: \@gobble: make skippable
  \def\@@magyar@@marktest@noexp{{\noexpand\@empty BA}{\noexpand\@empty BB}}
  \expandafter\org@markboth\@@magyar@@marktest@noexp
  % ^^^ Dat: since we call \org@markboth, the result doesn't depend on the Babel
  %     version, i.e. how Babel redefines \markboth
  % ^^^ Dat: call changes \@@magyar@@marktest
  %     amsart.cls   -> {\noexpand \@empty BA}{\noexpand \@empty BB}
  %     article.cls  -> {\@empty BA}{\@empty BB}
  \ifx\@@magyar@@marktest\@@magyar@@marktest@noexp
    % OK, now test for \markboth, as defined in Babel 3.8
    \def\org@markboth#1#2{\global\def\@@magyar@@marktest{#1..#2}}%
    \markboth{CA}{CB}%
    % ^^^ Dat: call changes \@@magyar@@marktest
    %     Babel 3.7 -> \foreignlanguage {magyar}{CA}..\foreignlanguage {magyar}{CB}
    %     Babel 3.8 -> \noexpand \foreignlanguage {\languagename }{\noexpand \bbl@restore@actives CA}..\noexpand \foreignlanguage {\languagename }{\noexpand \bbl@restore@actives CB}
    \def\reserved@a#1#2\hfuzz${#1}%
    \expandafter\expandafter\expandafter\ifx
      \expandafter\expandafter\expandafter\noexpand
      \expandafter\reserved@a\@@magyar@@marktest\relax\hfuzz$%
      % Dat: we reach this if \@@magyar@@marktest starts by \noexpand
      % Dat: So now we have amsart.cls + \markboth of Babel 3.8.
      %      The solution is to restore \markboth and \markright of Babel 3.7
      %\let\reserved@a\@empty \zzzzzz
      \def\reserved@a{%
        \let\markright\org@markright
        \bbl@redefine\markright##1{%
          \toks@{##1}%
          \edef\bbl@tempa{%
            \noexpand\org@markright{%
              \noexpand\foreignlanguage{\languagename}{\the\toks@}}}%
          \bbl@tempa
        }
        \let\markboth\org@markboth
        \bbl@redefine\markboth##1##2{%
          \toks@{##1}\toks8{##2}%
          \edef\bbl@tempa{%
            \noexpand\org@markboth{%
              \noexpand\foreignlanguage{\languagename}{\the\toks@}}{%
              \noexpand\foreignlanguage{\languagename}{\the\toks8}}}%
          \bbl@tempa
        }%
      }%
    \else \let\reserved@a\@empty
    \fi
  \else \let\reserved@a\empty
  \fi
  %\show\reserved@a \let\reserved@a\@empty
  \global\let\@@magyar@@marktest\@undefined
  \global\let\@@magyar@@marktest@noexp\@undefined
  \expandafter\endgroup\reserved@a
  \@gobble
{^}%

% --- showfix=
%
% Fix stupid \def\show{...} in AtBeginDocument in ucsencs.def by restoring the original
% definition.

\ifnum0<0%
  \magyar@opt@@showfix\relax
\space\else\@@magyar@skiplong\fi
  \def\magyar@stripcolon#1:#2\vfuzz{#2}%
  \def\magyar@show@begin@fix{%
    \edef\reserved@a{\expandafter\magyar@stripcolon\meaning\show:\vfuzz}%
    \ifx\reserved@a\@empty\else % \show is a macro
      \let\show\@@magyar@orig@show
    \fi
  }
  \edef\reserved@a{\expandafter\magyar@stripcolon\meaning\show:\vfuzz}%
  \ifx\reserved@a\@empty % \show is not a macro
    \let\@@magyar@orig@show\show
    \expandafter\gdef\expandafter\@preamblecmds\expandafter{%
      \expandafter\magyar@show@begin@fix\@preamblecmds}%
    %\show\@begindocumenthook
    %\AtBeginDocument{\magyar@show@begin@fix}%
  \fi
  \@gobble
{^}%

% --- captionfix=
%
% Fix ``1. ábra'' order in \caption defined by caption.sty 2004/07/16 v3.0c.
%
% The manual fix would be:
%
%  \DeclareCaptionLabelFormat{simpleMagyar}{#2.\bothIfSecond{\nobreakspace}{#1}}
%  \let\caption@lfmt\caption@lfmt@simpleMagyar
%

\if0\magyar@opt@@captionfix\@@magyar@skiplong\fi
  \def\@@magyar@captionfix{\@ifundefined{caption@lfmt}{}{%
    % Dat: only in preamble:  \DeclareCaptionLabelFormat{simpleMagyar}{#2.\bothIfSecond{\nobreakspace}{#1}}
    \def\caption@lfmt@simpleMagyar##1##2{##2.\bothIfSecond{\nobreakspace}{##1}}%
  }}
  \AtBeginDocument{\@@magyar@captionfix}
  \expandafter\addto\csname extras\CurrentOption\endcsname{%
    \ifx\caption@lfmt\caption@lfmt@default % Imp: not if both undefined
      \ifx\caption@lfmt@simpleMagyar\@undefined\else
	\babel@save\caption@lfmt
	\let\caption@lfmt\caption@lfmt@simpleMagyar
      \fi
    \fi}
  \@gobble
{^}%


% --- shortrefcmds=

\if0\magyar@opt@@shortrefcmds\@@magyar@skiplong\fi
  \def\azr{\aref}% better than \let, because it won't keep old value
  \def\Azr{\Aref}
  \def\azp{\apageref}
  \def\Azp{\Apageref}
  \def\azc{\acite}
  \def\Azc{\Acite}
  \@gobble
{^}%

% --- longcaption=

\ifx\magyar@caption@centering\@empty\@@magyar@skiplong\fi
  \def\magyar@caption@hsizecheck{\hsize}
  % We don't emit the two dots of `1. táblázat.' here, because
  % has already been emitted by \fnum@table etc.
  % We apply some formatting depending on the longcaption= option.
  % Dat: Gyurgyák, p95. says: `11. ábra. Hajtási változatok.'
  \let\@@magyar@do@makecaption\relax% before .toc
  \expandafter\addto\csname extras\CurrentOption\endcsname{%
    \@@magyar@do@makecaption}
  \def\@@magyar@do@makecaption@captiontwo@yes{%
    % Dat: caption2.sty or caption3.sty is loaded; do nothing.
  }
  \def\@@magyar@do@makecaption@captiontwo@no{%
    %** @param #1 \fnum@table or \fnum@figure
    \def\@makecaption##1##2{%
      \vskip\abovecaptionskip
      \sbox\@tempboxa{##1.\ ##2}% Dat: `: ' changed to `. ' to match Hungarian typography
      \ifdim \wd\@tempboxa>\magyar@caption@hsizecheck\relax
        {\magyar@caption@centering ##1.\magyar@caption@newline ##2\csname par\endcsname}%
      \else
        \global \@minipagefalse
        \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
      \fi
      \vskip\belowcaptionskip}}
  \AtBeginDocument{%
    \expandafter\ifx\csname captionlabeldelim\endcsname\relax
      \expandafter\ifx\csname caption@lsep@period\endcsname\relax
        \let\@@magyar@do@makecaption\@@magyar@do@makecaption@captiontwo@no
      \else
        % Dat: caption3.sty is loaded, and it has caption@lsep defined
        % Dat: \show\caption@lsep@colon  % \long\def\caption@lsep@colon{: }
        % Dat: \show\caption@lsep %\def\caption@lsep{\caption@lsep@colon}
        \ifx\caption@lsep\caption@lsep@default
          % There was no \captionsetup{labelsep=...} yet, so we set the
          % default to period (dot).
          %
          % This sets \caption@lsep@default and \caption@lsep.
          \caption@setdefaultlabelsep{period}%
        \fi
        \let\@@magyar@do@makecaption\@@magyar@do@makecaption@captiontwo@yes
      \fi
    \else
      % Dat: caption2.sty is loaded (and has \def\captionlabeldelim{.} -- but it might have {:})
      % Dat: we now redefine {:} to {.}
      % Dat: the user can force {:} by \def\captionlabeldelim{:\empty}
      % Dat: this works now: \usepackage[german,french,magyar]{babel} \usepackage{caption2} \begin{document} \renewcommand*\captionfont{\itshape} \renewcommand*\captionlabelfont{\scshape}
      \def\reserved@a{:}%
      \ifx\reserved@a\captionlabeldelim \def\captionlabeldelim{.}\fi
      \let\@@magyar@do@makecaption\@@magyar@do@makecaption@captiontwo@yes
    \fi}
  \@gobble
{^}%

% --- labelenums=

\if0\magyar@opt@@labelenums \@@magyar@skiplong\fi
  \providecommand\@greekalph[1]{%
    % We use the robust \ensuremath here, similarly to \def\@fnsymbol in
    % latex.ltx.
    \ensuremath{\ifcase#1\or\alpha\or\beta\or\gamma\or\delta%
    \or\varepsilon\or\zeta\or\eta\or\vartheta\or\iota\or\kappa%
    \or\lambda\or\mu\or\nu\or\xi\or\varphi\or\varpi\or\varrho%
    \or\varsigma\or\tau\or\upsilon\or\chi\or\psi\or\omega%
    \else\@ctrerr\fi}}
  \expandafter\ifx\csname c@enumv\endcsname\relax
    \@definecounter{enumv}% call this before \def\theenumv
  \fi
  \if3\magyar@opt@@labelenums
    \def\theenumi  {\@arabic   \c@enumi}  \def\labelenumi  {\theenumi.}
    \def\theenumii {\@alph     \c@enumii} \def\labelenumii {\itshape\theenumii)}
    \def\theenumiii{\@greekalph\c@enumiii}\def\labelenumiii{\itshape\theenumiii)}
    \def\theenumiv {\@Alph     \c@enumiv} \def\labelenumiv {\itshape\theenumiv)}
    \def\theenumv  {\@Roman    \c@enumv}  \def\labelenumc  {\theenumv.} % Dat: I'm not sure
  \else
    \def\theenumi{\@Roman\c@enumi}       \def\labelenumi{\theenumi.}
    \def\theenumii{\@arabic\c@enumii}    \def\labelenumii{\theenumii.}
    % !! correct \ref style for \the
    \if1\magyar@opt@@labelenums % hu-a
      \def\theenumiii{\@alph\c@enumiii}    \def\labelenumiii{\itshape\theenumiii)}
      \def\theenumiv{\@greekalph\c@enumiv} \def\labelenumiv{\itshape\theenumiv)}
      \def\theenumv{\@Alph\c@enumv}        \def\labelenumv {\itshape\theenumv)}
    \else% hu-A
      \def\theenumiii{\@Alph\c@enumiii}    \def\labelenumiii{\itshape\theenumiii)}
      \def\theenumiv{\@alph\c@enumiv}      \def\labelenumiv{\itshape\theenumiv)}
      \def\theenumv{\@greekalph\c@enumv}   \def\labelenumv {\itshape\theenumv)}
    \fi
  \fi
  \def\reserved@a{% copied from latex.ltx
    \ifnum \@enumdepth >\thr@@\@toodeep\else
      \advance\@enumdepth\@ne
      \edef\@enumctr{enum\romannumeral\the\@enumdepth}%
	\expandafter\list
	  \csname label\@enumctr\endcsname
	  {\usecounter\@enumctr\def\makelabel##1{\hss\llap{##1}}}%
    \fi}
  \ifx\reserved@a\enumerate
    \def\enumerate{% no \@enumdepth>3
      \advance\@enumdepth\@ne
      \expandafter\ifx\csname labelenum\romannumeral\the\@enumdepth\endcsname\relax
        \@toodeep\advance\@enumdepth\m@ne\else
	\edef\@enumctr{enum\romannumeral\the\@enumdepth}%
	  \expandafter\list
	    \csname label\@enumctr\endcsname
	    {\usecounter\@enumctr\def\makelabel##1{\hss\llap{##1}}}%
      \fi}
  \fi
  \@gobble
{^}%

% --- labelitems=

\if0\magyar@opt@@labelitems \@@magyar@skiplong\fi
  \def\labelitemi{\textendash}
  % vvv Dat: formerly 2.5pt
  \def\labelitemii {\raise0.58ex\hbox{\scriptsize\textbullet}}
  \def\labelitemiii{\raise0.58ex\hbox{\(\scriptstyle\circ\)}}
  \def\labelitemiv {\raise0.58ex\hbox{\scriptsize\textasteriskcentered}}
  \def\labelitemv  {\raise0.58ex\hbox{\scriptsize\textperiodcentered}}
  \def\reserved@a{% copied from latex.ltx
    \ifnum \@itemdepth >\thr@@\@toodeep\else
      \advance\@itemdepth\@ne
      \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}%
      \expandafter\list
	\csname\@itemitem\endcsname
	{\def\makelabel##1{\hss\llap{##1}}}%
    \fi}
  \ifx\reserved@a\itemize
    \def\itemize{% no \@itemdepth>3
      \advance\@itemdepth\@ne
      \expandafter\ifx\csname labelitem\romannumeral\the\@itemdepth\endcsname\relax
        \@toodeep\advance\@enumdepth\m@ne\else
	\edef\@itemitem{labelitem\romannumeral\the\@itemdepth}%
	\expandafter\list
	  \csname\@itemitem\endcsname
	  {\def\makelabel##1{\hss\llap{##1}}}%
      \fi}
  \fi
  \@gobble
{^}%

% --- postpara= and postsubpara= and postdescription=

\expandafter\ifx\csname magyar@opt@@paragraphs\endcsname\relax\@@magyar@skiplong\fi
  % Dat: We make sure that hspaces emitted by \magyar@post@... are unstretchable
  \def\magyar@post@dot{.\enskip}%
  \def\magyar@post@bfdot{\textbf.\enskip}%
  \let\magyar@post@quad\quad% not recommended in Hungarian
  \let\magyar@post@enskip\enskip% not recommended in Hungarian
  \def\magyar@post@em{\hskip1em\relax}%
  \let\magyar@post@empty\@empty
  %** from Gyurgy\'ak J\'anos: Szerkeszt\H{o}k \'es szerz\H{o}k k\'ezik\"onyve.
  %** We don't have a square-shaped, black diamond in our math fonts :-(.
  \def\magyar@post@diamond{%
    \enskip\raise.5ex\hbox{\font\f=msam10 at1.3ex \f\char7}\enskip%\ignorespaces% raised \blacklozenge
    %{\usefont{U}{msa}{m}{n}\small\char7}
  }
  \def\magyar@post@star{\enskip\({}^*\)\enskip}%
  \def\magyar@post@endash{ -- }%
  \def\magyar@post@semicolon{:\enskip}%
  \def\magyar@first#1#2\vfuzz{\noexpand#1}%
  %** Calls \magyar@pf@lowb, and never emits code resulting from #3 to TOC
  %** @param #1 empty or `*'
  %** @param #2 \@startsection{...}{...}... call
  %** @param #3 \paragraph or \subparagraph (selects one of \magyar@post@...)
  %** @param #4 paragraph title text
  \def\magyar@pf@lowa#1#2#3#4{%
    \if#1*\relax
      \bbl@afterelse\magyar@pf@lowb*%
    \else
      \bbl@afterfi  \magyar@pf@lowb{[#4]}%
    \fi
    {#2}{#3}{#4}%
  }%
  % !! a less obscure way for \paragraph, without -1sp etc.
  %** Calls \magyar@pf@lowb, and never emits code resulting from #3 to TOC
  %** @param #1 \@startsection{...}{...}... call
  %** @param #2 \paragraph or \subparagraph (selects one of \magyar@post@...)
  %** @param #3 paragraph title text
  %** @param #4 [...] arg to \paragraph
  \def\magyar@pf@lowc#1#2#3[#4]{%
    \magyar@pf@lowb{[#4]}{#1}{#2}{#3}%
  }%
  %** Calls \magyar@post@paragraph and \magyar@post@subparagraph
  %** @param #1 [#4] or `*' (what goes to TOC?)
  %** @param #2 \@startsection{...}{...}... call
  %** @param #3 \paragraph or \subparagraph
  %** @param #4 paragraph title text
  \def\magyar@pf@lowb#1#2#3#4{%
    #2#1{#4\csname magyar@post@\expandafter\@gobble\string#3\endcsname\kern\z@}%
    % ^^^ Dat: \kern\z@ is needed so \unskip won't occur at \paragraph*
    % ^^^ Dat: {#4\csname...} is needed so \magyar@post@dot makes a {\bf.}
    % Dat: \ignorespaces is superflous here, it also doesn't ignore \par
  }%
  %** Fixes (redefines) the specified macro so postpara= and postsubpara=
  %** takes effect. It is useful to call this after a `\renewcommand\paragraph'
  %** in a package. Has no effect if the definition of #1 doesn't look like
  %** the one in article.cls (i.e. \@startsection) or if it's not defined
  %** (such as in beamer.cls).
  %** @param #1 \paragraph or \subparagraph
  \def\magyar@paragraphfix#1{%
    \ifx#1\@undefined\else
      % Change only if defined.
      \expandafter\magyar@paragraphfix@defined\expandafter#1\fi
  }
  \def\magyar@paragraphfix@defined#1{%
    \expandafter\magyar@pf@lowd\expandafter#1#1\hfuzz........\vfuzz
  }
  \def\magyar@pf@lowd#1#2#3#4#5#6#7#8#9\vfuzz{%
    % Dat: \unskip doesn't work, have to change \hskip to -1sp: 1sp is the
    %      amount of horizontal space between the diamond and the paragraph text
    %      0sp would be bad, because it isn't negative (positive skips are
    %      interpreted as vertical).
    %%
    \expandafter\def\expandafter\reserved@a\expandafter{\magyar@first#9\vfuzz}%
    %\def\reserved@a{#9}\ifx\reserved@a\@empty
    \if\reserved@a\hfuzz\ifx#2\@startsection\if-\magyar@first#7\vfuzz
      \def#1{\@ifstar
        {\magyar@pf@lowa *{#2{#3}{#4}{#5}{#6}{-1sp}{#8}}#1}%
        {\@ifnextchar[%]
          {\magyar@pf@lowc{#2{#3}{#4}{#5}{#6}{-1sp}{#8}}#1}%
          {\magyar@pf@lowa{}{#2{#3}{#4}{#5}{#6}{-1sp}{#8}}#1}%
        }%
      }%
    \fi\fi\fi
  }
  % !! Imp: change Hungarian \paragraphs only, with dual load
  \expandafter\ifx\csname magyar@opt@@postpara\endcsname\relax\else
    \magyar@paragraphfix\paragraph
    \expandafter\let\expandafter\magyar@post@paragraph\csname magyar@post@\magyar@opt@@postpara\endcsname
    \ifx\magyar@post@paragraph\relax
      \@@magyar@error{Invalid arg for option: postpara = \magyar@opt@@postpara}%
    \fi
  \fi
  \expandafter\ifx\csname magyar@opt@@postsubpara\endcsname\relax\else
    \magyar@paragraphfix\subparagraph
    \expandafter\let\expandafter\magyar@post@subparagraph\csname magyar@post@\magyar@opt@@postsubpara\endcsname
    \ifx\magyar@post@subparagraph\relax
      \@@magyar@error{Invalid arg for option: postsubpara = \magyar@opt@@postsubpara}%
    \fi
  \fi
  \expandafter\ifx\csname magyar@opt@@postdescription\endcsname\relax\else
    \expandafter\let\expandafter\magyar@post@description\csname magyar@post@\magyar@opt@@postdescription\endcsname
    \ifx\magyar@post@description\relax
      \@@magyar@error{Invalid arg for option: postdescription = \magyar@opt@@postdescription}%
    \fi
    \def\magyar@@descriptionfont{\normalfont\bfseries}%
    \def\descriptionlabel#1{\hskip\labelsep{\magyar@@descriptionfont#1}\magyar@post@description\hskip-\labelsep}%
  \fi
  \@gobble
{^}%

% --- afterindent=

\ifnum\magyar@opt@@afterindent>8 \@@magyar@skiplong\fi
  \ifnum\magyar@opt@@afterindent<1 % force-no
    \expandafter\addto\csname extras\CurrentOption\endcsname{%
      \babel@save\@afterindenttrue
      \let\@afterindenttrue\@afterindentfalse
    }%
  \else% force-yes
    \expandafter\addto\csname extras\CurrentOption\endcsname{%
      \babel@save\@afterindentfalse
      \let\@afterindentfalse\@afterindenttrue
    }%
  \fi
  \@gobble
{^}

% --- default \frenchspacing; frenchspacing=

\if0\magyar@opt@@frenchspacing \@@magyar@skiplong\fi
  \if1\magyar@opt@@frenchspacing% =no
    \def\@@magyar@antifrenchspacing{% only does some caching
      \ifnum\the\sfcode`\.=\@m
	\nonfrenchspacing
	\let\@@magyar@nonfrenchspacing\frenchspacing
      \else
	\let\@@magyar@nonfrenchspacing\relax
      \fi}
    \let\@@magyar@nonantifrenchspacing\frenchspacing
    \expandafter\addto\csname   extras\CurrentOption\endcsname{\@@magyar@antifrenchspacing}
    \expandafter\addto\csname noextras\CurrentOption\endcsname{\@@magyar@nonantifrenchspacing}
  \else
    \expandafter\addto\csname   extras\CurrentOption\endcsname{\bbl@frenchspacing}
    \expandafter\addto\csname noextras\CurrentOption\endcsname{\bbl@nonfrenchspacing}
  \fi
  \@gobble
{^}


% --- Putting dots after section number in toc/lof/lot; sectiondot=
%
% This is to have a dot after figure/table numbers in lof/lot and
% section numbers in toc.
%
% The option sectiondot= is ill-named, because it doesn't apply to what is
% displayed in \section, but it applies to \tableofcontents, \listoftables
% and \listoffigures.

\if0\magyar@opt@@sectiondot \@@magyar@skiplong\fi
  \ifnum\magyar@opt@@sectiondot>1
    % This solution (for sectiondot=problematic) is what was provided by
    % magyar.ldf v1.4. It is incomatible with lots of packages.
    %
    % [pts] This doesn't work with nameref.sty.
    \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}}

    % [pts] This is incompatible with some packages.
    \expandafter\addto\csname extras\CurrentOption\endcsname{%
      % 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.
      \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}}}

    % [pts] This is incompatible with some packages.
    \expandafter\addto\csname extras\CurrentOption\endcsname{%
      % 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
      \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}}}
  \else
    % This implements option sectiondot=safe.
    %
    % [pts] We definitely want \numberline to emit table number in \listoftables as
    % `5.6.' instead of the default `5.6', but we don't want to redefine \@caption,
    % because the # args \addcontentsline adds to \contentsline depends on whether
    % nameref.sty (hyperref.sty) is loaded (no nameref: 3, w/ nameref: 4); this 
    % would cause the strange `Package hyperref Warning: No destination for
    % bookmark of \addcontentsline'.
    %   So we rather redefine \numberline. But we cannot simply add a dot, because
    % it might be already present (e.g in \tableofcontents). So we add a dot only
    % if it is missing. This modification affects \tableofcontents, \listoffigures
    % and \listoftables. The presence of the dot in TOC depends on the language
    % the section was defined in.
    %   amsart.sty uses \tocsection instead of \numberline, see amstocnumskip=
    % below
    \def\magyar@striplastdot@lowa#1.\relax{#1\relax}%
    \def\magyar@striplastdot@lowb#1\relax#2\relax{#1}%
    %** \@tempdima is set by \@dottedtocline, called by \l@section
    \def\magyar@numberline#1\vfuzz{\hb@xt@\@tempdima{#1.\hfil}}%
    \def\@@magyar@numberline@pre#1{%
      \expandafter\expandafter\expandafter\magyar@numberline
      \expandafter\magyar@striplastdot@lowb\magyar@striplastdot@lowa#1\relax.\relax\vfuzz
    }%
    \expandafter\addto\csname extras\CurrentOption\endcsname{%
      \babel@save\numberline
      %** Overrides latex.ltx
      \let\numberline\@@magyar@numberline@pre
    }
  \fi
  \@gobble
{^}

% --- amspostsectiondot=

\if0\magyar@opt@@amspostsectiondot \@@magyar@skiplong\fi
  % Now fix ams*.cls so that they don't put a dot after the section title.
  % First check whether the definition of \@sect contains
  % \global\@nobreaktrue\@xsect
  \long\def\@@magyar@amssect@fixa#1\global\@nobreaktrue\@xsect#2\hfuzz#3{%
    \ifx\hfuzz#2\hfuzz\else% found
      \@@magyar@amssect@fixb#3\fi}
  %** @param #1 a \cs, e.g \@sect
  \def\@@magyar@amssect@fixb#1{%
    \expandafter\let\csname @@magyar@amssect@saved\string#1\endcsname#1%
    \edef#1{\noexpand\expandafter\noexpand\@@magyar@amssect@low
       \expandafter\noexpand\csname @@magyar@amssect@saved\string#1\endcsname}%
    \let\@svsechd\@empty% prevent Undefied \cs
    %** Definition of \@sect in ams*.cs ends by `\global\@nobreaktrue{#5}'
    \long\def\@@magyar@amssect@low##1\global\@nobreaktrue{%
      ##1%
      \expandafter\def\expandafter\@svsechd\expandafter{%
	\expandafter\let\expandafter\@addpunct\expandafter\@gobble \@svsechd}%
      \global\@nobreaktrue
    }%
  }
  \expandafter\@@magyar@amssect@fixa\@sect[][][][][][][][]\global\@nobreaktrue\@xsect\hfuzz\@sect
  \expandafter\@@magyar@amssect@fixa\@sect[][][][][][][][]\global\@nobreaktrue\@xsect\hfuzz\NR@sect% with nameref.sty
  \@gobble
{^}%

% --- amstocnumskip=, amstocnumlang=
%
% Change \tocsection, \tocsubsection etc. in amsart.cls etc. These commands
% have effect in \tableofcontents, e.g. in the .toc file:
% `\contentsline {section}{\tocsubsection {}{1.1}{Foo}}{1}'
%
% We should be careful not to define \tocchapter and \tocsection if
% tocbibind.sty is (or will be) loaded, because it provides its own definition
% as \newcommand.

\ifx\@empty\magyar@opt@@amstocnumskip \@@magyar@skiplong\fi
  % Similar to titleskip=, but AMS classes don't look at \@seccntformat
  \def\@@magyar@amstocnumskip@lets{%
    \ifx\tocsubsection\@undefined\else
      \ifx\tocsubsection\tocparagraph
	\def\tocsubsection{\tocsection}%
	% These lines are similar to those in amsart.cls.
	\let\tocsubsubsection\tocsubsection
	\let\tocparagraph\tocsubsection
	\let\tocsubparagraph\tocsubsection
	\let\tocpart\tocsubsection
	\let\tocchapter\tocsubsection
      \fi
    \fi
  }%
  \def\@@magyar@amstocnumskip@defs{%
    \ifx\tocsubsection\@undefined\else
      \ifx\tocsubsection\tocparagraph
	%** Overrides amsart.cls, amsbook.cls etc.
	%** Only for Hungarian \section{}s. Changes \quad to
	%** \magyar@opt@@amstocnumskip in the definition. Also changes
	%** ``fejezet 1'' to ``1. fejezet'' for \chapter
	%** (We have \def\tocchapter{\tocsection} by default.)
	\def\tocsection##1##2##3{%
	  %%\typeout{--##3--}%
	  \indentlabel{%
	    \def\reserved@a{##1}%
	    \def\reserved@b{##2}%
	    \ifx\reserved@b\empty
	    \else\ifx\reserved@a\chaptername
	      % * Sometimes (but not in \tableofcontents) #1 is
	      %   `\csname chaptername\endcsname'. Why?
	      % * \tocappendix is called instead of \tocsection for the
	      %   appendix.
              \ifnum\magyar@opt@@chapternumber=1      \@huordinal{##2}~%
              \else\ifnum\magyar@opt@@chapternumber=2 \@Huordinal{##2}~%
              \else##2.~%
              \fi\fi
              ##1.\magyar@opt@@amstocnumskip
	    \else\ifx\reserved@a\partname
              \ifnum\magyar@opt@@partnumber=1      \@huordinal{##2}~%
              \else\ifnum\magyar@opt@@partnumber=2 \@Huordinal{##2}~%
              \else##2.~%
              \fi\fi
              ##1.\magyar@opt@@amstocnumskip
            \else
              \ignorespaces##1 ##2.\magyar@opt@@amstocnumskip
	    \fi\fi\fi}%
	  ##3}%
	%** Overrides amsart.cls etc. Only for Hungarian \section{}s. Changes \quad to
	%** \magyar@opt@@amstocnumskip in the definition.
	\def\tocappendix##1##2##3{%
	  \indentlabel{%
	    \def\reserved@a{##1}%
	    \ifx\reserved@a\appendixname
              ##2\ifx\@@magyar@appendixname\@empty.\fi~##1%
	    \else
	      ##1\@ifnotempty{##2}{ ##2}%
	    \fi
	    .\magyar@opt@@amstocnumskip}%
	  ##3}%
      \fi
    \fi
  }%
  \AtBeginDocument\@@magyar@amstocnumskip@lets  % must be before @defs
  \if2\magyar@opt@@amstocnumlang
    \AtBeginDocument\@@magyar@amstocnumskip@defs
    %\let\@@magyar@amstocnumskip@defs\@undefined% for use by the user
  \else
    \expandafter\addto\csname extras\CurrentOption\endcsname{%
      \babel@save\tocsection \babel@save\tocappendix
      \@@magyar@amstocnumskip@defs
    }
  \fi
  \@gobble
{^}%


% --- Fixup Babel language selection glitches; toclang=

% There are fundamental problem of emitting \select@language items in LOT
% files.
%
% Problem (3): When using \begin{table}...\end{table} \selectlanguage{foo}
% \begin{table}...\end{table}, the LaTeX-Babel scheme will not emit a
% \select@language{foo} between the two \contentsline{}s in \jobname.lot. The
% TOC file is OK, because section titles aren't floats. (But what about
% \mark{}s?).
%
% Problem (1): \selectlanguage emits .aux entries even
% if the language isn't really changed.
%
% Problem (2): babel.def has
% `\AtBeginDocument...\selectlanguage...\bbl@main@language', from which an
% \immediate is missing, so the \select@language is emitted to the .aux file
% after the first float has been typeset. A better solution would be
% `\select@language{\languagename}', which forcibly activates the default
% language.
%
% Problem (4): \ps@headings isn't run \AtBeginDocument, but book.cls runs
% \pagestyle{headings} when it is loaded. We should change this to
% \AtBeginDocument or similar.

\ifnum\magyar@opt@@toclang=0 \@@magyar@skiplong\fi
  \ifnum\magyar@opt@@toclang>1  % toclang=good
    % Solve problems (2) and (4). Timing is critical. \select@language must
    % be called after \AtBeginDocument, so \catcode{}s won't be \activated
    % too early. (Because some code in \AtBeginDocument might issue an
    % \input such as hyperref.sty which does \RequirePackage{nameref}.)
    % Note that \extrasmagyar containing the \catcode changes is
    % only run when `magyar' is the default language (last arg of
    % \usepackage[...]{babel}). If that is run after \AtBeginDocument hooks,
    % then most packages will use 12 as \catcode\string``, which is intended.
    %   \@@magyar@setup@psheadings might just be run \AtBeginDocument, it doesn't
    % need \@preamblecmds -- but it must be after \select@language.
    %
    % \@preamblecmds is expanded after \@begindocumenthook
    \expandafter\gdef\expandafter\@preamblecmds\expandafter{\@preamblecmds
      \@@magyar@setup@psheadings% Solve problem (4). Before \selectlanguage.
      \select@language{\languagename}% force initial language
    }%
    % Solve problem (1) and assist solving problem (2) by not emitting
    % \select@language twice.
    \def\bbl@set@language#1{%
      \edef\@Lang@tmp{%
	\ifcat\noexpand\noexpand\noexpand#1% a control sequence
	  \expandafter\expandafter\expandafter\@gobble\expandafter\string
	\fi
	#1%
      }%
      \ifx\languagename\@Lang@tmp\else
	\let\languagename\@Lang@tmp
	\select@language{\languagename}%
      \fi
    }%
    % Solve problem (3).
    \long\def\addtocontents#1#2{%
      % Dat: \noexpand should be avoided in \protected@write
      \protected@write\@auxout
	  {\let\label\@gobble \let\index\@gobble \let\glossary\@gobble \let\select@language\relax}%
	  {\string\@writefile{#1}{\string\select@language{\languagename} #2}}}
  \else
    % Solve problems (2) and (4).
    \AtBeginDocument{%
      \if@filesw \immediate\write\@mainaux{%
        \string\select@language{\languagename}%
        \string\@writefile{toc}{\string\select@language{\languagename}}%
        \string\@writefile{lof}{\string\select@language{\languagename}}%
        \string\@writefile{lot}{\string\select@language{\languagename}}%
      }\fi
      \@@magyar@setup@psheadings% Solve problem (4). Before \selectlanguage.
      \select@language{\languagename}% force initial language
    }
    % Solve problem (1) and assist solving problem (2) by not emitting
    % \select@language twice.
    \def\bbl@set@language#1{%
      \edef\@Lang@tmp{%
	\ifcat\noexpand\noexpand\noexpand#1% a control sequence
	  \expandafter\expandafter\expandafter\@gobble\expandafter\string
	\fi
	#1%
      }%
      \ifx\languagename\@Lang@tmp\else
	\let\languagename\@Lang@tmp
	\select@language{\languagename}%
	\if@filesw \protected@write\@auxout{}{%
	  \string\select@language{\languagename}%
	  \string\@writefile{toc}{\string\select@language{\languagename}}%
	  \string\@writefile{lof}{\string\select@language{\languagename}}%
	  \string\@writefile{lot}{\string\select@language{\languagename}}%
	\fi}%
      \fi
    }%
    % Don't solve problem (3).
  \fi
  \@gobble
{^}%

% --- suggestions=

\ifnum\magyar@opt@@suggestions=0 \@@magyar@skiplong\fi
  % Dat: buggy varioref.sty adds this to extrasmagyar (\AtBeginDocument is
  %      buggy, can be used only in the preamble.
  %     \def\reftextfaceafter {a k\"o\-vet\-kez\H{o} ol\-da\-lon}%
  %     \def\reftextfacebefore{az el\H{o}\-z\H{o} ol\-da\-lon}%
  %     \def\reftextafter     {a k\"o\-vet\-kez\H{o} ol\-da\-lon}%
  %     \def\reftextbefore    {az el\H{o}\-z\H{o} ol\-da\-lon}%
  %     \def\reftextcurrent   {ezen az ol\-da\-lon}%
  %     \def\reftextfaraway#1{\aza{\pageref{#1}} \pageref{#1}.~ol\-da\-lon}%
  %     \def\reftextpagerange#1#2{\vref@stringwarning\reftextpagerange
  %                               on pages~\pageref{#1}--\pageref{#2}}%
  %     \def\reftextlabelrange#1#2{\vref@stringwarning\reflabelpagerange
  %                                \ref{#1} to~\ref{#2}}%
  %     \AtBeginDocument{\providecommand\aza[1]{a/az%
  %        \PackageError{varioref}{%
  %          Proper definition for command \noexpand\aza missing}%
  %         {You need to (re)define the command \noexpand\aza that
  %          takes one argument (a number or a \noexpand\pageref command)
  %          and produces the string `a' or `az' depending on the argument
  %          value. It should also accept an optional argument (default `l')
  %          to denote whether or not the string should be lowercase or
  %          uppercase.}}}%
  \def\@@magyar@ignorehbox@pree#1\hbox$#2{}%$
  %\def\@@magyar@grep@reftextcurrent#1\def\reftextcurrent#2\hbox$
  \def\@@magyar@grep@reftextbegin#1\def\reftextfaceafter#2\hfuzz\hfuzz\hfuzz#3\hbox$#4{%$
    \toks@={#1#3}% Dat: # -> ## conversion for \def
    \expandafter\global\expandafter\edef\csname extras#4\endcsname
      {\the\toks@}%
  }
  \def\@@magyar@grep@reftextcurrent#1\def\reftextlabelrange#2#3#4#5#6%
    \AtBeginDocument#7#8\hbox$#9{%$ Dat: no need for \long\def
    % ^^^ Dat: Don't use `#21', because then #2 would match multiple tokens
    \ifx#31% found real data, not sentinel
      \PackageWarningNoLine{#9.ldf}{Do not load buggy \string\usepackage[magyar]{varioref},\MessageBreak load simply \string\usepackage{varioref}}%
      % vvv remove code inserted by varioref.sty
      \@@magyar@grep@reftextbegin#1\hfuzz\hfuzz\hfuzz#8\hbox${#9}%$
    \fi
  }
  \def\magyar@sugg@vr#1{%
    \expandafter\expandafter\expandafter\@@magyar@grep@reftextcurrent
       \csname extras#1\endcsname\hbox${#1}\@@magyar@ignorehbox@pree%$
       \def\reftextlabelrange23456\AtBeginDocument78\hbox${#1}%$
  }
  \def\magyar@sugg@to#1{%
    \def\reserved@a{T1}
    \edef\reserved@b{\encodingdefault}% \encodingdefault is \long for t1enc.sty, but not for fontenc.sty
    \ifx\reserved@a\reserved@b\else
      \@latex@warning@no@line{Please use \string\usepackage{t1enc} with\MessageBreak \string\usepackage[#1]{babel}, to get accented chars hyphenated}%
      % ^^^ Dat: \usepackage[T1]{fontenc} is equally good, but less effective
    \fi
  }
  \def\magyar@sugg@ie@lowb#1{\@latex@warning@no@line{Please use \string\usepackage[latin2]{inputenc} with\MessageBreak \string\usepackage[#1]{babel}}}%
  %** @param #1 \@inpenc@undefined@
  %** @param #2 input encoding name
  \def\magyar@sugg@ie@low#1#2#3\vfuzz#4{%
    \def\reserved@b{#2}%
    \def\reserved@a{latin2}%
    \ifx\reserved@a\reserved@b\else
      \def\reserved@a{utf8}%
      \ifx\reserved@a\reserved@b\else
        \def\reserved@a{utf8x}%
        \ifx\reserved@a\reserved@b\else
          \def\reserved@a{cp1250}%
          \ifx\reserved@a\reserved@b\else
            \magyar@sugg@ie@lowb{#4}%
          \fi
        \fi
      \fi
    \fi
  }
  \def\magyar@sugg@ie#1{%
    % Dat: don't print warning for missing \usepackage
    \expandafter\ifx\csname @inpenc@undefined\endcsname\relax
      \magyar@sugg@ie@lowb{#1}%
    \else
      % from inputenc.sty: \edef\@inpenc@undefined{\noexpand\@inpenc@undefined@{#1}}%
      % > \@inpenc@undefined=macro:
      % ->\@inpenc@undefined@ {latin2}.
      \expandafter\magyar@sugg@ie@low\@inpenc@undefined....\vfuzz{#1}%
    \fi
  }%
  \def\magyar@sugg@af#1{%
    \expandafter\ifx\csname#1Options\endcsname\relax\else
      \PackageWarningNoLine{#1.ldf}{No effect of \string\def\@backslashchar #1Options{...}\MessageBreak
      please move it before \string\usepackage[#1]{babel}}%
    \fi
  }%
  \def\@@magyar@@ps@fancy{\relax}%\@fancyplainfalse\ps@@fancy}%
  \def\magyar@sugg@fh#1{%
    \ifx\ps@fancy\@@magyar@@ps@fancy
      \PackageWarningNoLine{#1.ldf}{No effect on fancyhdr.sty,\MessageBreak
      please load it before \string\usepackage[#1]{babel}}%
    \fi
  }%
  \def\magyar@sugg@ap#1{%
    \expandafter\ifx\csname opt@#1.ldf.sty\endcsname\relax\else
      \PackageWarningNoLine{#1.ldf}{No effect of \@backslashchar PassOptionsToPackage{?}{#1.ldf}\MessageBreak
      please move it before \string\usepackage[#1]{babel}}%
    \fi
  }%
  \edef\reserved@a{\noexpand\AtBeginDocument{%
    \noexpand\magyar@sugg@pa{\CurrentOption}%
    \noexpand\magyar@sugg@af{\CurrentOption}%
    \noexpand\magyar@sugg@ap{\CurrentOption}%
    \noexpand\magyar@sugg@to{\CurrentOption}%
    \noexpand\magyar@sugg@ie{\CurrentOption}%
    \noexpand\magyar@sugg@vr{\CurrentOption}%
    \noexpand\magyar@sugg@fh{\CurrentOption}%
  }}\reserved@a
  \@gobble
{^}%

% --- Active characters and shorthands; active=, activeprefix=, activespace=

\ifnum0=\magyar@opt@@activespace\magyar@opt@@active\space
  \def\@@magyar@declare@shorthandx#1#2{%
    \expandafter\def\csname @@magyar@shorthand@\string#1\endcsname{#2}%
  }
\@@magyar@skiplong\fi
  \def\magyar@activate@shorthands{%
    \edef\reserved@a{%
      \noexpand\addto\expandafter\noexpand\csname extras\CurrentOption\endcsname
      {\noexpand\languageshorthands{\CurrentOption}}%
    }
    \reserved@a
    \let\magyar@activate@shorthands\relax
  }
  \let\@@magyar@saved@initiate@active@char\initiate@active@char
  %
  % vvv Fri Oct  1 18:09:55 CEST 2004
  %     This is the ultimate fix of the .aux file catcodes when
  %     \usepackage[german,magyar]{babel} or
  %     \usepackage[french,magyar]{babel}.
  %     This enforces \catcode\string``=12 very early into the .aux file.
  % Imp: don't let \catcode``\active too early...
  {\toks@\expandafter{\expandafter\@@magyar@protect@backtick\@begindocumenthook}%
   \xdef\@begindocumenthook{\the\toks@}}% Dat: \@begindocumenthook has #1 #2 etc.
  \def\@@magyar@protect@backtick{%
    \if@filesw\immediate\write\@auxout{\catcode\noexpand\string``=12}\fi}
  %
  %** @param #1 a non-active char token
  %** @param #2 activation type: 0, 1, 2 or 3
  % !! quick link to \@@magyar@shorthand
  \def\magyar@activate@char#1#2{%
    \ifnum#2>1 % ignore 0 and 1
      \ifnum#2>2 % 3
        % SUXX, breaks compatibility with graphicx.sty and hyperref.sty and possibly
        % with many other packages using \catcode`` etc.
        %** Fix .aux load timing bug.
        \AtBeginDocument{%
          \if@filesw\immediate\write\@auxout{\catcode\noexpand\string`#1=12}\fi
        }
        \initiate@active@char{#1}%
      \else% 2
        % Dat: german.ldf emits `\catcode`"\active'; we should emit our
        %      catcode change (\catcode\string``=12) before that
        % Dat: this works only with \usepackage[magyar,german,magyar]{babel},
	%      not with \usepackage[german,magyar]{babel}
	%      solution: \AtBeginDocument{\if@filesw\immediate\write\@auxout{\catcode\noexpand\string`#1=12}\fi}
        \let\magyar@saved@AtBeginDocument\AtBeginDocument
        \let\AtBeginDocument\@gobble
        % vvv Calls \AtBeginDocument to set \catcode to \active and also write such a
        %     line to the .aux file. We just ignore it.
        \initiate@active@char{#1}%
        \let\AtBeginDocument\magyar@saved@AtBeginDocument
        \let\magyar@saved@AtBeginDocument\@undefined
        \expandafter\addto\csname extras\CurrentOption\endcsname{%
          \babel@savevariable{\catcode\string`#1}%
          \catcode\string`#1=13 %
        }%
      \fi
      % Dat: now #1 is \active (done by \initiate@active@char)
      \lccode\string`~=\string`#1\lowercase{% Dat: luckily everything below is in lowercase
        \expandafter\addto\csname   extras\CurrentOption\endcsname  {\bbl@activate{~}}%
        \expandafter\addto\csname noextras\CurrentOption\endcsname{\bbl@deactivate{~}}%
      }
      \lccode\string`~=0
      \catcode\string`#1=12 % Imp: restore _old_ catcode
    \fi
  }
  %** @param #1 shorthand prefix character (depends on activeprefix=)
  %** @param #2 a single character (will be prefixed)
  %*  @param #3 TeX code
  \def\@@magyar@declare@shorthand@low#1#2#3{%
    \declare@shorthand{\CurrentOption}{#1#2}{#3}%
  }
  \edef\@@magyar@shorthandprefix{\string`}%
  %** @param #1 a single character (will be prefixed by ``' etc.)
  %*  @param #2 TeX code
  %\def\@@magyar@declare@shorthand#1#2{\magyar@opt@@activeprefix#1{#2}}% defined below
  \ifx\magyar@opt@@activeprefix\relax
    \def\magyar@opt@@active{0}% =none
    \def\magyar@opt@@openqq{0}% =unchanged  (this must be defined before processing openqq below)
  \else\edef\@@magyar@declare@shorthand#1#2{\noexpand\@@magyar@declare@shorthand@low\expandafter\string\magyar@opt@@activeprefix#1{#2}}\fi
  %\magyar@activate@shorthands% not yet
  \def\@@magyar@declare@shorthandx#1#2{%
    \magyar@activate@shorthands
    \expandafter\def\csname @@magyar@shorthand@\string#1\endcsname{#2}%
    \expandafter\@@magyar@declare@shorthand\expandafter#1\expandafter{\csname @@magyar@shorthand@\string#1\endcsname}%
  }
  \@gobble
{^}%

%** Call \@@magyar@shorthand@... For example: {`tty} and
%** {\@@magyar@shorthand tty} are interchangeable.
%** @param #1 a char token. 
\def\@@magyar@shorthand#1{%
  \expandafter\ifx\csname @@magyar@shorthand@\string#1\endcsname\relax
    \@@magyar@error{Unknown shorthand: \string#1 }%
  \else
    \expandafter\expandafter\csname @@magyar@shorthand@\string#1\endcsname
  \fi
}

% --- activespace= Extra \thispace before :, ;, ! and ?
%
% french.ldf has \space after `:', but we only have \thinspace

\ifnum\magyar@opt@@activespace=0 \@@magyar@skiplong\fi
  %** @param #1 any of : ; ! ?
  \def\magyar@thinspaced#1{%
    % Dat: `!' at the end of the word is OK, but at the beginning it makes the
    %      word unhyphenatable. Imp: maybe \nobreak\hskip\z@skip?
    % Dat: this is math-mode safe, because \ifhmode is false in math mode 
    \ifhmode% \ifhmode and \ifmmode are never true
      \ifdim\lastskip>\z@
        \unskip\penalty\@M\kern.1em% \thinspace is .16667em
      \else
        \kern.1em
      \fi
    \fi
    \string#1%
  }
  \magyar@activate@shorthands
  \magyar@activate@char;\magyar@opt@@activespace
  \declare@shorthand{\CurrentOption}{;}{\magyar@thinspaced;}
  \magyar@activate@char!\magyar@opt@@activespace
  \declare@shorthand{\CurrentOption}{!}{%
    \ifmmode
      \expandafter\ifx\csname factorial\endcsname\relax\mathchar"5021 \else\factorial\fi
    \else\magyar@thinspaced!\fi}
  % ^^^ compatibility with nath.sty
  \magyar@activate@char?\magyar@opt@@activespace
  \declare@shorthand{\CurrentOption}{?}{\magyar@thinspaced?}
  \magyar@activate@char:\magyar@opt@@activespace
  \declare@shorthand{\CurrentOption}{:}{\magyar@thinspaced:}
  \@gobble
{^}%


% --- active=
%
% Dat: active=safe isn't safe unless other .ldf files used don't call
%      \initiate@active@char{`}.
%
% `` `' `= `_ `-- `- `| `< `> `" `~ etc.

\ifnum\magyar@opt@@active=0
  \ifnum\magyar@opt@@openqq>0 \@@magyar@error{active=none implies openqq=unchanged}\fi
\@@magyar@skiplong\fi
  \ifnum\magyar@opt@@active>1
    \magyar@activate@shorthands% Dat: don't do it if \magyar@opt@@active=0
    \expandafter\magyar@activate@char\magyar@opt@@activeprefix\magyar@opt@@active
  \fi
  %
  \ifnum\magyar@opt@@openqq>1 % =down
    % Same as in in ukraineb.ldf
    \@@magyar@declare@shorthandx`{\glqq}% down 99  \glqq is Babel's macro containing \quotedblbase
    \@@magyar@declare@shorthandx'{\grqq}% up 66
  \else\ifnum\magyar@opt@@openqq>0 % =up
    \@@magyar@declare@shorthandx`{\grqq}% up 66
    \@@magyar@declare@shorthandx'{\glqq}% down 99
  \else
    \dMf @@magyar@shorthand@\string` {\string`\string`}% unchanged -- expect a ligature in font
    \dMf @@magyar@shorthand@\string' {\string`\string'}% unchanged -- expect a ligature in font
  \fi\fi
  %
  %** A hyphen, but hyphenation is OK at both sides
  %** reported and asked by Józsa Márton <jozsineni@freemail.hu>
  \@@magyar@declare@shorthandx ={\leavevmode\nobreak-\hskip\z@skip}
  % ^^^ Dat: no need for \nobreak\hskip\z@skip, because of the empty discretionary
  %** \shu?-- typesets an endash (--) with a small space around it (the one to
  %** the right is breakable). \shu?- typesets a normal hyphen, having
  %** hyphenation OK at both sides.
  %** @example Kiss Előd\shu?--Nagy Pál
  %** @example közgazdaság\shu?-tudományi
  \def\@@magyar@shorthandminus{%
    \ifmmode \mskip2.4mu plus3.6mu minus1.8mu \else % ,`- is just a space in math mode
      \if-\noexpand\@Lang@tmp \leavevmode\nobreak\,\nobreak\hbox{--}\,\expandafter\expandafter\expandafter\@gobble% Dat: \@gobble -
      \else                   \leavevmode\nobreak-\hskip\z@skip\fi% Dat: e.g hegyes`-szögű
    \fi
  }
  \@@magyar@declare@shorthandx -{\futurelet\@Lang@tmp\@@magyar@shorthandminus}%
  %** A hyphen that is displayed in both next and current lines. Hyphenation
  %** is OK at both sides. This differs from ukraineb.ldf.
  %** \showhyphens{nátrium`|klorid} -> nát-ri-um--klo-rid
  \@@magyar@declare@shorthandx |{\leavevmode\nobreak-\nobreak\discretionary{}{-}{}\nobreak\hskip\z@skip}% Dat: all \nobreak s are important % e.g egyszer`|kétszer
  \@@magyar@declare@shorthandx _{\leavevmode\nobreak\-\nobreak\hskip\z@skip}
  \@@magyar@declare@shorthandx <{\flqq}
  \@@magyar@declare@shorthandx >{\frqq}
  \@@magyar@declare@shorthandx "{\hskip\z@skip}% \allowbreak, but hyphenation is OK at both sides
  \@@magyar@declare@shorthandx ~{\textormath{\leavevmode\hbox{-}}{-}}% a hyphen that isn't part of ligatures -- and ---
  %
  % Dat: `CXY means \discretionary{CS-}{XY}{CXY}, which makes sense only for
  %      `CCS. But `Ccs wouldn't make sense, since there is no Hungarian word
  %      (whose first letter has to be capitalized) beginning with ccs.
  % Dat: \nobreak\bbl@allowhyphens: \showhyphens{ho`sszabbra} -> hosz-szabb-ra
  % Dat: \def\foo{`}\declare@shorthand{\CurrentOption{\foo c}{...} doesn't work
  % Dat: these work quite well in math mode
  % Dat: \showhyphens{a\hskip\z@skip b} displays "ab", but
  %      \showhyphens{a\hskip0pt b} displays "a b"
  %** These should be equivalent:
  %**   \showhyphens{verembepot\nobreak\discretionary{y-}{}{}\nobreak\hskip\z@skip tyantam}
  %**   \showhyphens{verembepo`ttyantam}
  \def\@@magyar@disc#1#2{#1\textormath{\nobreak\discretionary{#2-}{}{}}{}\nobreak\hskip\z@skip}%
  \@@magyar@declare@shorthandx c{\@@magyar@disc cs}% loccsan --> locs-csan (lo`ccsan)
  \@@magyar@declare@shorthandx C{\@@magyar@disc CS}
  \@@magyar@declare@shorthandx g{\@@magyar@disc gy}% poggy\'asz --> pogy-gy\'asz (po`ggy\'asz)
  \@@magyar@declare@shorthandx G{\@@magyar@disc GY}
  \@@magyar@declare@shorthandx l{\@@magyar@disc ly}% Kod\'allyal --> Kod\'aly-lyal (Kod\'a`llyal)
  \@@magyar@declare@shorthandx L{\@@magyar@disc LY}
  \@@magyar@declare@shorthandx n{\@@magyar@disc ny}% mennyei --> meny-nyei (me`nnyei)
  \@@magyar@declare@shorthandx N{\@@magyar@disc NY}
  \@@magyar@declare@shorthandx s{\@@magyar@disc sz}% vissza --> visz-sza (vi`ssza)
  \@@magyar@declare@shorthandx S{\@@magyar@disc SZ}
  \@@magyar@declare@shorthandx t{\@@magyar@disc ty}% pottyan --> poty-tyan (po`ttyan)
  \@@magyar@declare@shorthandx T{\@@magyar@disc TY}
  \@@magyar@declare@shorthandx z{\@@magyar@disc zs}% rizzsel --> rizs-zsel (ri`zzsel)
  \@@magyar@declare@shorthandx Z{\@@magyar@disc ZS}
  \def\magyar@fixddzs{\@@magyar@declare@shorthandx d{% bridzs-dzsel
    % vvv doesn't handle the rare combination dzs-dzs
    %\@@magyar@declare@shorthandx D}{\@@magyar@disc DZ}
    %\@@magyar@declare@shorthandx d}{\@@magyar@disc dz}% eddz\"unk (felsz. m.) --> edz-dz\"unk (e`ddz\"unk)
    \def\reserved@a{%
      \if\noexpand\reserved@b d%
        \def\reserved@a{%
	  \if\noexpand\reserved@b z%
	    \def\reserved@a{%
              \nobreak% so word before `ddzs gets hyphenated
	      \if\noexpand\reserved@b s%
	        \discretionary{dzs-}{dz}{ddz}% \showhyphens{szuper`ddzsungelben}
	      \else
	        \discretionary{dz-}{d}{dd}z% \showhyphens{szuper`ddzungelben}
	      \fi
              \nobreak\hskip\z@skip% allow both pre- and post breaks
	    }%
	    \bbl@afterelse\expandafter\futurelet\expandafter\reserved@b\expandafter\reserved@a\@gobble
	  \else
	    \bbl@afterfi dd%
	  \fi
	}%
	\bbl@afterelse\expandafter\futurelet\expandafter\reserved@b\expandafter\reserved@a\@gobble
      \else\bbl@afterfi d\fi
    }%
    \futurelet\reserved@b\reserved@a% doesn't remove next token
  }}%
  \magyar@fixddzs \expandafter\uppercase\expandafter{\magyar@fixddzs}
  \@gobble
{^}%


% --- hunumbers=

\ifnum\magyar@opt@@hunumbers=0 \@@magyar@skiplong\fi
\def\@@magyar@egyjegyu#1{%
  \ifcase#1 \or\or k\'et\or h\'arom\or n\'egy\or \"ot\or hat\or h\'et\or
    nyolc\or kilenc\fi
}
\def\@@magyar@upperfi@nine#1\fi\fi\fi\fi\fi\fi\fi\fi\fi{\fi\fi\fi\fi\fi\fi\fi\fi\fi#1}
\def\@@magyar@upperelse@nine#1\else#2\fi\fi\fi\fi\fi\fi\fi\fi\fi{\fi#1}
\def\@@magyar@uppernum#1{%
  \ifx#1\"\@@magyar@upperelse@nine\"O\@gobble% \"o
  \else\if\noexpand#1eE%
  \else\if\noexpand#1hH%
  \else\if\noexpand#1kK%
  \else\if\noexpand#1mM% mínusz
  \else\if\noexpand#1nN%
  \else\if\noexpand#1oO%
  \else\if\noexpand#1sS% sokadik
  \else\if\noexpand#1tT%
  \else\@@magyar@upperfi@nine\expandafter\@@magyar@uppernum#1% do an extra expansion
  \fi\fi\fi\fi\fi\fi\fi\fi\fi
}
%** For \pagenumbering{huordinal}. Expands to the Hungarian ordered numeral,
%** spelled out in letters (i.e 1 --> first --> első). Suitable for numbering
%** \part{}s and \chapter{}s of a book (\def\thepart{\@Huordinal\c@part}})
%** @param #1 a number (input for \number) in -9999..9999
\def\@huordinal#1{%
  % !! larger numbers, also for \@hunumeral
  \ifnum#1=-1 m\'nusz egyedik\else
  \ifnum#1=-2 m\'nusz kettedik\else
  \ifnum#1<0 m\'inusz \expandafter\@huordinal\expandafter{\number-#1 }\else
  \ifcase\number#1 nulladik\or els\H o\or m\'asodik\or harmadik\or negyedik\or
    \"ot\"odik\or hatodik\or hetedik\or nyolcadik\or kilencedik\else
    \ifnum#1>999 \expandafter\@@magyar@ezresedik\number#1.\else
    \ifnum#1>99 \expandafter\@@magyar@szazasodik\number#1\else
                \expandafter\@@magyar@tizesedik\number#1%
  \fi\fi\fi\fi\fi\fi
}
%** @param #1#2 1000..9999
\def\@@magyar@ezresedik#1#2.{%
  \ifnum#1#2>9999 sokadik\else
    \@@magyar@egyjegyu#1%
    \ifnum#2=0 ezredik\else
      ezer\ifnum#1>1 -\fi% kétezer-harmadik
      \ifnum#2<100
        \expandafter\@@magyar@tizesedik\number#2%
      \else
        \ifnum#2<200 egy\fi% ezerszázadik -> ezeregyszázadik
        \@@magyar@szazasodik#2%
      \fi
    \fi
  \fi
}
%** @param #1#2 100..999
%** Imp: binary search
\def\@@magyar@szazasodik#1#2#3{%
  \@@magyar@egyjegyu#1sz\'az%
  \@@magyar@tizesedik#2#3%
}
%** @param #1 a digit
%** @param #2 a digit
%** Imp: binary search
\def\@@magyar@tizesedik#1#2{%
       \ifnum#1#2>89 kilencven\@@magyar@egyesedik#2e%
  \else\ifnum#1#2>79  nyolcvan\@@magyar@egyesedik#2a%
  \else\ifnum#1#2>69    hetven\@@magyar@egyesedik#2e%
  \else\ifnum#1#2>59    hatvan\@@magyar@egyesedik#2a%
  \else\ifnum#1#2>49   \"otven\@@magyar@egyesedik#2e%
  \else\ifnum#1#2>39   negyven\@@magyar@egyesedik#2e%
  \else\ifnum#1#2>29   harminc\@@magyar@egyesedik#2a%
  \else\ifnum#1#2>20    huszon\@@magyar@egyesedik#2.%
  \else\ifnum#1#2=20  huszadik%
  \else\ifnum#1#2>10     tizen\@@magyar@egyesedik#2.%
  \else\ifnum#1#2=10   tizedik%
  \else                       \@@magyar@egyesedik#2a% ``kétszázadik''
  \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
}%
\def\@@magyar@egyesedik#1#2{%
  \ifcase#1 #2\or egye\or kette\or harma\or negye\or
    \"ot\"o\or hato\or hete\or nyolca\or kilence\fi dik%
}
%** Same as \@huordinal, but uppercase
\def\@Huordinal#1{%
  % Dat: \newlabel{hellopart}{{Els\H o}{3}} is correctly written out
  \ifcase#1 Nulladik\or Els\H o\or M\'asodik\or Harmadik\or Negyedik\or
    \"Ot\"odik\or Hatodik\or Hetedik\or Nyolcadik\or Kilencedik\or Tizedik%
    \or Tizenegyedik\or Tizenkettedik\else\@@magyar@uppernum\@huordinal{#1}\fi
}
\def\huordinal#1{\expandafter\@huordinal\csname c@#1\endcsname}
\def\Huordinal#1{\expandafter\@Huordinal\csname c@#1\endcsname}

%** For \pagenumbering{hunumeral}. Expands to the Hungarian ordered numeral,
%** spelled out in letters (i.e 1 --> first --> első). Suitable for numbering
%** \part{}s and \chapter{}s of a book (\def\thepart{\@Hunumeral\c@part}})
%** @param #1 a number (input for \number) in -9999..9999
\def\@hunumeral#1{%
  \ifnum#1<0 m\'inusz \expandafter\@hunumeral\expandafter{\number-#1 }\else
  \ifcase#1 nulla\or egy\or kett\H{o}\or h\'arom\or n\'egy\or
    \"ot\or hat\or h\'et\or nyolc\or kilenc\else
    \ifnum#1>999 \expandafter\@@magyar@ezer\number#1.\else
    \ifnum#1>99 \expandafter\@@magyar@szaz\number#1\else
                \expandafter\@@magyar@tiz\number#1%
  \fi\fi\fi\fi
}
%** @param #1#2 1000..9999
\def\@@magyar@ezer#1#2.{%
  \ifnum#1#2>9999 sokadik\else
    \@@magyar@egyjegyu#1%
    \ifnum#2=0 ezer\else
      ezer\ifnum#1>1 -\fi% kétezer-harmadik
      \ifnum#2<100
        \expandafter\@@magyar@tiz\number#2%
      \else
        \ifnum#2<200 egy\fi% ezerszázadik -> ezeregyszázadik
        \@@magyar@szaz#2%
      \fi
    \fi
  \fi
}
%** @param #1#2 100..999
%** Imp: binary search
\def\@@magyar@szaz#1#2#3{%
  \@@magyar@egyjegyu#1sz\'az%
  \@@magyar@tiz#2#3%
}
%** @param #1 a digit
%** @param #2 a digit
%** Imp: binary search
\def\@@magyar@tiz#1#2{%
       \ifnum#1#2>89 kilencven\@@magyar@egy#2%
  \else\ifnum#1#2>79  nyolcvan\@@magyar@egy#2%
  \else\ifnum#1#2>69    hetven\@@magyar@egy#2%
  \else\ifnum#1#2>59    hatvan\@@magyar@egy#2%
  \else\ifnum#1#2>49   \"otven\@@magyar@egy#2%
  \else\ifnum#1#2>39   negyven\@@magyar@egy#2%
  \else\ifnum#1#2>29   harminc\@@magyar@egy#2%
  \else\ifnum#1#2>20    huszon\@@magyar@egy#2%
  \else\ifnum#1#2=20  h\'usz%
  \else\ifnum#1#2>10     tizen\@@magyar@egy#2%
  \else\ifnum#1#2=10   t\'iz%
  \else                       \@@magyar@egy#2% ``kétszázadik''
  \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
}%
\def\@@magyar@egy#1{%
  \ifcase#1 \or egy\or kett\H{o}\or h\'arom\or n\'egy\or
    \"ot\or hat\or h\'et\or nyolc\or kilenc\fi%
}
%** Same as \@hunumeral, but uppercase
\def\@Hunumeral#1{%
  % Dat: \newlabel{hellopart}{{Els\H o}{3}} is correctly written out
  \ifcase#1 Nulla\or Egy\or Kett\H{o}\or H\'arom\or N\'egy\or
    \"Ot\or Hat\or H\'et\or Nyolc\or Kilenc\else\@@magyar@uppernum\@hunumeral{#1}\fi
}
\def\hunumeral#1{\expandafter\@hunumeral\csname c@#1\endcsname}
\def\Hunumeral#1{\expandafter\@Hunumeral\csname c@#1\endcsname}

\@gobble
{^}%

% --- Appending suffixes to numbers; told=

\ifnum\magyar@opt@@told=0 \@@magyar@skiplong\fi
% Dat: double accent combinations: +adik,+a,+as,+ad  +hoz,+an,+on,+at,+ban...

% vvv Terminal suffix variants

% Dat: meaning of classes(#1): {\ifcase 0\or 1\or 2\or 3\or 4\or 5\or 6\or 7\or 8\or 9\or 10\or 11/-1\or 12/-2\or 100\or 1000\or 10^6\or 10^9\or 20\or 30\or 40\or 60\fi}
% Dat: ...@st is is special for appending +t to \refstruc names
\def\@@magyar@suffix@adik#1{\ifnum#1=1 s\H o\else
                              \ifcase#1 a\or  e\or  o\or a\or e\or\"o\or o\or e\or a\or e\or e\or e\or  e\or a\or e\or a\or a\or a\or a\or e\or a\or e\or e\fi dik\fi}%
\def\@@magyar@suffix@a#1{\ifcase     #1 a\or je\or  a\or a\or e\or  e\or a\or e\or a\or e\or e\or e\or  e\or a\or e\or a\or a\or a\or a\or e\or a\fi}%
\def\@@magyar@suffix@as#1{\ifcase    #1  \or  e\or  e\or a\or e\or\"o\or o\or e\or a\or e\or e\or e\or  e\or a\or e\or  \or a\or a\or a\or e\or a\fi s}%
\def\@@magyar@suffix@ad#1{\ifcase    #1 a\or  e\or  e\or a\or e\or\"o\or o\or e\or a\or e\or e\or e\or  e\or a\or e\or a\or a\or a\or a\or e\or a\fi d}%
\def\@@magyar@suffix@@hoz#1#2{\ifcase#2 o\or  e\or\"o\or o\or e\or\"o\or o\or e\or o\or e\or e\or e\or\"o\or o\or e\or o\or o\or o\or o\or e\or o\fi#1}%
\def\@@magyar@suffix@@an#1{\ifcase   #1  \or  e\or  e\or a\or e\or  e\or a\or e\or a\or e\or e\or e\or  e\or a\or e\or a\or a\or a\or a\or e\or a\fi n}%
\def\@@magyar@suffix@on#1{\ifcase    #1  \or  e\or   \or o\or e\or\"o\or o\or e\or a\or e\or e\or e\or  e\or o\or e\or  \or o\or o\or o\or e\or o\fi n}%
\def\@@magyar@suffix@st#1{\ifcase    #1  \or   \or   \or  \or e\or   \or  \or  \or  \or  \or  \or  \or   \or  \or  \or  \or  \or  \or  \or  \or  \fi t}%
\def\@@magyar@suffix@@at#1{\ifcase   #1  \or  e\or   \or a\or e\or\"o\or o\or e\or a\or e\or e\or e\or   \or a\or e\or  \or a\or a\or a\or e\or a\fi t}%
\def\@@magyar@suffix@@a#1#2{\ifcase  #2 a\or  e\or  e\or a\or e\or  e\or a\or e\or a\or e\or e\or e\or  e\or a\or e\or a\or a\or a\or a\or e\or a\fi#1}%
\def\@@magyar@suffix@nal#1{n\ifcase  #1 \'a\or \'e\or \'e\or\'a\or \'e\or \'e\or\'a\or \'e\or\'a\or \'e\or \'e\or \'e\or \'e\or\'a\or \'e\or \'a\or \'a\or \'a\or\'a\or \'e\or\'a\fi l}%
\def\@@magyar@suffix@@ol#1{\ifcase   #1 \'o\or\H o\or\H o\or\'o\or\H o\or\H o\or\'o\or\H o\or\'o\or\H o\or\H o\or\H o\or\H o\or\'o\or\H o\or \'o\or \'o\or \'o\or\'o\or\H o\or\'o\fi l}%
\def\@@magyar@suffix@ul#1{\ifcase    #1   u\or \"u\or \"u\or  u\or \"u\or \"u\or  u\or \"u\or  u\or \"u\or \"u\or \"u\or \"u\or  u\or \"u\or   u\or   u\or   u\or  u\or \"u\or  u\fi l}%
\def\@@magyar@suffix@val#1{\ifcase   #1  va\or gye\or ve\or ma\or gye\or  te\or ta\or  te\or ca\or  ce\or  ze\or gye\or  ve\or za\or  re\or  va\or  da\or sza\or ca\or  ne\or na\fi l}%
% @example: \atold(2.31)+es+sel{}
\def\@@magyar@suffix@sal#1{\ifcase   #1  sa\or se\or  se\or sa\or  se\or  se\or sa\or  se\or sa\or  se\or  se\or  se\or  se\or sa\or  se\or  sa\or  sa\or  sa\or sa\or  se\or sa\fi l}%
% @example: \atold(2.31)+ed+del{}
\def\@@magyar@suffix@dal#1{\ifcase   #1  da\or de\or  de\or da\or  de\or  de\or da\or  de\or da\or  de\or  de\or  de\or  de\or da\or  de\or  da\or  da\or  da\or da\or  de\or da\fi l}%
% @example: \atold(2.31)+edik+kel{}
\def\@@magyar@suffix@kal#1{\ifcase   #1  ka\or ke\or  ke\or ka\or  ke\or  ke\or ka\or  ke\or ka\or  ke\or  ke\or  ke\or  ke\or ka\or  ke\or  ka\or  ka\or  ka\or ka\or  ke\or da\fi l}%
\def\@@magyar@suffix@an{\@@magyar@suffix@@an}% make \ifx\@@magyar@suffix@an faster
\def\@@magyar@suffix@at{\@@magyar@suffix@@at}% make \ifx\@@magyar@suffix@at faster
\def\@@magyar@suffix@hoz{h\@@magyar@suffix@@hoz z}
\def\@@magyar@suffix@ban{b\@@magyar@suffix@@a n}
\def\@@magyar@suffix@nak{n\@@magyar@suffix@@a k}
\def\@@magyar@suffix@ba{b\@@magyar@suffix@@a \@empty}
\def\@@magyar@suffix@ra{r\@@magyar@suffix@@a \@empty}
\def\@@magyar@suffix@bol{b\@@magyar@suffix@@ol}
\def\@@magyar@suffix@tol{t\@@magyar@suffix@@ol}
\def\@@magyar@suffix@rol{r\@@magyar@suffix@@ol}
\def\@@magyar@suffix@szor{sz\@@magyar@suffix@@hoz r}

% vvv Continued suffix variants

\def\@@magyar@skipfi\fi\else{\fi}%
%** Usage: \@@magyar@suffix@aS{5}\magyar@@suffix@hoz
\def\@@magyar@suffix@aS#1#2{%
  \ifnum#2=5 \ifx#1\@@magyar@suffix@at \"oset\else\@@magyar@skipfi\fi\else
    \ifcase#2  \or e\or e\or a\or e\or \"o\or o\or e\or a\or e\or e\or e\or e\or a\or e\or  \or a\or a\or a\or e\or a\fi s%
    \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
    \ifx#1\@@magyar@suffix@val\@@magyar@suffix@sal\else#1\fi % +es+vel -> +es+sel
    % Imp: +ad+val, +adik+val etc.
    \ifcase#2 3\or 1\or 1\or 3\or 1\or   5\or 3\or 1\or 3\or 1\or 1\or 1\or 1\or 3\or 1\or 3\or 3\or 3\or 3\or 1\or 3\fi
  \fi
}%
\def\@@magyar@suffix@aD#1#2{%
  \ifcase#2  \or e\or e\or a\or e\or \"o\or o\or e\or a\or e\or e\or e\or e\or a\or e\or  \or a\or a\or a\or e\or a\fi d%
  \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
  \ifx#1\@@magyar@suffix@val\@@magyar@suffix@dal\else#1\fi % +ed+vel -> +ed+del
  \ifcase#2 3\or 1\or 1\or 3\or 1\or   5\or 3\or 1\or 3\or 1\or 1\or 1\or 1\or 3\or 1\or 3\or 3\or 3\or 3\or 1\or 3\fi
}%
\def\@@magyar@suffix@adiK#1#2{%
  \ifnum#2=1 \ifx#1\@@magyar@suffix@at s\"ot\else\@@magyar@skipfi\fi\else
    \ifcase#2  \or e\or e\or a\or e\or \"o\or o\or e\or a\or e\or e\or e\or e\or a\or e\or  \or a\or a\or a\or e\or a\fi dik%
    \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
    \ifx#1\@@magyar@suffix@val\@@magyar@suffix@kal\else#1\fi % +edik+vel -> +ed+kel
    \ifcase#2 3\or 1\or 1\or 3\or 1\or   1\or 3\or 1\or 3\or 1\or 1\or 1\or 1\or 3\or 1\or 3\or 3\or 3\or 3\or 1\or 3\fi
  \fi
}%
\def\@@magyar@suffix@A#1#2{%
  \ifcase#2 \'a\or j\'e\or \'a\or \'a\or \'e\or \'e\or \'a\or \'e\or \'a\or \'e\or \'e\or \'e\or \'e\or \'a\or \'e\or \'a\or\'a\or\'a\or\'a\or\'e\or\'a\fi
  \ifx#1\@@magyar@suffix@at t\else
  \ifx#1\@@magyar@suffix@an n\else% Dat: suffix overload: 2-a-an => 2-án
    \expandafter#1\ifcase#2 3\or 1\or 1\or 3\or 1\or   1\or 3\or 1\or 3\or 1\or 1\or 1\or 1\or 3\or 1\or 3\or 3\or 3\or 3\or 1\or 3\fi
  \fi\fi
}%
\def\@@magyar@suffix@@bad#1#2{\@@magyar@error{Unknown suffix \string`#1' for \string\told}}

% vvv Input suffix parser

%** Also defined elsewhere.
%** @param #2 \else...\else...\fi...\fi etc.
\def\@@magyar@swaprelax#1#2\relax{#2#1}
%\def\@@magyar@swapno#1\noexpand{...}
\def\@@magyar@contn#1\relax{#1\@@magyar@told@cont{}}
\def\@@magyar@conta#1#2#3\relax{#3\noexpand#1\@@magyar@told@cont{#2}}
\def\@@magyar@badsuffix#1#2\relax{#2\noexpand\@@magyar@suffix@@bad{#1}\@@magyar@told@cont{#1}}%
\def\@@magyar@fs@#1{%
  \if a\noexpand#1\@@magyar@swaprelax\@@magyar@fs@a\else
  \if b\noexpand#1\@@magyar@swaprelax\@@magyar@fs@b\else
  \if d\noexpand#1\@@magyar@swaprelax\@@magyar@fs@d\else
  \if e\noexpand#1\@@magyar@swaprelax\@@magyar@fs@e\else
  \if h\noexpand#1\@@magyar@swaprelax\@@magyar@fs@h\else
  \if k\noexpand#1\@@magyar@swaprelax\@@magyar@fs@k\else
  \if n\noexpand#1\@@magyar@swaprelax\@@magyar@fs@n\else
  \if o\noexpand#1\@@magyar@swaprelax\@@magyar@fs@o\else
  \if r\noexpand#1\@@magyar@swaprelax\@@magyar@fs@r\else
  \if s\noexpand#1\@@magyar@swaprelax\@@magyar@fs@s\else
  \if t\noexpand#1\@@magyar@swaprelax\@@magyar@fs@t\else
  \if u\noexpand#1\@@magyar@swaprelax\@@magyar@fs@u\else
  \if v\noexpand#1\@@magyar@swaprelax\@@magyar@fs@v\else
  % Imp: SUXX: badsuffix doesn't work for +qal here -- fix error reporting
  \@@magyar@badsuffix{#1}{}\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\relax
}
\def\@@magyar@fs@a#1{%
  %\if -\noexpand#1\@@magyar@swapno\else
  \if +\noexpand#1\noexpand\@@magyar@suffix@A\@@magyar@swaprelax\@@magyar@fs@\else
  \if d\noexpand#1\@@magyar@swaprelax\@@magyar@fs@ad\else
  \if n\noexpand#1\noexpand\@@magyar@suffix@an\@@magyar@contn\else
  \if s\noexpand#1\@@magyar@swaprelax\@@magyar@fs@as\else
  \if t\noexpand#1\noexpand\@@magyar@suffix@at\@@magyar@contn\else
                  \@@magyar@conta\@@magyar@suffix@a{#1}%
  \fi\fi\fi\fi\fi\relax
}
\def\@@magyar@fs@ad#1{%
  %\if -\noexpand#1\@@magyar@swapno\else
  \if +\noexpand#1\noexpand\@@magyar@suffix@aD\@@magyar@swaprelax\@@magyar@fs@\else
  \if i\noexpand#1\@@magyar@swaprelax\@@magyar@fs@adi\else
                  \@@magyar@conta\@@magyar@suffix@ad{#1}%
  \fi\fi\relax
}
\def\@@magyar@fs@adi#1{%
  \if k\noexpand#1\@@magyar@swaprelax\@@magyar@fs@adik\else
  \@@magyar@badsuffix{adi#1}{}\fi\relax
}
\def\@@magyar@fs@adik#1{%
  %\if -\noexpand#1\@@magyar@swapno\else
  \if +\noexpand#1\noexpand\@@magyar@suffix@adiK\@@magyar@swaprelax\@@magyar@fs@\else
                  \@@magyar@conta\@@magyar@suffix@adik{#1}%
  \fi\relax
}
\def\@@magyar@fs@as#1{%
  %\if -\noexpand#1\@@magyar@swapno\else
  \if +\noexpand#1\noexpand\@@magyar@suffix@aS\@@magyar@swaprelax\@@magyar@fs@\else
                  \@@magyar@conta\@@magyar@suffix@as{#1}%
  \fi\relax
}
\def\@@magyar@fs@b#1{%
  \if a\noexpand#1\@@magyar@swaprelax\@@magyar@fs@ba\else
  \if e\noexpand#1\@@magyar@swaprelax\@@magyar@fs@ba\else
  \if o\noexpand#1\@@magyar@swaprelax\@@magyar@fs@bo\else
  \@@magyar@badsuffix{b#1}{}\fi\fi\fi\relax
}
\def\@@magyar@fs@ba#1{%
  \if n\noexpand#1\noexpand\@@magyar@suffix@ban\@@magyar@contn\else
                  \@@magyar@conta\@@magyar@suffix@ba{#1}%
  \fi\relax
}
\def\@@magyar@fs@bo#1{%
  \if l\noexpand#1\noexpand\@@magyar@suffix@bol\@@magyar@contn\else
  \@@magyar@badsuffix{bo#1}{}\fi\relax
}
\def\@@magyar@fs@d#1{%
  \if a\noexpand#1\@@magyar@swaprelax\@@magyar@fs@da\else
  \if e\noexpand#1\@@magyar@swaprelax\@@magyar@fs@da\else
  \@@magyar@badsuffix{d#1}{}\fi\fi\relax
}
\def\@@magyar@fs@da#1{%
  \if l\noexpand#1\noexpand\@@magyar@suffix@dal\@@magyar@contn\else
  \@@magyar@badsuffix{da#1}{}\fi\relax
}
\def\@@magyar@fs@e#1{%
  \if d\noexpand#1\@@magyar@swaprelax\@@magyar@fs@ad\else
  \if s\noexpand#1\@@magyar@swaprelax\@@magyar@fs@as\else
  \if t\noexpand#1\noexpand\@@magyar@suffix@at\@@magyar@contn\else
  \if n\noexpand#1\noexpand\@@magyar@suffix@an\@@magyar@contn\else
  \if +\noexpand#1\noexpand\@@magyar@suffix@A\@@magyar@swaprelax\@@magyar@fs@\else
  %\@@magyar@badsuffix{e#1}{}
  \@@magyar@conta\@@magyar@suffix@a{#1}{}%
  \fi\fi\fi\fi\fi\relax
}
\def\@@magyar@fs@h#1{%
  \if e\noexpand#1\@@magyar@swaprelax\@@magyar@fs@ho\else
  \if o\noexpand#1\@@magyar@swaprelax\@@magyar@fs@ho\else
  \@@magyar@badsuffix{h#1}{}\fi\fi\relax
}
\def\@@magyar@fs@ho#1{%
  \if z\noexpand#1\noexpand\@@magyar@suffix@hoz\@@magyar@contn\else
  \@@magyar@badsuffix{ho#1}{}\fi\relax
}
\def\@@magyar@fs@k#1{%
  \if a\noexpand#1\@@magyar@swaprelax\@@magyar@fs@ka\else
  \if e\noexpand#1\@@magyar@swaprelax\@@magyar@fs@ka\else
  \@@magyar@badsuffix{k#1}{}\fi\fi\relax
}
\def\@@magyar@fs@ka#1{%
  \if l\noexpand#1\noexpand\@@magyar@suffix@kal\@@magyar@contn\else
  \@@magyar@badsuffix{ka#1}{}\fi\relax
}
\def\@@magyar@fs@n#1{%
  \if a\noexpand#1\@@magyar@swaprelax\@@magyar@fs@na\else
  \if e\noexpand#1\@@magyar@swaprelax\@@magyar@fs@na\else
  \@@magyar@badsuffix{n#1}{}\fi\fi\relax
}
\def\@@magyar@fs@na#1{%
  \if k\noexpand#1\noexpand\@@magyar@suffix@nak\@@magyar@contn\else
  \if l\noexpand#1\noexpand\@@magyar@suffix@nal\@@magyar@contn\else
  \@@magyar@badsuffix{na#1}{}\fi\fi\relax
}
\def\@@magyar@fs@o#1{%
  \if d\noexpand#1\@@magyar@swaprelax\@@magyar@fs@ad\else
  \if n\noexpand#1\noexpand\@@magyar@suffix@on\@@magyar@contn\else
  \if s\noexpand#1\@@magyar@swaprelax\@@magyar@fs@as\else
  \if t\noexpand#1\noexpand\@@magyar@suffix@at\@@magyar@contn\else
  \@@magyar@badsuffix{o#1}{}\fi\fi\fi\fi\relax
}
\def\@@magyar@fs@r#1{%
  \if a\noexpand#1\noexpand\@@magyar@suffix@ra\@@magyar@contn\else
  \if e\noexpand#1\noexpand\@@magyar@suffix@ra\@@magyar@contn\else
  \if o\noexpand#1\@@magyar@swaprelax\@@magyar@fs@ro\else
  \@@magyar@badsuffix{r#1}{}\fi\fi\fi\relax
}
\def\@@magyar@fs@ro#1{%
  \if l\noexpand#1\noexpand\@@magyar@suffix@rol\@@magyar@contn\else
  \@@magyar@badsuffix{ro#1}{}\fi\relax
}
\def\@@magyar@fs@s#1{%
  \if z\noexpand#1\@@magyar@swaprelax\@@magyar@fs@sz\else
  \if a\noexpand#1\@@magyar@swaprelax\@@magyar@fs@sa\else
  \if e\noexpand#1\@@magyar@swaprelax\@@magyar@fs@sa\else
  \if t\noexpand#1\noexpand\@@magyar@suffix@st\@@magyar@contn\else
  \@@magyar@badsuffix{s#1}{}\fi\fi\fi\fi\relax
}
\def\@@magyar@fs@sa#1{%
  \if l\noexpand#1\noexpand\@@magyar@suffix@sal\@@magyar@contn\else
  \@@magyar@badsuffix{sa#1}{}\fi\relax
}
\def\@@magyar@fs@sz#1{%
  \if o\noexpand#1\@@magyar@swaprelax\@@magyar@fs@szo\else
  \if e\noexpand#1\@@magyar@swaprelax\@@magyar@fs@szo\else
  \@@magyar@badsuffix{sz#1}{}\fi\fi\relax
}
\def\@@magyar@fs@szo#1{%
  \if r\noexpand#1\noexpand\@@magyar@suffix@szor\@@magyar@contn\else
  \@@magyar@badsuffix{szo#1}{}\fi\relax
}
\def\@@magyar@fs@t#1{%
  \if o\noexpand#1\@@magyar@swaprelax\@@magyar@fs@to\else% Dat: works even if #1 is empty
                  \@@magyar@conta\@@magyar@suffix@at{#1}%
  \fi\relax
}
\def\@@magyar@fs@to#1{%
  \if l\noexpand#1\noexpand\@@magyar@suffix@tol\@@magyar@contn\else
  \@@magyar@badsuffix{to#1}{}\fi\relax
}
\def\@@magyar@fs@u#1{%
  \if l\noexpand#1\noexpand\@@magyar@suffix@ul\@@magyar@contn\else
  \@@magyar@badsuffix{u#1}{}\fi\relax
}
\def\@@magyar@fs@v#1{%
  \if a\noexpand#1\@@magyar@swaprelax\@@magyar@fs@va\else
  \if e\noexpand#1\@@magyar@swaprelax\@@magyar@fs@va\else
  \@@magyar@badsuffix{v#1}{}\fi\fi\relax
}
\def\@@magyar@fs@va#1{%
  \if l\noexpand#1\noexpand\@@magyar@suffix@val\@@magyar@contn\else
  \@@magyar@badsuffix{va#1}{}\fi\relax
}

% vvv Classification

% Old: \def\@@magyar@skipor#1\or#2\fi{\fi#1}%
%** Usage: \expandafter\@@magyar@skipor\expandafter\token\ifcase ... \else ... \or\else\fi
\def\@@magyar@skipor#1\or{\@@magyar@skipelse#1\else}%
\def\@@magyar@skipelse#1\else#2\fi{\fi#1}%

%** Usage: \@@magyar@classify@none{N}{...}
%**   Reads till \vfuzz, considers the last decimal number, ignores space,
%** punctuation and the minus `-' sign. Ignores spaces, so `1 2' and `12' are
%** treated the same number. There must ne no `{' or `}' inside `...'.
%**   x ends by 0..9, y ends by 1..9 below.
%** @expands to:
%**   c0: 0
%**   c1: 1
%**   c2: x2 ...
%**   c9: x9
%**   c10: x10
%**   c11: x1
%**   c12: x2
%**   c13: y00
%**   c14: y000 y0000 y00000
%**   c15: y000000 y0000000 y00000000
%**   c16: x000000000
%**   c17: x20
%**   c18: x30
%**   c19: x40 x50 x70 x90
%**   c20: x60 x80
%**   On error, expansion doesn't start with `c'
%** @param #1 default classification, if no (more) numbers found
%** @param #2 next token
\def\@@magyar@classify@none#1#2{%
  \if\noexpand#20\@@magyar@swaprelax{\@@magyar@classify@none{c0}}\else
  % Dat: smart way to test whether #1 is in 1..9: \ifnum0<0\string#1 foo\fi
  \ifnum0<0\string#2 \@@magyar@swaprelax{\@@magyar@classify@single#2}\else
  \if\noexpand#2- \@@magyar@swaprelax{\@@magyar@classify@neg{#1}}\else
  \ifx#2\vfuzz   \@@magyar@swaprelax{#1}\else% stop processing if terminating \vfuzz is found
                 \@@magyar@swaprelax{\@@magyar@classify@none{#1}}% find next (possibly) number
  % ^^^ Dat: it is safe to call \@@magyar@swaprelax here, even if #2 contains \relax
  \fi\fi\fi\fi\relax
}
\def\@@magyar@classify@neg#1#2{%
  \if\noexpand#20\@@magyar@swaprelax{\@@magyar@classify@none{c0}}\else
  % Dat: smart way to test whether #1 is in 1..9: \ifnum0<0\string#1 foo\fi
  \ifnum0<0\string#2 \@@magyar@swaprelax{\@@magyar@classify@singleneg#2}\else
  \if\noexpand#2- \@@magyar@swaprelax{\@@magyar@classify@none{#1}}\else% double negation
  \ifx#2\vfuzz   \@@magyar@swaprelax{#1}\else% stop processing if terminating \vfuzz is found
                 \@@magyar@swaprelax{\@@magyar@classify@none{#1}}% find next (possibly) number, start as positive
  % ^^^ Dat: it is safe to call \@@magyar@swaprelax here, even if #2 contains \relax
  \fi\fi\fi\fi\relax
}
%** @param #1 previous digit 1..9
%** @param #2 next token
\def\@@magyar@classify@single#1#2{%
  \if\noexpand#20\@@magyar@swaprelax{\@@magyar@classify@tens#1}\else
  \ifnum0<0\string#2 \@@magyar@swaprelax{\@@magyar@classify@more#2}\else
  \ifx#2\vfuzz   \@@magyar@swaprelax{c#1}\else
                 \@@magyar@swaprelax{\@@magyar@classify@none{c#1}#2}%
  % ^^^ Dat: it is safe to call \@@magyar@swaprelax here, even if #2 contains \relax
  \fi\fi\fi\relax
}
%** @param #1 previous digit 1..9
%** @param #2 next token
\def\@@magyar@classify@singleneg#1#2{%
  \if\noexpand#20\@@magyar@swaprelax{\@@magyar@classify@tens#1}\else
  \ifnum0<0\string#2 \@@magyar@swaprelax{\@@magyar@classify@more#2}\else
  \ifx#2\vfuzz   \@@magyar@swaprelax{c\ifcase#1 0\or11\or12\else#1\fi}\else % turn `-1' -> `11' and `-2' to `12'
  \if#11\@@magyar@swaprelax{\@@magyar@classify@neg{c11}#2}\else
  \if#12\@@magyar@swaprelax{\@@magyar@classify@neg{c12}#2}\else
                 \@@magyar@swaprelax{\@@magyar@classify@neg{c#1}#2}%
  % ^^^ Dat: it is safe to call \@@magyar@swaprelax here, even if #2 contains \relax
  \fi\fi\fi\fi\fi\relax
}
%** @param #1 previous digit 1..9
%** @param #2 next token
\def\@@magyar@classify@more#1#2{%
  \if\noexpand#20\@@magyar@swaprelax{\@@magyar@classify@tens#1}\else
  \ifnum0<0\string#2 \@@magyar@swaprelax{\@@magyar@classify@more#2}\else
                 \@@magyar@swaprelax{%
    \expandafter\@@magyar@skipor\expandafter\@@magyar@classify@none
    \ifcase#1 M\or {c11}\or {c12}\else {c#1}\or\else\fi#2}%
  % ^^^ Dat: it is safe to call \@@magyar@swaprelax here, even if #2 contains \relax
  \fi\fi\relax
}
%** @param #1 prev-prev digit, 1..9
%** @param #2 next token
\def\@@magyar@classify@tens#1#2{%
  \if\noexpand#20\@@magyar@swaprelax{\@@magyar@classify@zeroes2}\else
  \ifnum0<0\string#2 \@@magyar@swaprelax{\@@magyar@classify@more#2}\else
                 \@@magyar@swaprelax{%
    \expandafter\@@magyar@skipor\expandafter\@@magyar@classify@none
    \ifcase#1 T\or{c10}\or{c17}\or{c18}\or{c19}\or{c19}\or{c20}\or{c19}\or{c20}\else{c19}\or\else\fi#2}%
  % ^^^ Dat: it is safe to call \@@magyar@swaprelax here, even if #2 contains \relax
  \fi\fi\relax
}
%** @param #1 zero-count 2..9
%** @param #2 next token
\def\@@magyar@classify@zeroes#1#2{%
  \if\noexpand#20\@@magyar@swaprelax{%
     %\def\foo#1,{.(#1)}
     %\message{\expandafter\expandafter\expandafter\foo\expandafter
     %  \@@magyar@skipor\ifcase3 zero\or one\or two\else three\or\fi,done}
     \expandafter\@@magyar@skipor\expandafter\@@magyar@classify@zeroes
     %\ifcase#1 Y\or Y\or 3\or 4\or 5\or 6\or 7\or 8\or 9\or 9\or% Dat: no \else
     \ifcase#1 Y\or Y\or 3\or 4\or 5\or 6\or 7\or 8\else 9%
     \or\else\fi}\else% ^^^ Dat: 2 -> 3 ... 8 -> 9, 9 -> 9
  \ifnum0<0\string#2 \@@magyar@swaprelax{\@@magyar@classify@more#2}\else
                 \@@magyar@swaprelax{%
    \expandafter\@@magyar@skipor\expandafter\@@magyar@classify@none
    \ifcase#1 Z\or Z\or {c13}\or {c14}\or {c14}\or {c14}\or {c15}\or {c15}\or
    {c15}\else {c16}\or\else\fi#2}%
  % ^^^ Dat: it is safe to call \@@magyar@swaprelax here, even if #2 contains \relax
  \fi\fi\relax
}

% vvv The user interface for suffixing

\def\@@magyar@ccheck#1#2\vfuzz#3{%
  \if\noexpand#1c\relax\else
    \@@magyar@error{\string\told\space needs number, not \string`#3'}%
    \def\reserved@a{c0}%
  \fi
}

%** Expands #1 with \the if it is \cs (possibly \count or \toks etc.)
\def\@@magyar@the#1{%
  \ifx#1\relax\else\if\noexpand\noexpand\noexpand#1%
  \expandafter\expandafter\expandafter\the\fi\fi#1%
}%

\def\@@magyar@firsthfuzz#1#2\hfuzz{#1}
\def\@@magyar@secondhfuzz#1#2#3\hfuzz{#2}
%** See docs in magyar.dtx
\def\@@magyar@zerocite#1{%
  \ifx[#1\expandafter\@secondoftwo\fi\@thirdofthree\@firstoftwo
  {\@@magyar@zerocite@lowa[, }% had `['
  {\@@magyar@zerocite@lowa[]{#1}}%
}
\def\@@magyar@zerocite@lowa[#1]#2{[\@@magyar@zerocite@lowb#2,\hbox,${#1}}
\def\@@magyar@swapvfuzz#1#2\vfuzz{#2#1}
\def\@@magyar@zerocite@lowb#1#2,{%
  \ifx\hfuzz#1\hfuzz
  \else\ifx\hbox#1\@@magyar@swapvfuzz\@@magyar@zerocite@lowc
  \else\ifx,#1\@@magyar@swapvfuzz\@@magyar@zerocite@lowb{#2,}%
  \else\expandafter\ifx\csname b@#1#2\endcsname\relax
    0, \@@magyar@swapvfuzz\@@magyar@zerocite@lowb
  \else\expandafter\expandafter\expandafter\@@magyar@b@number
    \expandafter\expandafter\expandafter{\csname b@#1#2\endcsname},
    \@@magyar@swapvfuzz\@@magyar@zerocite@lowb
  \fi\fi\fi\fi\vfuzz}
\def\@@magyar@zerocite@lowc$#1{]#1}

%** Expands to the numeric value of a \b@foobar definition
%** Dat: with natbib.sty, we get \def\b@foobar{{1}{...}...},
%**      otherwise something like \def\b@foobar{\... 1}
%** @param #1 value of a \b@foobar
\def\@@magyar@b@number{%
  \expandafter\ifx\csname ver@natbib.sty\endcsname\relax
    \expandafter\@firstofone
  \else \expandafter\@@magyar@b@number@natbibone \fi
}
\def\@@magyar@b@number@natbibone#1{\@@magyar@b@number@natbibtwo#1.\vfuzz}
\def\@@magyar@b@number@natbibtwo#1#2\vfuzz{#1}%

\def\@@magyar@zeroaref#1{%
  % Dat: we cannot use \@ifnextchar here, because it is not expandable
  \ifx(#1\expandafter\@secondoftwo\fi\@thirdofthree\@firstoftwo
  {\@@magyar@zeroref}{% Dat: gobble the (
    \ifx*#1\expandafter\@secondoftwo\fi\@thirdofthree\@firstoftwo
    {\NotAllowedArefStar\@@magyar@zeropageref}% Dat: gobble the *
    {\@@magyar@zeroref{#1}}%
    {\@@magyar@zeroref{#1}}}%
}

\def\@@magyar@zeroapageref#1{%
  % Dat: we cannot use \@ifnextchar here, because it is not expandable
  \ifx*#1\expandafter\@secondoftwo\fi\@thirdofthree\@firstoftwo
  {\NotAllowedApagerefStar\@@magyar@zeropageref}% Dat: gobble the *
  {\@@magyar@zeropageref{#1}}%
}

\def\@@magyar@zeroref#1{%
  \expandafter\ifx\csname r@#1\endcsname\relax0\else
    \expandafter\expandafter\expandafter\@@magyar@firsthfuzz\csname r@#1\endcsname00\hfuzz
  \fi
}%
\def\@@magyar@zeroeqref#1{(\@@magyar@zeroref{#1})}%
\def\@@magyar@zerorefplus#1{\@@magyar@zerorefplus@low#1+\vfuzz}
\def\@@magyar@zerorefplus@low#1+#2\vfuzz{%
  \expandafter\ifx\csname r@#1\endcsname\relax0\else
    \expandafter\expandafter\expandafter\@@magyar@firsthfuzz\csname r@#1\endcsname00\hfuzz
  \fi
}%
\def\@@magyar@zeropageref#1{%
  \expandafter\ifx\csname r@#1\endcsname\relax0\else
    \expandafter\expandafter\expandafter\@@magyar@secondhfuzz\csname r@#1\endcsname00\hfuzz
  \fi
}%

%** A space might be discared after the suffix, depending on the suffix. So
%** please use `\told5+adik{} ' to ensure the space.
%**   May raise `! Package magyar.ldf Error: Unknown suffix `...' for \told', but
%** emits unchanged suffix to DVI file.
%**   \atold\apageref emits double article
%**   \cite, \acite etc. is allowed, but without comma
%**   \aref({...}), \aref*, \apageref*, \acite* aren't allowed
%** \refstruc doesn't work inside it, because \refstruc isn't expandable
%** @example \told4+a+a+a+a+adik raises strange error
%** @example no -en is provided for -an/-on, to avoid ambiguity
%** @example \told4+adik: 0-adik 1-ső 2-odik 3-adik 12-edik 10^8-adik
%** @example augusztus \told20-a: 1-je 2-a 3-a 4-e 5-e 6-a ... (augusztus 20-a)
%** @example \told3+as: 0-s(??) 1-es 2-es 3-as 4-es 5-ös 10^6-s
%** @example \told0+ad: 0-ad 1-ed 2-ed 3-ad 5-öd 10^6-ad
%** @example \told1000+hoz: 0-hoz 3-hoz 6-hoz 8-hoz 100-hoz 10^6-hoz 10^9-hoz 1-hez 4-hez 7-hez 9-hez 10-hez 1000-hez 2-höz 5-höz
%** @example \told5+an: 5-en 2-en 100-an 10^6-n
%** @example \told5+on: 5-ön 2-n 3-on 100-on 10^6-n
%** @example \told0+at: 0-t 2-t 10^6-t 1-et 4-et 7-et 9-et 10-et 1000-et 3-at 8-at 6-ot 10^9-ot 5-öt
%** @example \told1000+ban: 1000-ben
%** @example \told7+ba: 7-be
%** @example \told5+nak: 7-nek
%** @example \told2+ra: 2-re
%** @example \told4+nal: 4-nél
%** @example \told7+bol: 7-ből
%** @example \told5+tol: 5-től
%** @example \told3+rol: 3-ról
%** @example \told2+ul: 0-ul 1-ül 2-ül 3-ul
%** @example \told5+odik+hoz
%** @example \told{300}+szor
%** @example -i and -ig don't change have alternate forms
%** @param #1 something that expands to an integer, or `\count...' or `\toks...'
\DeclareRobustCommand \@@magyar@told{\@@magyar@xtold 0}
\DeclareRobustCommand\@@magyar@atold{\@@magyar@xtold a}
\DeclareRobustCommand\@@magyar@Atold{\@@magyar@xtold A}
\def\@@magyar@xtold#1#2+{\@@magyar@told@low{#2}#1}
%** @param #1 something that expands to an integer, or `\count...' or `\toks...'
%** @param #2 add \az? (0: no, a: lowercase A: uppercase)
\def\@@magyar@told@low#1#2{%
  % Dat: a level of braces has already been stripped from #1
  % Dat: negative sign isn't important, because it is skipped by \@@magyar@classify@none
  \begingroup\begingroup
  \@safe@activestrue% allow active `:' inside labels
  \let\@safe@activesfalse\@empty \let\@safe@activestrue\@empty% inside \b@... emitted by \cite
  % vvv Dat: gobbles its arg and `-' below
  %     `\@@magyar@toldas{42}' must be the very end of #1
  \let\@@magyar@toldas\@gobbletwo
  \let\-\relax
%  \let\@@magyar@save@tilde~%
  \let~\relax% influenced by \@safe@activestrue
  \let\refstruc\relax  \let\refstrucparen\relax
  \let \ref\relax \let \pageref\relax \let \cite\relax % all unexpandable, even for \@@magyar@the
  \let\aref\relax \let\apageref\relax \let\acite\relax
  \let\Aref\relax \let\Apageref\relax \let\Acite\relax
  \let\autoref\relax
  %\set@display@protect% \string. Why?? doesn't seem to screw up \r
  \set@typeset@protect% \relax.
  \edef\reserved@c{#1-}%
  \edef\reserved@c{\def\noexpand\reserved@c{\expandafter\@@magyar@the\reserved@c\@empty}}% `\expandafter' is here so `the' and `number' take place
  %
  \def\@@magyar@toldas##1{.##1.}% emit the number
  \let\romannumeral\number
  \def\refstruc##1{0}%
  \def\refstrucparen##1{0}%
  \let\@safe@activestrue\@empty% babel puts these inside \b@...: % Dat: \def\b@abook{\@safe@activesfalse 2}% (what is \@safe@actives??)
  \let\@safe@activesfalse\@empty% \b@DuplanJauneau1986 ->\@safe@activesfalse 15
  \def\hyper@@link[##1]##2##3##4{##4}% Dat: \def\b@abook{\hyper@@link [cite]{}{cite.sokt}{2}}% with hyperref.sty % BUGFIX at Tue Nov 21 03:15:32 CET 2006
  %
  \let\ref\@@magyar@zeroref
  \let\pageref\@@magyar@zeropageref
  \let\cite\@@magyar@zerocite
  \let\eqref\@@magyar@zeroeqref
  %
  \let\aref\@@magyar@zeroaref \let\Aref\aref % Dat: supports \aref* and \aref(
  \let\apageref\@@magyar@zeroapageref \let\Apageref\apageref % Dat: supports \apageref* and \apageref(
  \let\acite\cite \let\Acite\acite
  %
  \let\autoref\ref% Dat: SUXX: ``section 1-gyel''
  \edef\reserved@a{#1}%
  \edef\reserved@a{\expandafter\@@magyar@the\reserved@a\@empty}% `\expandafter' is here so `the' and `number' take place
  %\let~\@@magyar@save@tilde% vvv for ~ below etc.
  \if0#2\else
    #2% a or A
    % vvv Dat: we do \az with \romannumeral changed to \number
    \expandafter\@@magyar@az@set\expandafter{\reserved@a}\hbox$% Dat: \reserved@a is already expanded, as required by \@@magyar@az@set
    \nobreakspace% Dat: `~' is wrong here, it has been redefined !!
  \fi
  \edef\reserved@a{\noexpand\reserved@c\def\noexpand\reserved@a{\reserved@a}}%
  %
  \expandafter\expandafter\expandafter\endgroup\reserved@a% keep \reserved@a and \reserved@c
  %%\show\reserved@a \show\reserved@c \show\@@magyar@toldas
  % vvv Dat: shows friendly LaTeX error: \told{\refstruc{refstruc=}}+ban
  \def\refstruc{\@@magyar@error{Cannot use \string\refstruc\space inside \string\told}\@@magyar@refstruc}%
  \edef\reserved@a{\expandafter\@@magyar@classify@none\expandafter N\reserved@a\vfuzz}%
  %%\show\reserved@a
  \expandafter\@@magyar@ccheck\reserved@a..\vfuzz\reserved@c%
  %\edef\reserved@a{{\ifcase\expandafter\@gobble\reserved@a\space 0\or1\or2\or
  %  3\or4\or5\or6\or7\or8\or9\or10\or11\or12\or13\or14\or15\or16\or
  %  8\or8\else 9\fi}}% 20->8 30->8 40->9 % no need for this anymore
  \edef\reserved@a{{\number\expandafter\@gobble\reserved@a}}% keeps 17,18,19 for +val
  \expandafter\edef\expandafter\reserved@b\expandafter{\if}.\fi\@@magyar@fs@
}
%** @in \reserved@a is suffix classification in braces: {0}, {1} ... or {16}
%** @param #1 \@empty or a char token
\def\@@magyar@told@cont#1{%
  \reserved@a% add the suffix class, example: {11}
  #1%\if/\noexpand#1\else#1\fi% add extra char unless `/'
  \if{.\fi}% close \edef\reserved@b opened in \@@magyar@told
  % Now: example \reserved@b: \@@magyar@suffix@aS \@@magyar@suffix@sal {11}
  % Now: example \reserved@b: \@@magyar@suffix@aS \@@magyar@suffix@val {11}
  % Dat: \reserved@b is now like \@@magyar@suffix@A \@@magyar@suffix@ban
  % vvv Dat: \aref in \reserved@c may modify \reserved@b, so we call it
  %     late by \expandafter
  \expandafter\reserved@c% print the number and the hyphen
  \reserved@b% print the suffix
  \endgroup
}
% Dat: \told is an unused \cs in LaTeX and its standard packages
\ifnum\magyar@opt@@told>1
  \let \told\@@magyar@told
  \let\atold\@@magyar@atold
  \let\Atold\@@magyar@Atold
\else
  \expandafter\ifx\csname  told\endcsname\relax \let \told\@@magyar@told\fi
  \expandafter\ifx\csname atold\endcsname\relax \let\atold\@@magyar@atold\fi
  \expandafter\ifx\csname Atold\endcsname\relax \let\Atold\@@magyar@Atold\fi
\fi
\@gobble
{^}%

% --- hutoday=

% Dat: latex.ltx has \edef for \today, but we have \def
\def\SafeToday{\the\year/\two@digits{\the\month}/\two@digits{\the\day}:%
  \two@digits{\the\count@}:\two@digits{\the\count2}}

\ifnum\magyar@opt@@hutoday=0 \@namedef{date\CurrentOption}{\let\today\SafeToday}\@@magyar@skiplong\fi
%** Same as what latex.ltx has. Expansion doesn't change it, doesn't contain
%** accents.
\@namedef{date\CurrentOption}{%
  \def\today{%
    \number\year.~\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.\hbox{}}%
  }
% vvv Dat: ondate... and \ontoday is specific to magyar.ldf
\@namedef{ondate\CurrentOption}{%
  \number\year.~\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}
\edef\reserved@a{%
  \noexpand\addto\expandafter\noexpand\csname extras\CurrentOption\endcsname{%
  \noexpand\babel@save\noexpand\ontoday
  \let\noexpand\ontoday\expandafter\noexpand\csname ondate\CurrentOption\endcsname}
}
\reserved@a
\@gobble
{^}%

% --- refstruc=

\if0\magyar@opt@@refstruc \@@magyar@skiplong\fi
\def\@@magyar@nonumbers@skipa#1\@@magyar@nonumbers@s{#1\@@magyar@nonumbers@a}
%** Changes arabic and roman numbers to 1 or i, respectively.
%** Usage: \typeout{((\@@magyar@nonumbers@a 35.2.iv\hfuzz))} -> ((1.1.i))
\def\@@magyar@nonumbers@a#1{%
  \ifx#1\hfuzz \expandafter\@gobble
  \else\if\noexpand#101% !! Imp: 1<1\string#1
  \else\if\noexpand#111%
  \else\if\noexpand#121%
  \else\if\noexpand#131%
  \else\if\noexpand#141%
  \else\if\noexpand#151%
  \else\if\noexpand#161%
  \else\if\noexpand#171%
  \else\if\noexpand#181%
  \else\if\noexpand#191%
  \else\if\noexpand#1mi%
  \else\if\noexpand#1di%
  \else\if\noexpand#1ci%
  \else\if\noexpand#1li%
  \else\if\noexpand#1xi%
  \else\if\noexpand#1vi%
  \else\if\noexpand#1ii%
  \else\if\noexpand#1MI%
  \else\if\noexpand#1DI%
  \else\if\noexpand#1CI%
  \else\if\noexpand#1LI%
  \else\if\noexpand#1XI%
  \else\if\noexpand#1VI%
  \else\if\noexpand#1II%
  \else\noexpand#1\@@magyar@nonumbers@skipa
  \fi\fi\fi\fi\fi\fi\fi \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \fi\fi\fi\fi\fi\fi\fi \fi
  \@@magyar@nonumbers@s
}
\def\@@magyar@nonumbers@s#1{%
  \ifx#1\hfuzz \expandafter\@gobble
  \else\if\noexpand#10%
  \else\if\noexpand#11%
  \else\if\noexpand#12%
  \else\if\noexpand#13%
  \else\if\noexpand#14%
  \else\if\noexpand#15%
  \else\if\noexpand#16%
  \else\if\noexpand#17%
  \else\if\noexpand#18%
  \else\if\noexpand#19%
  \else\if\noexpand#1m%
  \else\if\noexpand#1d%
  \else\if\noexpand#1c%
  \else\if\noexpand#1l%
  \else\if\noexpand#1x%
  \else\if\noexpand#1v%
  \else\if\noexpand#1i%
  \else\if\noexpand#1M%
  \else\if\noexpand#1D%
  \else\if\noexpand#1C%
  \else\if\noexpand#1L%
  \else\if\noexpand#1X%
  \else\if\noexpand#1V%
  \else\if\noexpand#1I%
  \else\noexpand#1\@@magyar@nonumbers@skipa
  \fi\fi\fi\fi\fi\fi\fi \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \fi\fi\fi\fi\fi\fi\fi \fi
  \@@magyar@nonumbers@s
}

\let\@@magyar@toldas\@gobble
\def\@@magyar@strucname@part{r\'esz\@@magyar@toldas{4}}% SUXX: may not contain \-; !! résszel (vs. részszel)
\def\@@magyar@strucname@chapter{fejezet\@@magyar@toldas{9}}% !! fejezettel
\def\@@magyar@strucname@appendix{f\"ug\-gel\'ek\@@magyar@toldas{4}}% !! fuggelekkel
\def\@@magyar@strucname@section{szakasz\@@magyar@toldas{20}}%
\def\@@magyar@strucname@subsection{al\-sza\-kasz\@@magyar@toldas{20}}%
\def\@@magyar@strucname@subsubsection{al\-al\-szakasz\@@magyar@toldas{20}}%
\def\@@magyar@strucname@subsubsubsection{al\-al\-al\-szakasz\@@magyar@toldas{20}}%
\def\@@magyar@strucname@paragraph{bekezd\'es\@@magyar@toldas{4}}%
\def\@@magyar@strucname@subparagraph{albekezd\'es\@@magyar@toldas{4}}%
\def\@@magyar@strucname@subsubparagraph{alalbekezd\'es\@@magyar@toldas{4}}%
\def\@@magyar@strucname@figure{\'ab\-ra\@@magyar@toldas{4}}% !! ábrában etc.
\def\@@magyar@strucname@table{t\'ab\-l\'azat\@@magyar@toldas{6}}%
\def\@@magyar@strucname@equation{egyenlet\@@magyar@toldas{7}}%
\def\@@magyar@strucname@footnote{l\'ab\-jegy\-zet\@@magyar@toldas{7}}%
\def\@@magyar@strucname@item{elem\@@magyar@toldas{4}}% !! elemmel etc.
\def\@@magyar@strucname@FancyVerbLine{sor\@@magyar@toldas{8}}% !! sorral
\def\@@magyar@strucname@theorem{t\'e-tel\@@magyar@toldas{4}}% !! tétellel

%** Must be expandable.
%** @param #1 `section' etc.
%** @expands to its name in English
\def\@@magyar@strucname#1{#1}
%** @param #1 `section' etc.
%** @expands to its name in Hungarian
\def\@@magyar@strucname@hu#1{\csname @@magyar@strucname@#1\endcsname}

%** Keeps only structure number, discards page number etc.
\def\@@magyar@refstruc@parse#1#2\vfuzz{%
  \ifx\relax#1\let\reserved@a\relax
  \else\def\reserved@a{#1}\fi
}%
%** Retrieves the structure name (arg #4) from arg 2 of a \newlabel emitted
%** by hyperref.sty.
%** @example \newlabel{fig:vonal}{{1}{1}{my title}{figure.1}{}}
%**        \@namedef{r@fig:vonal}{{1}{1}{my title}{figure.1}{}}
%**          -> extract `figure' to \reserved@c
\def\@@magyar@refstruc@parsehyname#1#2#3#4#5\vfuzz{%
  \ifx\relax#1%
  \else\expandafter\@@magyar@refstruc@parsehynamedot#4\vfuzz\fi
}%
\def\@@magyar@refstruc@parsehynamedot#1.#2\vfuzz{%
  \expandafter\ifx\csname @@magyar@strucname@#1\endcsname\relax
  \else\def\reserved@c{#1}\fi
}

%** @param #1 name of a count register (e.g c@part)
\def\@@magyar@refstruc@setcnt#1{%
  \expandafter\ifx\csname#1\endcsname\relax\expandafter\@tempcnta
  \else\csname#1\endcsname\fi
}%

%** @param #1 a label name
\def\@@magyar@refstruc@ref#1{%
  \ref{#1}.~%
}

%** May not touch \reserved@a
\def\@@magyar@refstruc@split#1+#2\vfuzz#3{%
  \if\noexpand#30\else\@@magyar@refstruc@ref{#1}\fi
  \ifx\vfuzz#2%
    \textbf{??}%
    \G@refundefinedtrue
  \else
    \begingroup
      \@safe@activestrue% so active `:' etc. will work inside \csname...
      \edef\reserved@c{\noexpand\@@magyar@refstruc@splitlow
	\expandafter\ifx\csname r@#1\endcsname\relax\relax\else
	\expandafter\noexpand\csname r@#1\endcsname\fi}%
      % ^^^ Dat: would emit `undefined' instead of `\relax' w/o \ifx
    \expandafter\endgroup\reserved@c{#2}%
  \fi
}

%** @param #1 csname \r@foo:bar
%** @param #2 suffix to add
\def\@@magyar@refstruc@splitlow#1#2{%
  \ifx#1\relax
    \textbf{??+#2}%
    \G@refundefinedtrue
  \else
    \expandafter\@@magyar@refstruc@parse#1..\vfuzz%
    \@@magyar@refstruc@work#1%
    \let\@@magyar@save@m\-%
    \let\-\relax
    \let\@@magyar@toldas\relax
    \edef\reserved@c{\expandafter\@@magyar@strucname\expandafter{\reserved@c}}%
    \let\-\@@magyar@save@m
    \let\@@magyar@suffix@at\@@magyar@suffix@st% fix the -t suffix
    \ifx\reserved@b\@empty\else
      \@@magyar@refstruc@splitb#2\vfuzz% strip `+' from the end of #2
    \fi
  \fi
}

\def\@@magyar@refstruc@splitb#1+\vfuzz{%
  \expandafter\@@magyar@told\reserved@c+#1{}% fejezet -> fejezetben
}

%** The +val suffix does not produce the desired result.
%** @param #1 \ref id or with \told
%** (@param #2 1 to prefix with 1\ref{...}.~' in Hungarian order)
%** @example \refstruc{sec:foo}
%** @example \refstruc{sec:foo+as+an} 
%** May not touch \reserved@a
\def\@@magyar@refstruc@name#1{%
  \begingroup
  \begingroup
    \@safe@activestrue% so active `:' etc. will work inside \csname...
    \edef\reserved@c{\noexpand\@@magyar@refstruc@namelow
      \expandafter\ifx\csname r@#1\endcsname\relax\relax\else
      \expandafter\noexpand\csname r@#1\endcsname\fi}%
    % ^^^ Dat: would emit `undefined' instead of `\relax' w/o \ifx
  \expandafter\endgroup\reserved@c{#1}%
}

%** @param #1 csname \r@foo:bar
%** @param #2 foo:bar
%** @param #3 1 to prefix with 1\ref{...}.~' in Hungarian order)
\def\@@magyar@refstruc@namelow#1#2#3{%
  \ifx#1\relax
    \@@magyar@refstruc@split#2+\vfuzz#3% ends by +suffix, needs \told
  \else
    \expandafter\@@magyar@refstruc@parse#1..\vfuzz% sets \reserved@a to ref target
    %%\show\reserved@a% first arg of ref, i.e section number, eg. `1.2.3' -- or \relax
    \if\noexpand#30\else
      \begingroup% Dat: \ref might redefine \reserved@a, especially in hyperref.sty
      \@@magyar@refstruc@ref{#2}\endgroup\fi
    \@@magyar@refstruc@work#1%
    \expandafter\@@magyar@strucname\expandafter{\reserved@c}%
  \fi
  \endgroup
}

\def\@@magyar@appendix@chapapp{\appendixname}%

%** Input is \reserved@a, output is \reserved@c
%** @param #1 the control sequence \r@foo:bar
\def\@@magyar@refstruc@work#1{%
  \edef\reserved@a{\expandafter\@@magyar@nonumbers@a\reserved@a\hfuzz}%
  %\expandafter\lowercase\expandafter{\expandafter\def\expandafter\reserved@a\expandafter{\reserved@a}}%
  % ^^^ Dat: don't do lowercasing, deliberately.
  % Imp: referring from \@alph sections such as the appendix
  \@@magyar@refstruc@setcnt{c@part}1
  \@@magyar@refstruc@setcnt{c@chapter}1
  \@@magyar@refstruc@setcnt{c@section}1
  \@@magyar@refstruc@setcnt{c@subsection}1
  \@@magyar@refstruc@setcnt{c@subsubsection}1
  \@@magyar@refstruc@setcnt{c@subsubsubsection}1
  \@@magyar@refstruc@setcnt{c@paragraph}1
  \@@magyar@refstruc@setcnt{c@subparagraph}1
  \@@magyar@refstruc@setcnt{c@subsubparagraph}1
  \let\reserved@c\relax
  \expandafter\@@magyar@refstruc@parsehyname#1....\vfuzz%
  \ifx\reserved@c\relax% hyperref.sty and nameref.sty has helped us
  \def\reserved@c{subsubparagraph}\edef \reserved@b{\csname the\reserved@c\endcsname}\ifx\reserved@a\reserved@b\else
  \def\reserved@c{subparagraph}\edef    \reserved@b{\csname the\reserved@c\endcsname}\ifx\reserved@a\reserved@b\else
  \def\reserved@c{paragraph}\edef       \reserved@b{\csname the\reserved@c\endcsname}\ifx\reserved@a\reserved@b\else
  \def\reserved@c{subsubsubsection}\edef\reserved@b{\csname the\reserved@c\endcsname}\ifx\reserved@a\reserved@b\else
  \def\reserved@c{subsubsection}\edef   \reserved@b{\csname the\reserved@c\endcsname}\ifx\reserved@a\reserved@b\else
  \def\reserved@c{subsection}\edef      \reserved@b{\csname the\reserved@c\endcsname}\ifx\reserved@a\reserved@b\else
  \def\reserved@c{section}\edef         \reserved@b{\csname the\reserved@c\endcsname}\ifx\reserved@a\reserved@b\else
  \def\reserved@c{chapter}\edef         \reserved@b{\csname the\reserved@c\endcsname}\ifx\reserved@a\reserved@b\else
  \def\reserved@c{appendix}\edef        \reserved@b{\expandafter\ifx\csname c@chapter\endcsname\relax\else\@Alph\c@chapter\fi}\ifx\reserved@a\reserved@b\else% Imp: do this without changing counters in \appendix
  \def\reserved@c{part}\edef            \reserved@b{\csname the\reserved@c\endcsname}\ifx\reserved@a\reserved@b\else
  %%\show\@chapapp \show\@@magyar@appendix@chapapp
  \ifx\@chapapp\@@magyar@appendix@chapapp% we're in an appendix referring to a normal chapter
    \def\thechapter{\@arabic\c@chapter}\fi
  \def\reserved@c{subsubparagraph}\edef \reserved@b{\csname the\reserved@c\endcsname}\ifx\reserved@a\reserved@b\else
  \def\reserved@c{subparagraph}\edef    \reserved@b{\csname the\reserved@c\endcsname}\ifx\reserved@a\reserved@b\else
  \def\reserved@c{paragraph}\edef       \reserved@b{\csname the\reserved@c\endcsname}\ifx\reserved@a\reserved@b\else
  \def\reserved@c{subsubsubsection}\edef\reserved@b{\csname the\reserved@c\endcsname}\ifx\reserved@a\reserved@b\else
  \def\reserved@c{subsubsection}\edef   \reserved@b{\csname the\reserved@c\endcsname}\ifx\reserved@a\reserved@b\else
  \def\reserved@c{subsection}\edef      \reserved@b{\csname the\reserved@c\endcsname}\ifx\reserved@a\reserved@b\else
  \def\reserved@c{section}\edef         \reserved@b{\csname the\reserved@c\endcsname}\ifx\reserved@a\reserved@b\else
  \def\reserved@c{chapter}\edef         \reserved@b{\csname the\reserved@c\endcsname}\ifx\reserved@a\reserved@b\else
  %
  \@latex@error{Unknown structure level for ref \string`\reserved@a';
    \reserved@b}\@ehc%
  \def\reserved@c{??}% Dat: must be expandable
  \let\reserved@b\@empty
  \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
}

\def\@@magyar@refstruc@hu#1{\@@magyar@refstruc@name{#1}1}%
% Imp: Undocumented: \refstrucparen can be used instead of \refstruc
% to format the section number inside parentheses.
\def\@@magyar@refstrucparen@hu#1{%
  \begingroup
  \def\@@magyar@refstruc@ref##1{\told(\ref{##1})+es{}~}%
  \@@magyar@refstruc@name{#1}1%
  \endgroup}%
\def\@@magyar@refstruc#1{\@@magyar@refstruc@name{#1}0~\ref{#1}}%
\def\@@magyar@refstrucparen#1{\@@magyar@refstruc@name{#1}0~(\ref{#1})}%

\expandafter\addto\csname extras\CurrentOption\endcsname{%
  \babel@save\@@magyar@refstruc
  \babel@save\@@magyar@strucname
  \let\@@magyar@refstruc \@@magyar@refstruc@hu
  \let\@@magyar@refstrucparen \@@magyar@refstrucparen@hu
  \let\@@magyar@strucname\@@magyar@strucname@hu
}

\ifnum\magyar@opt@@refstruc \expandafter\ifx\csname refstruc\endcsname\relax1\fi>1 % 21, 2, 11, 1
  \DeclareRobustCommand\refstruc{\@@magyar@refstruc}%
  \DeclareRobustCommand\refstrucparen{\@@magyar@refstrucparen}%
\fi
\@gobble
{^}

% --- Printing dates; emitdate=

\ifnum\magyar@opt@@emitdate=0 \@@magyar@skiplong\fi
%** @param #1 1..12 (month number)
\def\@@magyar@month@a#1{\two@digits{#1}}%
\def\@@magyar@month@b#1{\ifcase#1\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}%
\def\@@magyar@month@c#1{\ifcase#1\or jan\or feb\or m\'arc\or
  \'apr\or m\'aj\or j\'un\or j\'ul\or aug\or szept\or
  okt\'\or nov\or dec\fi.\hbox{}}%
\def\@@magyar@month@d#1{\@Roman{#1}}%

\def\@@magyar@four@digits#1{%
  \ifnum#1<10 000\else\ifnum#1<100 00\else\ifnum#1<1000 0\fi\fi\fi\number#1%
}

\def\@@magyar@date@a#1#2#3{#1-\@@magyar@month@a{#2}-\two@digits{#3}}
\def\@@magyar@date@b#1#2#3{#1.~\@@magyar@month@b{#2} \number#3.\hbox{}}% Dat: \hbox is to force \frenchspacing
\def\@@magyar@date@c#1#2#3{#1.~\@@magyar@month@c{#2} \number#3.\hbox{}}
\def\@@magyar@date@d#1#2#3{#1.~\@@magyar@month@d{#2}.\ \number#3.\hbox{}}
\def\@@magyar@date@e#1#2#3{#1.~\@@magyar@month@a{#2}.\ \two@digits{#3}.\hbox{}}
\def\@@magyar@date@f#1#2#3{#1.~\@@magyar@month@b{#2}}% Dat: \hbox is to force \frenchspacing
\def\@@magyar@date@g#1#2#3{#1.~\@@magyar@month@b{#2} \number#3}% Dat: \told{\@@magyar@date@g{1848}{3}{15}}+e{}
\def\@@magyar@date@h#1#2#3{#1~\@@magyar@month@b{#2}}% Imp: suffixes to months
\def\@@magyar@date@i#1#2#3{#1/\@@magyar@month@a{#2}/\two@digits{#3}}% not Hungarian

\def\@@magyar@parsedate@a#1-#2-#3!#4\hfuzz{% ISO date: YYYY-MM-DD
  \ifx\hfuzz#4\hfuzz\else \ifnum1<1\string#1\relax \ifnum1<1\string#2\relax \ifnum1<1\string#3\relax
  \def\reserved@a{\@@magyar@fixdate{#1}{#2}{#3}}%
  \fi\fi\fi\fi
}
\def\@@magyar@parsedate@b#1/#2/#3!#4\hfuzz{% LaTeX date: YYYY/MM/DD
  \ifx\hfuzz#4\hfuzz\else \ifnum1<1\string#1\relax \ifnum1<1\string#2\relax \ifnum1<1\string#3\relax
  \def\reserved@a{\@@magyar@fixdate{#1}{#2}{#3}}%
  \fi\fi\fi\fi
}
\def\@@magyar@parsedate@c#1.#2.#3!#4\hfuzz{% English date: YYYY.DD.MM
  \ifx\hfuzz#4\hfuzz\else \ifnum1<1\string#1\relax \ifnum1<1\string#2\relax \ifnum1<1\string#3\relax
  \def\reserved@a{\@@magyar@fixdate{#1}{#3}{#2}}%
  \fi\fi\fi\fi
}
\def\@@magyar@mon@jan{1}%
\def\@@magyar@mon@feb{2}%
\def\@@magyar@mon@mar{3}%
\def\@@magyar@mon@apr{4}%
\def\@@magyar@mon@maj{5}%
\def\@@magyar@mon@may{5}% english.ldf
\def\@@magyar@mon@jun{6}%
\def\@@magyar@mon@jul{7}%
\def\@@magyar@mon@aug{8}%
\def\@@magyar@mon@sze{9}%
\def\@@magyar@mon@sep{9}% english.ldf
\def\@@magyar@mon@okt{10}%
\def\@@magyar@mon@oct{10}% english.ldf
\def\@@magyar@mon@nov{11}%
\def\@@magyar@mon@dec{12}%
\def\@@magyar@parsedate@d#1. #2#3#4#5 #6!#7\hfuzz{% {2003. oktober 25} with \catcodes 12 and 10
  \ifx\hfuzz#7\hfuzz\else
    % Dat: now: {#1} is {2003}, {#2#3#4#5} is {oktober}, {#6} is {25}
    \ifnum1<1\string#1\relax \ifnum1<1\string#6\relax
      \lowercase{%
        \expandafter\ifx\csname @@magyar@mon@#2#3#4\endcsname\relax\else
        %%\errmessage{(#1)(#2#3#4)(#6)}%
        \edef\reserved@a{\noexpand\@@magyar@fixdate{\number#1}{\csname @@magyar@mon@#2#3#4\endcsname}{\number#6}}\fi
      }%
  \fi\fi\fi
}
\def\@@magyar@parsedate@e#1#2#3#4 #5, #6!#7\hfuzz{% {October 25, 2003} with \catcodes 12 and 10
  \ifx\hfuzz#7\hfuzz\else
    \ifnum1<1\string#5\relax \ifnum1<1\string#6\relax
      \lowercase{%
        \expandafter\ifx\csname @@magyar@mon@#1#2#3\endcsname\relax\else
        \edef\reserved@a{\noexpand\@@magyar@fixdate{\number#6}{\csname @@magyar@mon@#1#2#3\endcsname}{\number#5}}\fi
      }%
  \fi\fi\fi
}

\def\@@magyar@parsedate@f#1/#2/#3:#4!#5\hfuzz{% LaTeX default \today: YYYY/MM/DD:XX:YY
  \ifx\hfuzz#5\hfuzz\else \ifnum1<1\string#1\relax \ifnum1<1\string#2\relax \ifnum1<1\string#3\relax
  \def\reserved@a{\@@magyar@fixdate{#1}{#2}{#3}}%
  \fi\fi\fi\fi
}

\def\@@magyar@stripdot@lowa#1.\relax{#1\relax}%
\def\@@magyar@stripdot@lowb#1\relax#2\relax{#1}%
%** by pts@fazekas.hu at Sun Jul 27 15:17:57 CEST 2003
%** Expands to #1, with a single optional dot (token `.') at the end removed.
%** @param #1 a token list not containing `\relax' (sic)
\def\@@magyar@stripdot#1{\expandafter\@@magyar@stripdot@lowb\@@magyar@stripdot@lowa#1\relax.\relax}%

%** Definies \reserved@a to {{YYYY}{MM}{DD}} (possibly fewer digits). Parsing
%** is not perfect, but can distinguish between the known formats
%** @param #1 a date in any format, will be expanded
\def\@@magyar@parsedate#1{%
  %\let\@@protect\protect \let\protect\@gobble \afterassignment\restore@protect
  \begingroup
    \def\today{\the\year-\the\month-\the\day}% ISO format
    \let\protect\string
    \let\'\@firstofone% Dat: (j\'unius, janu\'ar, okt\'ober) date won't contain other accents -- I hope
    \let~\space
    % ^^^ change `2003.~okt\'ober 25.' to `2003. oktober 25.'
    \edef\reserved@b{\def\noexpand\reserved@b{#1}}%
  \expandafter\endgroup\reserved@b
  \edef\reserved@b{\expandafter\@@magyar@stripdot\expandafter{\reserved@b}}%
  %%\show\reserved@b\tracingmacros1
  % vvv Wizardry: deep, parsing dates
  \let\reserved@a\@empty \expandafter\@@magyar@parsedate@a\reserved@b!--!\hfuzz
  \ifx\reserved@a\@empty \expandafter\@@magyar@parsedate@f\reserved@b!//:!\hfuzz \fi
  \ifx\reserved@a\@empty \expandafter\@@magyar@parsedate@b\reserved@b!//!\hfuzz \fi
  \ifx\reserved@a\@empty \expandafter\@@magyar@parsedate@c\reserved@b!..!\hfuzz \fi
  \ifx\reserved@a\@empty \expandafter\@@magyar@parsedate@d\reserved@b!. xyz !\hfuzz \fi
  \ifx\reserved@a\@empty \expandafter\@@magyar@parsedate@e\reserved@b!xyz , !\hfuzz \fi
  %%\show\reserved@a
  \ifx\reserved@a\@empty
    \@@magyar@error{Unrecognised date: \reserved@b}%
    %\@@magyar@fixdate{0}{1}{1}}%
    \def\reserved@a{{0}{1}{1} {\noexpand\reset@font\noexpand\bfseries \string?date\string?}}%
  \else
    \reserved@a% calls \@@magyar@fixdate, which sets \reserved@a
  \fi
  %%\show\reserved@a
}%
%** Definies \reserved@a to {{YYYY}{MM}{DD}} (possibly fewer digits)
%** @param #1 year (50..99 += 1900, 0..49 += 2000)
%** @param #2 month (1..12)
%** @param #3 day of month (1..31), validity of 29..31 not verified
\def\@@magyar@fixdate#1#2#3{%
  \edef\reserved@a{\number#1}%
  \ifnum\reserved@a<0   \def\reserved@a{0}\@@magyar@error{Year too small: #1}\else
  \ifnum\reserved@a<10  \edef\reserved@a{200\reserved@a}\else
  \ifnum\reserved@a<50  \edef\reserved@a{20\reserved@a}\else
  \ifnum\reserved@a<100 \edef\reserved@a{19\reserved@a}\else
  \ifnum\reserved@a<10000 \else
                        \def\reserved@a{0}\@@magyar@error{Year too large: #1}%
  \fi\fi\fi\fi\fi
  \ifnum#2<1  \@@magyar@error{Month too small: #2}\fi% Imp: reset to 0?
  \ifnum#2>12 \@@magyar@error{Month too large: #2}\fi
  \ifnum#3<1  \@@magyar@error{Day of month too small: #3}\fi% Imp: reset to 0?
  \ifnum#3>31 \@@magyar@error{Day of month too large: #3}\fi
  \edef\reserved@a{{\reserved@a}{\number#2}{\number#3}}%
}

%** Usage: \magyar@emitdate{FMT}{DATE} or \magyar@emitdate[SUFFIX]{FMT}{DATE}
%** @example [\emitdate{b}{October 25, 2003}]
%** @example %[\emitdate{b}{x-y-z}]% ! Package magyar.ldf Error: Unrecognised date: x-y-z.
%** @example A mai dátum: [\emitdate{b}{\today}].
%** @example [\emitdate[e]{g}{1848.15.3}] a nap, mikor elhangzott a Nemzeti dal.
%** @example [\emitdate{b}{1956-10-23}]
%** @example \told{\@@magyar@date@g{1848}{3}{115}}+a{} 
%** @param SUFFIX any suffix for \told, e.g `e' or `adik+an'
%** @param DATE date in any format, will be expanded
%** @param FMT a single letter, specifies the format of the emitted date
%**   a: 1848-03-15 (ISO dátumformátum, 2002-től(?) a magyar helyesírás része)
%**   b: 1848.\ március 15.
%**   c: 1848.\ márc.\ 15.
%**   d: 1848.\ III.\ 15.
%**   e: 1848.\ 03.\ 15.
%**   f: 1848. március közepe
%**   g: 1848. március 15[-e reggele]
%**   h: 1848 március [hónapjának közepe, márciusának közepe, márciusában stb.] birtokos rag
%** english.ldf: `October 25, 2003' or [UK]: `25th October 2003'
\def\@@magyar@emitdate{%
  \@ifnextchar[\@@magyar@emitdate@opt{\@@magyar@emitdate@opt[]}%]
}
\def\@@magyar@emitdate@opt[#1]#2#3{%
  \begingroup
    \@@magyar@parsedate{#3}%
    % Imp: error message if \@@magyar@told is undefined
    %\show\reserved@a
    \edef\reserved@a{%
      \ifx\vfuzz#1\vfuzz            \expandafter\noexpand\csname @@magyar@date@#2\endcsname\reserved@a
      \else \noexpand\@@magyar@told{\expandafter\noexpand\csname @@magyar@date@#2\endcsname\reserved@a}+#1{}\fi
    }%
    %\show\reserved@a
    %%\show~
    %\show\reserved@a% \told {\@@magyar@date@g {1848}{3}{15}}+e{}
    \reserved@a
  \endgroup
}

\ifnum\magyar@opt@@emitdate \expandafter\ifx\csname emitdate\endcsname\relax1\fi>1 % 21, 2, 11, 1
  \let\emitdate\@@magyar@emitdate
\fi
\@gobble
{^}%

% --- titleskip=

\ifx\magyar@opt@@titleskip\magyar@@unchanged
  \def\magyar@opt@@titleskip{\enspace}%  for the appendix with appendixdot=no
\@@magyar@skiplong\fi
  \expandafter\addto\csname extras\CurrentOption\endcsname{\magyar@@seccntfix}%
  \let\magyar@@seccntfix\@empty
  \let\magyar@@default@seccntformat\@seccntformat
  \AtBeginDocument{%
    % vvv \ifx added for compatiblity with other packages redefining \@seccntformat _after_ magyar.ldf has been loaded
    \ifx\@seccntformat\magyar@@default@seccntformat
      % \@seccntformat affects dot after the section number in the main text.
      % We don't change the TOC file, because we've changed \numberline. Also
      % \ps@headings in book.cls already contains a dot.
      \def\magyar@@seccntfix{%
        \ifx\@seccntformat\@gobble\else
          \babel@save\@seccntformat
          \def\@seccntformat##1{\csname the##1\endcsname.\magyar@opt@@titleskip}%
        \fi
      }
    \fi
  }
  \@gobble
{^}%

% --- footnote=

\if0\magyar@opt@@footnote \@@magyar@skiplong\fi
  %** Overrides latex.ltx. Expand old contents of \cl@#2 only once.
  \def\@addtoreset#1#2{%
    \begingroup
      \edef\reserved@a{\noexpand\@elt{#1}}%
      \expandafter\magyar@fo@consra\csname cl@#2\endcsname\gdef
    \endgroup
  }
  %** Similar to \@cons in latex.ltx
  %** Appends first-level expansion of \reserved@a
  %** @param #1 a \cs
  %** @param #2 \def or \gdef
  \def\magyar@fo@consra{\expandafter\magyar@fo@cons\expandafter{\reserved@a}}%
  %** @param #1 tokens to append
  %** @param #2 a \cs
  %** @param #3 \def or \gdef
  \def\magyar@fo@cons#1#2#3{\expandafter#3\expandafter#2\expandafter{#2#1}}%

  % vvv Dat: \@definecounter can be called twice, \newcounter cannot
  \@definecounter{footnote@add}% \newcounter{footnote@add}
  %** Number of times footnote numbering has been reset
  \@definecounter{footnote@ch}

  \def\magyar@fo@pickzero#1#2#3\hfuzz#4{%
    \ifx\relax#1\else \def#4{{#1}{#2}}\fi% pick {#1}{#2}
  }
  %** Dat: footnotes inside \begin{minipage} are not affected -- intentionally.
  %** Will be called by \stepcounter{...} after `\advance\c@footnote1'
  \def\magyar@fo@resetzero@afterpage{%
    {% { is better \begingroup, because { works in a tabular
    \@tempcnta\c@footnote@add
    \advance\@tempcnta\c@footnote
    \let\reserved@a\@empty% default
    % Dat: we ignore \@roman etc. in \thefootnote
    \expandafter\expandafter\expandafter\magyar@fo@pickzero\csname r@footnote&\the\c@footnote@ch&\the\@tempcnta\endcsname00\hfuzz\reserved@a% this footnote
    \ifx\reserved@a\@empty \G@refundefinedtrue\fi
    %
    \def\magyar@fo@@prevfn{-}% default
    \advance\@tempcnta\m@ne
    \expandafter\expandafter\expandafter\magyar@fo@pickzero\csname r@footnote&\the\c@footnote@ch&\the\@tempcnta\endcsname00\hfuzz\magyar@fo@@prevfn% previous footnote
    \advance\@tempcnta\@ne
    %
    \ifx\reserved@a\magyar@fo@@prevfn\else
      % Restart footnote numbering (from 1) if \label is missing for previous
      % footnote, or \label reports that prev and this footnotes aren't on the
      % same page.
      \global\advance\c@footnote@add\c@footnote
      \global\advance\c@footnote@add\m@ne
      \global\c@footnote\@ne
    \fi
    \def\@currentlabel{\noexpand\number\c@page}%
    % ^^^ Dat: \noexpand is here to make \number\c@page expanded during \shipout
    \ifx\@listdepth\@mplistdepth% inside \begin{minipage}
      % vvv Dat: expand \thepage both early (minipage) and late (real page)
      \edef\@currentlabel{\@currentlabel-\thepage}%
    \fi
    \edef\reserved@a{\noexpand\label{footnote&\the\c@footnote@ch&\the\@tempcnta}}%
    % ^^^ Dat: the \label command above produces correct warning (LaTeX
    %     Warning: Label(s) may have changed. Rerun to get cross-references
    %     right.), and it also produces `LaTeX Warning: There were undefined
    %     references.' in case a footnote is removed or changed, and also for
    %     the very first run. Fine.
    \reserved@a
    }%\endgroup
  }  

  \let\magyar@fo@resetzero\relax

  %\magyar@fo@cons{XY}\cl@footnote\gdef
  \magyar@fo@cons{\magyar@fo@resetzero}\cl@footnote\gdef

  %\def\magyar@fo@resetadd{%
  %  \global\advance\c@footnote\c@footnote@add
  %  \global\c@footnote@add\z@
  %}
  \def\magyar@fo@aftergrouprelax#1{%
    \ifx#1\relax\else
      \aftergroup#1%
      \expandafter\magyar@fo@aftergrouprelax
    \fi
  }

  \def\magyar@fo@mtostar#1{%
    \if#1m%
      *\expandafter\magyar@fo@mtostar
    \fi
  }
  %** Producing `m's based on the idea of David Kastrup.
  %** The default `*' character is in raised position, and we also move it to
  %** \@textsuperscript, so it will be double raised. But never mind.
  \def\magyar@fo@thefootnote@stars{\expandafter\magyar@fo@mtostar\romannumeral\number\c@footnote000A}%
  \def\magyar@fo@thefootnote@starsspmax{\ifcase\c@footnote\or*\or**\or***\or\dag\or\dag\dag\or\dag\dag\dag\else*\the\c@footnote\fi}%
  \def\magyar@fo@thefootnote@arabic{\@arabic\c@footnote}
  \def\magyar@fo@thempfootnote@stars{\expandafter\magyar@fo@mtostar\romannumeral\number\c@mpfootnote000 A}%
  \def\magyar@fo@thempfootnote@starsspmax{\ifcase\c@mpfootnote\or*\or**\or***\or\dag\or\dag\dag\or\dag\dag\dag\else*\the\c@mpfootnote\fi}%
  \def\magyar@fo@thempfootnote@arabic{\@arabic\c@mpfootnote}

  % !! indent=article must work within \maketitle for article.cls etc.

  %** Copied from article.cls, added \,.
  %** Has #1, but partially applied here
  \def\magyar@fo@indent@articlesp{%
    \parindent1em % SUXX: impossible to acquire default value
    % Dat: don't use \@makefnmark here, because it puts the footnote mark
    %      only to the main text
    \noindent\hb@xt@1.8em{\hss\@textsuperscript{\normalfont\@thefnmark\,}}%
  }
  %** Same as \@makefntext in article.cls
  %** Has #1, but partially applied here
  \def\magyar@fo@indent@articlenosp{%
    \parindent1em % SUXX: impossible to acquire default value
    % Dat: don't use \@makefnmark here, because it puts the footnote mark
    %      only to the main text
    \noindent\hb@xt@1.8em{\hss\@textsuperscript{\normalfont\@thefnmark}}%
  }
  \def\magyar@@fo@indent@dimensetup{%
    \parindent1em % SUXX: impossible to acquire default value
    %\advance\leftskip1.8em % SUXX: impossible to acquire default value
    \leftskip\leftmargini % SUXX: impossible to acquire default value
  }
  %** Has #1, but partially applied here
  \def\magyar@fo@indent@hulist{%
    % Dat: superscript is emitted by \@makefnmark
    % Dat: \parindent doesn't apply for the 1st par of the footnote
    \magyar@@fo@indent@dimensetup
    \ifvmode\noindent\hb@xt@\z@\else\hbox\fi
    % ^^^ \usepackage[para]{footmisc} emits footnotes in horizontal mode
      {\hss\@textsuperscript{\normalfont\@thefnmark\,}}%
  }

  %** Limit the size of the footnote mark (in main text) to \normalsize.
  %** Overrides latex.ltx
  \def\magyar@fo@makefnmark{%
    \hbox{% has \begingroup
      \edef\reserved@a{\f@size}%
      {\normalsize\edef\reserved@b{\def\noexpand\reserved@b{\f@size}}\expandafter}\reserved@b
      \ifdim\reserved@a pt>\reserved@b pt
           %\normalsize\@textsuperscript{\normalfont\footnotesize\@thefnmark}% Dat: would place index too low
           \@textsuperscript{\normalfont\scriptsize\@thefnmark}%
      \else\@textsuperscript{\normalfont\@thefnmark}\fi
    }%
  }
  \let\magyar@fo@@cont@number\@empty
  \def\magyar@fo@savecont{\global\edef\magyar@fo@@cont@number{\global\c@footnote\the\c@footnote\space}}

  %** \footnoterule, as defined in latex.ltx
  \def\magyar@fo@defaultrule{\kern-3\p@
    \hrule \@width 2in \kern 2.6\p@} % the \hrule is .4pt high
  \def\magyar@fo@fourthrule{\kern-3\p@%\hrule\hrule\hrule
    \hrule \@width .25\textwidth \kern 2.6\p@} % the \hrule is .4pt high
  \def\magyar@fo@onelinerule{%
    \unskip% undo \vskip\skip\footins
    {\normalsize% Dat: \normalfont is superfluous
      \vskip1\baselineskip plus.1\baselineskip minus .1\baselineskip}%
    % ^^^ Dat: plus,minus is necessary to avoid `Overfull \vbox (8.86676pt too high)'
  }
  \def\magyar@fo@chooserule{\relax
    \ifx \@listdepth\@mplistdepth \mpfootnoterule \else
      \ifnum\split@prev=\z@ \pagefootnoterule \else \splitfootnoterule
      \fi
      %%\typeout{\string\split@prev=\split@prev}%
      \xdef\split@prev{\the\insertpenalties}%
    \fi
  }

  % `Szerkesztők és szerzők kézikönyve, p. 116' says this about Hungarian
  % footnotes. Implementation notes are marked with [...]. See better docs
  % in magyarldf-doc.tex
  %
  % (1) Use numbering and/or stars (in upper index) for footnote marks.
  %     Numbering is recommended.
  % [1] Use \footnotestyle{mark=...}
  % (2) You can put footnotes by the editor with a star, and footnotes by the
  %     author with numbers.
  % [2] Use \footnotestyle{huplain} in the preamble, and emit each editorial
  %     footnote with {\footnotestyle{editor}\footnote{Her note.}}
  % (3) Don't put \footnoterule if the footnote starts on current page.
  % [3] Use \footnotestyle{rule=none}. Please make sure that the group lasts
  %     till \shipout.
  % (4) Put a \footnoterule (1/3\textwidth or 1/4\textwidth) if footnote is
  %     continued from previous page.
  % [4] Not supported. Imp: how to?      
  % (5) Multiple short footnotes may be put into a single line.
  % [5] \usepackage[para]{footmisc} or \usepackage{fnpara}
  % (6) Footnotes for \begin{figure} and \begin{table} must be put just under
  %     them, not at EOP.
  % [6] The author should enclose the matrial in a \begin{minipage}
  % (7) The size of the \footnotemark should not be scaled up.
  % [7] Use \footnotestyle{marksize=max-normal}
  % (8) It is possible to use either \parindent or \item when starting a
  %     footnote.
  % [8] Use \footnotestyle{indent=hulist} 
  % (9) The footnotemark must be followed by a thin space (only at BOP).
  % [9] OK, see \@makefntext
  % (10) Don't emit too much stars. Recommended: * ** *** + ++ +++
  % [10] OK, see \footnoterule{mark=stars-max}. `\dag' is emitted instead
  %      of `+', and `*7' is emitted for the 7th footnote on the page.
  %

  \@namedef{fos@reset=none}{\let\magyar@fo@resetzero\relax}%
  %** Similar to \@addtoreset{footnote}{section}, but isn't \global.
  \@namedef{fos@reset=section}{%
    \let\magyar@fo@resetzero\relax
    \magyar@fo@cons{\@elt{footnote}}\cl@section\def
    \magyar@fo@cons{\@elt{footnote}}\cl@chapter\def
  }%
  \@namedef{fos@reset=chapter}{%
    \let\magyar@fo@resetzero\relax
    \magyar@fo@cons{\@elt{footnote}}\cl@chapter\def
  }%
  %** Next footnote-mark will be `*'. The slots of `*'s of \fos@huplain
  %** were skipped when changing back to \fos@plain. Restarts numbering from
  %** 1 (`*'). Usually called as \footnotestyle{resume,reset=page-cont}
  \@namedef{fos@reset=page}{%
    \stepcounter{footnote@ch}%
    \global\c@footnote@add\z@%
    \global\c@footnote\z@%
    \let\magyar@fo@resetzero\magyar@fo@resetzero@afterpage
    %\aftergroup\magyar@fo@resetadd% switched off deliberately
  }
  %** editorial footnote on the same page
  \@namedef{fos@reset=page-cont}{%
    \aftergroup\magyar@fo@savecont
    \fos@resume% only \aftergroup
    \magyar@fo@@cont@number
    \let\magyar@fo@resetzero\magyar@fo@resetzero@afterpage
  }
  \@namedef{fos@reset=page-resume}{%
    \fos@resume \csname fos@reset=page\endcsname
  }
  %** Resume to the previous footnote number at the end of the group. (Default: don't resume)	       
  %** \footnotestyle{resume,reset=page} is the correct order
  \def\fos@resume{%
    \aftergroup\global
    \aftergroup\c@footnote
    \expandafter\magyar@fo@aftergrouprelax\the\c@footnote\relax
    \aftergroup\space
    %\magyar@fo@resetadd% Dat: not needed because \magyar@fo@resetzero@afterpage won't find prev. ref
  }
  %
  \@namedef{fos@indent=article-sp}{\let\@makefntext\magyar@fo@indent@articlesp}%
  \@namedef{fos@indent=article-nosp}{\let\@makefntext\magyar@fo@indent@articlenosp}%
  \@namedef{fos@indent=hulist}{\let\@makefntext\magyar@fo@indent@hulist}%
  %** This is not a 100% solution, because there might be multiple iterations
  %** of \footnoterule with different \split@prev values.
  \@namedef{fos@rule=choose}{% ripped from footmisc.sty
    \ifx\footnoterule\magyar@fo@chooserule
      \let\footnoterule\magyar@fo@defaultrule
    \fi
    \expandafter\ifx\csname  pagefootnoterule\endcsname\relax \let \pagefootnoterule\footnoterule\fi
    \expandafter\ifx\csname    mpfootnoterule\endcsname\relax \let   \mpfootnoterule\footnoterule\fi
    \expandafter\ifx\csname splitfootnoterule\endcsname\relax \let\splitfootnoterule\magyar@fo@fourthrule\fi
    \expandafter\ifx\csname split@prev\endcsname\relax \gdef\split@prev{0}\fi
    % ^^^ Dat: \split@prev is named the same in footmisc.sty
    \let\footnoterule\magyar@fo@chooserule
  }
  \@namedef{fos@rule=none}{\let\footnoterule\@empty}%
  \@namedef{fos@rule=fourth}{\let\footnoterule\magyar@fo@fourthrule}%
  \@namedef{fos@rule=one-line}{\let\footnoterule\magyar@fo@onelinerule}%
  \@namedef{fos@marksize=max-normal}{\let\@makefnmark\magyar@fo@makefnmark}%
  \@namedef{fos@mark=arabic}{\let\thefootnote\magyar@fo@thefootnote@arabic}%
  \@namedef{fos@mark=stars}{\let\thefootnote\magyar@fo@thefootnote@stars}%
  \@namedef{fos@mark=stars-max}{\let\thefootnote\magyar@fo@thefootnote@starsspmax}%
  \@namedef{fos@mpmark=arabic}{\let\thempfootnote\magyar@fo@thempfootnote@arabic}%
  \@namedef{fos@mpmark=stars}{\let\thempfootnote\magyar@fo@thempfootnote@stars}%
  \@namedef{fos@mpmark=stars-max}{\let\thempfootnote\magyar@fo@thempfootnote@starsspmax}%
  %\def\fos@globalmark{\expandafter\global\expandafter\let\csname the\@mpfn\endcsname\endcsname\thefootnote}
  %\def\fos@globalmpmark{\global\let\thempfootnote\thefootnote}

  \def\fos@plain{\csname fos@reset=none\endcsname\csname fos@mark=arabic\endcsname}
  \def\fos@huplain  {\csname fos@marksize=max-normal\endcsname \csname fos@reset=none\endcsname\csname fos@mark=arabic\endcsname\csname fos@rule=none\endcsname\csname fos@indent=hulist\endcsname}
  \def\fos@starplain{\fos@huplain\csname fos@reset=page\endcsname\csname fos@mark=stars-max\endcsname}%
  %\def\fos@editor{\fos@resume\fos@starplain}%
  \def\fos@editor{\fos@huplain\csname fos@reset=page-cont\endcsname\csname fos@mark=stars-max\endcsname}%
  
  \def\footnotestyle#1{%
    \@for\reserved@a:=#1\do{%
      \@ifundefined{fos@\reserved@a}{\@latex@error{Undefined footnote style: \reserved@a}\@ehc}%
      {\csname fos@\reserved@a\endcsname}%
    }%
  }

  \def\editorfootnote#1{\begingroup\footnotestyle{editor}%
    \footnote{#1}\endgroup}%
  \def\headingfootnote{%
    \ifx\protect\@typeset@protect\expandafter\footnote
    \else\expandafter\@gobble\fi
    % ^^^ Dat: this test is better, because it makes magyar.ldf compatible
    %     with nath.sty that says \def\protect{\noexpand} in its redefinition
    %     of \addtocontents
    %\ifx\protect\@unexpandable@protect\expandafter\@gobble
    %\else\expandafter\footnote\fi
  }

  %** @param #1 an end-csname, example: \endfigure
  \def\magyar@fo@mp@setup#1{%
    \let\@footnotetext\@mpfootnotetext
    \def\@mpfn{mpfootnote}\def\thempfn{\thempfootnote}\c@mpfootnote\z@
    % ^^^ This line is optional, but strongly recommended. Restart numbering
    %     for each float, and number with \thempfootnote.
    % vvv Very tricky use of `#' in expansion.
    % Dat: \magyar@fo@mp@show is idempotent
    % vvv Prepend \magyar@fo@mp@show to the definition of \@makecaption
    \expandafter\def\expandafter\@makecaption\expandafter##\expandafter1%
      \expandafter##\expandafter2\expandafter{\expandafter\magyar@fo@mp@show%
      \@makecaption{##1}{##2}%
    }%
    %%\show\@currenvir
    % vvv Dat: this prepending has only local effect.
    \expandafter\def\expandafter#1\expandafter{%
      \expandafter\magyar@fo@mp@show#1}%
    %\expandafter\magyar@fo@mp@prepend\csname\@currenvir\endcsname
    \setbox\@mpfootins\box\voidb@x
  }
  \def\magyar@fo@mp@show{% ripped from latex.ltx (\endminipage)
    \ifvoid\@mpfootins\else
      \par\unskip \vskip\skip\@mpfootins
      \normalcolor \footnoterule
      \expandafter\ifx\csname mpmakefootnoteparagraph\endcsname\relax
        \unvbox\@mpfootins
      \else% fnpara.sty
        \mpmakefootnoteparagraph
      \fi
    \fi
  }

  %** Only works if \cs of #1 doesn't have macro arguments. It works for
  %** \figure and \table, because their optional argument `[b]' etc. is not
  %** a macro argument.
  %** @example \makeFootnotable{figure}
  %** @example \makeFootnotable{} -- current instance of current environment
  \def\makeFootnotable#1{%
    \if\relax#1\relax
      \expandafter\magyar@fo@mp@setup\csname end\@currenvir\endcsname
    \else
      \expandafter\expandafter\expandafter\magyar@fo@makef@low
      \expandafter\expandafter\csname #1\endcsname
      \csname end#1\endcsname
    \fi
  }
  %** @example \magyar@fo@makef@low\table\endtable
  \def\magyar@fo@makef@low#1#2{\expandafter\def\expandafter#1\expandafter{%
    \expandafter\magyar@fo@mp@setup\expandafter#2#1}}%

  \if2\magyar@opt@@footnote \fos@huplain\fi
  \if3\magyar@opt@@footnote \fos@starplain\fi
  \@gobble
{^}

% --- mathbrk=

\if0\magyar@opt@@mathbrk \@@magyar@skiplong\fi
  %** Similar to \@@magyar@fixmathcmd@low, but inserts symbol immediately.
  %** @param #1 `\mathchar', all catcodes
  %** @param #2 hex code
  %** @param #3 ignored
  %** @param #4 a \cs
  \def\@@magyar@breakmathcmd@low#1"#2"#3\hfuzz#4{%
    \def\reserved@a{#1}%
    \edef\reserved@b{\string\mathchar}%
    \ifx\reserved@a\reserved@b
      \mathchar"#2
      \ifnum"#2<"8000 % redundant sanity check, trueness implied by #1==\mathchar
	\nobreak\discretionary{}{\hbox{\(\mathchar"#2 \)}}{}%
      \fi
    \fi
  }%
  %** Dat: robustness is tested and works with nath.sty
  %** @param #1 a \cs or char of a MathBin or MathRel, e.g `\prec' or `+'
  \DeclareRobustCommand\MathBrkAll[1]{%
    \ifcat\noexpand#1\relax
      \expandafter\@@magyar@breakmathcmd@low\meaning#1""\hfuzz#1%
    \else
      \ifnum\mathcode`#1="8000
        \expandafter\expandafter\expandafter#1% keep original meaning
      \else
	\mathchar\the\mathcode`#1\relax% disable \active meaning
	\ifnum\mathcode`#1<"8000 % redundant sanity check
	  \nobreak\discretionary{}{\hbox{\(\mathchar\the\mathcode`#1\relax\)}}{}%
	\fi
      \fi
    \fi
  }
  \let\MathBrk\relax
  \expandafter\addto\csname extras\CurrentOption\endcsname{%
    \babel@save\MathBrk
    \let\MathBrk\MathBrkAll
  }
  \@gobble
{^}

\if2\magyar@opt@@mathbrk\else \@@magyar@skiplong\fi  % mathbrk=fix
  \def\@@magyar@resetmathchars{%
    \mathcode`+"202B \catcode`+12
    \mathcode`-"2200 \catcode`-12
    \mathcode`*"2203 \catcode`*12
    \mathcode`/"013D \catcode`/12
    \mathcode`>"313E \catcode`>12
    \mathcode`<"313C \catcode`<12
    \mathcode`="303D \catcode`=12
    % vvv Dat: leave these chars intact, for compatibility (with nath.sty and others)
    %\mathcode`:"303A \catcode`:12
    %\mathcode`;"603B \catcode`;12
    %\mathcode`,"613B \catcode`,12
    %\mathcode`!"5021 \catcode`!12
    %\mathcode`?"503F \catcode`?12
    %\mathcode`|"026A \catcode`|12
    %\mathcode`."013A \catcode`.12
  }
  %** Dat: don't do `/', because slash is unbreakable
  \def\@@magyar@domathbins{%
    \do-\@@magyar@fix@newmcodes@dash
    \do+\do*\do>\do<\do=\do:}%
  %** @param #1 a char token with \mathcode != "8000, like +
  \def\@@magyar@fixmathbinchar#1{%
    \ifnum\mathcode`#1="8000 \else
      % Dat: \(...\) is safer than `$...$', because \( has a fixed \catcode
      %      that works with and w/o nath.sty
      \begingroup\lccode\string`~\string`#1\lowercase{\endgroup\edef~}{%
	\mathchar\the\mathcode`#1\relax% Dat: would need \space\space
        \noexpand\ifx\noexpand\MathBrk\noexpand\MathBrkAll% Hungarian language is active
          \nobreak\discretionary{}{\hbox{\noexpand\(\mathchar\the\mathcode`#1 \noexpand\)}}{}%
        \noexpand\fi}%
      \mathcode`#1"8000
    \fi
    \catcode`#112
  }
  %** \newmcodes@ defined in amsopn.sty doesn't work (triggered by 
  %** \DeclareMathOperator{\tg}{tg} $\tg$) because it wants to assign
  %** \mathchardef\std@minus\mathcode`\-, which is "8000, which is a bad
  %** matchar. We fix that by prepending \mathcode`-45 to \newmcodes@ .
  %** This is OK, because \newmcodes@ is protected by a block set up by
  %** \qopname.
  \def\@@magyar@newmcodes@fixed{\mathcode`-"45 \magyar@@newmcodes}%
  \def\@@magyar@fix@newmcodes@dash{%
    \ifx\newmcodes@\@undefined\else
      \ifx\newmcodes@\@@magyar@newmcodes@fixed\else  % Protect against double redefinition such as in \begin{align*}\tg\end{align*}
        \let\magyar@@newmcodes\newmcodes@
        \let\newmcodes@\@@magyar@newmcodes@fixed
      \fi
    \fi
  }%

  %** @param #1 `\mathchar', all catcodes
  %** @param #2 hex code
  %** @param #3 ignored
  %** @param #4 a \cs
  \def\@@magyar@fixmathcmd@low#1"#2"#3\hfuzz#4{%
    % Imp: check \cong and \notin with txfonts and pxfonts. Do they look OK?
    \def\reserved@a{#1}%
    \edef\reserved@b{\string\mathchar}%
    \ifx\reserved@a\reserved@b
      \ifnum"#2<"8000 % redundant sanity check, trueness implied by #1==\mathchar
        % Make #4 robust.
	\edef#4{\noexpand\protect\expandafter\noexpand\csname
          \expandafter\@gobble\string#4 \endcsname}%
	% vvv Imp: \def would be better than \edef?
	\expandafter\edef\csname\expandafter\@gobble\string#4 \endcsname{%
	  % Dat: \mathchar already produces: `! Missing $ inserted.'
	  \mathchar"#2
          \noexpand\ifx\noexpand\MathBrk\noexpand\MathBrkAll% Hungarian language is active
            \nobreak\discretionary{}{\hbox{\noexpand\(\mathchar"#2 \noexpand\)}}{}%
          \noexpand\fi
	}%
      \fi
    \fi
  }%
  %** Works even if #1 is undefined (but consumes hash memory)
  %** @param #1 a \cs of a MathBin or MathRel, e.g \prec
  \def\@@magyar@fixmathcmd#1{%
    \expandafter\@@magyar@fixmathcmd@low\meaning#1""\hfuzz#1%
  }

  \let\@@magyar@domathbins@prefix\@empty
  \def\@@magyar@fixeverymathcmds@appendto#1{%
    \expandafter\def\expandafter#1\expandafter{#1% append
      \@@magyar@resetmathchars
      \let\do\@@magyar@fixmathbinchar
      \@@magyar@domathbins@prefix\@@magyar@domathbins% only in math mode start
    }%
  }
  \def\@@magyar@fixeverymathcmds@setup{%
    \expandafter\ifx\csname mathoptions@on\endcsname\relax% no nath.sty
	 \@@magyar@fixeverymathcmds@appendto\check@mathfonts
    \else\@@magyar@fixeverymathcmds@appendto\mathoptions@on\fi
  }

  % The definition of \@tabular contains a $, which calls
  % \@@magyar@domathbins, which has some unintended side effects of changing
  % \catcode values and the meaning of the active character : . This magic
  % prevents the call to \@@magyar@domathbins .
  %
  % Test code: \author{a:b} \maketitle
  % Test code: \def\foo{a:b} \begin{tabular}[t]{c}x\foo y\end{tabular}
  \def\@@magyar@mathbins@tabularfix#1${%
    #1\def\@@magyar@domathbins@prefix{%
      \let\@@magyar@domathbins@prefix\@empty\@gobble}$}%
  \expandafter\expandafter\expandafter\def
  \expandafter\expandafter\expandafter\@tabular
  \expandafter\expandafter\expandafter{%
    \expandafter\@@magyar@mathbins@tabularfix\@tabular}

  \def\@@magyar@fixmathcmds{%
    \let\do\@@magyar@fixmathcmd
    % vvv Binary relations listed in Table 3.4 in lshort.dvi
    \do\leq\do\le\do\ll\do\prec\do\preceq\do\subset\do\subseteq\do\sqsubset
    \do\sqsubseteq\do\in\do\vdash\do\mid\do\smile\do\geq\do\ge\do\gg\do\succ
    \do\succeq\do\supset\do\supseteq\do\sqsupset\do\sqsupseteq\do\ni\do\owns
    \do\dashv\do\parallel\do\frown\do\notin\do\equiv\do\doteq\do\sim\do\simeq
    \do\approx\do\cong\do\Join\do\bowtie\do\propto\do\models\do\perp\do\asymp
    \do\neq\do\ne
    % vvv Binary operators listed in Table 3.5 in lshort.dvi
    %\do\cdot% unbreakable
    \do\pm\do\times\do\cup\do\sqcup\do\vee\do\lor\do\oplus\do\odot\do\otimes
    \do\bigtriangleup\do\lhd\do\unlhd\do\mp\do\div\do\setminus\do\cap\do\sqcap
    \do\wedge\do\land\do\ominus\do\oslash\do\bigcirc\do\bigtriangledown\do\rhd
    \do\unrhd\do\triangleleft\do\triangleright\do\star\do\ast\do\circ\do\bullet
    \do\diamond\do\uplus\do\amalg\do\dagger\do\ddagger\do\wr
    \edef\cdot{\noexpand\protect\csname cdot \endcsname}%
    \expandafter\def\csname cdot \endcsname{\nobreak\mathchar"2201\nobreak}%
    \def\slash{\nobreak/\nobreak}% only in math-mode start, \nobreak
    % ^^^ Dat: \slash is fragile in latex.ltx
  }
  \AtBeginDocument{\@@magyar@fixmathcmds\@@magyar@fixeverymathcmds@setup}
  \@gobble
{^}

% --- mathfactorial=

\if0\magyar@opt@@mathfactorial \@@magyar@skiplong\fi
  % Imp: weak define? It doesn't conflict with nath.sty -- yet.
  \def\factorial{\mathchar"5021\mathopen{}\mathinner{}}
  \@gobble
{^}

\if2\magyar@opt@@mathfactorial\else \@@magyar@skiplong\fi
  \expandafter\addto\csname \expandafter\ifx\csname mathoptions@on\endcsname
   \relax check@mathfonts\else mathoptions@on\fi\endcsname{% detect nath.sty
    \catcode`!12 \mathcode`!"8000
    \begingroup\lccode`~`!\lowercase{\endgroup\def~}{\factorial}%
  }
  \@gobble
{^}

% --- mathhucomma=

\if0\magyar@opt@@mathhucomma \@@magyar@skiplong\fi
  %** Dat: works for all catcodes, even for `end group character 5'
  %** Inspired by Donald Aresenau
  %** @param #1 the
  %** @param #2 character
  %** @example The sample in your article would be typed 
  %**   \[  F_{i}(x,y) = y^i + 1,3x \qquad x,y \in A,\ i = 1, 2, 3,\ldots \]
  \edef\@@magyar@hucomma@lowa#1#2 #3#4 #5#6\hfuzz{%
    \noexpand\ifnum9<1#5 \noexpand\if#1t\noexpand\if#3c%
    \noexpand\mathord\noexpand\fi\noexpand\fi\noexpand\fi\mathchar
    \ifnum\mathcode`,="8000 "613B \else\the\mathcode`, \space\fi% immed expand
    % Dat: "613B is the punctuation, "013B is ordinary
  }%
  %%\show\@@magyar@hucomma@lowa
  \def\@@magyar@hucomma@lowb{\expandafter\@@magyar@hucomma@lowa\meaning\reserved@a/ / /\hfuzz}%
  %** Put a \mathord, if it is followed by a digit; otherwise put a normal,
  \DeclareRobustCommand\HuComma{\futurelet\reserved@a\@@magyar@hucomma@lowb}
  \@gobble
{^}

\if2\magyar@opt@@mathhucomma\else \@@magyar@skiplong\fi
  % !! into \extrasmagyar
  \expandafter\addto\csname \expandafter\ifx\csname mathoptions@on\endcsname
   \relax check@mathfonts\else mathoptions@on\fi\endcsname{% detect nath.sty
    \catcode`,12 \mathcode`,"8000
    \begingroup\lccode`~`,\lowercase{\endgroup\def~}{\HuComma}%
  }
  \@gobble
{^}

% --- mathmuskips=

% 
\if1\magyar@opt@@mathmuskips% =latex, as defined in latex.ltx
  \thickmuskip 5mu plus 5mu
  \medmuskip   4mu plus 2mu minus 4mu
  \thinmuskip  3mu
\fi
\if2\magyar@opt@@mathmuskips% =hu
  \thickmuskip 4mu plus 2mu minus 4mu
  \medmuskip   2mu plus 1.5mu minus 2mu % \medmuskip<\thinmuskip OK
  \thinmuskip  3mu
\fi

% --- hynumberline=
% by pts@fazekas.hu at Tue Nov 21 00:34:37 CET 2006
%
% hynumberline=hu adds a dot after the section number in the bookmarks/outline
% with \hypersetup{bookmarksnumbered=true} in hyperref.sty.

\if0\magyar@opt@@hynumberline \@@magyar@skiplong\fi
  %** Overrides original definition (\def\Hy@numberline#1{#1 }) in
  %** pdfmark.def.
  %** Also possible with:
  %** \pdfstringdefDisableCommands{\renewcommand*{\numberline}[1]{#1. }}
  \def\@@magyar@@hynumberline@old#1{#1 }% as defined in pdfmark.def
  \def\@@magyar@@hynumberline@hu #1{#1. }%
  \expandafter\addto\csname extras\CurrentOption\endcsname{%
    \ifx  \Hy@numberline\@@magyar@@hynumberline@old
      \let\Hy@numberline\@@magyar@@hynumberline@hu \fi}%
\@gobble
{^}%

% --- mathreal=

\if0\magyar@opt@@mathreal \@@magyar@skiplong\fi
  %** @param #1 a number with a possible decimal digit, e.g `12' or `-12.3'
  \def\@@magyar@mathreal@lowa#1{\ensuremath{\@@magyar@mathreal@lowb#1\@gobble.}}%
  \def\@@magyar@mathreal@lowb#1.{%
    #1%
    \@secondoftwo\@gobble% Wizardry: \@secondoftwo may be \@gobbled by token before `.'
    {\mathchar"013B \@@magyar@mathreal@lowb}%
  }
  \DeclareRobustCommand\@@magyar@mathreal{\ensuremath}%
  \expandafter\expandafter\expandafter\addto
  \expandafter\expandafter\csname extras\CurrentOption\endcsname\expandafter{%
    \expandafter\babel@save\csname @@magyar@mathreal \endcsname
    \expandafter\let\csname @@magyar@mathreal \endcsname \@@magyar@mathreal@lowa}%
  \ifnum\magyar@opt@@mathreal \expandafter\ifx\csname mathreal\endcsname\relax1\fi>1 % 21, 2, 11, 1
    \let\MathReal\@@magyar@mathreal
  \fi
\@gobble
{^}%

% --- \documentclass-specific modifications; classmod=

% Callback which redefines \ps@headings and runs it again if needed, when
% magyar.ldf has an override for the standard \ps@headings, and
% \pagestyle{headings} is active either explictly (e.g. in article.cls) or
% by default (e.g. in book.cls).
\let\@@magyar@setup@psheadings\relax

%** Localized definition which replaces \ps@headings, if appropriate.
\let\@@magyar@overridden@psheadings\@empty

\ifx\magyar@opt@@classmod\relax\@@magyar@skiplong\fi

%** Appends the first-level expansion of argless macro ##2 to ##1.
\def\magyar@letappendto#1#2{%
  \expandafter\expandafter\expandafter\def
    \expandafter\expandafter\expandafter#1%
    \expandafter\expandafter\expandafter{%
    \expandafter#1#2}}%

%** Defines #1 to the concatenation of \partmark ... \subparagraphmark,
%** \oddfoot, \evenfoot, \oddhead, \evenhead.
\def\magyar@mark@fingerprint@def#1{%
  % We have ! here because some macros (such as \partmark) have #1, which
  % gets expanded by \expandafter
  \def#1{markfp: }%
  \ifx\partmark\@undefined
    \expandafter\def\expandafter\reserved@b\expandafter{%
      \expandafter{-partmark}}%
  \else
    \expandafter\def\expandafter\reserved@b\expandafter{%
      \expandafter{\partmark!:partmark}}%
  \fi
  \magyar@letappendto#1\reserved@b
  %
  \ifx\chaptermark\@undefined
    \expandafter\def\expandafter\reserved@b\expandafter{%
      \expandafter{-chaptermark}}%
  \else
    \expandafter\def\expandafter\reserved@b\expandafter{%
      \expandafter{\chaptermark!:chaptermark}}%
  \fi
  \magyar@letappendto#1\reserved@b
  %
  \expandafter\def\expandafter\reserved@b\expandafter{%
    \expandafter{\sectionmark!:sectionmark}}%
  \magyar@letappendto#1\reserved@b
  \expandafter\def\expandafter\reserved@b\expandafter{%
    \expandafter{\subsectionmark!:subsectionmark}}%
  \magyar@letappendto#1\reserved@b
  \expandafter\def\expandafter\reserved@b\expandafter{%
    \expandafter{\paragraphmark!:paragraphmark}}%
  \magyar@letappendto#1\reserved@b
  \expandafter\def\expandafter\reserved@b\expandafter{%
    \expandafter{\subparagraphmark!}}%
  \magyar@letappendto#1\reserved@b
  \expandafter\def\expandafter\reserved@b\expandafter{%
    \expandafter{\@oddfoot!:oddfoot}}%
  \magyar@letappendto#1\reserved@b
  \expandafter\def\expandafter\reserved@b\expandafter{%
    \expandafter{\@evenfoot!:evenfoot}}%
  \magyar@letappendto#1\reserved@b
  \expandafter\def\expandafter\reserved@b\expandafter{%
    \expandafter{\@evenhead!:evenhead}}%
  \magyar@letappendto#1\reserved@b
  \expandafter\def\expandafter\reserved@b\expandafter{%
    \expandafter{\@oddhead!:oddhead}}%
  \magyar@letappendto#1\reserved@b
  % Dat: don't use \@mkboth (\let\@mkboth\markboth)
}%

%** Branches based on whether the \pagestyle has changed since loading the
%** class file.
%** @param #1 class file name, e.g. `book.cls'. Tested with book.cls and
%**    report.cls.
%** @param #2 tokens to insert before fingerprinting the current page style.
%** @param implicit-#3 then-branch
%** @param implicit-#4 else-branch
\def\magyar@if@originalpagestyle#1#2{%
  \begingroup
  % article.cls calls \pagenumbering, which does a \gdef\thepage and
  % \global\c@page=1. We'll cancel that below.
  \let\magyar@@pagestyle@save@thepage\thepage
  \edef\magyar@@pagestyle@save@c@page{\the\c@page\space}
  \edef\magyar@@pagestyle@save@c@tocdepth{\the\c@tocdepth\space}
  % Dat: no \paragraphmark or \subparagraphmark
  % vvv Dat: already defined in latex.ltx
  %\providecommand\sectionmark[1]{\relax}
  %\providecommand\subsectionmark[1]{\relax}
  #2\magyar@mark@fingerprint@def\@@magyar@now@marks
  %
  \def\ProvidesClass##1[##2]{}%
  \def\NeedsTeXFormat##1[##2]{}% avoid ``can be used only in preamble''
  \long\def\DeclareOption##1##2{}%
  \def\ExecuteOptions##1{}%
  \def\ProcessOptions{}%
  \def\DeclareOldFontCommand##1##2##3{}%
  %
  \def\magyar@gobbleopt[##1]{}%
  % Dat: \newcommand etc. are not \global. Good.
  \let\newdimen\@gobble
  \let\newif\@gobble
  \let\newskip\@gobble
  \let\newmuskip\@gobble
  \let\newcount\@gobble
  \let\newbox\@gobble
  \let\newtoks\@gobble
  \let\newread\@gobble
  \let\newwrite\@gobble
  \let\newlaunguage\@gobble
  \let\newlength\@gobble
  \def\newcounter##1{\@ifnextchar[\magyar@gobbleopt{}}%
  \def\setcounter##1##2{\@ifundefined{c@##1}{\@nocounterr{##1}}%
      {\csname c@##1\endcsname##2\relax}}
  %** Like \newcommand, but always overrides old values.
  \def\magyar@defcommand{\@star@or@long\magyar@defcommand@low}
  \def\magyar@defcommand@low##1{%
    \begingroup
      \escapechar\m@ne\xdef\@gtempa{\string##1}%
    \endgroup
    \expandafter\let\csname\@gtempa\endcsname\@undefined
    \@star@or@long\new@command##1%
  }%
  \def\newcommand{\magyar@defcommand}%
  \def\renewcommand{\magyar@defcommand}%
  \def\magyar@defenvironment##1{%
    \@ifundefined{##1}{}{%
      \expandafter\let\csname ##1\endcsname\@undefined
      \expandafter\let\csname end##1\endcsname\@undefined
    }%
    \@star@or@long\new@environment{##1}%
  }%
  \def\newenvironment{\magyar@defenvironment}%
  \def\renewenvironment{\magyar@defenvironment}%
  %
  \ps@empty  % Clean \@oddhead as of latex.ltx
  \let\@mkboth\@gobbletwo
  \let\@oddhead\@empty
  \let\@evenhead\@empty
  \let\@oddfoot\@empty
  \let\@evenfoot\@empty
  %
  \def\input##1 {} % size10.clo etc.
  \makeatletter \@@input #1 %
  #2\magyar@mark@fingerprint@def\@@magyar@class@marks
  %\message{AAA \meaning\@@magyar@now@marks}%
  %\message{BBB \meaning\@@magyar@class@marks}%
  \global\let\thepage\magyar@@pagestyle@save@thepage
  \global\c@page\magyar@@pagestyle@save@c@page
  \global\c@tocdepth\magyar@@pagestyle@save@c@tocdepth
  \ifx\@@magyar@now@marks\@@magyar@class@marks
    \endgroup\expandafter\@firstoftwo
  \else
    \endgroup\expandafter\@secondoftwo
  \fi
}

%\begingroup
%\magyar@mark@fingerprint@def\OOO
%\message{OOO \meaning\OOO}%
%\endgroup

%** Branches based on whether the specified \pagestyle is active.
%** @param #1 tokens which change to the \pagestyle specified, e.g.
%**   `\ps@headings'.
%** @param implicit-#2 then-branch
%** @param implicit-#3 else-branch
\def\magyar@if@currentpagestyle#1{%
  \begingroup
  \magyar@mark@fingerprint@def\@@magyar@now@marks
  #1%
  \magyar@mark@fingerprint@def\@@magyar@specified@marks
  \ifx\@@magyar@now@marks\@@magyar@specified@marks
    \endgroup\expandafter\@firstoftwo
  \else
    \endgroup\expandafter\@secondoftwo
  \fi
}

%** Redefine \@@magyar@setup@psheadings for #2.cls.
%** @param #1 is the expanded value of \CurrentOption (`magyar').
\def\magyar@def@psheadings#1#2{%
  \def\@@magyar@setup@psheadings{%
    % SUXX: \show doesn't work here.
    \ifx\@@magyar@overridden@psheadings\ps@headings
      \@@magyar@error{assert: \string\let\string\ps@headings\string\@@magyar@overridden@psheadings\space was too early}%
    \else\ifx\@@magyar@overridden@psheadings\@empty
      \@@magyar@error{assert: \string\@@magyar@overridden@psheadings\space should be redefined}%
    \else
      \magyar@if@originalpagestyle{#2.cls}{\ps@headings}{%
        % \ps@headings still has its original definition (as of #1.cls).
        %
        % For efficiency reasons, we make the following restriction. If the
        % user does \selectlanguage{...} throughout the document, he should
        % call \pagetsyle{...} after that to make the pagestyle
        % language-dependent.
        %
        % !! add support for \thispagestyle in the preamble.
        % !! don't add this if extras gets cleared.
        \expandafter\addto\csname extras#1\endcsname{%
          \babel@save\ps@headings
          \let\ps@headings\@@magyar@overridden@psheadings
        }%
        \magyar@if@currentpagestyle{\ps@headings}{%
          % The current \pagestyle has been selected by the current
          % \ps@headings, i.e. \pagestyle{headings} is active.
          \edef\reserved@a{\languagename}%
          \edef\reserved@a{\expandafter\strip@prefix\meaning\reserved@a}%
          \edef\reserved@b{#1}%
          \edef\reserved@b{\expandafter\strip@prefix\meaning\reserved@a}%
          \ifx\reserved@a\reserved@b
            % Localize the current \pagestyle to Hungarian `headings'.
            \@@magyar@overridden@psheadings
          \fi
        }{}%
      }{}%
    \fi\fi
  }%
}

\def\magyar@ulladik{ulladik0}% [Nn]ulladik, `0' at end is intentional

\def\@@magyar@macro@appendixname{\appendixname}

%** \thechapter (possibly with huordinal), dot, space.
\def\magyar@huordinal@chapterheaddot{%
  \ifx\@chapapp\@@magyar@appendixname \thechapter\hbox{\magyar@opt@@titleskip}% appendixdot=no
  \else\ifx\@chapapp\@@magyar@macro@appendixname \thechapter.~%
  \else\ifnum\magyar@opt@@chapternumber=1 \@huordinal\c@chapter~%
  \else\ifnum\magyar@opt@@chapternumber=2 \@Huordinal\c@chapter~%
  \else \thechapter.~%
  \fi\fi\fi\fi
}

%** \thepart (possibly with huordinal), dot, space.
\def\magyar@huordinal@partheaddot{%
  \ifnum\magyar@opt@@partnumber=1 \@huordinal\c@part~%
  \else\ifnum\magyar@opt@@partnumber=2 \@Huordinal\c@part~%
  \else \thepart.~%
  \fi\fi
}

%** Emits the rule to the running head. Must put something of zero width
%** to the horizontal list.
%** @param #1 0: even page, 1: odd page, 3: page w/o [twoside]
\def\@@magyar@headrule#1{}
\def\@@magyar@slshape{}% running head is not slanted

\ifx\magyar@opt@@classmod\@empty
  \let\@@magyar@ifclassloaded\@ifclassloaded
\else
  \def\@@magyar@ifclassloaded#1#2{% force specific class
    \def\reserved@a{#1}%
    \ifx\reserved@a\magyar@opt@@classmod #2\fi
   }
\fi

\@@magyar@ifclassloaded{amsbook}{%
  \let\magyar@hunumbers@errmsg\@empty
  \let\@@magyar@orig@makechapterhead\@makechapterhead
  \def\@makechapterhead#1{%
    \begingroup
    \let\@@magyar@orig@centerline\centerline
    \def\centerline##1{%
      \@@magyar@orig@centerline{%
        \normalsize\mdseries
        \ifx\chaptername\appendixname  % We're in the appendix.
          \ifx\@@magyar@appendixname\@empty
            % print a dot in the appendix only if appendixdot=yes
            \thechapter.~%
          \else
            \thechapter\hbox{\magyar@opt@@titleskip}%
          \fi
        \else\ifnum\magyar@opt@@chapternumber=1
          \uppercase\@xp{\@huordinal\c@chapter}~%
        \else\ifnum\magyar@opt@@chapternumber=2
          \uppercase\@xp{\@Huordinal\c@chapter}~%
        \else\thechapter.~%
        \fi\fi\fi
        \uppercase\@xp{\chaptername}%
      }%
    }%
    \@@magyar@orig@makechapterhead{#1}%
    \endgroup
  }%
  \let\@@magyar@orig@chapter\@chapter
  \def\@chapter{%
    \let\@@magyar@orig@chapter@typeout\typeout
    \def\typeout##1{%
      % Original: \typeout{\chaptername\space\@secnumber}
      \@@magyar@orig@chapter@typeout{%
        \ifnum\c@secnumdepth<\z@
          \chaptername\space
        \else
          \thechapter\ifx\chaptername\appendixname\else.\fi
          \space\chaptername
        \fi
      }%
      \let\typeout\@@magyar@orig@chapter@typeout
    }%
    \@@magyar@orig@chapter
  }%
  % Just to be sure, no need for this in amsbook.cls 2004/08/06
  \@ifundefined{tocpart}{\let\tocpart\tocsection}{}
  % TODO(pts): Override only parts of \@part
  \def\@part[#1]#2{%
    \ifnum \c@secnumdepth >-2\relax \refstepcounter{part}%
      % TODO(pts): What does \tocpart do for a non-hungarian \tableofcontents?
      \addcontentsline{toc}{part}{\protect\tocpart{\partname}{\thepart}%
          {#1}}%
    \else
      \addcontentsline{toc}{part}{#1}\fi
    \begingroup\centering
    \ifnum \c@secnumdepth >-2\relax
         {\fontsize{\@xviipt}{22}\bfseries
          \ifnum\magyar@opt@@partnumber=1      \@huordinal\c@part~%
          \else\ifnum\magyar@opt@@partnumber=2 \@Huordinal\c@part~%
          \else\thechapter.~%
          \fi\fi
          \partname
         } \vskip 20\p@ \fi
    \fontsize{\@xxpt}{25}\bfseries
        #1\vfil\vfil\endgroup \newpage\thispagestyle{empty}}
}{}

\@@magyar@ifclassloaded{book}{%
  \let\magyar@hunumbers@errmsg\@empty
  % Headings: inserting dots, changing orders
  %\def\@@magyar@appendixname{\appendixname}% by appendixdot=
  \def\@@magyar@overridden@psheadings{%
    \if@twoside
      \let\@oddfoot\@empty\let\@evenfoot\@empty
      \def\@evenhead{\@@magyar@headrule0\thepage\hfil\@@magyar@slshape\leftmark}%
      \def\@oddhead {\@@magyar@headrule1{\@@magyar@slshape\rightmark}\hfil\thepage}%
      \let\@mkboth\markboth
      \def\chaptermark##1{%
	\markboth {\MakeUppercase{%
	  \ifnum \c@secnumdepth >\m@ne
	    \if@mainmatter% Dat: mainmatter only in book.cls, not in report.cls
              \magyar@huordinal@chapterheaddot
	      \@chapapp.\magyar@opt@@hdrtitleskip% \ %
	    \fi
	  \fi
	  ##1}}{}}%
      \def\sectionmark##1{%
	\markright {\MakeUppercase{%
	  \ifnum \c@secnumdepth >\z@
	    \thesection.\magyar@opt@@hdrtitleskip% \ %
	  \fi
	  ##1}}}%
    \else
      \let\@oddfoot\@empty
      \def\@oddhead{\@@magyar@headrule3{\@@magyar@slshape\rightmark}\hfil\thepage}%
      \let\@mkboth\markboth
      \def\chaptermark##1{%
	\markright {\MakeUppercase{%
	  \ifnum \c@secnumdepth >\m@ne
	    \if@mainmatter
               \magyar@huordinal@chapterheaddot
               \@chapapp.\magyar@opt@@hdrtitleskip% \ %
	    \fi
	  \fi
	  ##1}}}%
    \fi
  }%
  \expandafter\magyar@def@psheadings\expandafter{\CurrentOption}{book}%
  % Part: inserting dot, changing order, toc
  \expandafter\addto\csname extras\CurrentOption\endcsname{%
    \babel@save\@part
    \def\@part[#1]#2{% book
        \ifnum \c@secnumdepth >-2\relax
          \refstepcounter{part}%
          \ifnum\magyar@opt@@partnumber>0 \protected@edef\@currentlabel{\@huordinal\c@part}\fi
          \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 \magyar@huordinal@partheaddot\partname% hu
           \csname par\endcsname
           \vskip 20\p@
         \fi
         \Huge \bfseries #2\csname par\endcsname}%
        \@endpart}}
  % Chapter: dot, changing typeout, toc
  \expandafter\addto\csname extras\CurrentOption\endcsname{%
    \babel@save\@chapter
    \def\@chapter[#1]#2{% !! don't \def, but \let, other places, too
      \ifnum \c@secnumdepth >\m@ne
         \if@mainmatter
           \refstepcounter{chapter}%
           \typeout{\thechapter\ifx\@chapapp\@@magyar@appendixname\else.\fi\space\@chapapp.}%
           \ifx\@chapapp\@@magyar@appendixname
             % \@gobble gobbles the dot emitted by \numberline.
             \addcontentsline{toc}{chapter}{\protect\numberline{\thechapter\protect\@gobble}#1}%
           \else
             \addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}#1}%
           \fi
           \ifx\@chapapp\@@magyar@appendix@chapapp\else
             \ifnum\magyar@opt@@chapternumber>0 \protected@edef\@currentlabel{\@huordinal\c@chapter}\fi
           \fi
         \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}%
        %\csname par\endcsname
	\@afterheading % Imp: why doesn't it work?
      \fi}}
  \if0\magyar@opt@@chapterhead\else
    % Chapter: dot, changing order
    \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
              \magyar@huordinal@chapterheaddot \@chapapp{}%
              \csname par\endcsname\nobreak
              \vskip 20\p@
            \fi
          \fi
          \interlinepenalty\@M
          \Huge \bfseries #1\csname par\endcsname\nobreak
          \vskip 40\p@
        }}%
    }%
  \fi
}{}

\@@magyar@ifclassloaded{report}{%
  \let\magyar@hunumbers@errmsg\@empty
  %\def\@@magyar@appendixname{\appendixname}% by appendixdot=
  % Headings: inserting dots, changing orders
  \def\@@magyar@overridden@psheadings{%
    \if@twoside
      \let\@oddfoot\@empty\let\@evenfoot\@empty
      \def\@evenhead{\@@magyar@headrule0\thepage\hfil\@@magyar@slshape\leftmark}%
      \def\@oddhead {\@@magyar@headrule1{\@@magyar@slshape\rightmark}\hfil\thepage}%
      \let\@mkboth\markboth
      \def\chaptermark##1{%
	\markboth {\MakeUppercase{%
	  \ifnum \c@secnumdepth >\m@ne
            \magyar@huordinal@chapterheaddot
	    \@chapapp.\magyar@opt@@hdrtitleskip% \ %
	  \fi
	  ##1}}{}}%
      \def\sectionmark##1{%
	\markright {\MakeUppercase{%
	  \ifnum \c@secnumdepth >\z@
	    \thesection.\magyar@opt@@hdrtitleskip% \ %
	  \fi
	  ##1}}}%
    \else
      \let\@oddfoot\@empty
      \def\@oddhead{%
        \@@magyar@headrule3{\@@magyar@slshape\rightmark}\hfil\thepage}%
      \let\@mkboth\markboth
      \def\chaptermark##1{%
	\markright{\MakeUppercase{%
	  \ifnum \c@secnumdepth >\m@ne
            \magyar@huordinal@chapterheaddot
	    \@chapapp.\magyar@opt@@hdrtitleskip% \ %
	  \fi
	  ##1}}}%
    \fi
  }%
  \expandafter\magyar@def@psheadings\expandafter{\CurrentOption}{report}%
  % Chapter: dot, changing typeout, toc
  % Part...
  \expandafter\addto\csname extras\CurrentOption\endcsname{%
    \babel@save\@chapter
    \def\@chapter[#1]#2{%
      \ifnum \c@secnumdepth >\m@ne
           \refstepcounter{chapter}%
           \typeout{\thechapter\ifx\@chapapp\@@magyar@appendixname\else.\fi\space\@chapapp.}%
           \ifx\@chapapp\@@magyar@appendixname
             % \@gobble gobbles the dot emitted by \numberline.
             \addcontentsline{toc}{chapter}{\protect\numberline{\thechapter\protect\@gobble}#1}%
           \else
             \addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}#1}%
           \fi
           \ifx\@chapapp\@@magyar@appendix@chapapp\else
             \ifnum\magyar@opt@@chapternumber>0 \protected@edef\@currentlabel{\@huordinal\c@chapter}\fi
           \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}%
    \babel@save\@part
    \def\@part[#1]#2{% report; added at Fri Jul 23 11:45:57 CEST 2004
      \ifnum \c@secnumdepth >-2\relax
	\refstepcounter{part}%
        \ifnum\magyar@opt@@partnumber>0 \protected@edef\@currentlabel{\@huordinal\c@part}\fi
        \addcontentsline{toc}{part}{\thepart.\hspace{1em}#1}%
      \else
	\addcontentsline{toc}{part}{#1}%
      \fi
	\markboth{}{}% %%%%% \l@chapter in report.cls
	{\centering
	 \interlinepenalty \@M
	 \normalfont
	 \ifnum \c@secnumdepth >-2\relax
	   \huge\bfseries \magyar@huordinal@partheaddot\partname% hu
	   \csname par\endcsname
	   \vskip 20\p@
	 \fi
	 \Huge \bfseries #2\csname par\endcsname}%
	\@endpart}%
  }
  \if0\magyar@opt@@chapterhead\else
    % Chapter: dot, changing order
    \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
	      \magyar@huordinal@chapterheaddot \@chapapp{}%
              \vskip 20\p@
          \fi
          \interlinepenalty\@M
          \Huge \bfseries #1\csname par\endcsname\nobreak
          \vskip 40\p@
        }}%
    }%
  \fi
}{}

\@@magyar@ifclassloaded{article}{%
  \let\magyar@hunumbers@errmsg\@empty
  % Headings: inserting dots
  % In order for this to take effect, \pagestyle{plain} should be put below
  % \begin{document}.
  \def\@@magyar@overridden@psheadings{%
    \if@twoside
        \let\@oddfoot\@empty\let\@evenfoot\@empty
        % Dat: by pts: \slshape -> \relax
        \def\@evenhead{\@@magyar@headrule0\thepage\hfil\@@magyar@slshape\leftmark}%
        \def\@oddhead {\@@magyar@headrule1{\@@magyar@slshape\rightmark}\hfil\thepage}%
        \let\@mkboth\markboth
      \def\sectionmark##1{%
        \markboth {\MakeUppercase{%
          \ifnum \c@secnumdepth >\z@
            \thesection.\magyar@opt@@hdrtitleskip
          \fi
          ##1}}{}}%
      \def\subsectionmark##1{%
        \markright {%
          \ifnum \c@secnumdepth >\@ne
            \thesubsection.\magyar@opt@@hdrtitleskip
          \fi
          ##1}}%
    \else
      \let\@oddfoot\@empty
      \def\@oddhead{\@@magyar@headrule3{\@@magyar@slshape\rightmark}\hfil\thepage}%
      \let\@mkboth\markboth
      \def\sectionmark##1{%
        \markright {\MakeUppercase{%
          \ifnum \c@secnumdepth >\m@ne
            \thesection.\magyar@opt@@hdrtitleskip
          \fi
          ##1}}}
    \fi}%
  \expandafter\magyar@def@psheadings\expandafter{\CurrentOption}{article}%
  \expandafter\addto\csname extras\CurrentOption\endcsname{%
    \babel@save\@part
    \def\@part[#1]#2{% article % added at Fri Jul 23 11:45:57 CEST 2004
      \ifnum \c@secnumdepth >\m@ne
	\refstepcounter{part}%
        \ifnum\magyar@opt@@partnumber>0 \protected@edef\@currentlabel{\@huordinal\c@part}\fi
        \addcontentsline{toc}{part}{\thepart.\hspace{1em}#1}%
      \else
	\addcontentsline{toc}{part}{#1}%
      \fi
      {\parindent \z@ \raggedright
       \interlinepenalty \@M
       \normalfont
       \ifnum \c@secnumdepth >\m@ne
         \Large\bfseries \magyar@huordinal@partheaddot\partname% hu
	 \csname par\endcsname\nobreak
       \fi
       \huge \bfseries #2%
       \markboth{}{}\csname par\endcsname}%
      \nobreak
      \vskip 3ex
      \@afterheading}}%
}{}

\@@magyar@ifclassloaded{letter}{%
  % Dat: no: \let\magyar@hunumbers@errmsg\@empty here
  % Headings: inserting dots
  % In order for this to take effect, \pagestyle{plain} should be put below
  % \begin{document}.
  \def\@@magyar@overridden@psheadings{%
    \if@twoside
        \let\@oddfoot\@empty\let\@evenfoot\@empty
        \def\@oddhead{\@@magyar@headrule3\@@magyar@slshape\headtoname{:} \ignorespaces\toname
                      \hfil \@date
                      \hfil \thepage.~\pagename}%
        \let\@evenhead\@oddhead
    \else
        \let\@oddfoot\@empty
        \def\@oddhead{\@@magyar@headrule3\@@magyar@slshape\headtoname{:} \ignorespaces\toname
                      \hfil \@date
                      \hfil \thepage.~\pagename}%
    \fi}%
  \expandafter\magyar@def@psheadings\expandafter{\CurrentOption}{letter}%
}{}
\@gobble
{^}%

% --- mond=

\if0\magyar@opt@@mond \@@magyar@skiplong\fi
%** Dat: `--\enspace' would be too much
%** Use this in the beginning of the paragraph.
\def\@@magyar@mond{%
  % Dat: \noindent after \subsection in article.cls
  % Dat: \indent after \subsection in amsart.cls (\@noskipsecfalse)
  % vvv Dat: strange: \ifvmode anf \if@noskipsec.
  \ifvmode\if@noskipsec\leavevmode\fi\par\vskip-\parskip
  \else\@noskipsecfalse\par\vskip-\parskip\fi
  \leavevmode--\hbox{ }}
\ifnum\magyar@opt@@mond \expandafter\ifx\csname mond\endcsname\relax1\fi>1 % 21, 2, 11, 1
  \let\mond\@@magyar@mond
\fi
\@gobble
{^}%

% --- hang=

\if0\magyar@opt@@hang \@@magyar@skiplong\fi
%** Usage: \hang{-- } Foo\par
\def\@@magyar@hang#1{%
  \begingroup
  \setbox0\hbox{#1}%
  \advance\linewidth-\wd0 % not \hsize
  \advance\@totalleftmargin\wd0
  \edef\reserved@a{\parshape=1 \the\@totalleftmargin\space\space\the\linewidth\space}%
  \par\noindent\kern-\wd0 \box0 % Dat: \box0 destroys \wd0
  \expandafter\endgroup\expandafter\begingroup\reserved@a
  \let\hang@@par\par
  \def\par{\hang@@par\endgroup}% OK, works even inside \begin{quotation}
  %\def\par{\endgroup\par}% doesn't work, restores \parshape too early
  \ignorespaces
}%
\ifnum\magyar@opt@@hang \expandafter\ifx\csname hang\endcsname\relax1\fi>1 % 21, 2, 11, 1
  \let\hang\@@magyar@hang
\fi
\@gobble
{^}%

% vvv hyphenmins=

\ifx\magyar@opt@@hyphenmins\@empty\else
  \edef\reserved@a{\noexpand\@namedef{\CurrentOption hyphenmins}{\magyar@opt@@hyphenmins}}
  \reserved@a
\fi

% !!

%\def\skipfoo #1foo {%
%  \ifx#1\hfuzz\else
%    (#1)%
%    \expandafter\skipfoo
%  \fi
%}


% vvv cjhebrewfix= % by pts@fazekas.hu at Tue Apr 19 18:26:54 CEST 2005
%     thanks to Zoltán Hamar for reporting the problem
% Dat: the ultimate solution is active=onlycs, but it limits other
%      functionality
% Dat: use \def\h{\cjRL} in the preamble to abbreviate \cjRL
%      wrong: \let\h\cjRL
%      wrong: \newcommand{\h}[1]{\cjRL{#1}}
% Dat: cjhebrew uses the following strings for typesetting Hebrew letters:
%      ' b g d h w z .h .t y k K l m M n N s ` p P .s .S q r ,s +s t * a a:
%      /a e i o O u U E E: A A: | * : ; --
% Dat: headings in `\pagestyle{headings} \section{(\cjRL{`l})}' doesn't work
%      as expected, because \MakeUppercase capitalizes the L, too.
%      Solution #1:
%        \DeclareRobustCommand\mycjcommand{\cjRL{`l}}
%        \section{(\mycjcommand)}
%      Solution #2: (won't convert any heading to uppercase)
%        % change the definition of \ps@headings, remove \MakeUppercase
%        \makeatletter \def\ps@headings{%
%          \let\@oddfoot\@empty \let\@mkboth\markboth  
%          \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%  
%          \def\sectionmark##1{\markright {\iffalse\MakeUppercase\fi{%
%            \ifnum \c@secnumdepth >\m@ne \thesection\quad \fi##1}}}}
\if0\magyar@opt@@cjhebrewfix \@@magyar@skiplong\fi
% Dat: \cjRL{`l} in cjhebrew.sty should typeset two letters, but typesets
%      only one if ` is \active. Use this code to fix it.
% Imp: also fix in command arguments etc. Change catcode later.
\if1\magyar@opt@@cjhebrewfix % =onlyouter
% Dat: this doesn't work in the argument of \section etc., but it allows
%      LaTeX commands (\) in the arg of \cjRL
\def\@@magyar@cjhebrewfix{%
  \let\@@magyar@orig@cjRL\cjRL
  \def\cjRL{\begingroup\catcode\string``=12 \@@magyar@cjRL@low}%
  \def\@@magyar@cjRL@low##1{\@@magyar@orig@cjRL{##1}\endgroup}}
\else % =yes
% Dat: this works in the argument of \section etc., but it doesn't allow
%      LaTeX commands (\) in the arg of \cjRL
\def\reserved@b{\protect}
\edef\reserved@b{\expandafter\strip@prefix\meaning\reserved@b}
%\show\reserved@b
\edef\reserved@a{%
  \noexpand\def\noexpand\@@magyar@cjhebrew@skipa##1\reserved@b{%
  \noexpand\ifx##1\noexpand\hfuzz\noexpand\@empty\noexpand\else
    ##1%(##1)%
    \noexpand\expandafter\noexpand\@@magyar@cjhebrew@skipa
  \noexpand\fi}%
  \noexpand\def\noexpand\@@magyar@cjhebrew@skipb##1\noexpand\hfuzz{% Dat: this removes all `\protect '
    \noexpand\@@magyar@cjhebrew@skipa##1\reserved@b\noexpand\hfuzz\reserved@b}}
\reserved@a
\def\@@magyar@cjhebrewfix{%
  \let\@@magyar@orig@cjRL\cjRL
  %\let\@@magyar@orig@cjRL\bf
  \DeclareRobustCommand\cjRL[1]{\begingroup
    \toks@{##1}%
    %\showthe\toks@
    \edef\reserved@a{\the\toks@}%
    \edef\reserved@a{\expandafter\strip@prefix\meaning\reserved@a}%
    % Dat: we're almost complete here, but 1st we want to remove all
    %      instances of `\protect ' (catcodes 12 and 10), which were inserted
    %      into \firstmark, i.e. with \section{A\cjRL{`l}B}, \firstmark
    %      becomes: `{}{\protect \csname foreignlanguage \endcsname {magyar}{\protect \MakeUppercase {1\hskip 1em\relax A\protect \cjRL  {\protect `l}B}}}'
    \edef\reserved@a{\expandafter\@@magyar@cjhebrew@skipb\reserved@a\hfuzz}%
    %\show\reserved@a
    \expandafter\@@magyar@orig@cjRL\expandafter{\reserved@a}\endgroup}}
\fi
\AtBeginDocument{\ifx\cjRL\@undefined\else\@@magyar@cjhebrewfix\fi}
\@gobble
{^}%

% vvv varioref=

\if0\magyar@opt@@varioref \@@magyar@skiplong\fi
\expandafter\addto\csname extras\CurrentOption\endcsname{%
  \@@magyar@setup@varioref} % Dat: we are we late enough so we override varioref.sty
% vvv don't apply changes if varioref.sty wasn't loaded 
\AtBeginDocument{\expandafter\ifx\csname vpagerefrange\endcsname\relax
  \let\@@magyar@setup@varioref\@empty\fi}
\def\@@magyar@setup@varioref{% Dat: must be a separate macro for suggestions= not to find our \reftextfaceafter etc.
  \def\reftextfaceafter {\reftextvario{a t\'ul\-ol\-da\-lon}{a k\"o\-vet\-kez\H{o} ol\-da\-lon}}%
  \def\reftextfacebefore{\reftextvario{a t\'ul\-ol\-da\-lon}{az el\H{o}\-z\H{o} ol\-da\-lon}}%
  \def\reftextafter     {a k\"o\-vet\-kez\H{o} ol\-da\-lon}%
  \def\reftextbefore    {az el\H{o}\-z\H{o} ol\-da\-lon}%
  \def\reftextcurrent   {ezen az ol\-da\-lon}%
  \def\reftextfaraway##1{a~\csname @@magyar@az@lowxu\endcsname{\pageref{##1}}.~ol\-da\-lon}%
  \def\reftextpagerange##1##2{a~\csname @@magyar@az@lowxu\endcsname{\pageref{##1}}%
    --\pageref{##2}.~ol\-da\-la\-kon}%
  \def\reftextlabelrange##1##2{{}\csname @@magyar@told\endcsname\ref{##1}+tol{}
    \ref{##2}-ig}% Dat: `{}' is here for anti-\capitalize
}
\@gobble
{^}%

% vvv fancyhdr=
%
% Dat: magyar.ldf has to be loaded first, otherwise it cannot fix
%      `\usepackage{fancyhdr} \pagestyle{fancy}'

\if0\magyar@opt@@fancyhdr \@@magyar@skiplong\fi
\expandafter\ifx\csname ps@fancy\endcsname\relax
  % Emit a warning if \pagestyle{fancy} is used after this.
  % The original definition: \def\ps@fancy{\@fancyplainfalse\ps@@fancy}
  \def\@@magyar@@ps@fancy{\@fancyplainfalse\ps@@fancy}%
\else
  \addto\ps@fancy{% works for article.cls, report.cls and book.cls
    \@ifundefined{chapter}{%
      % article:
      % > \sectionmark=macro:
      %#1->\markboth {\MakeUppercase {\ifnum \c@secnumdepth >\z@
      %\thesection \hskip 1em\relax \fi #1}}{}.
      \def\sectionmark#1{\markboth{\MakeUppercase{\ifnum \c@secnumdepth>\z@
        \thesection.\magyar@opt@@hdrtitleskip \fi #1}}{}}%
      % vvv Imp: do we need \if@twoside to set \subsectionmark here?
      % #1->\markright {\ifnum \c@secnumdepth >\@ne \thesubsection
      % \hskip 1em\relax \fi #1}.
      \def\subsectionmark#1{\markright {\ifnum \c@secnumdepth >\@ne
        \thesubsection.\magyar@opt@@hdrtitleskip \fi #1}}%
    }{\def\chaptermark#1{
        \markboth{\MakeUppercase{\ifnum \c@secnumdepth>\m@ne
        % report.cls doesn't have \if@mainmatter, so we replace it with \iftrue
        \@gobble\iftrue  % balance for quick skipping
        \@@magyar@ifmainmatter  % must be macro if quick skipping
        \magyar@huordinal@chapterheaddot
        \@chapapp.\magyar@opt@@hdrtitleskip
        \fi  % for \if@mainmatter
        \fi#1}}{}}%
      \def\sectionmark#1{\markright{\MakeUppercase{\ifnum \c@secnumdepth>\z@
        \thesection.\magyar@opt@@hdrtitleskip \fi#1}}}}}%
  \def\@@magyar@@ps@fancy{\relax}% must be done after suggestions=
\fi
% This definition must be outside \iffalse.
\def\@@magyar@ifmainmatter{%
  \csname \ifx\if@mainmatter\@undefined iftrue\else if@mainmatter\fi
  \endcsname}
\@gobble
{^}%

% vvv ntheoremfix=

%** Fix for the `! Undefined control sequence. \select' error message with
%** ntheorem.sty
%**
%** The reason for the error is that magyar.ldf emits
%** \select@language{magyar} into .thm files (as well as .toc, .lof, .lot
%** etc. files), and LaTeX cannot read those files without \makeatletter
%** because of the @ in the \select@language command.
%**
%** Our solution: add \makeatletter somewhere before \@input{\jobname.thm} to
%** the macro which reads the .thm file (\thm@processlist) in ntheorem.sty .
\if0\magyar@opt@@ntheoremfix \@@magyar@skiplong\fi
  \def\magyar@@ntheoremfix{%
    \expandafter\ifx\csname ver@ntheorem.sty\endcsname\relax\else
      \ifx\thm@processlist\@undefined\else
        % This doesn't work, because the body of \thm@processlist contains #
        %\expandafter\def\expandafter\thm@processlist\expandafter{%
        %  \expandafter\begingroup\expandafter\makeatletter
        %  \thm@processlist\endgroup}%
        \expandafter\@temptokena\expandafter{%
          \expandafter\begingroup\expandafter\makeatletter
          \thm@processlist\endgroup}%
        \edef\thm@processlist{\the\@temptokena}%
      \fi
    \fi
  }
  \AtBeginDocument{\magyar@@ntheoremfix}
  \@gobble
{^}%

% vvv extras=, must be last

\ifnum\magyar@opt@@extras=0
  % Dat: \extrasmagyar might break compatibility with future LaTeX packages.
  %      Use this option to turn all of them off, for debugging purposes.
  \expandafter\let\csname extras\CurrentOption\endcsname\@empty
  \expandafter\let\csname noextras\CurrentOption\endcsname\@empty
\fi

% --- Finish

\ldf@finish\CurrentOption% \input \CurrentOption.cfg

% !! doc: (\string!)
% !! doc: \umlautlow is much more important in OT1 cmr fonts than in T1
% !! %** @example értelmezés\/beállítás
%    \def\per{/\penalty\exhyphenpenalty\hskip\z@skip}
% !! \itemize identation
% !! layout.sty
%\DeclareOption{magyar}{%
%  \def\Headertext{Fejl\'ec}
%  \def\Bodytext{A dokumentum teste\qquad}
%  \def\Footertext{L\'abl\'ec}
%  \def\MarginNotestext{Sz\'el-\\jegyzet}
%  \def\oneinchtext{1 inch}
%  \def\notshown{nem l\'atszik}
%  }
% !! vvv this w/ and w/o nathb.sty: $H_{`symm}$, $H_``symm $
%\let\@@magyar@saved@mathoptions@on\mathoptions@on
%\def\mathoptions@on{% overrides nath.sty
%  \catcode``12 % deactivate
%  \begingroup\lccode`~``\lowercase{\endgroup\def~}{\abbreviation}%
%  % ^^^ \def`{\abbreviation}, but with active `
%  \@@magyar@saved@mathoptions@on
%}
% !! doc: hegyes`-szögű
% !! option to detect new magyar.ldf from a TeX file
% !! book.cls \appendix \chapter, sub-numbers into TOC, need dot after `A. függelék'? Gyurgyák recommends `1. függelék'.
% !! \MathReal, frenchb.ldf, \nombre
% !! \told\ref{foo}+ban{}, if \foo expands to empty (no \section etc. in .tex file)
% !! french.ldf number decimal comma etc.
% !! \hunnewlabel should store `table', `figure', `section', `equation' etc.
% !! letter.cls
% !! should \newlabel emit a `.' ? (now doesn't) -- compatibility
%    `\aref{ekezetek}.\ táblázat' needs explicit `.'
% !! alternative solutions for meny-nyi (possibly defining ligatures?)
% !! baseline grid?
% !! Bujdosó`--Wettl: http://www.math.bme.hu/~wettl/plcv/pdf/BWfinal.pdf
% !!   some comments not related to magyar.ldf, but to *hyph.tex etc.
% !!   add their postpara symbols
% !!   section title sizes
% !!   baseline grid
% !!   rigid \parskip=0pt unless in prospestus or other short doc with \parindent=0pt
% !!   add their \leftmargini and variations
% !!   substitute bold-extended fonts with bold fonts
% !!   no page numbers on blank pages
% !!   \hsize <= 24cc (or 20cc) => parindent:=1quad else 2quad
% !!   length of last line of par... (break line)
% !!   reduce vertical whitespace around \section
%
% !! \MathReal{1.25 cm}
% !! \H,\. in OT1 \texttt
% !! maybe \index{|run husort.pl}
% !! virtual fonts to support \umlauthigh and \umlautlow in T1 encoding
%    fnt_def1: scaled size is relative (2^20==1), design size is absolute (same as in local TFM)
%    disallowed DVI: bop,eop, >=243
%    down(2^19) moves down 10/2 pt if the design size is 10pt
%    dimensions must be <2^24 (160pt, ~5.62cm)
%    w=x=y=z=0
% !! \begin{description} \bf -> \em ?, auto-dot
% !! \def\mdqon{\shorthandon{"}} \def\mdqoff{\shorthandoff{"}} (possibly deactivate `?' etc.)
% !! fix \initiate@active@char for other languages
% !! \addto\shorthandsspanish...
% !! spanish.ldf \es@activate, \if@safe@actives\then
% !! esperanto.ldf why? \declare@shorthand{system}{^}{\csname normal@char\string^\endcsname}
% !! add other low accents for umlaut=low: \. (i) and \'
% !! full amsart.cls compatibility??
% !! huhyph.tex wrong \showhyphens{azthehe}% az-t-hehe
% !! huhyph.tex wrong zs-hehe
% !! huhyph.tex why sza-badstrand, but szbadsg-rand
% !! \index{foo|hyperpagearg{\textbf}}
% !! combine \magyar@opt@@titleskip, amstocnumskip and \magyar@post@...
% !! \begin{textqq} ? combined command and env
% !! tmagyar.tex \tableofcontents wide \section
% !! \restoreparindent in \item in \itemize
%    \edef\restoreparindent{\parindent\the\parindent\relax} in \@listi
% !! 1848 március+ának közepe
% !! should \told insert \, ?? (no, only \told*??)
% !! \told45{-ed-hez} ??
% !! \told{45}-ed-hez ??
% !! \told45\od\hoz \told45+\od\hoz
% !! \told45+adik+val +ad+val etc.
% !! \azhuphy
% !! \huphy{-3331234.5678pF^{-1}} -> $-$3\,331\,234,5678\,pF^{-1}
% !! \huphy if non-Hungarian is the lang {,}->{.}
% !! \huphy ifmmode?
% !! french.ldf \CyrillicGuillemets
% !! french.ldf \LasyGuillemets
% !! huplain.bst   editor = "Wizar{\BN dj} V. Oz and Mihalis Yannakakis",
% !! huplain.bst w/o magyar.ldf
% !! hyperref.sty bugfix when turning hyperref.sty on, \ref is spoiled:
%    w/ or w/o magyar.ldf
%    ! Argument of \@fifthoffive has an extra }.
%    <inserted text> 
%                    \par 
%    l.48 Ld. \ref{tab}
% !! >    Kipróbáltam, s tényleg pontosan ugyanaz a fájl magyar.ldf (texmf fában) és
%    > magyar-0510.ldf (aktuális könyvtárban) néven más eredményt ad.
%    (cjhebrew)
% !! a4wide.sty doesn't compile
%    \documentclass[12pt,a4paper]{article}
%    \usepackage{t1enc}                   
%    \usepackage{times}% Imp: math mode
%    \usepackage[magyar]{babel}
%    \usepackage{graphicx}
%    \usepackage[latin2]{inputenc}
%    %\usepackage{a4wide}% SUXX: doesn't work with magyar.ldf
%    \pagestyle{empty}
%    \begin{document}
% !! % Imp: magyar.ldf: \textdt{tudja`=e}, \textdt{tudja`-e};
% !! space in front of `;' is too large with \usepackage{times}
%    \declare@shorthand{\CurrentOption}{;}{\magyar@thinspaced;}
% !! doc: `- not suitable in .bib files etc.
% !! \cite{foo,bar} -> `[2, 1]' increasing order preferred
% Imp: indent using the maximum footnotemark *** count on the current page
% Imp: generate ,,harmincháromból'' by \told{\@huordinal{33}}+bol etc.
%
% Dat: \mathcode`\,="013B     % és így a tizedes törtekben matematikai módban sem lesz köz
% Dat:  \mathchardef\comma="613B  % a vesző (,) ami matematikai módban elválasztó karakterként használható
% Dat: additive \PassOptionsToPackage{foo=bar}{magyar.ldf}
% Dat: for book.cls and article.cls: the user has to run \pagestyle{headings} after \selectlanguage{magyar} -- for performance reasons
% Dat: doc: \let\@@magyar@setup@psheadings\relax maybe needed in the preamble 
% Dat: \pagestyle{headings} is forced \AtBeginDocument -- user should change it later
% Dat: babel.def assumes we have: \textquotedblright \textquoteright \ll \gg
%      < >
% Dat: babel.def defines for OT1 and others: \quotedblbase \quotesinglbase
%      \guillemotleft \guillemotright \guilsinglleft \guilsinglright \ij \IJ
%      \dj \DJ \SS 
% Dat: babel.def defines the following robust commands in math and text modes:
%      \glq \grq \glqq \grqq \flq \frq \flqq \frqq
% Dat: OT1 encoding respects accents=low (\umlauthigh and \umlautlow), but T1
%      doesn't -- but we need T1 for hyphenation of accented words
% Dat: \usepackage{t1enc} is faster than \usepackage[T1]{fontenc}
% Dat: \languageattribute should be specified in the document preamble, and
%      not changed again
% Dat: it is possible to have 1 letter, e.g \declare@shorthand{turkish}{=}{...}
% Dat: Babel \@activated emits a \PackageInfo entry
% Dat: (` `) is equivalent to (``), because TeX ignores spaces before macro
%      arguments
% Dat: example of the so-called ``dual load'':
%      \PassOptionsToPackage{frenchspacing=yes}{magyar.ldf}
%      \PassOptionsToPackage{frenchspacing=no}{hungarian.ldf}
%      \usepackage[hungarian,magyar]{babel}
% Dat: argument of \az and \told may not contain \if..., \else and \fi
% OK: works with article.cls: (mathbrk=fix)
%    \noindent és ebből a további három rész területe
%    $\displaystyle{1\over3}-{1\over 4}={1\over 12}$,
%    $\displaystyle{1\over 2}-{1\over 4}={1\over 4}$ és
%    $\displaystyle{1\over 4}+\bigg({1\over 2}-{1\over 3}\bigg)={1\over 4}+{1\over 6}}=\displaystyle{5\over 12}$
%    területegység. 
% OK: doc in magyarldf-doc.tex: enumeration in math, see $a,\ b$ in nath.sty
% OK: mathbrk=fix +\\+ (all binary ops and relations) in math, \nobreak\cdot, \nobreak\slash
% OK: footnote text indented, asterisks on pages
% OK: Kiss Előd\nobreak\,\nobreak--\,Nagy Pál ...
% OK: \partname in book.cls (seems to work now)
% OK: Első rész
% OK: smartly disable active chars in preamble
% OK: \@inpenc@undefined defined and != latin2 => recommend \usepackage[latin2]{inputenc}
% OK: \encodingdefault != T1 => recommend \usepackage{t1enc}
% OK: Warning if \l@hungarian vs \l@magyar undefined
% OK: amsart.cls \listoftables overfull \hbox (\magyar@amslevelfix)
% OK: dzs-dzs
% OK: \expandafter\addto\csname extras\CurrentOption\endcsname{\bbl@frenchspacing}
% OK: provide \magyarhyphenmins
% OK: compatibility with latex.ltx, theorem.sty, ntheorem.sty, amsthm.sty
% OK: \PackageWarning if \magyarOptions defined too late
% OK: like frenchb.ldf \declare@shorthand{french}{;}{
% OK: \told\ref{hellopart}+es{} részt olvasd el.
% OK: \told appends suffixes to numbers
% OK: activeacute, activegrave babel options
% OK: even more parts made conditional
% OK: \@hunumeral \@huordinal \@Hunumeral \@Huordinal
% OK: negative numbers \told-5-nek, `mínusz kettedik' etc.
% OK: magyar.ldf defaults=hu-min (mathbrk=define) $x+116=\break x-97$ adds space only to BOL; added \nobreak before \discretionary -- and the problem was solved
% OK: fixed. varioref.sty (2001/09/04 v1.3c) mustn't be loaded with option
%     [magyar], because that option contains a stupid \AtBeginDocument hook
%     added to \extrasmagyar
% OK: Bujdosó`--Wettl: add their {itemize} symbols and {enumerate} styles
% OK: spacing around excl. marks in math mode  ! closing(5) -> punct(6)
%     better solution (found in nath.sty): \def!{\mathchar20513\relax\mathopen{}\mathinner{}},
%     because it doesn't need braces
% No: \@makecaption in frenchb.ldf -> magyar.ldf

\@@magyar@restcats
\endinput% of magyar.ldf
