\NeedsTeXFormat{LaTeX2e}
%
\ProvidesClass{basm}
%
%----- Identification section
\typeout{}
\typeout{Article class for BASM}
\typeout{Version 1.9, January 14, 2003}
\typeout{(c) 2002, 2003 by Alexander Colesnicov, Ludmila Malahova}
\typeout{}
%----- Standard class section
\LoadClass[11pt,a4paper,twoside]{article}
%----- Required packages section
%---------- User packages subsection
\RequirePackage{amsmath}
\RequirePackage{amsfonts}
\RequirePackage{amssymb}
\RequirePackage{amsthm}
\RequirePackage{array}
\RequirePackage{latexsym}
%---------- Service packages subsection
\RequirePackage{calc}
\RequirePackage{cite}
\RequirePackage{fancyhdr}
\RequirePackage{ifthen}
\RequirePackage{indentfirst}
%--------------- Input encoding = Windows Cyrillic (cp1251)
\RequirePackage[cp1250,cp1251]{inputenc}
%--------------- Add/modify name definitions for the package 'babel'
\RequirePackage[romanian,russian,english]{babel}
%
\addto\captionsenglish{%
  \def\examplename{Example}%
  \def\affirmationname{Affirmation}%
  \def\claimname{Claim}%
  \def\definitionname{Definition}%
  \def\theoremname{Theorem}%
  \def\lemmaname{Lemma}%
  \def\propositionname{Proposition}%
  \def\remarkname{Remark}%
  \def\observationname{Observation}%
  \def\corollaryname{Corollary}%
  \def\algorithmname{Algorithm}%
  \def\stepname{Step}%
  \def\casename{Case}%
  \def\undefexamplename{Example}%
  \def\undefaffirmationname{Affirmation}%
  \def\undefclaimname{Claim}%
  \def\undefdefinitionname{Definition}%
  \def\undeftheoremname{Theorem}%
  \def\undeflemmaname{Lemma}%
  \def\undefpropositionname{Proposition}%
  \def\undefremarkname{Remark}%
  \def\undefobservationname{Observation}%
  \def\undefcorollaryname{Corollary}%
}
\addto\captionsrussian{%
  \def\bibname{{\cyr\CYRB\cyri\cyrb\cyrl\cyri\cyro\cyrg\cyrr\cyra\cyrf\cyri\cyrya}}%
  \def\figurename{{\cyr\CYRF\cyri\cyrg.}}%
  \def\indexname{{\cyr\CYRU\cyrk\cyraç\cyra\cyrt\cyre\cyrl\cyrsftsn}}%
  \def\refname{{\cyr\CYRL\cyri\cyrt\cyre\cyrr\cyra\cyrt\cyru\cyrr\cyra}}%
  \def\examplename{{\cyr\CYRP\cyrr\cyri\cyrm\cyre\cyrr}}%
  \def\affirmationname{{\cyr\CYRU\cyrt\cyrv\cyre\cyrr\cyrzh\cyrd\cyre\cyrn\cyri\cyre}}%
  \def\claimname{{\cyr\CYRU\cyrt\cyrv\cyre\cyrr\cyrzh\cyrd\cyre\cyrn\cyri\cyre}}% Claim?
  \def\definitionname{{\cyr\CYRO\cyrp\cyrr\cyre\cyrd\cyre\cyrl\cyre\cyrn\cyri\cyre}}%
  \def\theoremname{{\cyr\CYRT\cyre\cyro\cyrr\cyre\cyrm\cyra}}%
  \def\lemmaname{{\cyr\CYRL\cyre\cyrm\cyrm\cyra}}%
  \def\propositionname{{\cyr\CYRP\cyrr\cyre\cyrd\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyre}}%
  \def\remarkname{{\cyr\CYRZ\cyra\cyrm\cyre\cyrch\cyra\cyrn\cyri\cyre}}%
  \def\observationname{{\cyr\CYRN\cyra\cyrb\cyrl\cyryu\cyrd\cyre\cyrn\cyri\cyre}}%
  \def\corollaryname{{\cyr\CYRK\cyro\cyrr\cyro\cyrl\cyrl\cyra\cyrr\cyri\cyrishrt}}%
  \def\algorithmname{{\cyr\CYRA\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm}}%
  \def\stepname{{\cyr\CYRSH\cyra\cyrg}}%
  \def\casename{{\cyrŃ\cyrl\cyru\cyrch\cyra\cyrishrt}}%
  \def\undefexamplename{{\cyr\CYRP\cyrr\cyri\cyrm\cyre\cyrr}}%
  \def\undefaffirmationname{{\cyr\CYRU\cyrt\cyrv\cyre\cyrr\cyrzh\cyrd\cyre\cyrn\cyri\cyre}}%
  \def\undefclaimname{{\cyr\CYRU\cyrt\cyrv\cyre\cyrr\cyrzh\cyrd\cyre\cyrn\cyri\cyre}}% Claim?
  \def\undefdefinitionname{{\cyr\CYRO\cyrp\cyrr\cyre\cyrd\cyre\cyrl\cyre\cyrn\cyri\cyre}}%
  \def\undeftheoremname{{\cyr\CYRT\cyre\cyro\cyrr\cyre\cyrm\cyra}}%
  \def\undeflemmaname{{\cyr\CYRL\cyre\cyrm\cyrm\cyra}}%
  \def\undefpropositionname{{\cyr\CYRP\cyrr\cyre\cyrd\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyre}}%
  \def\undefremarkname{{\cyr\CYRZ\cyra\cyrm\cyre\cyrch\cyra\cyrn\cyri\cyre}}%
  \def\undefobservationname{{\cyr\CYRN\cyra\cyrb\cyrl\cyryu\cyrd\cyre\cyrn\cyri\cyre}}%
  \def\undefcorollaryname{{\cyr\CYRK\cyro\cyrr\cyro\cyrl\cyrl\cyra\cyrr\cyri\cyrishrt}}%
}
\addto\captionsfrench{%
  \def\examplename{Exemple}%
  \def\affirmationname{Affirmation}%
  \def\claimname{Affirmation}% Claim?
  \def\definitionname{D\'efinition}%
  \def\theoremname{Th\'eor\`eme}%
  \def\lemmaname{Lemme}%
  \def\propositionname{Proposition}%
  \def\remarkname{Remarque}%
  \def\observationname{Observation}%
  \def\corollaryname{Corollaire}%
  \def\algorithmname{Algorithme}%
  \def\stepname{Pas}%
  \def\casename{Cas}%
  \def\undefexamplename{Exemple}%
  \def\undefaffirmationname{Affirmation}%
  \def\undefclaimname{Affirmation}% Claim?
  \def\undefdefinitionname{D\'efinition}%
  \def\undeftheoremname{Th\'eor\`eme}%
  \def\undeflemmaname{Lemme}%
  \def\undefpropositionname{Proposition}%
  \def\undefremarkname{Remarque}%
  \def\undefobservationname{Observation}%
  \def\undefcorollaryname{Corollaire}%
}
\addto\captionsromanian{%
  \def\alsoname{vezi de asemenea}%
  \def\contentsname{Cuprins}% Tabla de materii, Cuprinsul
  \def\indexname{Index}% Glosar
  \def\listfigurename{Lista figurilor}%
  \def\listtablename{Lista tabelelor}%
  \def\pagename{pag.}%
  \def\refname{Lista de referin\c{t}e}%
  \def\seename{vezi}%
  \def\tablename{Tabelul}%
  \def\examplename{Exemplul}%
  \def\affirmationname{Afirma\c{t}ia}%
  \def\claimname{Afirma\c{t}ia}% Claim?
  \def\definitionname{Defini\c{t}ia}%
  \def\theoremname{Teorema}%
  \def\lemmaname{Lema}%
  \def\propositionname{Propozi\c{t}ia}%
  \def\remarkname{Remarca}%
  \def\observationname{Observa\c{t}ia}%
  \def\corollaryname{Consecin\c{t}a}%
  \def\algorithmname{Algoritm}%
  \def\stepname{Pasul}%
  \def\casename{Cazul}%
  \def\undefexamplename{Exemplu}%
  \def\undefaffirmationname{Afirma\c{t}ie}%
  \def\undefclaimname{Afirma\c{t}ie}% Claim?
  \def\undefdefinitionname{Defini\c{t}ie}%
  \def\undeftheoremname{Teorem\u{a}}%
  \def\undeflemmaname{Lem\u{a}}%
  \def\undefpropositionname{Propozi\c{t}ie}%
  \def\undefremarkname{Remarc\u{a}}%
  \def\undefobservationname{Observa\c{t}ie}%
  \def\undefcorollaryname{Consecin\c{t}\u{a}}%
}
%
\theoremstyle{plain}
\newtheorem{thm}{\theoremname}
\newtheorem{lem}{\lemmaname}
\newtheorem{prop}{\propositionname}
\newtheorem{cor}{\corollaryname}
\newtheorem{aff}{\affirmationname}
\newtheorem{clm}{\claimname}
\newtheorem*{nthm}{\undeftheoremname}
\newtheorem*{nlem}{\undeflemmaname}
\newtheorem*{nprop}{\undefpropositionname}
\newtheorem*{ncor}{\undefcorollaryname}
\newtheorem*{naff}{\undefaffirmationname}
\newtheorem*{nclm}{\undefclaimname}
\theoremstyle{definition}
\newtheorem{defn}{\definitionname}
\newtheorem{exa}{\examplename}
\newtheorem*{ndefn}{\undefdefinitionname}
\newtheorem*{nexa}{\undefexamplename}
\theoremstyle{remark}
\newtheorem{rem}{\remarkname}
\newtheorem{obs}{\observationname}
\newtheorem*{undefrem}{\undefremarkname}
\newtheorem*{undefobs}{\undefobservationname}
\theoremstyle{plain}
%
%--------------- Correction for standard caption
\def\CaptionSeparator{.\ }
%
\long\def\@makecaption#1#2{%
  \vskip\abovecaptionskip
  \sbox\@tempboxa{#1\CaptionSeparator\ #2}%
  \ifdim \wd\@tempboxa >\hsize
    #1\CaptionSeparator #2\par
  \else
    \global \@minipagefalse
    \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
  \fi
  \vskip\belowcaptionskip%
}
%--------------- Correction for the package 'cite' (no space before a citation)
\def\@cite#1#2{\leavevmode
  \@tempskipa\lastskip \edef\@tempa{\the\@tempskipa}\unskip
  \ifnum\lastpenalty=\z@ \penalty\@highpenalty \fi
  \ifx\@tempa\@zero@skip \spacefactor1001 \fi % if no space before, set flag
%  \ifnum\spacefactor>\@m \ \else \hskip\@tempskipa \fi
  \ifnum\spacefactor>\@m \else \hskip\@tempskipa \fi
  \citeleft{#1\if@tempswa \citemid #2\fi}\citeright
  \spacefactor\@m % punctuation in note doesn't affect outside
}
%----- Accommodation section
%      Higher tolerance
\tolerance750
%      Permitting display breaks for better vertical alignment
\allowdisplaybreaks[4]
%----- Current issue section
\newcounter{Year}
\setcounter{Year}{2008}
\newcounter{Number}
\setcounter{Number}{2}
\newcounter{Issue}
\setcounter{Issue}{57}
\def\CurrentYear{\arabic{Year}}
\def\CurrentNumber{\arabic{Number}}
\def\CurrentIssue{\arabic{Issue}}
%----- ISSN section
\def\Serial{ISSN 1024--7696}
\def\ttSerial{\texttt{ISSN 1024-7696}}
%----- Start page section
\newcounter{StartPage}
\setcounter{StartPage}{1}
\def\StartPage#1{\setcounter{StartPage}{#1}}
%
\def\P@ge{\ifnum \value {StartPage}=0 \strut \else \small \thepage \fi }
%----- List with no additional spaces around section
\def\zlist{%
  \parskip \z@ \parsep \z@ \topsep \z@ \@topsep \z@ \@topsepadd \z@ %
  \partopsep \z@ \@outerparskip \z@ \itemsep \z@ }
%----- Sectioning section
\renewcommand\section{\@startsection {section}{1}{\z@}%
                                   {-3.5ex \@plus -1ex \@minus -.2ex}%
                                   {2.3ex \@plus.2ex}%
                                   {\normalfont\large\bfseries}}
%----- Page layout and fancy header section
%      Page sizes
\setlength{\evensidemargin}{9.6mm}
\setlength{\oddsidemargin}{9.6mm}
\setlength{\topmargin}{8.1mm}
\textwidth140mm
\textheight232mm % Corrected later
%      Some new dimensions
\newlength{\halftextwidth}
\newlength{\thirdtextwidth}
\newlength{\quartertextwidth}
\newlength{\threequartertextwidth}
\newlength{\twofifthstextwidth}
\newlength{\threefifthstextwidth}
\setlength{\halftextwidth}{\textwidth / 2}
\setlength{\thirdtextwidth}{\textwidth / 3}
\setlength{\quartertextwidth}{\textwidth / 4}
\setlength{\threequartertextwidth}{\quartertextwidth * 4}
\setlength{\twofifthstextwidth}{\textwidth * 2 / 5}
\setlength{\threefifthstextwidth}{\textwidth * 3 / 5}
%      A length for calculations
\newlength{\TempLength}
%      Running headers
\def\LeftHe@d{\strut}
\def\RightHe@d{\strut}
\def\RunningHead#1#2{\def\LeftHe@d{\footnotesize\MakeUppercase{#1}}\def\RightHe@d{\footnotesize\MakeUppercase{#2}}}
%      Pages for the article
\def\P@ges{%
    Pages \arabic{page}--\pageref{\jobname L@STP@GE}%
}
%      Fancy headers
\pagestyle{fancy}
%
\fancyhf{}
\fancyhead[LE,RO]{\P@ge}
\fancyhead[CE]{\LeftHe@d}
\fancyhead[CO]{\RightHe@d}
\renewcommand{\headrulewidth}{0pt}
%
\fancypagestyle{plain}{%
\fancyhf{}
  \fancyhead[L]{%
     \tiny\relax\begin{flushleft}\zlist
     BULETINUL ACADEMIEI DE \c{S}TIIN\c{T}E\\
     A REPUBLICII MOLDOVA. MATEMATICA\\
     Number \CurrentNumber(\CurrentIssue), \CurrentYear, \P@ges\\
     \Serial
     \end{flushleft}}
  \fancyfoot[C]{\P@ge}
\renewcommand{\headrulewidth}{0.4pt}%
}
\headheight13.6pt
\setlength{\textheight}{\textheight - \topmargin - \headheight - \headsep}
%----- Multilanguage author, title,  keywords, and abstract section
%
\newtoks\@AuthorToks
\newtoks\@TitleToks
\newtoks\@xToks
%
\let\s@veauthor\author
\s@veauthor{}
\renewcommand*{\author}[2][english]{%
  \@AuthorToks{#2}
  \s@veauthor{\the\@AuthorToks}%
}
%
\let\s@vetitle\title
\renewcommand*{\title}[2][english]{%
  \@TitleToks{#2}
  \s@vetitle{\the\@TitleToks}%
}
%
\newtoks\Keyw@rdsToks
\newcommand*{\Keywords}[2][english]{%
  \Keyw@rdsToks{#2}%
}
%
\newtoks\Abstr@ctToks
\newcommand*{\Abstract}[2][english]{%
  \Abstr@ctToks{#2}%
}
%
\if@titlepage
  \renewenvironment{abstract}{%
      \titlepage
      \null\vfil
      \noindent\textbf{\abstractname.\ }}
     {\par\vfil\null\endtitlepage}
\else
  \renewenvironment{abstract}{%
      \if@twocolumn
        \section*{\abstractname}%
      \else
        \footnotesize
        \quotation
        \noindent\textbf{\abstractname.\ }%
      \fi}
      {\if@twocolumn\else\endquotation\fi}
\fi

%
\let\s@veendabstract\endabstract
\def\endabstract{%
  \if\the\Keyw@rdsToks  \else\if\the\MSCToks  \else%
    \vspace{5pt}%
     \if\the\MSCToks  \else%
       \par %
        \noindent\textbf{Mathematics subject classification:\ }\the\MSCToks.
     \fi%
     \if\the\Keyw@rdsToks  \else%
       \par %
        \noindent\textbf{Keywords and phrases:\ }\the\Keyw@rdsToks.
       \fi%
    \fi\fi%
  \s@veendabstract%
}
%
%----- Copyright section
% \CopyRight{1993 by I.Ivanov} makes a footnote on the title page
\newtoks\t@CopyRight
\def\CopyRight#1{\t@CopyRight{#1}}
%----- Mathematical Subject Classification section
\newtoks\MSCToks
\long\def\MSC#1{%
  \MSCToks{#1}%
}
%----- Date section
\date{}
%----- Address section
\let\@AddressHook\@empty
\long\def\Address#1{\g@addto@macro\@AddressHook{\@Address{#1}}}
\long\def\@Address#1{%
  \begin{minipage}[t]{\threefifthstextwidth}\ZPage\footnotesize\raggedright %
    \ignorespaces #1 %
  \end{minipage}%
}
%----- Received section
\let\@ReceivedHook\@empty
\newcommand*{\Received}[2][]{\g@addto@macro\@ReceivedHook{\@R@ceived{#2}{#1}}}
\long\def\@R@ceived#1#2{%
  \begin{minipage}[t]{\twofifthstextwidth}\ZPage\footnotesize\itshape\raggedleft %
    Received #1 %
    \ifthenelse{\equal{#2}{}}{}{\par Revised #2}
  \end{minipage}%
}
%----- Title section
\def\@maketitle{%
  \newpage
  \null
  \vskip 2em%
  \begin{center}%
  \let \footnote \thanks
    {\Large \if\the\t@CopyRight      % \Copyright is a 0th footnote if any
     \else \setcounter{footnote}{-1}
           \thanks{ \kern -17pt \copyright\the\t@CopyRight}
     \fi \bfseries \ignorespaces \@title \par}%
    \vskip 1.5em%
    {\large
      \lineskip .5em%
      \begin{tabular}[t]{c}%
        \ignorespaces \@author
      \end{tabular}\par}%
  \end{center}%
  \par
  \vskip 1.0em%
  \if\the\Abstr@ctToks  \else
    \begin{abstract}
       \ignorespaces \the\Abstr@ctToks
     \end{abstract}
  \fi
}
%
% If the current page is odd, type it and begin the next even page
\def\EvenPage{\relax\ifodd\c@page\newpage\else\fi}
% If the current page is even, type it and begin the next odd page
\def\OddPage{\relax\ifodd\c@page\else\newpage\fi}
% Never skip an empty page to begin from the odd page
\let\cleardoublepage\clearpage

\newcommand{\@PBS}[1]{\let\T@mp=\\#1\let\\=\T@mp}

\newenvironment{RLPage}[1]{\par\noindent%
  \setlength{\TempLength}{\halftextwidth - #1/2}%
  \begin{tabular}%
    {@{\strut}>{\@PBS\raggedleft\hspace{\z@}}p{\TempLength}%
     @{\hspace*{#1}}>{\@PBS\raggedright\hspace{\z@}}p{\TempLength}@{\strut}}%
}{\end{tabular}\par}

\newenvironment{twopartpage}{\par\noindent\begin{tabular}%
  {@{\strut}p{\halftextwidth}@{\strut}p{\halftextwidth}@{\strut}}%


}{\end{tabular}\par}

\def\zlist{%
  \parskip\z@\parsep\z@\topsep\z@\@topsep\z@\@topsepadd\z@ %
  \partopsep\z@\@outerparskip\z@\itemsep\z@}

\newcounter{@Case}
\newcommand{\Case}{\item{}}
\newcommand{\CaseChar}{.\ }
\newenvironment{Cases}{%
  \begin{list}%
  {\emph{\casename{} \arabic{@Case}\CaseChar }}{\usecounter{@Case}%
   \setlength{\listparindent}{\parindent}%
   \setlength{\labelsep}{\z@}%
   \setlength{\leftmargin}{\z@}%
   \setlength{\labelwidth}{\z@}%
   \setlength{\itemsep}{\z@}%
   \setlength{\itemindent}{\parindent}%
   \zlist }}%
 {\end{list}}

\newcounter{@Step}
\newcommand{\Step}{\item{}}
\newcommand{\StepChar}{.\ }
\newenvironment{Steps}{\begin{list}%
  {\emph{\stepname{} \arabic{@Step}\StepChar }}{\usecounter{@Step}%
   \setlength{\listparindent}{\parindent}%
   \setlength{\labelsep}{\z@}
   \setlength{\leftmargin}{\z@}%
   \setlength{\labelwidth}{\z@}%
   \setlength{\itemsep}{\z@}%
   \setlength{\itemindent}{\parindent}%
   \zlist}}%
 {\end{list}}

\def\ZPage{%
  \parindent\z@%
  \evensidemargin\z@%
  \oddsidemargin\z@%
  \marginparsep\z@%
  \marginparwidth\z@%
}

\def\Indent{\hspace*{\parindent}}


%----- Begin Document section

\AtBeginDocument{%
    {\setcounter{page}{\value{StartPage}}}%
    \newcounter{NPages}%
    \setcounter{NPages}{\value{page}}%
}

%----- End Document section

\AtEndDocument{%
    \par\vspace*{10pt}\noindent %
    \begingroup %
      \footnotesize\relax %
      \begin{tabular}{@{\strut}p{\threefifthstextwidth}@{\strut}p{\twofifthstextwidth}@{\strut}}%
       \@AddressHook & \@ReceivedHook%
      \end{tabular}%
      \normalsize\relax %
    \endgroup%
    \label{\jobname L@STP@GE}%
    \setcounter{NPages}{1 - \value{NPages} + \value{page}}%
    \typeout{--- Total \the\c@NPages \space pages}%
  \def\baselinestretch{1.0}%
}

%-----

% Make thebibliography to set \footnotesize font
\def\Jlist{%
  \parsep\z@\topsep\z@\@topsep\z@\@topsepadd\z@ %
  \partopsep\z@\@outerparskip\z@\itemsep 0.05\itemsep}

\let\@s@vethebibliography\thebibliography
\let\@s@veendthebibliography\endthebibliography
\def\thebibliography#1{\@s@vethebibliography{#1}\begingroup\Jlist\footnotesize\selectfont\relax}
\def\endthebibliography{\normalsize\selectfont\relax\endgroup\@s@veendthebibliography}

%-----

% A counter for calculations
\newcounter{@T@mp}
\setcounter{@T@mp}{0}

\endinput
