%%
%% This is file `bmzhart.cls'.
%%
%%
%%
%% ---------------------------------------------------
%%   This system is distributed in the hope that it will be useful,
%%   but WITHOUT ANY WARRANTY; without even the implied warranty of
%%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
%%
%% IMPORTANT COPYRIGHT NOTICE:
%%
%% Permission is granted to customize the declarations in this file to
%% serve the needs of your installation.
%%
%% However, NO PERMISSION is granted to distribute a modified version
%% of this file under its original name.
%%
%%
%% MODIFICATION ADVICE:
%%
%% If you want to customize this file, it is best to make a copy of
%% the source file(s) from which it was produced.  Use a different
%% name for your copy(ies) and modify the copy(ies); this will ensure
%% that your modifications do not get overwritten when you install a
%% new release of the standard system.
%%
%% You can then easily distribute your modifications by distributing
%% the modified and renamed copy of the source file.
%%
%%
\ProvidesClass{bmzhart}
[2014/06/07 v0.3 style for Bukovinian mathematical journal]
%
\makeatletter
\def\pj@theoname{Theorem}
\def\pj@proponame{Proposition}
\def\pj@lemmaname{Lemma}
\def\pj@corolname{Corollary}
\def\pj@remarkname{Remark}
\def\pj@defname{Definition}
\def\pj@exampname{Example}
\def\pj@exampsname{Examples}
\def\pj@recname{Received}
\def\pj@revname{Revised}
\def\pj@keywname{Key words and phrases}
\def\pj@unusedbib{Unused}

\def\pj@ddmain{english}
%
\DeclareOption{ua}{%
    \def\pj@ddmain{ukrainian}%
    \def\pj@theoname{\CYRT\cyre\cyro\cyrr\cyre\cyrm\cyra}%
    \def\pj@proponame{\CYRT\cyrv\cyre\cyrr\cyrd\cyrzh\cyre\cyrn\cyrn\cyrya}%
    \def\pj@lemmaname{\CYRL\cyre\cyrm\cyra}%
    \def\pj@corolname{\CYRN\cyra\cyrs\cyrl\cyrii\cyrd\cyro\cyrk}%
    \def\pj@remarkname{\CYRZ\cyra\cyru\cyrv\cyra\cyrzh\cyre\cyrn\cyrn\cyrya}%
    \def\pj@defname{\CYRO\cyrz\cyrn\cyra\cyrch\cyre\cyrn\cyrn\cyrya}%
    \def\pj@exampname{\CYRP\cyrr\cyri\cyrk\cyrl\cyra\cyrd}%
    \def\pj@exampsname{\CYRP\cyrr\cyri\cyrk\cyrl\cyra\cyrd\cyri}%
    \def\pj@recname{\CYRN\cyra\cyrd\cyrii\cyrishrt\cyrsh\cyrl\cyro}%
    \def\pj@revname{\CYRP\cyrii\cyrs\cyrl\cyrya\ \cyrp\cyre\cyrr\cyre\cyrr\cyro\cyrb\cyrk\cyri}%
    \def\pj@keywname{\CYRK\cyrl\cyryu\cyrch\cyro\cyrv\cyrii\ \cyrs\cyrl\cyro\cyrv\cyra\ \cyrii\ \cyrf\cyrr\cyra\cyrz\cyri}%
}
%
\DeclareOption{en}{%
    \def\pj@ddmain{english}%
    \def\pj@theoname{Theorem}%
    \def\pj@proponame{Proposition}%
    \def\pj@lemmaname{Lemma}%
    \def\pj@corolname{Corollary}%
    \def\pj@remarkname{Remark}%
    \def\pj@defname{Definition}%
    \def\pj@exampname{Example}%
    \def\pj@exampsname{Examples}%
    \def\pj@recname{Received}%
    \def\pj@revname{Revised}%
    \def\pj@keywname{Key words and phrases}%
}

\DeclareOption{win}{\PassOptionsToPackage{cp1251}{inputenc}}
\DeclareOption{koi}{\PassOptionsToPackage{koi8-u}{inputenc}}
\PassOptionsToPackage{cp1251}{inputenc}


\let\ifpj@draft\iffalse
\let\ifpj@othsec\iffalse
\let\ifpj@thmsec\iffalse

\DeclareOption{draft}{\let\ifpj@draft\iftrue \PassOptionsToClass{draft}{article}}
\DeclareOption{bysec}{\let\ifpj@othsec\iftrue}
\DeclareOption{thmbysec}{\let\ifpj@thmsec\iftrue \let\ifpj@othsec\iftrue}

\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}

\ProcessOptions

\LoadClass[a4paper]{article}

% Page parameters

\topmargin=-15mm
\oddsidemargin=0mm
\evensidemargin=0mm
\headsep=0mm
\headheight=0pt
\headsep=6mm
\headheight=12pt
\textheight=682pt
\textwidth=165mm

\edef\pj@babelopts{english,ukrainian,\pj@ddmain}
\let\@xp\expandafter
\@xp\PassOptionsToPackage\@xp{\pj@babelopts}{babel}

\let\englishhyphenmins\undefined
\usepackage{inputenc}
\usepackage{babel}
\usepackage[T2A]{fontenc}
\usepackage{amsmath,amsfonts,amsthm,amssymb,latexsym}

% Restore numero sign
%\DeclareRobustCommand{\No}{%
%   \ifmmode{\nfss@text{\textnumero}}\else\textnumero\fi}

\def\th@plain{\slshape} % instead of \itshape
\theoremstyle{plain}

\ifpj@thmsec
\newtheorem{theorem}{\pj@theoname}[section]
\else
\newtheorem{theorem}{\pj@theoname}
\fi

\ifpj@othsec
\newtheorem{proposition}{\pj@proponame}[section]
\newtheorem{lemma}{\pj@lemmaname}[section]
\newtheorem{corollary}{\pj@corolname}[section]
\newtheorem{remark}{\pj@remarkname}[section]
\newtheorem{definition}{\pj@defname}[section]
\newtheorem{example}{\pj@exampname}[section]
\newtheorem{examples}[example]{\pj@exampsname}
\else
\newtheorem{proposition}{\pj@proponame}
\newtheorem{lemma}{\pj@lemmaname}
\newtheorem{corollary}{\pj@corolname}
\newtheorem{remark}{\pj@remarkname}
\newtheorem{definition}{\pj@defname}
\newtheorem{example}{\pj@exampname}
\newtheorem{examples}[example]{\pj@exampsname}
\fi

\newtheorem*{theorem*}{\pj@theoname}
\newtheorem*{proposition*}{\pj@proponame}
\newtheorem*{lemma*}{\pj@lemmaname}
\newtheorem*{corollary*}{\pj@corolname}
\newtheorem*{remark*}{\pj@remarkname}
\newtheorem*{definition*}{\pj@defname}
\newtheorem*{example*}{\pj@exampname}
\newtheorem*{examples*}{\pj@exampsname}

\let\pj@shorttitle\empty
\newcommand\shorttitle[1]{%
  \gdef\pj@shorttitle{#1}}

\let\pj@addresses\empty
\newcommand\institute[1]{%
  \ifx\pj@addresses\empty
      \gdef\pj@addresses{#1}%
  \else
      \g@addto@macro\pj@addresses{\par\vskip 0.1in \noindent #1.}%
  \fi}

\let\@email\empty
\newcommand\email[1]{%
  \gdef\@email{\hfil e-mail:\ {\itshape #1} \hfil}}

\let\pj@volume\empty
\newcommand\volume[1]{%
  \gdef\pj@volume{#1}}

\let\pj@issue\empty
\newcommand\issue[1]{%
  \gdef\pj@issue{#1}}

\@xp\gdef\@xp\pj@year\@xp{\the\year}
\newcommand\pyear[1]{%
  \gdef\pj@year{#1}}

\let\pj@UDC\empty
\newcommand\UDC[1]{%
  \gdef\pj@UDC{#1}}

\let\pj@subjclass\empty
\newcommand\subjclass[1]{%
  \gdef\pj@subjclass{#1}}

\let\pj@thanks\empty
\renewcommand\thanks{}
\long\def\thanks#1{%
  \gdef\pj@thanks{#1}}

\let\pj@keywords\empty
\newcommand\keywords[1]{%
  \gdef\pj@keywords{#1}}

\let\pj@received\empty
\newcommand\received[1]{%
  \gdef\pj@received{#1}}

\let\pj@revised\empty
\newcommand\revised[1]{%
  \gdef\pj@revised{#1}}

\def\pj@pages{%
  \ifx\pj@endpage\undefined
    1--???
  \else
    \ifx\pj@startpage\pj@endpage
      \pj@startpage
    \else
      \pj@startpage--\pj@endpage
    \fi
  \fi
}%

\def\pj@evolinfo{%
  \ifx\pj@volume\empty
    \texfbf{???}%
  \else
    \textbf{\pj@volume}%
  \fi
  \ifx\pj@issue\empty
  \else
    , \pj@issue
  \fi
}%

\def\pj@uvolinfo{%
  \CYRT.%
  \ifx\pj@volume\empty
    ???%
  \else
    \pj@volume
  \fi
  \ifx\pj@issue\empty
  \else
    ,\ \No \pj@issue
  \fi
}%

\newcommand\enabstract{}
\newcommand\uaabstract{}

\let\pj@enauthtitle\empty
\let\pj@enabstract\empty

\long\def\enabstract#1#2#3#4{
  \gdef\pj@enauthtitle{#1 {\it #2}}%
  \global\long\def\pj@enabstract{#3}%
  \gdef\pj@enkeywords{#4}
}

\let\pj@ukauthtitle\empty
\let\pj@ukabstract\empty

\long\def\uaabstract#1#2#3#4{
  \gdef\pj@ukauthtitle{#1 {\it #2}}%
  \global\long\def\pj@ukabstract{#3}%
  \gdef\pj@uakeywords{#4}
}

\def\contentslistfile#1{%
  \gdef\contents@list@file{#1}%
}

\@onlypreamble\contentslistfile

\newcounter{ipn}

\newif\if@ipnexists
\newif\if@contlistexists
\@ipnexistsfalse
\@contlistexistsfalse

\def\check@start@end@pages{%
   \gdef\pj@startpage{1}%
   \global\let\pj@endpage\undefined
   \IfFileExists{\jobname.ipn}{%
     \@ipnexiststrue
   }{%
     \@ipnexistsfalse
   }%
   \ifx\contents@list@file\undefined
     \@contlistexistsfalse
   \else
        \IfFileExists{\contents@list@file}{%
          \@contlistexiststrue
        }{%
          \@contlistexistsfalse
        }%
   \fi
   \if@contlistexists
           \begingroup
             \def\startpage##1{\global\c@ipn ##1\relax}%
             \def\issueinfo##1##2##3{%
               \gdef\pj@volume{##1}%
               \gdef\pj@issue{##2}%
               \gdef\pj@year{##3}%
             }%
             \def\artfile{%
               \begingroup
                 \@tempcnta 1
                 \def\@tempa{%
                   \ifnum\@tempcnta<256
                     \catcode\@tempcnta=12
                     \advance\@tempcnta by 1
                   \else
                     \let\@tempa\relax
                   \fi
                   \@tempa
                 }%
                 \@tempa
                 \catcode`\{=1
                 \catcode`\}=2
%                \catcode`\ =?
                 \def\@tempa####1{%
                   \endgroup
                   \@artfile{####1}%
                 }%
                 \@tempa
             }%
             \def\@artfile##1{%
               \edef\@tempa{\jobname}%
               \filename@parse{##1}%
               \ifx\@tempa\filename@base
                 \xdef\pj@startpage{\the\c@ipn}%
                 \def\pagespan####1####2{%
                   \advance\c@ipn by -####1
                   \advance\c@ipn by ####2
                   \xdef\pj@endpage{\the\c@ipn}%
                 }%
                 \@input{\pj@list@root\filename@area\filename@base.ipn}%
                 \endinput
               \else
                 \@input{\pj@list@root\filename@area\filename@base.ipn}%
               \fi
             }%
             \def\eartinfo##1{}%
             \def\uartinfo##1{}%
             \def\rartinfo##1{}%
             \def\pagespan##1##2{%
               \advance\c@ipn by -##1
               \advance\c@ipn by ##2
               \global\advance\c@ipn by 1
               \xdef\pj@startpage{\the\c@ipn}%
             }%
             \c@ipn=1
             \filename@parse{\contents@list@file}%
             \ifx\filename@area\empty
               \let\pj@list@root\empty
             \else
               \edef\pj@list@root{\filename@area/}
             \fi
             \input{\contents@list@file}%
             \global\c@page\pj@startpage
           \endgroup
    \else
      \if@ipnexists
           \def\eartinfo##1{}%
           \def\uartinfo##1{}%
           \def\rartinfo##1{}%
           \def\pagespan##1##2{%
                \gdef\pj@startpage{##1}%
                \gdef\pj@endpage{##2}%
                \global\c@page\pj@startpage
           }%
           \input{\jobname.ipn}%
      \else
           \@xp\gdef\@xp\pj@startpage\@xp{\the\c@page}%
      \fi
    \fi
}
\newwrite\@ipnfile

