%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Стилевой файл А.В.Полозова с исправлением Алексея Малистова.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Опции:
% params: установка различных параметров по умолчанию
% macros: различные макросы: stamp'ы, пробелы выносной математики
% headrules: линия под колонтитулами
% sections: исправление вида заголовков
% listindent: абзацный отступ в списках
% plainaligns: plainTeX'овские макросы выравнивания выносных формул
% eqnlabels: макросы для модифицирования меток уравнений (кружки,тильды,штрихи)
% names:  различные математические символы, подправка акцентов
% envirs: макроскобки (теоремы, леммы, примеры...)
% discret: перенос (дублирование знаков) в строчных формулах
% figs:   макросы для вставки рисунков (плавающих и обтекаемых)
\NeedsTeXFormat{LaTeX2e}[1996/11/28]
\def\filedate{1999/12/15}
\def\fileversion{2.0}
\ProvidesPackage{correct1}[\filedate\space \fileversion\space
Стандарты русскоязычной печати (Полозов А.В.)]
\RequirePackage{russian}
\RequirePackage{amsfonts,amssymb}
%%% \RequirePackage{amsfonts,amssymb,xspace}
%%% \RequirePackage{wrapfig}

\DeclareOption{params}{
\renewcommand\arraystretch{1.2}
\newdimen\mm
\mm=2.84526\p@ % = 1 mm. Useful for different purposes
\arraycolsep2\p@
\topskip\z@ %plus \z@
\splittopskip\z@ %plus \z@
\evensidemargin\z@
\oddsidemargin\z@
\tabcolsep=3pt
}

