 \NeedsTeXFormat{LaTeX2e}[1995/12/01]
%Feb 5, 2010
%\ProvidesClass{article}
%              [1998/05/05 v1.3y
% Standard LaTeX document class]
\ProvidesClass{ems-journal-prims}
%%%              [2000/05/11 v0.01 LaTeX document class]
%%%              [2000/06/20 v0.02 LaTeX document class]
%%%              [2000/07/14 v0.03 LaTeX document class]
%%%              [2000/09/11 v3.01 LaTeX document class]
%%%              [2000/09/25 v4.01 LaTeX document class]
%%%              [2000/10/10 v2.1 LaTeX document class]
%%%              [2000/11/10 v2.2 LaTeX document class]
%%%              [2000/12/15 v2.3 LaTeX document class]
%%%              [2001/01/15 v2.4 LaTeX document class]
%%%              [2001/10/19 v2.5 LaTeX document class]
%%%              [2006/11/20 v2.9 LaTeX document class]
%%%              [2023/09/15 v3.0 LaTeX document class]
%%%              [2023/11/26 v3.1 LaTeX document class]
              [2023/12/08 v3.2 LaTeX document class]
\newif\if@restonecol

\RequirePackage{xpatch}
\def\ems@warnpatch#1{\PackageWarning{ems}{Failed to patch #1.}}

\RequirePackage{kvoptions}
\SetupKeyvalOptions{ family = ems, prefix = @ems@ }
\DeclareStringOption[???]{journal}
\DeclareStringOption[submission]{mode}
\DeclareStringOption{paper}
%\DeclareStringOption[numeric]{cite}
\DeclareStringOption[american]{lang}%british

\@twosidetrue  \@mparswitchtrue

%\setlength\paperheight {731pt}
%\setlength\paperwidth  {518pt}
\setlength\paperheight{297mm}
\setlength\paperwidth{210mm}

\RequirePackage{geometry}

\RequirePackage{caption}

\RequirePackage{pdftexcmds}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\setcounter{secnumdepth}{3}
\newcounter {part}
\newcounter {section}
\newcounter {subsection}[section]
\newcounter {subsubsection}[subsection]
\newcounter {paragraph}[subsubsection]
\newcounter {subparagraph}[paragraph]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newif\if@ems@openaccess	\@ems@openaccessfalse

\DeclareOption{draft}{\setlength\overfullrule{5pt}}
\DeclareOption{final}{\setlength\overfullrule{0pt}}
\DeclareOption{journal=PRIMS}{}
\DeclareOption{mode=online}{}
\DeclareOption{mode=print}{}
\DeclareOption{mode=work}{}
\DeclareOption{mode=submission}{}

\DeclareOption{onecolumn}{\@twocolumnfalse}
\DeclareOption{twocolumn}{\@twocolumntrue}