\def\write@start@end@pages{%
   \begingroup
     \immediate\openout\@ipnfile \jobname.ipn
     \let\protect\@unexpandable@protect
     \ifx\pj@enauthtitle\empty \else
       \edef\@tempa{\string\eartinfo{\pj@enauthtitle}}%
       \@xp\immediate\@xp\write\@xp\@ipnfile\@xp{\@tempa}%
     \fi
     \ifx\pj@ukauthtitle\empty \else
       \edef\@tempa{\string\uartinfo{\pj@ukauthtitle}}%
       \@xp\immediate\@xp\write\@xp\@ipnfile\@xp{\@tempa}%
     \fi
     \edef\@tempa{\string\pagespan{\pj@startpage}}%
     \@xp\immediate\@xp\write\@xp\@ipnfile\@xp{\@tempa{\the\c@page}}%
     \immediate\closeout\@ipnfile
   \endgroup
}

\AtBeginDocument{%
    \check@start@end@pages
    \let\volume\undefined
    \let\issue\undefined
    \let\pyear\undefined
    \let\shorttitle\undefined
    \let\UDC\undefined
    \let\subjclass\undefined
    \let\keywords\undefined
    \let\received\undefined
    \let\revised\undefined
    \renewcommand{\refname}{References}
}

\long\def\maketitle{%
    \ifpj@draft
       \ifx\@author\empty  \def\@author{??}\fi
       \ifx\@title\empty  \def\@title{??}\fi
       \ifx\pj@UDC\empty  \def\pj@UDC{??}\fi
       \ifx\pj@subjclass\empty  \def\pj@subjclass{??}\fi
       \ifx\pj@received\empty  \def\pj@received{??}\fi
       \ifx\pj@enauthtitle\empty
         \def\pj@enauthtitle{\@author. {\it \@title}}%
         \def\pj@enabstract{This paper \dots}%
       \fi
       \ifx\pj@ukauthtitle\empty
         \def\pj@ukauthtitle{\@author. {\it \@title}}%
         \def\pj@ukabstract{\CYRS\cyrt\cyra\cyrt\cyrt\cyrya\ \cyrp\cyrr\cyro\ \dots}%
       \fi
    \fi
    \ifx\pj@shorttitle\empty  \let\pj@shorttitle\@title \fi
    \@xp\gdef\@xp\pj@firstpage\@xp{\the\c@page}%
    \markboth{{\@author}}{{\pj@shorttitle}}%
    \footnotetext{\textup{\scriptsize{\Ukrainian \CYRU\CYRD\CYRK\ \pj@UDC}}}
    \ifx\pj@subjclass\empty \else
       \footnotetext{\textrm{2010 \textit{Mathematics Subject
           Classification:\/}\,\pj@subjclass.}}
    \fi
    \hbox to \textwidth{\scriptsize\sffamily
      Bukovinian Math. Journal. \pj@year, \pj@evolinfo, \pj@pages\hfill
      \CYRB\cyru\cyrk\cyro\cyrv\cyri\cyrn\cyrs\cyrsftsn\cyrk\cyri\cyr\u{\cyri}\
      \cyrm\cyra\cyrt\cyre\cyrm.\
	  \cyrzh\cyru\cyrr\cyrn\cyra\cyrl\
      \pj@year, \pj@uvolinfo, \pj@pages
}

    \ifx\pj@keywords\empty \else
       \footnotetext{\textrm{\textit{\pj@keywname:\/}\;\pj@keywords.}}
    \fi

    \vspace{0.3in}
    \ifx\pj@subjclass\empty \else
    \fi

    \ifx\pj@thanks\empty \else
       \footnotetext{\textrm{\pj@thanks}}
    \fi

    \ifx\@author\empty \else
        \begin{center} \textsc {\@author} \end{center}%
    \fi
    \ifx\@title\empty \else
        \let\@tempa\@title
        \begin{center} \renewcommand{\baselinestretch}{1.3}%
        \bf {\MakeUppercase\@tempa} \end{center}%
    \fi

    \vspace{20pt plus 0.5pt} {
        \footnotesize
        \vspace{-.5em}\vspace{0pt}
        \quotation
        \def\@tempa{english}
        \def\@tempb{ukrainian}
        \ifx\pj@ddmain\@tempa
         \ifx\pj@enauthtitle\empty \else
           \English
           \par%
           \pj@enabstract
           \par%
           {\itshape \pj@keywname:\/}\; \pj@enkeywords.\\
           \vrule height 0.5truept width 0.15\hsize
           \pj@printaddress
         \fi
        \else
        \ifx\pj@ddmain\@tempb
         \ifx\pj@ukauthtitle\empty \else
           \par\bigskip
           \Ukrainian
           \par%
           \pj@ukabstract
           \par%
           {\itshape \pj@keywname:\/}\; \pj@uakeywords.\\
           \vrule height 0.5truept width 0.15\hsize
           \pj@printaddress
         \fi
        \fi\fi
        \endquotation
     }
     \vskip40pt
} % end of \maketitle