\DeclareOption{macros}{
\def\toughpage{\global\abovedisplayskip=2pt
            \global\belowdisplayskip=2pt
            \global\abovedisplayshortskip=0pt
            \global\belowdisplayshortskip=0pt}
\def\midpage{\global\abovedisplayskip=4pt plus2pt
            \global\belowdisplayskip=4pt plus2pt
            \global\abovedisplayshortskip=0pt minus4pt
            \global\belowdisplayshortskip=0pt }
\def\loosepage{\global\abovedisplayskip=6pt
            \global\belowdisplayskip=6pt
            \global\abovedisplayshortskip=2pt
            \global\belowdisplayshortskip=2pt}

\providecommand{\stamp}[1]{
  \AtEndDocument{\footskip=\z@
\@tempcnta=\c@page
\multiply\@tempcnta by 100
\divide\@tempcnta16
  \def\@evenfoot{\small\hfil\ttfamily Подписано в печать\hfill
                  Усл.печ.л.~0,\number\@tempcnta\ Тираж~#1 экз.\hfil}%
  \let\@oddfoot\@evenfoot}}
\providecommand{\voidstamp}[2]{
  \AtEndDocument{\footskip=\z@
  \def\@evenfoot{\small\hfil\ttfamily Подписано в печать\hfil
                  Усл.печ.л.~#1 \ \ Тираж~#2 экз.\hfil}%
  \let\@oddfoot\@evenfoot}}
\providecommand{\shortstamp}[2]{
  \AtEndDocument{\footskip=\z@
  \def\@evenfoot{\small\hfil\ttfamily Заказ\hfil Тираж~#1 экз.\hspace{2em} МФТИ-#2 \hfil}
  \let\@oddfoot\@evenfoot}}

\def\headers#1#2{\def\@oddhead{#1}\def\@evenhead{#2}}
\def\eqref#1{{\rm(\ref{#1})}} % very handy, especially in theorem environments
\def\risref#1{(см. рис.~\ref{ris:#1})}
\def\clap#1{\hb@xt@\z@{\hss#1\hss}}
}

\DeclareOption{headrules}{
\newif\if@headfoot
\@headfootfalse
\newif\if@headrules
\@headrulestrue
\def\ps@headfoots{\@headfoottrue%
    \def\@oddfoot{\hfill\thepage}\def\@evenfoot{\thepage\hfill}
    \if@headrules
      \def\@evenhead{\vbox{\hb@xt@\textwidth
      {\slshape\leftmark\hfill}\vskip2\p@\hrule}}
      \def\@oddhead{\vbox{\hb@xt@\textwidth
      {\hfill\slshape\rightmark}\vskip2\p@\hrule}}
    \else
      \def\@evenhead{\slshape\leftmark\hfill}%
      \def\@oddhead{\hfill{\slshape\rightmark}}%
    \fi
    \let\chaptermark\@gobble
    \def\ps@plain{\let\@oddhead\empty\let\@evenhead\empty}
     }
}

\newif\ifsst
\ssttrue
\DeclareOption{sections}{
\def\@tocrmarg{\z@ plus 1fil}

\def\l@chapter#1#2{%
    \addpenalty{-\@highpenalty}%
    \vskip 1.0ex \@plus\p@
    \begingroup
     \hyphenpenalty\@M%
    \parindent \z@
    \leftskip=1.25em%
    {\rightskip \@tocrmarg \parfillskip -\rightskip
     %\rightskip \@pnumwidth plus 1fil \advance\rightskip 1em%
     %\protect{\advance\linewidth-3em}
     \leavevmode\relax
     {\large\bfseries #1\nobreak
      \leaders\hbox{$\m@th\mkern\@dotsep mu\hbox{.}\mkern\@dotsep mu$}\hfill
      \nobreak\hb@xt@\@pnumwidth{\hfil\normalcolor #2}}
     \par}%
    \penalty\@highpenalty%\vskip.5ex
   \endgroup}
\def\l@section#1#2{\vskip.5ex%
     \begingroup%
     \hyphenpenalty\@M%
     \leftskip=3em\noindent%
     {\rightskip \@tocrmarg \parfillskip -\rightskip
      %\rightskip \@pnumwidth plus 1fil \advance\rightskip 1em%
      %\protect{\advance\linewidth-3em}
      \leavevmode\relax%
      {\bfseries #1\nobreak
       \leaders\hbox{$\m@th \mkern\@dotsep mu\hbox{.}\mkern\@dotsep mu$}\hfill
       \nobreak\hb@xt@\@pnumwidth{\hfil\normalcolor #2}}
      \par}%
     \penalty\@highpenalty%\vskip.5ex%
     \endgroup}
\def\l@subsection   {\@dottedtocline{1}{3em}{0pt}}
\def\l@subsubsection{\@dottedtocline{2}{3.5em}{2.0em}}
\def\l@paragraph    {\@dottedtocline{3}{5em}{2.5em}}
\def\l@subparagraph {\@dottedtocline{4}{6em}{3em}}

\def\chaptersize{\Huge}
\def\chapterfont{\bfseries}

\newif\ifschap
\schaptrue

\def\chapter{\@ifstar{\schaptrue\@chap}{\schapfalse\@chap}}
\def\@chap{\@ifnextchar[{\@@chap}{\@@chap[]}}
\def\@@chap[#1]#2{\@ifnextchar[{\@@@chap[#1]#2}{\@@@chap[#1]#2[#1]}}

\def\@@@chap[#1]#2[#3]{\clearpage\thispagestyle{plain}%
  \ifschap \def\chmark{}
    \ifx #1\relax\else \addcontentsline{toc}{chapter}{#1}\fi
  \else   \refstepcounter{chapter}\def\chmark{\chaptername~\thechapter.}
    \ifx #1\relax\else \addcontentsline{toc}{chapter}{\chmark\enspace #1}\fi
  \fi
  \markboth{\chmark\enspace\sl #3}{}
  {\reset@font\chaptersize\chapterfont%
  \hyphenpenalty=\@M%
%  \vspace*{2ex}
  \begin{center}
  \ifschap\else\chaptername\enspace\thechapter\fi\par
  #2
  \end{center}}
  \@afterheading
  \hyphenpenalty=50%
  \vskip 1ex}

\def\sectionsize{\LARGE}
\def\sectionfont{\bfseries}

\renewcommand\section{\@ifstar{\ssttrue\@sct}{\sstfalse\@sct}}
\def\@sct{\@ifnextchar[{\@@sct}{\refstepcounter{section}\@@sct[\thesection.]}}%
\def\@@sct[#1]#2{\@ifnextchar[{\@@@sct[#1]#2}{\@@@sct[#1]#2[#2]}}%

\def\@@@sct[#1]#2[#3]{\goodbreak%
  \vskip 3ex\@plus .5ex \@minus .5ex%
  \ifsst \gdef\labsect{} \gdef\marksect{}
  \else  \gdef\labsect{\BS\hskip.15em #1\ }
         \gdef\marksect{{\rm\S\,#1}\enspace}\fi%
  \vbox{\reset@font\sectionsize\sectionfont%
      \hyphenpenalty=\@M\interlinepenalty=\@M%
      \advance\linewidth -1in\centering%
      \leavevmode\labsect\boldmath{#2}\unboldmath}%
  \if@headfoot
     \markright{\ifsst\else\marksect\fi\sl #3}
  \else
     \markright{\@hangfrom{\marksect}\sl #3}
  \fi%
  \addcontentsline{toc}{section}%
    {\llap{\labsect}{\hbox to\z@{}}{\ifsst #3\else #2\fi}}
  \hyphenpenalty=50\interlinepenalty=0%
  \@afterheading\par\nopagebreak\vskip1ex}

\def\subsectionsize{\large}
\def\subsectionfont{\bfseries\sffamily}

\def\subsection{\@ifnextchar[{\@subsect}
      {\refstepcounter{subsection}\@subsect[\thesubsection]}}
\def\@subsect[#1]#2{\ifnum\c@subsection>1%
    \goodbreak\vskip1ex plus .5ex minus .5ex%
  \else\nopagebreak[4]\fi%
  \vbox{\reset@font\subsectionsize\subsectionfont%
    \hyphenpenalty=\@M\interlinepenalty=\@M%
    \settowidth{\leftskip}{#1.\enspace}%
    \raggedright%
    \hskip-\leftskip%
    \boldmath\@hangfrom{#1.\enspace}#2\unboldmath}%
  \addcontentsline{toc}{subsection}{\thesubsection.\hskip\labelsep#2}%
  \hyphenpenalty=50\interlinepenalty=0\@afterheading%
  \par\nopagebreak\vskip.5ex\nopagebreak}

\renewcommand{\thesection}{\arabic{section}}
\renewcommand{\thesubsection}{\arabic{section}.\arabic{subsection}}

\renewcommand\tableofcontents{%\clearpage\pagestyle{plain}
    \centerline{\LARGE\scshape\contentsname}
    \@afterindenttrue\vskip 30pt\par%
    \@starttoc{toc}%
    }
}

\DeclareOption{listindent}{
\def\list#1#2{\ifnum \@listdepth >5\relax \@toodeep
     \else \global\advance\@listdepth\@ne \fi
  \rightmargin \z@  \itemindent\z@ %\listparindent\z@
  \csname @list\romannumeral\the\@listdepth\endcsname
  \def\@itemlabel{#1}\let\makelabel\@mklab \@nmbrlistfalse #2\relax
  \@trivlist
  \parskip\parsep %\parindent\listparindent
  \advance\linewidth -\rightmargin \advance\linewidth -\leftmargin
  \advance\@totalleftmargin \leftmargin
  \parshape \@ne \@totalleftmargin \linewidth
  \ignorespaces}
}

\DeclareOption{plainaligns}{
\def\eqalign#1{\null\,\vcenter{\openup\jot\m@th
  \ialign{\strut\hfil$\displaystyle{##}$&$\displaystyle{{}##}$\hfil
      \crcr#1\crcr}}\,}
\def\eqalignno#1{\displ@y \tabskip\@centering
  \halign to\displaywidth{\hfil$\@lign\displaystyle{##}$\tabskip\z@skip
    &$\@lign\displaystyle{{}##}$\hfil\tabskip\@centering
    &\llap{$\@lign##$}\tabskip\z@skip\crcr
    #1\crcr}}
}


\DeclareOption{eqnlabels}{

\let\CL\@currentlabel         % Abbreviation for use in text


\def\mlab#1{\def\@currentlabel{$\thesection.#1$}\hbox{(\@currentlabel)}}

%     Useful macros for future, though somewhat buggy.
%     Makes non-standart (modified on fly) labels for
%     eqnarray* and equation* <new!> environments
%     Syntaxis:   \begin{equation*}{modifying_tokens}[first_number]
%                  . . . eqnarray* . . .
%
%\@namedef{equation*}#1{\@ifnextchar[{\@eqnl{#1}}{\@@eqnl{#1}}}
%\def\@eqnl#1[#2]{\eqlabs{#1}[#2]$$\def\@currentlabel{\theequation}}
%\def\@@eqnl#1{\eqlabs{#1}$$\refstepcounter{equation}%
%      \def\@currentlabel{\theequation}}
%\@namedef{endequation*}{
%\eqno \hbox{\@eqnnum}$$\eqrestore\global\@ignoretrue
%}
%
%\@namedef{eqnarray*}#1{\@ifnextchar[{\@eqna{#1}}{\@@eqna{#1}}}
%\def\@eqna#1[#2]{\count@#2\advance\count@-\@ne%
%      \eqlabs{#1}[\the\count@]\eqnarray\def\@currentlabel{\theequation}}
%\def\@@eqna#1{\eqlabs{#1}\eqnarray\def\@currentlabel{\theequation}}
%\@namedef{endeqnarray*}{\ifsst\nonumber\fi\endeqnarray\eqrestore}


\newcounter{eqntil} \newif\if@til \@tilfalse
\newcounter{eqncir} \newif\if@cir \@cirfalse
\newcounter{eqnpri} \newif\if@pri \@prifalse
\newcounter{eqnmask}

\newmuskip\m@

\def\domodifiers{\ifnum\c@eqnmask>99%
  \expandafter\xdef\expandafter\eqboxname{TILB\romannumeral\c@eqnmask}%
  \expandafter\ifx \csname \eqboxname\endcsname\relax%
    \expandafter\global\expandafter\newbox\csname\eqboxname\endcsname \fi%
  \expandafter\global\expandafter\chardef\expandafter\tilbox\expandafter=%
    \csname \eqboxname\endcsname%
  \setbox\tilbox\hbox{$\m@th\phantom{\the\c@equation}$}%
  \skip@\wd\tilbox \m@=\strip@pt\skip@ mu \m@.75\m@%
  \count@\c@eqnmask \divide\count@100%
    \loop \ifnum \count@>0  \advance\count@-\@ne%
    \global\setbox\tilbox\hbox to \z@{\hss$\tilde{\copy\tilbox}$\hss}%
    \repeat%
  \xdef\tils{\mkern-\the\m@\hb@xt@\z@{\hss\copy\csname\eqboxname\endcsname}\mkern\the\m@}%
  \else\def\tils{}%
  \fi%
  \count@\c@eqnmask \@tempcnta\count@%
  \ifnum\count@>9%
    \ifnum\@tempcnta>99\divide\@tempcnta100\multiply\@tempcnta100%
     \advance\count@-\@tempcnta%
    \fi%
    \divide\count@10%
\begingroup%
  \aftergroup\xdef\aftergroup\cirs\aftergroup{%
  \loop\ifnum\count@>0\advance\count@-\@ne%
  \aftergroup{\aftergroup^\aftergroup\circ\aftergroup}\repeat\aftergroup}%
\endgroup%
  \else \def\cirs{}%
  \fi%
  \count@\c@eqnmask \@tempcnta\count@%
  \divide\@tempcnta10 \multiply\@tempcnta10%
  \advance\count@-\@tempcnta%
  \ifnum\count@>0%
\begingroup%
  \aftergroup\xdef\aftergroup\pris\aftergroup{ \aftergroup^\aftergroup{%
  \loop\ifnum\count@>0\advance\count@-\@ne%
  \aftergroup\prime\repeat\aftergroup}\aftergroup}%
\endgroup%
  \else \def\pris{}%
  \fi}

\newcounter{eqncount}
\newcounter{labcount}
\newif\ifloc
\locfalse

\def\eqlabs#1{\gdef\tils{} \gdef\cirs{} \gdef\pris{}%
\@ifnextchar[{\loctrue\@eqlabs#1}{\locfalse\@eqlabs#1[]}}
\def\@eqlabs#1[#2]{\ifmmode \else %
      \global\let\oldtheeq\theequation \global\c@eqncount\c@equation\fi%
\global\sstfalse \global\setcounter{eqnmask}{0}%
  \def\reserved@c{#1} \@onelevel@sanitize\reserved@c%
\expandafter\@tfor\expandafter\@eqnsp\expandafter:\expandafter=\reserved@c\do{%
  \if\@eqnsp\noexpand~ \addtocounter{eqnmask}{100}   \fi%
  \if\@eqnsp o \addtocounter{eqnmask}{10}            \fi%
  \if\@eqnsp ' \addtocounter{eqnmask}{1}             \fi%
  \if\@eqnsp * \gdef\@eqncr{\nonumber\@seqncr} \global\ssttrue \fi}%
%\typeout{1: eqn=\the\c@eqncount, equation=\the\c@equation, old=\oldtheeq}
  \ifnum \c@eqnmask=0%
   \PackageWarning{`correct'}{Empty label modifiers list in \noexpand\eqlabs.^^J
                  Assuming plain numeration: (equation)}%
  \ifloc \global\c@equation=#2 \else \gdef\@eqncr{\nonumber\@seqncr} \fi%
  \expandafter\def\expandafter\theequation\expandafter{$\m@th\oldtheeq$}%
  \else%
  \expandafter\xdef\expandafter\eqname{EQ\romannumeral\c@eqnmask}%
  \expandafter\ifx \csname c@\eqname\endcsname\relax%
    \expandafter\newcount \csname c@\eqname\endcsname%
    \expandafter\@addtoreset\expandafter{\eqname}{labcount} \fi%
  \expandafter\global\expandafter\c@equation%
      \csname c@\eqname \endcsname%
  \ifloc \global\c@equation=#2 \fi%
\typeout{2:\eqname=\expandafter\the\csname c@\eqname\endcsname,
      eqn=\the\c@eqncount, equation=\the\c@equation, old=\oldtheeq}
  \domodifiers%
  \expandafter\gdef\expandafter\theequation\expandafter
    {$\m@th\oldtheeq\tils\cirs\pris$}
  \fi
}

\def\eqrestore{\ifnum \the\c@eqnmask=0 \else \ifloc\else%
%\typeout{Restoring `no labels' case...}
      \expandafter\global\csname c@\eqname\endcsname=\c@equation%
\global\c@equation\c@eqncount \global\let\theequation\oldtheeq%
      \fi\fi%
\global\locfalse%
\global\@tilfalse \global\@cirfalse \global\@prifalse%
\gdef\tils{} \gdef\cirs{} \gdef\pris{}}
}

\DeclareOption{names}{
\let\le\leqslant
\let\ge\geqslant
\def\C{\ensuremath{\mathbb{C}}\xspace}
\def\N{\ensuremath{\mathbb{N}}\xspace}
\def\R{\ensuremath{\mathbb{R}}\xspace}
\def\Z{\ensuremath{\mathbb{Z}}\xspace}
\def\Beta{\mathrm{B}}
\newcommand\nothing{\ensuremath{\mbox{\large$\varnothing$}}}
\let\emptyset\varnothing
\def\BS{\boldmath$\mathsection$\unboldmath}
\catcode`\№=\active \let№\No
\newcommand\ch{\ensuremath{\mathop\mathrm{ch}\nolimits}}
\newcommand\sh{\ensuremath{\mathop\mathrm{sh}\nolimits}}
\renewcommand\th{\ensuremath{\mathop\mathrm{th}\nolimits}}
\newcommand\cth{\ensuremath{\mathop\mathrm{cth}\nolimits}}
\newcommand\tg{\ensuremath{\mathop\mathrm{tg}\nolimits}}
\newcommand\arctg{\ensuremath{\mathop\mathrm{arctg}\nolimits}}
\newcommand\arcctg{\ensuremath{\mathop\mathrm{arcctg}\nolimits}}
\newcommand\arcch{\ensuremath{\mathop\mathrm{arcch}\nolimits}}
\newcommand\arcsh{\ensuremath{\mathop\mathrm{arcsh}\nolimits}}
\newcommand\arcth{\ensuremath{\mathop\mathrm{arcth}\nolimits}}
\newcommand\arccth{\ensuremath{\mathop\mathrm{arccth}\nolimits}}
\newcommand\Ln{\ensuremath{\mathop\mathrm{Ln}\nolimits}}
\newcommand\ctg{\ensuremath{\mathop\mathrm{ctg}\nolimits}}
\newcommand\sign{\ensuremath{\mathop\mathrm{sign}\nolimits}}
\newcommand\sgn{\ensuremath{\mathop\mathrm{sgn}\nolimits}}
\renewcommand\div{\ensuremath{\mathop\mathrm{div}\nolimits}}
\newcommand\grad{\ensuremath{\mathop\mathrm{grad}\nolimits}}
\newcommand\rot{\ensuremath{\mathop\mathrm{rot}\nolimits}}
\newcommand\const{\ensuremath{\mathop\mathrm{const}\nolimits}}
\newcommand\res{\ensuremath{\mathop\mathrm{res}}}
\newcommand\Ker{\ensuremath{\mathop\mathrm{Ker}}}
\renewcommand\Re{\ensuremath{\mathop\mathrm{Re}\nolimits}}
\renewcommand\Im{\ensuremath{\mathop\mathrm{Im}\nolimits}}
\def\mathslash#1#2{\setbox\@tempboxa{$\m@th #1$}\setbox\@tempboxb{$\m@th #2$}%
\mathchoice{\kern.25ex\raise.5ex\box\@tempboxa/\kern.25ex\raise.5ex\box\@tempboxb}
{\kern.25ex\raise.5ex\box\@tempboxa/\kern.25ex\raise.5ex\box\@tempboxb}
{\kern.25ex\raise.5ex\box\@tempboxa/\kern.25ex\raise.5ex\box\@tempboxb}
{\kern.25ex\raise.5ex\box\@tempboxa/\kern.25ex\raise.5ex\box\@tempboxb}}
\newbox\parenlu
\newbox\parenru
\setbox\parenlu\hbox{\@circlefnt\kern-3.5\p@\char 2}
\setbox\parenru\hbox{\@circlefnt\kern-\p@\char 1}
\wd\parenlu\z@ \dp\parenlu\z@ \ht\parenlu\z@
\wd\parenru\z@ \dp\parenru\z@ \ht\parenru\z@
\def\upparenfill{$\m@th\mkern10mu%
  \raise2\p@\copy\parenlu\mkern-2mu\leaders\vrule height2.4\p@
  depth-2\p@\hfill\mkern3mu
  \raise2\p@\copy\parenru$}

\def\sm#1{\vbox{\m@th\ialign{##\crcr\noalign{\kern2\p@}
      \upparenfill\crcr \noalign{\nointerlineskip}
      $\hfil\displaystyle{#1}\hfil$\crcr}}}

\def\rightarrowfill{$\m@th\smash-\mkern-7mu%
  \cleaders\hbox{$\mkern-2mu\smash-\mkern-1.5mu$}\hfill%
  \mkern-3mu\raise5.1\p@\hbox to\z@{\kern-.8em\vbox to\z@%
  {\noindent$\scriptstyle\mathchar "0221$\vss}\hss}$}

\def\overrightarrow#1{\vbox{\m@th\ialign{##\crcr
      \rightarrowfill\crcr\noalign{\kern-.5\p@\nointerlineskip}
      $\hfil\displaystyle{#1}\hfil$\crcr}}}

\let\Vec\overrightarrow

\let\oldvec\vec
\let\mkvec\relax
\def\vec#1{\ifx 0#1\relax\skew{-3}\oldvec#1\else\def\reserved{#1}
\expandafter\futurelet\expandafter\testtoken\expandafter\@vec\fi}
\def\@vec{\ifx'\testtoken \def\mkvec{\skew{-3}}\fi
\ifx)\testtoken \def\mkvec{\skew{-3}}\fi
\mkvec\oldvec \reserved \let\mkvec\relax}

\def\tilde#1{\mathchoice{\mathaccent"707E {#1}}{\mathaccent"707E {#1}}
{\mathaccent"0365 {#1}}{\mathaccent"0365 {#1}}}
\def\hat#1{\mathchoice{\mathaccent"705E {#1}}{\mathaccent"705E {#1}}
{\mathaccent"0362 {#1}}{\mathaccent"0362 {#1}}}

\renewcommand\frac[2]{\mathchoice{{{#1}\over{#2}}}
{\hbox{\small$#1\mathstrut$}\over\hbox{\small$#2\mathstrut$}}
{{{#1}\over{#2}}}{{{#1}\over{#2}}}}

\def\azbuka#1{\expandafter\@azbuka\csname c@#1\endcsname}
\def\Azbuka#1{\expandafter\@Azbuka\csname c@#1\endcsname}
\def\@azbuka#1{%
  \ifcase#1\or а\or б\or в\or г\or д\or е\or ж\or з\or и\or
   к\or л\or м\or н\or о\or п\or р\or с\or т\or у\or ф\or х\or ц\or ч\or
   ш\or щ\or э\or ю\or я
    \else\@ctrerr\fi}
\def\@Azbuka#1{%
  \ifcase#1\or А\or Б\or В\or Г\or Д\or Е\or Ж\or З\or И\or
   К\or Л\or М\or Н\or О\or П\or Р\or С\or Т\or У\or Ф\or Х\or Ц\or Ч\or
   Ш\or Щ\or Э\or Ю\or Я
    \else\@ctrerr\fi}

\providecommand\dateslot{\@ifstar\@@dslot\@dslot}
\def\@dslot{<<\rule{1.5em}{.5pt}>>\rule{5em}{.5pt}199\rule{1em}{.5pt}\,г.\ }
\def\@@dslot{<<\rule{1.5em}{.5pt}>>\rule{5em}{.5pt}\,\the\year\,г.\ }

\def\dokaz{\@ifstar{\ssttrue\dokvo}{\sstfalse\dokvo}}
%\def\dokvo{\@ifnextchar[{\dok}{\dok[1]}}
\newcommand\dokvo[1][1]{\leavevmode\hbox{Д\kern#1\mm о\kern#1\mm к\kern#1\mm а\kern#1\mm з\kern#1\mm а%
\kern#1\mm т\kern#1\mm е\kern#1\mm л\kern#1\mm ь\kern#1\mm с\kern#1\mm т%
\kern#1\mm в\kern#1\mm о}\ifsst\ \else.\fi\ }%
\def\zamech{\smallskip\par\underline{З а м е ч а н и е.} \enspace}
\def\ukaz{\par\underline{\it Указание.}\ }
\newcommand\resh{\par Р е ш е н и е.\ }
}

\DeclareOption{envirs}{
\newcounter{theorem}%[subsection]
\newcounter{lemma}  %[subsection]
\newcounter{sled}   %[subsection]
\newcounter{opred}  %[subsection]
\newcounter{primer} %[subsection]
\renewcommand\theequation{\arabic{equation}}
\newenvironment{primer}{\refstepcounter{primer}\par\vskip6pt{П\ р\ и\ м\ е\ р\ \ \theprimer.}\ }{\vskip3pt}%
\newenvironment{noprimer}{\par\vskip6pt\textbf{П\ р\ и\ м\ е\ р.}\ }{\vskip3pt}%
\newenvironment{theorem}[1][\relax]{\refstepcounter{theorem}\par\vskip6pt%
   \let\@currentlabel\thetheorem
   \textbf{\hbox{Теорема~\thetheorem}\ifx #1\relax\else\ (#1)\fi.}\ \slshape}
   {\upshape\vskip6pt}%
\newenvironment{notheorem}{\par\vskip6pt\textbf{Теорема.}\ \slshape}{\upshape\vskip6pt}%
\newenvironment{lemma}[1][\relax]{\refstepcounter{lemma}\par\vskip6pt%
      \let\@currentlabel\thelemma%
      \textbf{\hbox{Лемма~\thelemma}\ifx #1\relax\else\ (#1)\fi.}\quad\slshape}
      {\upshape\vskip6pt}%
\newenvironment{nolemma}{\par\vskip6pt\textbf{Лемма.}\ \slshape}{\upshape\vskip6pt}%
\newenvironment{sled}{\refstepcounter{sled}\par\vskip6pt\textbf{Следствие~\thesled.}\ \slshape}{\upshape\vskip6pt}%
\newenvironment{nosled}{\par\vskip6pt\textbf{Следствие.}\ \slshape}{\upshape\vskip6pt}%
\newenvironment{opred}{\refstepcounter{opred}\par\vskip6pt\textbf{Определение~\theopred.}\ }{\nopagebreak\nobreak\par\vskip3pt}%
\newenvironment{noopred}{\par\vskip6pt\textbf{Определение.}\ }{\nobreak\par\vskip3pt}%
\renewcommand\theprimer{\arabic{primer}}
\renewcommand\thetheorem{\textbf{\arabic{theorem}}}
\renewcommand\theopred{\textbf{\arabic{opred}}}
\renewcommand\thesled{\textbf{\arabic{sled}}}
%\@namedef{theorem*}[#1]{\advance\c@theorem-\@ne \let\oldthethe\thetheorem%
%      \def\thetheorem{\arabic{part}.#1}\theorem}
%\@namedef{endtheorem*}{\endtheorem\let\thetheorem\oldthethe}
}

\DeclareOption{figs}{
\def\Side{\@ifstar{\ssttrue\@Side}{\sstfalse\@Side}}

\newcommand\@Side[2][0]{\refstepcounter{figure}%
  \setbox\@tempboxa\vtop{\parindent\z@\input{\picspath#2.pic}\smallskip}
  \dimen@=\wd\@tempboxa \@tempdima\dimen@ \divide\@tempdima\tw@
  \wd\@tempboxa\dimen@
  \begin{wrapfigure}{o}{\wd\@tempboxa}
  \centering
  \box\@tempboxa
  \ifsst\else\label{ris:#2}Рис.~\thefigure\def\@currentlabel{\thefigure}\fi
  \vskip#1\baselineskip
  \end{wrapfigure}}

\newcommand\sfig[1]{\begin{figure}[!htb]\refstepcounter{figure}
\if@little\Lengthunit=.75mm\else\Lengthunit=1mm\fi
\Nhalfperiods=1\magnitude=1000
\hfil\input{\picspath#1.pic}\hfil\par
\hfil Рис.~\thefigure\label{ris:#1}\hfil
\end{figure}}

\newcommand\dfig[2]{\begin{figure}[!htb]\refstepcounter{figure}
\if@little\Lengthunit=.75mm\else\Lengthunit=1mm\fi
\Nhalfperiods=1\magnitude=1000
\hfil\input{\picspath#1.pic}\hfil\input{\picspath#2.pic}\hfil\par
\hskip\z@ plus1fil Рис.~\thefigure\label{ris:#1}\refstepcounter{figure}
\hskip\z@ plus2fil Рис.~\thefigure\label{ris:#2}\hskip\z@ plus1fil
\end{figure}}

\def\picspath{}
}

\newif\if@discret
\@discretfalse

\DeclareOption{discret}{\@discrettrue
\def\mkdiscret#1#2#3#4#5{\gdef#1{\mathchar"#2#3#4#5\nobreak\discretionary{}%
{\hbox{$\m@th\mathchar"0#3#4#5$}}{}}}%

\def\discret#1#2#3#4{\mathchar"#1#2#3#4\nobreak\discretionary{}%
    {\hbox{$\m@th\mathchar"0#2#3#4$}}{}}

\def\*{\mathop{}}

\mkdiscret \cap225C
\mkdiscret \cup225B
\mkdiscret \mp2207
\mkdiscret \pm2206
\mkdiscret \times2202
\mkdiscret \parallel326B
\mkdiscret \mid326A
\mkdiscret \leq3214         %\let\le=\leq
\mkdiscret \geq3215         %\let\ge=\geq
\mkdiscret \supset321B
\mkdiscret \subset321A
\mkdiscret \in3232
\mkdiscret \ni3233          \let\owns=\ni
\mkdiscret \gg321D
\mkdiscret \ll321C
\mkdiscret \rightarrow3221  \let\to=\rightarrow
\mkdiscret \sim3218
\mkdiscret \simeq3227
\mkdiscret \perp323F
\mkdiscret \equiv3211
\mkdiscret \asymp3210
\mkdiscret \leftrightarrow3224
\mkdiscret \Leftrightarrow 322C
\mkdiscret \Leftarrow3228
\mkdiscret \Rightarrow3229
\mkdiscret \rightrightarrows 3{\hexnumber@\symAMSa}13
\mkdiscret \leqslant         3{\hexnumber@\symAMSa}36
\mkdiscret \geqslant         3{\hexnumber@\symAMSa}3E
%\mkdiscr \setminus226E
\mathcode`\+="8000
\mathcode`\-="8000
\mathcode`\=="8000
\mathcode`\>="8000
\mathcode`\<="8000
%\mathcode`\:="8000
%{\catcode`\:=\active \gdef:{\discret303A} }
\def\ne{\mathchar"3236\mathchar"303D\discretionary{}%
{\hbox{$\m@th\mathchar"3236\mathchar"303D$\nobreak}}{}}%
\def\neq{\mathchar"3236\mathchar"3211\discretionary{}%
{\hbox{$\m@th\mathchar"3236\mathchar"3211$\nobreak}}{}}%
\def\nin{\mathchar"3236\mathchar"3232\discretionary{}%
{\hbox{$\m@th\mathchar"3236\mathchar"3232$\nobreak}}{}}%
}

%\ExecuteOptions{params,macros,headrules,sections,listindent,plainaligns,names,envirs,figs,discret}
\ProcessOptions

\if@discret
{\catcode`\+=\active \gdef+{\discret202B} }
{\catcode`\-=\active \gdef-{\discret2200} }
{\catcode`\==\active \gdef={\discret303D} \gdef\={=\break=} }
{\catcode`\>=\active \gdef>{\discret313E} }
{\catcode`\<=\active \gdef<{\discret313C} }
\fi

\endinput
