\ProvidesClass{mce}[2016/09/28 v0.3.1]
\def\class@name{mce}%
\GenericInfo{}{\space
 Copyright (c) 2004 ITP TU Berlin.^^J
 Copyright (c) 2007-2016 MSU Moscow.^^J
 Licensed under the LPPL:^^Jhttp://www.ctan.org/tex-archive/macros/latex/base/lppl.txt^^J
 \@gobble
}%

\DeclareOption{eng}{
\gdef\@langeng{true}
      \PackageWarning{mce}{Debug: `\CurrentOption'}%
}
\gdef\@langeng{}
\ProcessOptions\relax

\LoadClass[12pt,a4paper]{article}
\usepackage[a4paper,left=25mm,width=16cm,right=25mm,top=38mm,height=22cm,bottom=38mm]{geometry}

\usepackage{amssymb}
\usepackage{amstext}
\usepackage{amsfonts}
\usepackage[fleqn]{amsmath}

\@ifundefined{XeTeXversion}{
    %\usepackage{pscyr}
    \usepackage[math]{pscyr}
    \usepackage[T2A]{fontenc}
    \RequirePackage[utf8]{inputenc}
    \RequirePackage[russian,english]{babel}
    \PrerenderUnicode{«»АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЬЫЪЭЮЯабвгдеёжзийклмнопрстуфхцчшщьыъэюя–№}
    \renewcommand{\rmdefault}{ftm}
}{
	\usepackage[cm-default]{fontspec} 
	\usepackage{xunicode} 
	\usepackage{xltxtra}
	\usepackage{polyglossia} 
	\setdefaultlanguage{russian} 
	\setotherlanguage{english}
	\newfontfamily\russianfont[Mapping=tex-text]{Times New Roman} 
	% Default fonts - you need to have msttcorefonts installed on linux
	\setromanfont[Mapping=tex-text]{Times New Roman} 
	\setsansfont[Mapping=tex-text]{Arial} 
	\setmonofont[Mapping=tex-text]{Courier New} 
	\setmainfont[Mapping=tex-text]{Times New Roman}
}

\RequirePackage{ifthen}

\sloppy

\AtBeginDocument{
  \pagestyle{empty}
  \bibliographystyle{alpha}
}

\gdef\@contacts{}
\gdef\@author{}
\def\author[#1]#2{
	\ifx\@author\@empty\else\g@addto@macro\@author{, }\fi
	\g@addto@macro\@author{\mbox{#2\ifx\\#1\\\else\@textsuperscript{\textbf{#1}}\fi}}
}
\def\contacts[#1]#2{
	\ifx\@contacts\@empty\else\g@addto@macro\@contacts{\par}\fi
	\g@addto@macro\@contacts{\ifx\\#1\\\else\@textsuperscript{\textbf{#1}}\fi#2}
}
\def\langeng#1{\gdef\@langeng{#1}}

\def\maketitle{
	\begin{center}
  	{\bf\MakeUppercase{\@title} \par}
	  \vskip 1em                         % Vertical space after title.
  	{\textbf{\@author}}
  	\vskip 1em                         % Vertical space after title.
  	{\@contacts}
  	\vskip 1.5em                         % Vertical space after title.
	\end{center} \par
	\let\maketitle\relax
	\def\documentclass##1{}
}

\renewenvironment{thebibliography}[1]
{
  \vskip 1em
	\ifx\@langeng\@empty\textbf{Литература.}\else\textbf{References.}\fi
  \list{\@arabic\c@enumiv.}%
  {
    \samepage
    \itemsep=0ex\topsep=0ex\partopsep=0ex\parskip=0ex\parsep=0ex
    \settowidth\labelwidth{\@biblabel{#1}}%
    \leftmargin\labelwidth
    \advance\leftmargin\labelsep
    \@openbib@code
    \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}