\def\pj@printabstracts{
    \vspace{10pt plus 0.5pt}
    \centerline{\hfill\vrule height 1truept width 0.25\hsize\relax\hfill}
    \vspace{10pt plus 0.5pt} {
        \footnotesize
        \vspace{-.5em}\vspace{0pt}
        \quotation
%         \def\@tempa{english}
%         \ifx\pj@ddmain\@tempa \else
%          \ifx\pj@enauthtitle\empty \else
%            \English
%            \noindent \pj@enauthtitle,
%            Car\-pa\-thian\
%            Math.\
%            Publ.\
%            \pj@evolinfo\ (\pj@year), \pj@pages.
%            \par\vspace{3pt}%
%            \pj@enabstract
%          \fi
%         \fi
        \def\@tempb{ukrainian}
        \ifx\pj@ddmain\@tempb \else
         \ifx\pj@ukauthtitle\empty \else
           \par\bigskip
           \Ukrainian
           \noindent \pj@ukauthtitle\ \sep
           \CYRK\cyra\cyrr\-\cyrp\cyra\cyrt\-\cyrs\cyrsftsn\cyrk\cyrii\
           \cyrm\cyra\-\cyrt\cyre\cyrm.\
           \cyrp\cyru\cyrb\cyrl.\
           ---~\pj@year.\ ---~\pj@uvolinfo. ---~C. \pj@pages.
           \par\vspace{3pt}%
           \pj@ukabstract
         \fi
        \fi
        \endquotation
     }
     \vskip15pt
}