\DeclareOption{fleqn}{\input{fleqn.clo}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DeclareOption{secnum}{%
	\renewcommand\theequation {\thesection.\@arabic\c@equation}
	\@addtoreset{equation}{section}}
\DeclareOption{ssecnum}{%
	\renewcommand\theequation {%
		\@arabic\c@section.%
		\ifnum \the\c@subsection = 0\else\@arabic\c@subsection.\fi%
		\@arabic\c@equation}
	\@addtoreset{equation}{subsection}}
\DeclareOption{nsecnum}{%
	\renewcommand\theequation {\@arabic\c@equation}}
\DeclareOption{openaccess}{\@ems@openaccesstrue}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ProcessKeyvalOptions*
\def\ems@check#1#2{%
	\ifnum\pdf@strcmp{\@nameuse{@ems@#1}}{\unexpanded{#2}}=0 %
		\expandafter\@firstoftwo
	\else
		\expandafter\@secondoftwo
	\fi
}
\newcommand*\ems@journalname{{ENTER JOURNAL CODE}}
\ems@check{journal}{PRIMS}{%
    \renewcommand*\ems@journalname{Publ. RIMS Kyoto Univ.}%
}{\errmessage{please include the journal name among the package options as journal=PRIMS}}%

\ExecuteOptions{onecolumn,final}
\ProcessOptions

\usepackage[OT1]{fontenc}

\newif\ifems@onlinefirst
\ems@check{mode}{onlinefirst}{\ems@onlinefirsttrue \xdef\@ems@mode{online}}{}

%%% color
\ems@check{mode}{print}{
	\RequirePackage[cmyk]{xcolor}
	\definecolorset{cmyk}{ems}{}{%
		red, 0, 0.8, 0.8, 0.2;%
		green, 0.5, 0, 0.9, 0.3;%
		blue, 1, 0.2, 0, 0.4;%
		yellow, 0, 0.1, 0.9, 0.3%
	}
}{
	\RequirePackage[rgb]{xcolor}
	\definecolorset{HTML}{ems}{}{%
		red, CC2929;%
		green, 59B312;% RGB triadic
		blue, 007A99;%
		yellow, B3A112% RYB triadic
	}
}

\ems@check{paper}{a4}{
	\geometry{
		a4paper,
		layouthoffset = \z@,
		layoutvoffset = 10mm,
		marginparwidth = 32mm,
		asymmetric
	}
}{}


%leqno.clo
\renewcommand\@eqnnum{\hb@xt@.01\p@{}%
                      \rlap{\normalfont\normalcolor
                        \hskip -\displaywidth(\theequation)}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%\ProvidesFile{size10.clo}
%%%              [1998/05/05 v1.3y
%%%      Standard LaTeX file (size option)]
\renewcommand\normalsize{%
   \@setfontsize\normalsize\@xpt{13.5}%
   \abovedisplayskip 8\p@ \@plus2\p@ \@minus2\p@
   \abovedisplayshortskip \z@ \@plus3\p@
   \belowdisplayshortskip 4\p@ \@plus2\p@ \@minus2\p@
   \belowdisplayskip \abovedisplayskip
   \let\@listi\@listI}
\normalsize
\newcommand\small{%
   \@setfontsize\small\@ixpt{11}%
   \abovedisplayskip 6\p@ \@plus2\p@ \@minus2\p@
   \abovedisplayshortskip \z@ \@plus2\p@
   \belowdisplayshortskip 4\p@ \@plus2\p@ \@minus2\p@
   \def\@listi{\leftmargin\leftmargini
%               \topsep 4\p@ \@plus2\p@ \@minus2\p@
%               \parsep 2\p@ \@plus\p@ \@minus\p@
               \itemsep \parsep}%
   \belowdisplayskip \abovedisplayskip
}
\newcommand\footnotesize{%
   \@setfontsize\footnotesize\@viiipt{9.5}%
   \abovedisplayskip 6\p@ \@plus2\p@ \@minus2\p@
   \abovedisplayshortskip \z@ \@plus\p@
   \belowdisplayshortskip 4\p@ \@plus2\p@ \@minus2\p@
   \def\@listi{\leftmargin\leftmargini
%               \topsep 3\p@ \@plus\p@ \@minus\p@
%               \parsep 2\p@ \@plus\p@ \@minus\p@
               \itemsep \parsep}%
   \belowdisplayskip \abovedisplayskip
}
\newcommand\scriptsize{\@setfontsize\scriptsize\@viipt\@viiipt}
\newcommand\tiny{\@setfontsize\tiny\@vpt\@vipt}
\newcommand\large{\@setfontsize\large\@xiipt{14}}
\newcommand\Large{\@setfontsize\Large\@xivpt{18}}
\newcommand\LARGE{\@setfontsize\LARGE\@xviipt{22}}
\newcommand\huge{\@setfontsize\huge\@xxpt{25}}
\newcommand\Huge{\@setfontsize\Huge\@xxvpt{30}}

\setlength\smallskipamount{3\p@ \@plus 1\p@ \@minus 1\p@}
\setlength\medskipamount{6\p@ \@plus 2\p@ \@minus 2\p@}
\setlength\bigskipamount{12\p@ \@plus 4\p@ \@minus 4\p@}


\setlength\topmargin{16bp}%88bp-1inch
\setlength\oddsidemargin  {20bp}%92bp - 1inch
\setlength\evensidemargin {12bp}%84bp - 1inch

\setlength\headheight{8\p@}
\setlength\headsep   {15\p@}

\setlength\topskip   {12\p@}
%\setlength\footskip{30\p@}
\setlength\footskip{11mm}
\setlength\maxdepth{.5\topskip}

\setlength\textwidth{12.5cm}
\setlength\textheight{524pt}
\setlength\parindent{2 em}

\setlength\marginparwidth {50bp}%marginpar will not used
\setlength\marginparpush{5\p@}


\setlength\footnotesep{6.65\p@}
\setlength{\skip\footins}{12\p@ \@plus 6\p@ \@minus 2\p@}
\setlength\floatsep    {12\p@ \@plus 2\p@ \@minus 2\p@}
\setlength\textfloatsep{20\p@ \@plus 2\p@ \@minus 4\p@}
\setlength\intextsep   {12\p@ \@plus 2\p@ \@minus 2\p@}
\setlength\dblfloatsep    {12\p@ \@plus 2\p@ \@minus 2\p@}
\setlength\dbltextfloatsep{20\p@ \@plus 2\p@ \@minus 4\p@}
\setlength\@fptop{0\p@ \@plus 1fil}
\setlength\@fpsep{8\p@ \@plus 2fil}
\setlength\@fpbot{0\p@ \@plus 1fil}
\setlength\@dblfptop{0\p@ \@plus 1fil}
\setlength\@dblfpsep{8\p@ \@plus 2fil}
\setlength\@dblfpbot{0\p@ \@plus 1fil}
%\setlength\partopsep{2\p@ \@plus 1\p@ \@minus 1\p@}
\setlength\partopsep{0\p@}
\def\@listi{\leftmargin\leftmargini
            \parsep 0\p@
            \topsep 6\p@ \@plus2\p@ \@minus2\p@
            \itemsep2\p@}
\let\@listI\@listi
\@listi
\def\@listii {\leftmargin\leftmarginii
              \labelwidth\leftmarginii
              \advance\labelwidth-\labelsep
              \topsep    6\p@ \@plus2\p@ \@minus2\p@
              \parsep    0\p@
              \itemsep   2\p@}
\def\@listiii{\leftmargin\leftmarginiii
              \labelwidth\leftmarginiii
              \advance\labelwidth-\labelsep
              \topsep    6\p@ \@plus2\p@ \@minus2\p@
              \parsep    0\p@
              \itemsep   2\p@}
\def\@listiv {\leftmargin\leftmarginiv
              \labelwidth\leftmarginiv
              \advance\labelwidth-\labelsep}
\def\@listv  {\leftmargin\leftmarginv
              \labelwidth\leftmarginv
              \advance\labelwidth-\labelsep}
\def\@listvi {\leftmargin\leftmarginvi
              \labelwidth\leftmarginvi
              \advance\labelwidth-\labelsep}
%%%\endinput
%%
%% End of file `size10.clo'.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% appendix author/affil. data
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% appendix
\newcommand*\appendixauthor[2]{%
	\gdef\@appendixauthor{\leavevmode\null#1}%
	\gdef\@appendixauthor@abbr{#2}%
}
\newcommand*\Appendixauthor{\@ifstar\@Appendixauthor\@@Appendixauthor}
\newcommand*\@Appendixauthor{\let\ems@correspcheck\relax\@@@Appendixauthor}
\newcommand*\@@Appendixauthor{\let\ems@correspcheck\@undefined\@@@Appendixauthor}
\newcommand*\@@@Appendixauthor[3]{%
	\csxdef{ems@aaffil#1name}{\ifx\ems@correspcheck\relax\else%\leavevmode\null
#3\fi}%
%	\csxdef{ems@affil#1name}{#3\ifx\ems@correspcheck\relax\ems@corresplabel\fi}%
	\ifnum\c@aauthors >\@ne
		\@namedef{@sepa\number\c@aauthors}{\Authsep}%
	\fi
	\refstepcounter{aauthors}%
	\begingroup
		\let\protect\@unexpandable@protect
		\@temptokena=\expandafter{\ems@aauthors}%
%		\@temptokenb=\expandafter{\ems@authors@abbr}%
		{%
			\xdef\ems@aauthor{#2}%
%			\xdef\ems@author@abbr{#3}%
			\ifnewaaffil
				\global\let\ems@laas\@empty
				\gdef\ems@laasx{\protect\Authand}%
				\global\let\ems@aas\@empty
				\xdef\ems@aauthors{\the\@temptokena}%
%				\xdef\ems@authors@abbr{\the\@temptokenb}%
			\else
				\xdef\ems@aauthors{\the\@temptokena\ems@aas\ems@aau@str}%
%				\xdef\ems@authors@abbr{\the\@temptokenb\ems@as\ems@au@str@abbr}%
				\global\let\ems@laas\ems@laasx
				\gdef\ems@laasx{\protect\Authands}%
				\gdef\ems@aas{\Authsep}%
			\fi
			\gdef\ems@aau@str{#2}%
%			\gdef\ems@au@str@abbr{#3}%
		}%
		\@temptokena=\expandafter{\ems@aauthlist}%
		\xdef\ems@aauthlist{%
			\the\@temptokena
			\protect\@nameuse{@sepa\number\c@aauthors}#2%
		}%
%		\@temptokenb=\expandafter{\ems@authlist@abbr}%
%		\xdef\ems@authlist@abbr{%
%			\the\@temptokenb
%			\protect\@nameuse{@sep\number\c@authors}#3%
%		}%
	\endgroup
	\ifnum\c@aauthors >\tw@
		\@namedef{@sepa\number\c@aauthors}{\Authands}%
	\fi
	\newaaffilfalse
}
\newcommand*\appendixaffil[1]{\gdef\@appendixaffil{#1}}
\newcommand\Appendixaffil[2]{%
	\newaaffiltrue
	\global\ems@affemail@setfalse
	\expandafter\ifx\csname ems@aaffil#1name\endcsname\@empty\else
	\begingroup
		%%% no page breaks for \\
		\let\\\ems@affilcr
		\let\protect\@unexpandable@protect
		\@temptokena=\expandafter{\ems@aauthors}%
		{\init@ffil\setbox0\hbox{#2}\ems@emailcheck\xdef\ems@temp{\build@ffil}\init@ffil}%
		\xdef\ems@aauthors{\the\@temptokena\ems@laas\ems@aau@str\ems@temp}%
		\global\let\ems@laas\@empty
		\global\let\ems@aau@str\@empty
%		{\init@ffil\setbox0\hbox{#2}\xdef\ems@temp{\build@ffil}\init@ffil}%
%		\@temptokena=\expandafter{\ems@affillist}%
		\@temptokena=\expandafter{\ems@aaffillist}%%
%		\xdef\@appendixaffil{\ems@temp}%
		\xdef\ems@aaffillist{\the\@temptokena\ems@aaffilnameformat{#1}\ems@temp}%
	\endgroup
	\fi
}
\newcommand*\appendixauthorsection[2][(by~\null\ems@aauthlist%\@appendixauthor
)]{\section[#2]{#2 \textmd{#1}}}

%% author data
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\providecommand*\Authsep{, {\null}}
\providecommand*\Authand{ and {\null}}
\providecommand*\Authands{ and {\null}}
\def\ems@corresplabel{\null\space\textmd{(corresponding author)}}
\robustify\ems@corresplabel
\newcounter{authors}
\newcounter{aauthors}
\newif\ifnewaffil \newaffiltrue
\newif\ifnewaaffil \newaaffiltrue
\@namedef{@sep1}{}
\@namedef{@sep2}{\Authand}
\@namedef{@sepa1}{}
\@namedef{@sepa2}{\Authand}
\def\ems@authlist{}
\def\ems@aauthlist{}
\def\ems@authors{}
\def\ems@aauthors{}
\newtoks\@temptokenb
\def\ems@authlist@abbr{}
\def\ems@authors@abbr{}
\newcommand*\emsauthor{\@ifstar\@emsauthor\@@emsauthor}
\def\@emsauthor{\let\ems@correspcheck\relax\@@@emsauthor}
\def\@@emsauthor{\let\ems@correspcheck\@undefined\@@@emsauthor}
\def\@@@emsauthor#1#2#3{%
	\csxdef{ems@affil#1name}{#3\ifx\ems@correspcheck\relax\ems@corresplabel\fi}%
	\ifnum\c@authors >\@ne
		\@namedef{@sep\number\c@authors}{\Authsep}%
	\fi
	\refstepcounter{authors}%
	\begingroup
		\let\protect\@unexpandable@protect
		\@temptokena=\expandafter{\ems@authors}%
		\@temptokenb=\expandafter{\ems@authors@abbr}%
		{%
			\xdef\ems@author{#2}%
			\xdef\ems@author@abbr{#3}%
			\ifnewaffil
				\global\let\ems@las\@empty
				\gdef\ems@lasx{\protect\Authand}%
				\global\let\ems@as\@empty
				\xdef\ems@authors{\the\@temptokena}%
				\xdef\ems@authors@abbr{\the\@temptokenb}%
			\else
				\xdef\ems@authors{\the\@temptokena\ems@as\ems@au@str}%
				\xdef\ems@authors@abbr{\the\@temptokenb\ems@as\ems@au@str@abbr}%
				\global\let\ems@las\ems@lasx
				\gdef\ems@lasx{\protect\Authands}%
				\gdef\ems@as{\Authsep}%
			\fi
			\gdef\ems@au@str{#2}%
			\gdef\ems@au@str@abbr{#3}%
		}%
		\@temptokena=\expandafter{\ems@authlist}%
		\xdef\ems@authlist{%
			\the\@temptokena
			\protect\@nameuse{@sep\number\c@authors}#2%
		}%
		\@temptokenb=\expandafter{\ems@authlist@abbr}%
		\xdef\ems@authlist@abbr{%
			\the\@temptokenb
			\protect\@nameuse{@sep\number\c@authors}#3%
		}%
	\endgroup
	\ifnum\c@authors >\tw@
		\@namedef{@sep\number\c@authors}{\Authands}%
	\fi
	\newaffilfalse
}
%%% affiliation
\def\ems@affillist{}
\def\ems@aaffillist{}
\def\ems@aff@tst{}
%%% no page breaks for \\
\def\ems@affilcr{\let\reserved@e\vadjust \let\reserved@f\nobreak \@xnewline}
\robustify\ems@affilcr
%%% name format
%\newdimen\jems@affilsep
%\jems@affilsep .25ex
%\def\ems@affilskip{\par \vskip\jems@affilsep}
\def\ems@affilskip{\parskip0pt\par}
% TODO
\def\ems@affilnameformat#1{\strut \csuse{ems@affil#1name}:\space}
\def\ems@aaffilnameformat#1{\strut \csuse{ems@aaffil#1name}:\space}

\newcommand*\breakemail[1]{\unskip;\linebreak \jems@email{#1}}
\newcommand*\secondemail[1]{\unskip, \jems@email{#1}}
\newcommand*\emsaffil{\@ifstar\@emsaffil\@@emsaffil}
\def\@emsaffil#1#2{{\let\ems@affilnameformat\@gobble \@@emsaffil{#1}{#2}}}
\def\@@emsaffil#1#2{%
	\newaffiltrue
% 	TODO
	%%% add semicolon in front of e-mail (without space!)
	\begingroup
		\let\\\ems@affilcr
		\let\protect\@unexpandable@protect
		\@temptokena=\expandafter{\ems@authors}%
		{\xdef\ems@temp{#2}}%
		\xdef\ems@authors{\the\@temptokena\ems@las\ems@au@str\ems@temp}%
		\global\let\ems@las\@empty
		\global\let\ems@au@str\@empty
		{\xdef\ems@temp{#2}}%
		\xdef\ems@affillist{%
			\the\@temptokena
			\ems@affilskip\ems@affilnameformat{#1}\ems@temp
		}%
	\endgroup
}
\newcommand\Emsaffil[2]{%
	\newaffiltrue
	\global\ems@affemail@setfalse
	\begingroup
		%%% no page breaks for \\
		\let\\\ems@affilcr
		\let\protect\@unexpandable@protect
		\@temptokena=\expandafter{\ems@authors}%
		{\init@ffil\setbox0\hbox{#2}\ems@emailcheck\xdef\ems@temp{\build@ffil}\init@ffil}%
		\xdef\ems@authors{\the\@temptokena\ems@las\ems@au@str\ems@temp}%
		\global\let\ems@las\@empty
		\global\let\ems@au@str\@empty
%		{\init@ffil\setbox0\hbox{#2}\xdef\ems@temp{\build@ffil}\init@ffil}%
		\@temptokena=\expandafter{\ems@affillist}%
		\xdef\ems@affillist{\the\@temptokena
			\ifx\ems@affillist\ems@aff@tst\else\ems@affilskip\fi\ems@affilnameformat{#1}\ems@temp
		}%
	\endgroup
}
\newdimen\ems@mp@ \ems@mp@=-1pt % this saves macro space and time
\def\ems@if@cs@def#1#2#3{\expandafter\ifx\csname ems@#1\endcsname\relax\else#2\csname ems@#1\endcsname#3\fi}
\def\ems@if@@cs@def#1#2#3{\expandafter\ifx\csname ems@#1\endcsname\relax#3\else#2\fi}
\def\ems@if@cs@eq#1#2#3#4{\ifnum\pdf@strcmp{\csname ems@#1\endcsname}{\csname ems@#2\endcsname}=\z@#3\else\expandafter\ifx\csname ems@#1\endcsname\relax\expandafter\ifx\csname ems@#2\endcsname\relax#3\else#4\fi\else#4\fi\fi}
\def\ems@if@cs@zro#1#2#3#4{\expandafter\ifx\csname ems@#1\endcsname\relax\expandafter\ifx\csname ems@#2\endcsname\relax#3\else#4\fi\else#4\fi}
\def\ems@if@uniq@addr#1#2#3#4{\ems@if@cs@eq{address#1}{address#2}{\ems@if@cs@eq{zip#1}{zip#2}{\ems@if@cs@eq{city#1}{city#2}{#3}{#4}}{#4}}{#4}}
\def\ems@if@zero@aff#1#2#3#4{\ems@if@cs@zro{department#1}{department#2}{\ems@if@cs@zro{organisation#1}{organisation#2}{\ems@if@cs@zro{address#1}{address#2}{\ems@if@cs@zro{zip#1}{zip#2}{\ems@if@cs@zro{city#1}{city#2}{#3}{#4}}{#4}}{#4}}{#4}}{#4}}
\def\ems@if@uniq@org#1#2#3{\ems@if@cs@eq{organisation#1}{organisation#2}{\ems@if@uniq@addr{#1}{#2}{\ems@if@zero@aff{#1}{#2}{}{;\space}}{#3}}{#3}}
\def\ems@city@zip@post#1#2{\ems@if@@cs@def{country#1}{\ems@if@cs@eq{country#1}{country#2}{\ems@if@@cs@def{posttext#1}{\null}{;}\space}{,\space}}{\ems@if@@cs@def{posttext#1}{\null}{;}\space}}%
\def\ems@city@zip#1#2{\ifnum\pdf@strcmp{\csname ems@country#1\endcsname}{\ignorespaces USA\ignorespaces}=\z@\ems@city@zip@US{#1}{#2}\else\ifnum\pdf@strcmp{\csname ems@country#1\endcsname}{\ignorespaces Canada\ignorespaces}=\z@\ems@city@zip@US{#1}{#2}\else\ems@city@zip@normal{#1}{#2}\fi\fi}%
\def\ems@city@zip@normal#1#2{\ems@if@cs@def{zip#1}{}{\ems@if@@cs@def{city#1}{~}{\ems@city@zip@post#1#2}}\ems@if@cs@def{city#1}{}{\ems@city@zip@post#1#2}}
\def\ems@city@zip@US#1#2{\ems@if@cs@def{city#1}{}{\ems@if@@cs@def{zip#1}{,\space}{\ems@city@zip@post#1#2}}\ems@if@cs@def{zip#1}{}{\ems@city@zip@post#1#2}}
\def\ems@build@one@affil#1#2#3{\ems@if@cs@def{pretext#2}{\ems@if@@cs@def{posttext#1}{\null}{\null}}{\null\space}%
	\ems@if@cs@def{department#2}{}{}%
	\ems@if@uniq@org{#2}{#3}{\ems@if@@cs@def{department#2}{,\space}{}%
		\ems@if@cs@def{organisation#2}{}{,\space}%
		\ems@if@cs@def{address#2}{}{,\space}%
		\ems@city@zip{#2}{#3}%
		\ems@if@cs@eq{country#2}{country#3}{}{%
			\ems@if@cs@def{country#2}{}{\ems@if@@cs@def{posttext#2}{\null}{;}\space}%
		}%
	}%
	\ems@if@cs@def{posttext#2}{\null}{\null\space}%
}
\def\ems@chk@email#1#2{\expandafter\ifx\csname ems@affemail#1\endcsname\relax#2\else\email{\href{mailto:\csname ems@affemail#1\endcsname}{\mbox{\csname ems@affemail#1\endcsname}}}\ignorespaces\fi}
\def\ems@further@email@check#1{\expandafter\ifx\csname ems@furtheremail#1\endcsname\relax\else,\space\href{mailto:\csname ems@furtheremail#1\endcsname}{\texttt{\mbox{\csname ems@furtheremail#1\endcsname}}}\ignorespaces\fi}%
\def\build@ffil{\leavevmode\ems@build@one@affil012%
	\ems@build@one@affil123%
	\ems@build@one@affil234%
	\ems@build@one@affil345%
	\ems@build@one@affil456%
	\ems@build@one@affil567%
	\ems@build@one@affil678%
	\ems@build@one@affil789%
%	\ems@build@one@affil89{10}
%	\ems@build@one@affil9{10}{11}
	\ems@chk@email1{\ems@chk@email2{\ems@chk@email3{\ems@chk@email4{\ems@chk@email5{\ems@chk@email6{\ems@chk@email7{\ems@chk@email8{%\ems@chk@email9{%\ems@chk@email{10}{}%
%}
}}}}}}}}%
%	\expandafter\ifx\csname ems@affemail1\endcsname\relax%
%		\expandafter\ifx\csname ems@affemail2\endcsname\relax%
%			\expandafter\ifx\csname ems@affemail3\endcsname\relax%
%				\else\href{mailto:\csname ems@affemail3\endcsname}{\mbox{\csname ems@affemail3\endcsname}}\ignorespaces\fi%
%			\else\href{mailto:\csname ems@affemail2\endcsname}{\mbox{\csname ems@affemail2\endcsname}}\ignorespaces\fi%
%		\else\href{mailto:\csname ems@affemail1\endcsname}{\mbox{\csname ems@affemail1\endcsname}}\ignorespaces\fi%
	\ems@further@email@check1%
	\ems@further@email@check2%
	\ems@further@email@check3%
	\ems@further@email@check4%
	\ems@further@email@check5%
	\ems@further@email@check6%
	\ems@further@email@check7%
	\ems@further@email@check8%
%	\ems@further@email@check9%
%	\ems@further@email@check{10}%
}
\newif\ifems@temp@test	\ems@temp@testfalse
\def\ems@emailcheck{\ems@temp@testfalse\ifems@affemail@set\else\expandafter\ifx\csname ems@furtheremail1\endcsname\relax\else\ems@temp@testtrue\fi\expandafter\ifx\csname ems@furtheremail2\endcsname\relax\else\ems@temp@testtrue\fi\expandafter\ifx\csname ems@furtheremail3\endcsname\relax\else\ems@temp@testtrue\fi\expandafter\ifx\csname ems@furtheremail4\endcsname\relax\else\ems@temp@testtrue\fi\expandafter\ifx\csname ems@furtheremail5\endcsname\relax\else\ems@temp@testtrue\fi\expandafter\ifx\csname ems@furtheremail6\endcsname\relax\else\ems@temp@testtrue\fi\expandafter\ifx\csname ems@furtheremail7\endcsname\relax\else\ems@temp@testtrue\fi\expandafter\ifx\csname ems@furtheremail8\endcsname\relax\else\ems@temp@testtrue\fi\fi\ifems@temp@test\errmessage{\noexpand\furtheremail without \noexpand\affemail - please use exactly one \noexpand\affemail before using any \noexpand\furtheremail per author}\fi}%
\newcount\ems@temp@affil@num
\def\init@ffil{\ems@temp@affil@num=0	\loop\ifnum\ems@temp@affil@num<8	\advance\ems@temp@affil@num by1%
	\pretext{\the\ems@temp@affil@num}{}%
	\department{\the\ems@temp@affil@num}{}%
	\organisation{\the\ems@temp@affil@num}{}%
	\rorid{\the\ems@temp@affil@num}{}%
	\address{\the\ems@temp@affil@num}{}%
	\zip{\the\ems@temp@affil@num}{}%
	\city{\the\ems@temp@affil@num}{}%
%	\state{\the\ems@temp@affil@num}{}%
	\country{\the\ems@temp@affil@num}{}%
	\posttext{\the\ems@temp@affil@num}{}%
	\affemail{\the\ems@temp@affil@num}{}%
	\furtheremail{\the\ems@temp@affil@num}{}%
	\repeat}
%%% metadata
\newcommand*\ems@newmeta[1]{%
	\@ifundefined{#1}{%
%		\csdef{#1}##1{\csgdef{ems@#1}{\ignorespaces ##1}}%
		\csdef{#1}##1{\ignorespaces\csgdef{ems@#1}{\ignorespaces ##1\ignorespaces}\ignorespaces}%
	}{\PackageError{ems}{Command #1 already defined.}{}}%
}
\newcommand*\ems@newmeta@append[1]{%
	\@ifundefined{#1}{%
%		\csdef{#1}##1{\csgdef{ems@#1}{\ignorespaces ##1}}%
		\csdef{#1}##1{\ems@m@dateGBtoUS##1!\ignorespaces\csxdef{ems@#1}{\ignorespaces \ems@if@@cs@def{#1}{\@nameuse{ems@#1};\space\null}{}\ems@m@expanded\ignorespaces}\ignorespaces}%
	}{\PackageError{ems}{Command #1 already defined.}{}}%
}
\gdef\ems@glet{\global\let}
\providecommand*\ems@name@init[1]{%
  \expandafter\ems@glet\csname #1\endcsname\relax}
\newcommand*\ems@newmeta@two[1]{%
	\@ifundefined{#1}{%
	    \csdef{#1}##1{\@ifnextchar\bgroup{\ems@meta@two@args{#1}{##1}}{\ems@meta@one@arg{#1}{##1}}}
	}{\PackageError{ems}{Command #1 already defined.}{}}%
}
\newif\ifems@affemail@set	\ems@affemail@setfalse
\def\ems@meta@two@args#1#2#3{\ignorespaces
	\def\ems@orig@param{#1}
	\def\ems@second@param{#3}
	\def\ems@mailname{affemail}
	\def\ems@mailfurthername{furtheremail}
%	\def\ems@rorname{rorid}
	\ifx\ems@second@param\empty
		\ems@name@init{ems@#1#2}
	\else
	    \expandafter\ifx\csname ems@#1#2\endcsname\relax
		\ifx\ems@orig@param\ems@mailname
		    \ifems@affemail@set
			\errmessage{only one \noexpand\affemail is allowed, please use \noexpand\furtheremail for listing further emails for the author (all subsequent \noexpand\affemail ignored)}%
		    \else
			\global\ems@affemail@settrue
			\csgdef{ems@#1#2}{#3}%
		    \fi
		\else
		    \ifx\ems@orig@param\ems@mailfurthername
%			\ifems@affemail@set
%			    \message{\noexpand\furtheremail without preceding \noexpand\affemail - please use exactly one \noexpand\affemail before any \noexpand\furtheremail per author}%
%			\fi
			\csgdef{ems@#1#2}{#3}%
		    \else
%			\ifx\ems@orig@param\ems@rorname
%				\csgdef{ems@#1#2}{#3}%
%			\else
				\csgdef{ems@#1#2}{\ignorespaces #3\ignorespaces}%
%			\fi
		    \fi
		\fi
	    \else
		\errmessage{#1#2 already defined (new: #3), possibly wrong \ifx#21(or missing) \fi affiliation ordinal}%
	    \fi
	\fi
\ignorespaces}%
\def\ems@meta@one@arg#1#2{\ems@meta@two@args{#1}1{#2}}%
\ems@newmeta{accepted}
\ems@newmeta{copyrightyear}
\ems@newmeta{dedication}
\ems@newmeta{doinumber}
\ems@newmeta{doi}
\ems@newmeta{issue}
\ems@newmeta{journal}
\ems@newmeta{published}
\ems@newmeta{received}
\ems@newmeta@append{revised}
\ems@newmeta{volumeyear}
\ems@newmeta{volume}
\ems@newmeta{communicated}
\newcommand\givenname[1]{\unskip\ignorespaces #1\ignorespaces}%
\newcommand*\surname[1]{\unskip\ignorespaces~\@unexpandable@protect\textsc{\ignorespaces #1\ignorespaces}\ignorespaces}%
\ems@newmeta{mrid}
\ems@newmeta{orcid}
\ems@newmeta{editflow}
\ems@newmeta@two{pretext}
\ems@newmeta@two{department}
\ems@newmeta@two{organisation}
\ems@newmeta@two{rorid}
\ems@newmeta@two{address}
\ems@newmeta@two{zip}
\ems@newmeta@two{city}
%\ems@newmeta@two{state}
\ems@newmeta@two{country}
\ems@newmeta@two{posttext}
\ems@newmeta@two{affemail}
\ems@newmeta@two{furtheremail}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% end of author data
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand*\keywords[1]{\gdef\ems@keywords{\ignorespaces #1}}
%
\providecommand*\appendixbyname{with an appendix by}
\providecommand*\receivedname{Received}
\providecommand*\revisedname{Revised}
\providecommand*\acceptedname{accepted}
\providecommand*\keywordsname{Keywords}
\providecommand*\classificationname{Mathematics Subject Classification 2020}
%
\newcommand*\classification[2][]{%
	\ifx\relax#1\relax
		\gdef\ems@classification{\ignorespaces #2}%
	\else
		\gdef\ems@classification{%
			\ignorespaces #2\nobreakspace(primary);\space
			\ignorespaces #1\nobreakspace(secondary)}%
	\fi
}
%%% defaults
\doinumber{?}
\journal{\expandafter{\@ems@journal}}
\doi{10.4171/\ems@journal/\ems@doinumber}
\copyrightyear{\the\year}
\issue{0}
\volumeyear{0}
\volume{0}

%%% first and last page
\newcounter{FirstPage}
\newcommand*\firstpage[1]{\setcounter{page}{#1}\xdef\ems@FirstPage{#1}}
\AtBeginDocument{\firstpage{1}}
\iffalse
\RequirePackage{zref-base}[2019/11/29]
\ifx\ZREF@base@ok Y\else\expandafter\endinput\fi
\zref@newlist{LastPage}
\newcommand*\ems@lastpage{%
	\if@filesw
		\begingroup
			\toks@\expandafter\expandafter\expandafter{%
				\expandafter\Z@L@main
				\Z@L@LastPage
			}%
			\expandafter\zref@wrapper@immediate\expandafter{%
				\expandafter\ZREF@label\expandafter{\the\toks@}{LastPage}%
			}%
		\endgroup
	\fi
}
\fi
%%% end of first and last page

\setlength\lineskip{1\p@}
\setlength\normallineskip{1\p@}
\renewcommand\baselinestretch{}

\setlength\parskip{0\p@}

\@lowpenalty   51
\@medpenalty  151
\@highpenalty 301

\setcounter{topnumber}{2}
\renewcommand\topfraction{.7}
\setcounter{bottomnumber}{1}
\renewcommand\bottomfraction{.3}
\setcounter{totalnumber}{3}
\renewcommand\textfraction{.2}
\renewcommand\floatpagefraction{.5}
\setcounter{dbltopnumber}{2}
\renewcommand\dbltopfraction{.7}
\renewcommand\dblfloatpagefraction{.5}



\def\title#1{\gdef\@title{#1}
	\@ifundefined{@TitleHead}{\TitleHead{#1}}{}}
\def\TitleHead#1{\def\@TitleHead{#1}}
\def\dedicatory#1{\gdef\@dedicatory{#1}}

\def\author#1{\gdef\@author{#1}%
	\@ifundefined{@AuthorHead}{\AuthorHead{#1}}{}}
\def\AuthorHead#1{\def\@AuthorHead{#1}}



\def\VolumeNo#1{%
  \def\@VolumeNo{#1}
}
\def\YearNo#1{%
%%%%  \def\@YearNo{#1} %%%% revised, rims29.cls
      \def\@YearNo{#1}\let\volyr=\@YearNo
}
\def\PagesNo#1{%
  \def\@PagesNo{#1}
}
\VolumeNo{\null}
\YearNo{\null}
\PagesNo{\@startpage--\@endpage}


\def\communication#1{\def\@comm{#1}}
\communication{\null}


%\def\classification#1{\def\@class{#1}}
%\classification{\null}

%\def\keywords#1{\gdef\@keywords{{\it Keywords:} #1}}
%\keywords{}

\def\support#1{\gdef\@support{#1}}

\newif\ifCopyNRes
\global\CopyNResfalse%

%%%%\def\volyr{2006}% %%%% deleted, rims29.cls
%%Modified by M.S. Lakshmi on 081005
%\def\volyr{200x}%

\gdef\FooterText{\ifnum\currentpageno=\c@page%
\ifCopyNRes%
  \vbox{\footnotesize%
    \hbox to\textwidth{\hfill Published by Research Institute for Mathematical Sciences, Kyoto University.}%
    \hbox to\textwidth{\hfill}%
       }%
\else%
  \vbox{\footnotesize%
    \hbox to\textwidth{$\copyright$ %\volyr
\ems@copyrightyear\ Research Institute for Mathematical Sciences, Kyoto University.\hfill}%
\if@ems@openaccess
	This work is licensed under a\space
	\href{https://creativecommons.org/licenses/by/4.0/}{CC BY 4.0}\space
	license.
\fi
       }%
\fi%
\else%
\fi}%

  \def\ps@headings{%
      \def\@oddfoot{\FooterText}%
      \def\@evenfoot{\FooterText}%
      \def\@evenhead{\footnotesize\rlap{\thepage}\hfil\scshape\ifx\ems@authlist@abbr\@empty\else\ems@authlist@abbr\fi\hfil}%
      \def\@oddhead{\footnotesize\hfil{\scshape\@TitleHead}\hfil\llap{\thepage}}}
\def\ps@myheadings{%
      \def\@oddfoot{\FooterText}%
      \def\@evenfoot{\FooterText}%
      \def\@evenhead{\footnotesize\rlap{\thepage}\hfil\scshape\ifx\ems@authlist@abbr\@empty\else\ems@authlist@abbr\fi\hfil}%
%%%from fancyheadings.sty%%%
      \def\@oddhead{\scriptsize %
                   \hbox to\textwidth{\vbox to8pt{\hbox
                   {\rlap{\parbox[b]{\textwidth}%
                   {\raggedright{\it{\ems@journalname}} {\bf{%\@VolumeNo
\ems@volume}} (%\@YearNo 
\ems@volumeyear), %\@PagesNo
%\ems@FirstPage
\@startpage--\@endpage%\zref@extract{LastPage}{page}
                   \strut}}}%
                    DOI \ems@doi\hfil\vss}}}%
    \let\@mkboth\@gobbletwo
    \let\sectionmark\@gobble
    \let\subsectionmark\@gobble
    }


\def\nrdoi#1{\def\@nrdoi{#1}}
\nrdoi{*}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\@@fnsymbol#1{\ensuremath{\ifcase#1\or *\or **\or *{**}\or \dagger\or
   \ddagger\or \mathsection\or \mathparagraph\or \dagger\dagger
   \or \ddagger\ddagger \else\@ctrerr\fi}}

\def\@startpage{\pageref{FirstPage}}
\def\@endpage{\pageref{LastPage}}
\def\startpage#1{\gdef\@startpage{#1}\c@page#1}
\def\endpage#1{\gdef\@endpage{#1}}    \def\lastpage@putlabel{%
      \addtocounter{page}{-1}%
      \if@filesw
        \begingroup
          \ifHy@pageanchor
            \ifHy@hypertexnames
              \ifHy@plainpages
                \def\Hy@temp{\arabic{page}}%
              \else
                \let\textlatin\@firstofone
                \edef\Hy@temp{\thepage}%
              \fi
            \else
              \def\Hy@temp{\the\Hy@pagecounter}%
            \fi
          \fi
          \immediate\write\@auxout{%
            \string\newlabel
              {LastPage}{{}{\thepage}{}{%
                \ifHy@pageanchor page.\Hy@temp\fi}{}}%
          }%
        \endgroup
      \fi
      \addtocounter{page}{1}%
    }
\AtEndDocument{%
    \clearpage\lastpage@putlabel}%

\newcount\currentpageno%

\newcommand\maketitle{\par
\currentpageno\c@page%
  \thispagestyle{myheadings}\label{FirstPage}%
  \begingroup
    \renewcommand\thefootnote{}%
    \def\@makefnmark{\rlap{\@textsuperscript{\normalfont\@thefnmark}}}%
    \long\def\@makefntext##1{##1}
%%%
      \newpage
      \global\@topnum\z@   % Prevents figures from going at top of page.
      \@maketitle
  \@thanks
  \endgroup\par
  \setcounter{footnote}{0}%
  \global\let\thanks\relax
  \global\let\maketitle\relax
  \global\let\@maketitle\relax
  \global\let\@thanks\@empty
  \global\let\@author\@empty
  \global\let\@date\@empty
  \global\let\@title\@empty
  \global\let\@dedicatory\@empty
  \global\let\@support\@empty
  \global\let\title\relax
  \global\let\dedicatory\relax
  \global\let\support\relax
  \global\let\author\relax
%  \global\let\@keywords\@empty
%  \global\let\keywords\relax
}
\def\email#1{\hfill\break e-mail: \texttt{#1}}

\def\@maketitle{%
  \newpage
  \null
  \vskip 2pt%%%
  \begin{center}%%%
  \let \footnote \thanks
    {\Large\bfseries \@title \par}%
	\ems@check{mode}{print}{}{%
		\hypersetup{ pdftitle = \@title }%
	}%
    \@ifundefined{@dedicatory}%
      {}{\vskip \baselineskip {\normalsize\itshape \@dedicatory \par}}%
    \vskip 20pt%%%
    {\footnotesize by \par}
    \vskip 10pt%%%
	\ifx\ems@authlist\@empty\else
	    {\normalsize\leavevmode\ems@authlist\par%\@author
	    \ifx\ems@authlist@abbr\@empty\else
		\ems@check{mode}{print}{}{%
			{\def\setbox##1##2{}\def\box##1{}\def\hbox##1{##1}\hypersetup{ pdfauthor = \ems@authlist@abbr }}%
		}%
	    \fi
	    \ifx\ems@aauthlist\@empty\else\leavevmode(\appendixbyname\space\null\ems@aauthlist)\par\fi
	    }
	\fi
  \end{center}
  \footnote[0]{\ifx\ems@communicated\relax\else Communicated by %\@comm
\ems@communicated.\space\fi\ifx\ems@received\relax\else\receivedname\space\ems@m@dateGBtoUS\ems@received!\ems@m@expanded.\fi\ifx\ems@revised\relax\else\space\revisedname\space\ems@revised.\fi
\vspace*{4pt}}
%  \@ifundefined{@keywords}%
%      {}{\footnotetext[0]{\@keywords}}%
  \@ifundefined{@support}%
      {}{\footnotetext[0]{\@support}}%
  \ifx\ems@affillist\relax\else
        \begingroup
                \let\footnotelayout\raggedright
                \let\@makefnmark\relax
                \footnotetext[0]{\raggedright\ems@affillist}%
		\ifx\ems@aaffillist\@empty\else%
	                \footnotetext[0]{\raggedright\ems@aaffillist}%
		\fi
        \endgroup
  \fi
}
%
\xdef\ems@m@expanded{}%
\def\ems@m@errDateFormat#1{\errmessage{please use proper British date format: DD MonthName Year (improper month name: #1)}}%
\def\ems@m@dateGBtoUS#1!{{\def\ignorespaces{}\expandafter\ems@m@dateGBtoUStwo#1;}\ignorespaces}%
\def\ems@m@dateGBtoUStwo#1 #2 #3;{\expandafter\xdef\noexpand\ems@m@check@month{\ems@m@convertEMmonthToUS@month{#1}{#2}}\relax\expandafter\xdef\noexpand\ems@m@expanded{\ems@m@convertEMmonthToUS{#1}{#2}\space#3}}%
\xdef\ems@m@cMi{January}\xdef\ems@m@cMf{February}\xdef\ems@m@cMm{March}\xdef\ems@m@cMa{April}\xdef\ems@m@cMp{May}\xdef\ems@m@cMj{June}\xdef\ems@m@cMk{July}\xdef\ems@m@cMb{August}\xdef\ems@m@cMs{September}\xdef\ems@m@cMo{October}\xdef\ems@m@cMn{November}\xdef\ems@m@cMd{December}%
\def\@m@check#1#2#3{\ifnum\pdf@strcmp{#1}{#2}=0 #3\fi}
\xdef\ems@m@check@month{}%
\def\ems@m@convertEMmonthToUS@month#1#2{%
	\@m@check{#2}\ems@m@cMi{January}\@m@check{#2}\ems@m@cMf{February}\@m@check{#2}\ems@m@cMm{March}\@m@check{#2}\ems@m@cMa{April}\@m@check{#2}\ems@m@cMp{May}\@m@check{#2}\ems@m@cMj{June}%
	\@m@check{#2}\ems@m@cMk{July}\@m@check{#2}\ems@m@cMb{August}\@m@check{#2}\ems@m@cMs{September}\@m@check{#2}\ems@m@cMo{October}\@m@check{#2}\ems@m@cMn{November}\@m@check{#2}\ems@m@cMd{December}%
}
\def\ems@m@convertEMmonthToUS#1#2{\ems@m@cv@two{#1}{#2}}%
\def\ems@m@cv@two#1#2{\ifx\ems@m@check@month\@empty\ems@m@errDateFormat{#2}#2\else\ems@m@check@month\fi\space#1,}%
%
\newenvironment{abstract}{\begingroup
\centerline{\normalsize\textbf{Abstract}}\par
\vspace{3ex}\small\noindent\ignorespaces
}{%
	\par\vspace{3ex}\small
\noindent\textit{\classificationname:}\enskip%\@class
\ems@classification.\par
\noindent\textit{\keywordsname:}\enskip\ems@keywords.\par
\endgroup
%	\vspace{13.5pt}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%from latex.ltx
%%%\def\@seccntformat#1{\csname the#1\endcsname\quad}
%%%this command cause blank space (\quad) before title,
%%%even if no chapter mark is setted.
\def\@seccntformat#1{\csname the#1\endcsname}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\renewcommand \thepart {\@Roman\c@part}
\renewcommand \thesection {\@arabic\c@section}
\renewcommand \thesubsection   {\thesection.\@arabic\c@subsection}
\renewcommand \thesubsubsection{\thesubsection.\@arabic\c@subsubsection}
\renewcommand \theparagraph    {\thesubsubsection.\@arabic\c@paragraph}
\renewcommand \thesubparagraph {\theparagraph.\@arabic\c@subparagraph.}


\newcommand\part{\par
   \addvspace{4ex}%
   \@afterindentfalse
   \secdef\@part\@spart
}

\def\@part[#1]#2{%
    \ifnum \c@secnumdepth >\m@ne
      \refstepcounter{part}%
      \addcontentsline{toc}{part}{\protect\numberline{\thepart}#1}
      \addtocontents{toc}{\protect\addvspace{.5em}}%
    \else
      \addcontentsline{toc}{part}{#1}%
    \fi
    {\parindent \z@ \raggedright
     \interlinepenalty \@M
     \normalfont
     \ifnum \c@secnumdepth >\m@ne
       %\Large\bfseries \partname~\thepart           %amd--too big--
       %\par\nobreak                                 %amd
       \centering\large\bfseries \partname~\thepart. %amd
     \fi
     %\huge \bfseries #2%                            %amd
     \large \bfseries #2%                            %amd
     \markboth{}{}\par}%
    \nobreak
    \vskip 3ex
    \@afterheading}
\def\@spart#1{%
    {\parindent \z@ \raggedright
     \interlinepenalty \@M
     \normalfont
     \huge \bfseries #1\par}%
     \nobreak
     \vskip 3ex
     \@afterheading}


%%%%%%%%%%%%%

\newcommand\section{\@startsection {section}{1}{\z@}%
                                   {-18pt \@plus -2pt \@minus -2pt}%
                                   {6pt \@plus1pt}%
                                   {\normalfont\bfseries}}
\newcommand\subsection{\@startsection{subsection}{2}{\z@}%
                                     {-8pt\@plus -2pt \@minus -2pt}%
                                     {6pt \@plus 1pt}%
                                     {\normalfont\bfseries}}
\newcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
                                     {6pt\@plus 1pt \@minus 1pt}%
                                     {-.55em}%
                                     {\normalfont\normalsize\bfseries}}

\newcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
                                    {6pt \@plus1pt \@minus1pt}%
                                    {-.55em}%
                                    {\normalfont\normalsize\bfseries}}
\newcommand\subparagraph{\@startsection{subparagraph}{5}{\parindent}%
                                       {6pt \@plus1pt \@minus 1pt}%
                                       {-.55em}%
                                      {\normalfont\normalsize\bfseries}}

\def\@seccntformat#1{\csname the#1\endcsname.\enskip}
\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  \ifnum #2<3\centering\bf\sectionname\fi
      #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}}
\def\@ssect#1#2#3#4#5{%
  \@tempskipa #3\relax
  \ifdim \@tempskipa>\z@
    \begingroup\centering
      #4{%
        \@hangfrom{\hskip #1}%
          \interlinepenalty \@M #5\@@par}%
    \endgroup
  \else
    \def\@svsechd{#4{\hskip #1\relax #5}}%
  \fi
  \@xsect{#3}}

\newif\ifkropka
\kropkatrue
\def\bezkropki{\kropkafalse}
\def\@xsect#1{%
  \@tempskipa #1\relax
  \ifdim \@tempskipa>\z@
    \par \nobreak
    \vskip \@tempskipa
    \@afterheading
  \else
    \@nobreakfalse
    \global\@noskipsectrue
    \everypar{%
      \if@noskipsec
        \global\@noskipsecfalse
       {\setbox\z@\lastbox}%
        \clubpenalty\@M
        \begingroup \@svsechd\ifkropka.\fi\global\kropkatrue \endgroup
        \unskip
        \@tempskipa #1\relax
        \hskip -\@tempskipa
      \else
        \clubpenalty \@clubpenalty
        \everypar{}%
      \fi}%
  \fi
  \ignorespaces}

%%%\setlength\leftmargini  {2.5em}
\setlength\leftmargini  {1.8em}%%% If itemlabel is wider, increase this.
\leftmargin  \leftmargini
\setlength\leftmarginii  {2.2em}
\setlength\leftmarginiii {1.87em}
\setlength\leftmarginiv  {1.7em}
\setlength\leftmarginv  {1em}
\setlength\leftmarginvi {1em}
\setlength  \labelsep  {.5em}
\setlength  \labelwidth{\leftmargini}
\addtolength\labelwidth{-\labelsep}
\@beginparpenalty -\@lowpenalty
\@endparpenalty   -\@lowpenalty
\@itempenalty     -\@lowpenalty
\renewcommand\theenumi{\@arabic\c@enumi}
\renewcommand\theenumii{\@alph\c@enumii}
\renewcommand\theenumiii{\@roman\c@enumiii}
\renewcommand\theenumiv{\@Alph\c@enumiv}
\newcommand\labelenumi{\theenumi.}
\newcommand\labelenumii{(\theenumii)}
\newcommand\labelenumiii{\theenumiii.}
\newcommand\labelenumiv{\theenumiv.}
\renewcommand\p@enumii{\theenumi}
\renewcommand\p@enumiii{\theenumi(\theenumii)}
\renewcommand\p@enumiv{\p@enumiii\theenumiii}
\newcommand\labelitemi{\textbullet}
\newcommand\labelitemii{\normalfont\bfseries \textendash}
\newcommand\labelitemiii{\textasteriskcentered}
\newcommand\labelitemiv{\textperiodcentered}

\newenvironment{description}
               {\list{}{\labelwidth\z@ \itemindent-\leftmargin
                        \let\makelabel\descriptionlabel}}
               {\endlist}
\newcommand*\descriptionlabel[1]{\hspace\labelsep
                                \normalfont\bfseries #1}

\newenvironment{verse}
               {\let\\\@centercr
                \list{}{\itemsep      \z@
                        \itemindent   -1.5em%
                        \listparindent\itemindent
                        \rightmargin  \leftmargin
                        \advance\leftmargin 1.5em}%
                \item\relax}
               {\endlist}
\newenvironment{quotation}
               {\list{}{\listparindent 1.5em%
                        \itemindent    \listparindent
                        \rightmargin   \leftmargin
                        \parsep        \z@ \@plus\p@}%
                \item\relax}
               {\endlist}
\newenvironment{quote}
               {\list{}{\rightmargin\leftmargin}%
                \item\relax}
               {\endlist}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%amd\newcommand\appendix{\par
%amd  \setcounter{section}{0}%
%amd  \setcounter{subsection}{0}%
%amd  \renewcommand\thesection{Appendix \@Alph\c@section}
%amd  \renewcommand\sectionname{}
%amd%%%  \addcontentsline{toc}{section}{\thesection.\hspace{1em}#1}%
%amd}%
%amd replacement
\newcommand\appendix{\par
\renewcommand{\appendixname}{}
\renewcommand\sectionname{Appendix~}
  \setcounter{section}{0}%
  \setcounter{subsection}{0}%
  \renewcommand{\thesection}{\Alph{section}}
%%%  \addcontentsline{toc}{section}{\thesection.\hspace{1em}#1}%
}%
\newcommand\oneappendix{\par
\renewcommand{\appendixname}{}
\renewcommand\sectionname{Appendix}
  \setcounter{section}{0}%
  \setcounter{subsection}{0}%
  \renewcommand{\thesection}{}
%%%  \addcontentsline{toc}{section}{\thesection.\hspace{1em}#1}%
}%
%amd

\setlength\arraycolsep{1\p@}
\setlength\tabcolsep{6\p@}
\setlength\arrayrulewidth{.4\p@}
\setlength\doublerulesep{2\p@}
\setlength\tabbingsep{\labelsep}
\skip\@mpfootins = \skip\footins
\setlength\fboxsep{3\p@}
\setlength\fboxrule{.4\p@}


\newcounter{figure}
\renewcommand \thefigure {\@arabic\c@figure}
\def\fps@figure{tbp}
\def\ftype@figure{1}
\def\ext@figure{lof}
\def\fnum@figure{\figurename~\thefigure}
\newenvironment{figure}
               {\@float{figure}}
               {\end@float}
\newenvironment{figure*}
               {\@dblfloat{figure}}
               {\end@dblfloat}

\newcounter{table}
\renewcommand\thetable{\@arabic\c@table}
\def\fps@table{tbp}
\def\ftype@table{2}
\def\ext@table{lot}
\def\fnum@table{\tablename~\thetable}
\newenvironment{table}
               {\@float{table}}
               {\end@float}
\newenvironment{table*}
               {\@dblfloat{table}}
               {\end@dblfloat}

%\newlength\abovecaptionskip
%\newlength\belowcaptionskip
\setlength\abovecaptionskip{10\p@}
\setlength\belowcaptionskip{0\p@}
\long\def\@makecaption#1#2{%
  \vskip\abovecaptionskip
  \sbox\@tempboxa{#1. #2}%
  \ifdim \wd\@tempboxa >\hsize
    #1. #2\par
  \else
    \global \@minipagefalse
    \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
  \fi
  \vskip\belowcaptionskip}

\DeclareOldFontCommand{\rm}{\normalfont\rmfamily}{\mathrm}
\DeclareOldFontCommand{\sf}{\normalfont\sffamily}{\mathsf}
\DeclareOldFontCommand{\tt}{\normalfont\ttfamily}{\mathtt}
\DeclareOldFontCommand{\bf}{\normalfont\bfseries}{\mathbf}
\DeclareOldFontCommand{\it}{\normalfont\itshape}{\mathit}
\DeclareOldFontCommand{\sl}{\normalfont\slshape}{\@nomath\sl}
\DeclareOldFontCommand{\sc}{\normalfont\scshape}{\@nomath\sc}
\DeclareRobustCommand*\cal{\@fontswitch\relax\mathcal}
\DeclareRobustCommand*\mit{\@fontswitch\relax\mathnormal}

\newcommand\@pnumwidth{1.55em}
\newcommand\@tocrmarg{2.55em}
\newcommand\@dotsep{4.5}
\setcounter{tocdepth}{2}
\newcommand\tableofcontents{%
    \vspace*{-6.75pt}
    \section*{\contentsname}%
    {\small\@starttoc{toc}%
%    \vspace*{13.5pt}
    }\normalsize}
\newcommand*\l@part[2]{%
  \ifnum \c@tocdepth >-2\relax
    \addpenalty\@secpenalty
    \addvspace{.8em \@plus\p@}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
%      {\leavevmode
%       \large \bfseries #1\hfil \hb@xt@\@pnumwidth{\hss #2}}\par
%       \nobreak
%replacement-start
 \leavevmode \normalsize%\bfseries
      \advance\leftskip\@tempdima
      \hskip -\leftskip
      #1\quad
\nobreak\hb@xt@\@pnumwidth{\hss #2}\hfill\null\par
%replacement-end
       \if@compatibility
         \global\@nobreaktrue
         \everypar{\global\@nobreakfalse\everypar{}}%
      \fi
    \endgroup
  \fi}
\newcommand*\l@section[2]{%
  \ifnum \c@tocdepth >\z@
    \addpenalty\@secpenalty
%    \addvspace{0.3em \@plus\p@}%%%% changed 20/06/2000
    \setlength\@tempdima{1.75em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode %\bfseries
      \advance\leftskip\@tempdima
      \hskip -\leftskip
      #1\quad
\nobreak\hb@xt@\@pnumwidth{\hss #2}\hfill\null\par
     % #1      \hfill\mbox{}
      %\par
    \endgroup
  \fi}

\newcommand\@tocline[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}\quad\nobreak\hb@xt@\@pnumwidth{\hss #5}\hfill\null
      \par}%
  \fi}

\newcommand*\l@subsection{\@tocline{2}{1.75em}{2.2em}}
\newcommand*\l@subsubsection{\@tocline{3}{3.95em}{3.2em}}
\newcommand*\l@paragraph{\@tocline{4}{7.0em}{4.1em}}
\newcommand*\l@subparagraph{\@tocline{5}{10em}{5em}}
\newcommand\listoffigures{%
    \section*{\listfigurename
      \@mkboth{\MakeUppercase\listfigurename}%
              {\MakeUppercase\listfigurename}}%
    \@starttoc{lof}%
    }
\newcommand*\l@figure{\@dottedtocline{1}{1.5em}{2.3em}}
\newcommand\listoftables{%
    \section*{\listtablename
      \@mkboth{%
          \MakeUppercase\listtablename}{\MakeUppercase\listtablename}}%
    \@starttoc{lot}%
    }
\let\l@table\l@figure





\renewcommand\footnoterule{
  \kern-3\p@
  \hrule\@width.4\columnwidth
  \kern2.6\p@}
\newcommand\@makefntext[1]{
    \parindent 2em%
    \noindent
    \hb@xt@2em{\hss\@makefnmark}#1}
%%%\long\def\@makefntext#1{%
%%%    \parindent 1em%
%%%    \noindent
%%%    \hb@xt@1.8em{\hss\@makefnmark}%
%%%    \@tempdima\columnwidth%
%%%    \advance\@tempdima-1.8em%
%%%    \parbox[t]{\@tempdima}{#1}
%%%    }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%\@ifpackageloaded{amsgen}{}{\input{amsgen.sty}}
%%%        from amsgen.sty
\let\@xp=\expandafter
\let\@nx=\noexpand
\def\@oparg#1[#2]{\@ifnextchar[{#1}{#1[#2]}}
\long\def\@ifempty#1{\@xifempty#1@@..\@nil}
\long\def\@xifempty#1#2@#3#4#5\@nil{%
  \ifx#3#4\@xp\@firstoftwo\else\@xp\@secondoftwo\fi}
\long\def\@ifnotempty#1{\@ifempty{#1}{}}
\def\@addpunct#1{\ifnum\spacefactor>\@m \else#1\fi}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% from  amsthm.sty [1996/10/24 v1.2d]
\newcommand{\theoremstyle}[1]{%
  \@ifundefined{th@#1}{%
    \PackageWarning{amsthm}{Unknown theoremstyle `#1'}%
    \thm@style{plain}%
  }{%
    \thm@style{#1}%
  }%
}
\newtoks\thm@style
\thm@style{plain}
\newtoks\thm@bodyfont
\thm@bodyfont{\itshape}
\newtoks\thm@headfont
\thm@headfont{\bfseries}
\newtoks\thm@notefont
\thm@notefont{\rm }
\newtoks\thm@headpunct
\thm@headpunct{.}
\newtoks\thm@numberfont
\thm@numberfont{\bfseries\upshape}
%%%\newskip\thm@preskip \thm@preskip\topsep
\newskip\thm@preskip \thm@preskip8pt plus2pt minus2pt
%%%\newskip\thm@postskip \thm@postskip\topsep
\newskip\thm@postskip \thm@postskip8pt plus2pt minus2pt
\renewcommand{\newtheorem}{\@ifstar{\@xnthm *}{\@xnthm \relax}}
\def\@xnthm#1#2{%
  \let\@tempa\relax
  \@xp\@ifdefinable\csname #2\endcsname{%
    \global\@xp\let\csname end#2\endcsname\@endtheorem
    \ifx *#1% unnumbered, need to get one more mandatory arg
      \edef\@tempa##1{%
        \gdef\@xp\@nx\csname#2\endcsname{%
          \@nx\@thm{\@xp\@nx\csname th@\the\thm@style\endcsname}%
            {}{##1}}}%
    \else % numbered theorem, need to check for optional arg
      \def\@tempa{\@oparg{\@ynthm{#2}}[]}%
    \fi
  }%
  \@tempa
}
\def\@ynthm#1[#2]#3{%
  \ifx\relax#2\relax
    \def\@tempa{\@oparg{\@xthm{#1}{#3}}[]}%
  \else
    \@ifundefined{c@#2}{%
      \def\@tempa{\@nocounterr{#2}}%
    }{%
      \@xp\xdef\csname the#1\endcsname{\@xp\@nx\csname the#2\endcsname}%
      \toks@{#3}%
      \@xp\xdef\csname#1\endcsname{%
        \@nx\@thm{%
          \let\@nx\thm@swap
            \if S\thm@swap\@nx\@firstoftwo\else\@nx\@gobble\fi
          \@xp\@nx\csname th@\the\thm@style\endcsname}%
            {#2}{\the\toks@}}%
      \let\@tempa\relax
    }%
  \fi
  \@tempa
}
\def\@xthm#1#2[#3]{%
  \ifx\relax#3\relax
    \newcounter{#1}%
  \else
    \newcounter{#1}[#3]%
    \@xp\xdef\csname the#1\endcsname{\@xp\@nx\csname the#3\endcsname
      \@thmcountersep\@thmcounter{#1}}%
  \fi
  \toks@{#2}%
  \@xp\xdef\csname#1\endcsname{%
    \@nx\@thm{%
      \let\@nx\thm@swap
        \if S\thm@swap\@nx\@firstoftwo\else\@nx\@gobble\fi
      \@xp\@nx\csname th@\the\thm@style\endcsname}%
      {#1}{\the\toks@}}%
}
\def\@thm#1#2#3{\normalfont
  \trivlist
  \edef\@restorelabelsep{\labelsep\the\labelsep}%
  \labelsep.55em\relax \let\thmheadnl\relax
  \let\thm@indent\noindent % no indent
%  \let\thm@indent\indent % no indent
  \let\thm@swap\@gobble
  \thm@headfont{\bfseries}% heading font bold
  \thm@numberfont{\bfseries}% heading font bold
  \thm@headpunct{.}% add period after heading
%%%  \thm@preskip\topsep
  \thm@preskip \abovedisplayskip
  \thm@postskip\thm@preskip
  #1% style overrides
  \@topsep \thm@preskip               % used by first \item
  \@topsepadd \thm@postskip           % used by \@endparenv
  \def\@tempa{#2}\ifx\@empty\@tempa
    \def\@tempa{\@oparg{\@begintheorem{#3}{}}[]}%
  \else
    \refstepcounter{#2}%
    \def\@tempa{\@oparg{\@begintheorem{#3}{\csname the#2\endcsname}}[]}%
  \fi
  \@tempa
}
\let\@ythm\relax
\let\thmname\@iden \let\thmnote\@iden \let\thmnumber\@iden
\providecommand\@upn{\textup}
\def\thmhead@plain#1#2#3{%
%%%  \thmname{#1}\thmnumber{\@ifnotempty{#1}{ }#2}%
  \thmname{#1}\thmnumber{\@ifnotempty{#1}{ }#2}%
 \thmnote{ {\the\thm@notefont(#3)}\rm}}
%%%  \thmnote{ {\the\thm@notefont #3}}}
\let\thmhead\thmhead@plain
\def\swappedhead#1#2#3{%
  \thmnumber{#2}\thmname{\@ifnotempty{#2}{. }#1}%
%%%  \thmnote{ {\the\thm@notefont (#3)}}}
  \thmnote{ {\the\thm@notefont (#3)}}}
\let\thmheadnl\relax
\def\@begintheorem#1#2[#3]{%
  \item[\normalfont % reset in case body font is abnormal
  \hskip\labelsep
  \the\thm@headfont
  \thm@indent
  \@ifempty{#1}{\let\thmname\@gobble}{\let\thmname\@iden}%
  \@ifempty{#2}{\let\thmnumber\@gobble}{\let\thmnumber\@iden}%
  \@ifempty{#3}{\let\thmnote\@gobble}{\let\thmnote\@iden}%
%%%  \thm@swap\swappedhead\thmhead{#1}{#2}{#3}%
  \thm@swap\swappedhead\thmhead{#1}
  {\the\thm@numberfont{#2}}
  {\rm{#3}}%
%%%  \the\thm@headpunct]%
  \the\thm@headpunct]%
  \@restorelabelsep
  \thmheadnl % possibly a newline.
  \ignorespaces}
\def\nonslanted{\relax
  \@xp\let\@xp\@tempa\csname\f@shape shape\endcsname
  \ifx\@tempa\itshape\upshape
  \else\ifx\@tempa\slshape\upshape\fi\fi}
\def\swapnumbers{\edef\thm@swap{\if S\thm@swap N\else S\fi}}
\def\thm@swap{N}%
\let\@opargbegintheorem\relax
%%%
%%% plain %%%%%%%%%%%%%%%%%%%
\def\th@plain{%
%%  \let\thm@indent\noindent % no indent
%%  \thm@headfont{\bfseries}% heading font is bold
%%  \thm@numberfont{\bfseries}% number font is bold
%%  \thm@notefont{}% same as heading font
%%  \thm@headpunct{.}% add period after heading
%%  \let\thm@swap\@gobble
%%  \thm@preskip\topsep
%%  \thm@postskip\theorempreskipamount
  \itshape % body font
}
%%%
%%% definition %%%%%%%%%%%%%%
\def\th@definition{%
  \normalfont % body font
}
%%%
%%% remark %%%%%%%%%%%%%%%%%%
\def\th@remark{%
  \thm@headfont{\itshape}%
%%%  \thm@numberfont{\itshape}%
  \thm@numberfont{\rm}%
  \normalfont % body font
%%%  \thm@preskip\topsep
  \thm@preskip \abovedisplayskip
%%%  \divide\thm@preskip\tw@
  \thm@postskip\thm@preskip
}
%%%
\def\@endtheorem{\endtrivlist\@endpefalse }
\newcommand{\newtheoremstyle}[9]{%
  \@ifempty{#5}{\dimen@\z@skip}{\dimen@#5\relax}%
  \ifdim\dimen@=\z@
%%%    \toks@{#4\let\thm@indent\noindent}%
    \toks@{#4\let\thm@indent\indent}%
  \else
%%%    \toks@{#4\def\thm@indent{\noindent\hbox to#5{}}}%
    \toks@{#4\def\thm@indent{\indent\hbox to#5{}}}%
  \fi
  \def\@tempa{#8}\ifx\space\@tempa
    \toks@\@xp{\the\toks@ \labelsep\fontdimen\tw@\font\relax}%
  \else
    \def\@tempb{\newline}%
    \ifx\@tempb\@tempa
      \toks@\@xp{\the\toks@ \labelsep\z@skip
        \def\thmheadnl{%
          \@noskipsectrue \global\@nobreaktrue
          \everypar{\global\@minipagefalse \global\@newlistfalse
            \global\@inlabelfalse \global\@nobreakfalse
            {\setbox\z@\lastbox}\box\@labels\par
            \nobreak\vskip-\parskip
            \everypar{}\noindent}}%
      }%
    \else
      \toks@\@xp{\the\toks@ \labelsep#8\relax}%
    \fi
  \fi
  \begingroup \th@plain % to set \thm@preskip and postskip
  \@defaultunits\@tempskipa#2\thm@preskip\relax\@nnil
  \@defaultunits\@tempskipb#3\thm@postskip\relax\@nnil
  \xdef\@gtempa{\thm@preskip\the\@tempskipa
    \thm@postskip\the\@tempskipb\relax}%
  \endgroup
  \@temptokena\@xp{\@gtempa
    \thm@headfont{#6}\thm@headpunct{#7}%
  }%
  \@ifempty{#9}{%
    \let\thmhead\thmhead@plain
  }{%
    \@namedef{thmhead@#1}##1##2##3{#9}%
    \@temptokena\@xp{\the\@temptokena
      \@xp\let\@xp\thmhead\csname thmhead@#1\endcsname}%
  }%
  \@xp\xdef\csname th@#1\endcsname{\the\toks@ \the\@temptokena}%
}
%%% Proof %%%%%%%%%%%%%%%%%%%%
\DeclareRobustCommand{\qed}{%
  \ifmmode % if math mode, assume display: omit penalty etc.
  \else \leavevmode\unskip\penalty9999 \hbox{}\nobreak\hfill
  \fi
  \quad\hbox{\qedsymbol}}
\newcommand{\openbox}{\leavevmode
  \hbox to.77778em{%
  \hfil\vrule
  \vbox to.675em{\hrule width.6em\vfil\hrule}%
  \vrule\hfil}}
\newcommand{\qedsymbol}{\openbox}
\newenvironment{proof}[1][\proofname]{\vskip-\lastskip\par
%%%  \vskip \abovedisplayskip%
\vskip 8pt plus2pt minus2pt%  \vskip \parsep%
  \normalfont
%%%  \topsep6\p@\@plus6\p@ \trivlist
%%%  \item[\hskip\labelsep\itshape
%%%    #1\@addpunct{.}]\ignorespaces
\noindent  {\itshape
  #1\@addpunct{.}}\hspace{.55em}\mdseries \ignorespaces
}{%
  \qed%\endtrivlist
  {\vskip 8pt plus2pt minus2pt }
}
\newcommand{\proofname}{Proof}
%new environment to replicate \qedhere (add \qedsymbol manually to text)
\newenvironment{qproof}[1][\proofname]{\vskip-\lastskip\par
%%%  \vskip \abovedisplayskip%
\vskip 8pt plus2pt minus2pt%  \vskip \parsep%
  \normalfont
%%%  \topsep6\p@\@plus6\p@ \trivlist
%%%  \item[\hskip\labelsep\itshape
%%%    #1\@addpunct{.}]\ignorespaces
\noindent  {\itshape
  #1\@addpunct{.}}\hspace{.55em}\mdseries \ignorespaces
}{%
  %\qed%\endtrivlist <--- no box placed by qproof
  {\vskip 8pt plus2pt minus2pt }
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% end  amsthm.sty [1996/10/24 v1.2d]  by  HIK NACOS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%





\newenvironment{thebibliography}[1]
     {\section*{\refname
        \@mkboth{\MakeUppercase\refname}{\MakeUppercase\refname}%
        \addcontentsline{toc}{section}{References}}\vskip5pt%
      \footnotesize%%%
      \list{\@biblabel{\@arabic\c@enumiv}}%
           {%
            \setlength{\parsep}{0pt}%%%
            \setlength{\itemsep}{3pt plus 0.5pt minus 0.5pt}%%%
            \settowidth\labelwidth{\@biblabel{#1}}%
            \leftmargin\labelwidth
            \advance\leftmargin\labelsep
            \usecounter{enumiv}%
            \let\p@enumiv\@empty
            \renewcommand\theenumiv{\@arabic\c@enumiv}}%
      \sloppy
      \clubpenalty4000
      \@clubpenalty \clubpenalty
      \widowpenalty4000%
      \sfcode`\.\@m}
     {\def\@noitemerr
       {\@latex@warning{Empty `thebibliography' environment}}%
      \endlist}
\newcommand\newblock{\hskip .11em\@plus.33em\@minus.07em}

\def\@lbibitem[#1]#2{\item[\hfill\@biblabel{#1}]\if@filesw
      {\let\protect\noexpand
       \immediate
       \write\@auxout{\string\bibcite{#2}{#1}}}\fi\ignorespaces}

\providecommand{\bysame}{\leavevmode\hbox to3em{\hrulefill}\thinspace}



\newenvironment{theindex}
               {\if@twocolumn
                  \@restonecolfalse
                \else
                  \@restonecoltrue
                \fi
                \columnseprule \z@
                \columnsep 35\p@
                \twocolumn[\section*{\indexname}]%
                \@mkboth{\MakeUppercase\indexname}%
                        {\MakeUppercase\indexname}%
                \thispagestyle{plain}\parindent\z@
                \parskip\z@ \@plus .3\p@\relax
                \let\item\@idxitem}
               {\if@restonecol\onecolumn\else\clearpage\fi}
\newcommand\@idxitem{\par\hangindent 40\p@}
\newcommand\subitem{\@idxitem \hspace*{20\p@}}
\newcommand\subsubitem{\@idxitem \hspace*{30\p@}}
\newcommand\indexspace{\par \vskip 10\p@ \@plus5\p@ \@minus3\p@\relax}



\newcommand\contentsname{Contents}
\newcommand\listfigurename{List of Figures}
\newcommand\listtablename{List of Tables}
\newcommand\refname{References}
\newcommand\indexname{Index}
\newcommand\figurename{Figure}
\newcommand\tablename{Table}
\newcommand\partname{Part}
\newcommand\sectionname{\S}
\newcommand\appendixname{Appendix}


\newcommand\dash{%
  \raise .65ex\hbox{\vrule width 36pt height 0.4pt depth 0pt}}


%%% language
\ems@check{lang}{french}{\PassOptionsToPackage{shorthands = off}{babel}%\AtBeginDocument{\selectlanguage{french}\shorthandon{:}\protected\edef:{\unexpanded\expandafter{:}}\shorthandoff{:}}
}{\PassOptionsToPackage{shorthands = off}{babel}}
\RequirePackage[american, british, french, \@ems@lang]{babel}%french, 
\lefthyphenmin \tw@
\righthyphenmin \thr@@
\renewcommand*\americanhyphenmins{33}
\renewcommand*\britishhyphenmins{33}
\renewcommand*\frenchhyphenmins{23}
\ifFB@mainlanguage@FR
	\frenchsetup{
		StandardLayout = true,
		SmallCapsFigTabCaptions = false
	}
\fi

\clubpenalty \@M
\widowpenalty \@M

\doublehyphendemerits 100000000\relax
%%% end language block

\frenchspacing
\clubpenalty=10000
\widowpenalty=10000

\def\today{\ifcase\month\or
  January\or February\or March\or April\or May\or June\or
  July\or August\or September\or October\or November\or December\fi
  \space\number\day, \number\year}
\setlength\columnsep{10\p@}
\setlength\columnseprule{0\p@}
\pagestyle{headings}
\pagenumbering{arabic}
\normalfont
\normalsize

\newcommand{\bm}[1]{\hbox{\boldmath$#1$}}%
\newcommand{\sbm}[1]{\hbox{\scriptsize\boldmath$#1$}}%

\RequirePackage{amsmath}

\def\xhref#1#2{\hskip.55em plus.2em\href{#1}{\hbox{#2}}}
\def\Zblpre #1 {\xhref{http://www.zentralblatt-math.org/zmath/en/advanced/?q=an:#1&format=complete}{Zbl pre#1}}
\newcommand{\Zbl}[1]{\xhref{http://www.zentralblatt-math.org/zmath/en/advanced/?q=an:#1&format=complete}{Zbl #1}}
\newcommand{\MR}[1]{\xhref{http://www.ams.org/mathscinet-getitem?mr=#1}{MR #1}}
\newcommand{\JFM}[1]{\xhref{http://www.zentralblatt-math.org/zmath/en/advanced/?q=an:#1&format=complete}{JFM #1}}
\newcommand\arx[1]{\href{http://arxiv.org/abs/#1}{\hbox{arXiv:#1}}}
\newcommand\mydoi[1]{\href{http://dx.doi.org/#1}{\hbox{doi:#1}}}
\newcommand\myhref[1]{\href{#1}{\hbox{#1}}}

\RequirePackage[hyphens]{url}
%%% do not break http:// at colon
\patchcmd\UrlBreaks{\do\/}{}{}{\ems@warnpatch{UrlBreaks}}
\appto\UrlBigBreaks{\do\/}{}{}
\urlstyle{same}
%\RequirePackage[psdextra]{hyperref}
\RequirePackage[pdfa]{hyperref}
\hypersetup{ pdfencoding = auto, psdextra }
%\hypersetup{colorlinks=true, allcolors=blue, breaklinks}%backref blue orange
\ems@check{mode}{print}%
	{\hypersetup{ draft, pdftrapped = false }}%
	{\hypersetup{ allcolors = %emsblue
blue, colorlinks, bookmarksdepth = 3, breaklinks }}%bookmarksnumbered, 

\pdfstringdefDisableCommands{%
	\def\titlebreak{\space\ignorespaces}%
	\def\tocbreak{\space\ignorespaces}%
	\let\,\space
	\let\\\textbackslash
	\let\boldmath\relax
	\let\nobreakdash\relax
	\let\sb\textunderscore
	\let\sp\textasciicircum
	\let\unskip\relax
%	\def\hbox#1{#1}%
}

\geometry{
%	heightrounded,
	includehead,
	marginparwidth = 16mm, %%?
	paperheight = 240mm,
	paperwidth = 170mm,
%	textwidth = 357pt,
  textwidth = 125mm,
  textheight = 524pt,
%	top = 13mm,
  top = 18mm,
  headsep = 15pt, %%!
	twoside %%?
}

\ems@check{mode}{online}%
	{\geometry{ hmarginratio = {1:1}, asymmetric }}%
	{\geometry{ inner = 20mm }}
\ems@check{mode}{work}{\geometry{ showframe } \overfullrule 1em\relax}{}
%\geometry{ twoside, inner = 20mm}%print
%\geometry{ hmarginratio = {1:1}, asymmetric}%online
%\hypersetup{%
%pdftitle=\@title,
%pdfauthor=\@author@abbr}
%colorlinks=true, allcolors=blue, breaklinks %backref blue orange

\endinput
%%
%% End of file `ems-journal-prims.cls'.