\pagestyle{myheadings}

\newcommand\sep{/\kern-2pt/ }

\newcommand{\pageno}[1]{\setcounter{page}{#1}}
\renewcommand{\@biblabel}[1]{#1.\hfill}

\renewcommand{\section}{\@startsection{section}{1}{0pt}{3.5ex plus
    1ex minus .2ex}{2.3ex plus 2.ex}{\hfil\textsc}}

\renewcommand{\@evenhead}{\footnotesize
    \ifnum\c@page=\pj@firstpage \else \thepage \hfil \textsc {\leftmark}\fi \hfil}
\renewcommand{\@oddhead}{\footnotesize
    \hfil\ifnum\c@page=\pj@firstpage \else \textsc {\rightmark}\hfil  \thepage \fi}

\newcommand{\logo}{\baselineskip2pc \hbox to\hsize{\hfil\copyright\,\footnotesize
    \@author, \pj@year}}

\renewcommand{\footnoterule}{\vspace*{-3pt}
    \hrule width 2cm \vspace*{2.6pt}}

\renewcommand{\@oddfoot}{{\ifnum\c@page=\pj@firstpage
    \logo \fi}}
\renewcommand{\@evenfoot}{{\ifnum\c@page=\pj@firstpage
    \logo \fi}}

\renewcommand{\@makefntext}[1]{\parindent=1em\noindent  #1}

\newcommand\pj@printaddress{%
    \ifx\pj@addresses\empty \else
       \vskip0.2in
       \bgroup
       \footnotesize
       \noindent
       \pj@addresses\\
       \@email
       \egroup
    \fi
}

\newcommand\pj@printreceived{%
    \ifx\pj@received\empty \else
       \vskip0.1in
       \bgroup
       \footnotesize
       \itshape
       \noindent
       \hfill \pj@recname~\pj@received
       \egroup
    \fi
    \ifx\pj@revised\empty \else
       \vskip0.1in
       \bgroup
       \footnotesize
       \itshape
       \noindent
       \hfill\pj@revname~\pj@revised
       \egroup
    \fi
}

\let\pj@thebibliography\thebibliography
\def\thebibliography{\footnotesize\pj@thebibliography}

\AtEndDocument{\pj@printreceived\pj@printabstracts
                \write@start@end@pages}

\DeclareMathOperator*{\suplim}{\overline{lim}}
\renewcommand{\varlimsup}{\suplim}
\DeclareMathOperator*{\inflim}{\underline{lim}}
\renewcommand{\varliminf}{\inflim}
\renewcommand{\Re}{\mathop{\rm Re}}
\renewcommand{\Im}{\mathop{\rm Im}}
\renewcommand{\emptyset}{\varnothing}
\renewcommand{\phi}{\varphi}
\renewcommand{\epsilon}{\varepsilon}

% Clever bibliography
\def\@lbibitem[#1]#2{%
     \@ifundefined{seen-b@#2}%
       {\def\@biblabel##1{[\textbf{\pj@unusedbib: ##1}]}}%
       {\def\@biblabel##1{[##1]}}%
     \item[\@biblabel{#1}\hfill]%
     \if@filesw
      {\let\protect\noexpand
       \immediate
       \write\@auxout{\string\bibcite{#2}{#1}}}%
     \fi\ignorespaces}
\def\@bibitem#1{%
     \@ifundefined{seen-b@#1}%
       {\def\@biblabel##1{[\textbf{\pj@unusedbib: ##1}]}}%
       {\def\@biblabel##1{[##1]}}%
     \item\if@filesw \immediate\write\@auxout
       {\string\bibcite{#1}{\the\value{\@listctr}}}\fi\ignorespaces}
\def\@citex[#1]#2{\leavevmode
  \let\@citea\@empty
  \@cite{\@for\@citeb:=#2\do
    {\@citea\def\@citea{,\penalty\@m\ }%
     \edef\@citeb{\expandafter\@firstofone\@citeb\@empty}%
     \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
     \@xp\global\@xp\def\csname seen-b@\@citeb\endcsname{seen}%
     \@ifundefined{b@\@citeb}{\hbox{\reset@font\bfseries ?}%
       \G@refundefinedtrue
       \@latex@warning
         {Citation `\@citeb' on page \thepage \space undefined}}%
       {\@cite@ofmt{\csname b@\@citeb\endcsname}}}}{#1}}


%% End of file `bmzhart.cls'.
