
\usepackage{theorem,amsmath,amssymb,russcorr, fancyhdr, russcorr, russlh,epsfig}
\usepackage{ifthen}  % provides conditonals

\def\arrow{{\:\longrightarrow\:}}
\newcommand{\restrict}[1]{{\left|_{{\phantom{|}\!\!}_{#1}}\right.}}
\newcommand{\cntrct}                % contraction with a vector field
{\hspace{2pt}\raisebox{1pt}{\text{$\lrcorner$}}\hspace{2pt}}

\renewcommand{\leq}{\leqslant}
\renewcommand{\geq}{\geqslant}
\renewcommand{\epsilon}{\varepsilon}


%\addtolength{\topmargin}{-5mm}
%\addtolength{\textheight}{40mm}
%\addtolength{\oddsidemargin}{-25mm}
%\addtolength{\textwidth}{45mm}

\setlength{\headheight}{15pt}
\pagestyle{fancy} 
\lhead{\tiny матфак ВШЭ, весна 2014} 
\lfoot{\tiny впервые выдано \firstdate} 
\cfoot{-- \thepage \ -- } \rfoot{\tiny листок \thesection,\ \ \sc\version}
\rhead{{\tiny  Миша Вербицкий}}


\def\1{\sqrt{-1}}
\def\6{\partial}
\newcommand{\g}{{\mathfrak g}}
\def\rad{\operatorname{\sf rad}}
\def\Alt{\operatorname{\sf Alt}}
\def\Tr{\operatorname{\sf Tr}}
\def\Sym{\operatorname{\sf Sym}}
\def\Id{\operatorname{\sf Id}}
\def\rk{\operatorname{\sf rk}}
\def\Hom{\operatorname{Hom}}
\def\im{\operatorname{im}}
\def\Vol{\operatorname{Vol}}
\def\Lie{\operatorname{Lie}}
\def\Aut{\operatorname{Aut}}
\def\Map{\operatorname{Map}}
\newcommand{\End}{\operatorname{End}}
\newcommand{\Hol}{\operatorname{Hol}}
\newcommand{\Diff}{\operatorname{Diff}}
\newcommand{\Mat}{\operatorname{Mat}}
\newcommand{\Tot}{\operatorname{Tot}}
\newcommand{\diam}{\operatorname{\sf diam}}
\newcommand{\hor}{{\operatorname{\sf hor}}}
\newcommand{\Exp}{\operatorname{exp}}
\def\Der{\operatorname{Der}}
\newcommand{\Char}{\operatorname{\sf char}}

\def\calo{{\mathcal O}}
\def\Z{{\mathbb Z}}
\def\R{{\mathbb R}}
\def\C{{\mathbb C}}
\def\Q{{\mathbb Q}}
\def\N{{\mathbb N}}




\newif\ifshaded

\makeatletter
\begingroup
\gdef\th@upshape{\normalfont
  \def\@begintheorem##1##2{%
        \item[\hskip\labelsep \theorem@headerfont ##1\ ##2.]
        \writevedomost{\string\mc{\thezadacha} \string & \string & \string 
        \\ \string \hline}
   \shadedfalse
   }%
\def\@opargbegintheorem##1##2##3{%
   \item[\hskip\labelsep \theorem@headerfont ##1\ ##2\ (##3).]
   \writevedomost{\string\mc{\thezadacha ##3}  \string & \string \grd \string & \string\grp
   \string \\ \string \hline}
   \shadedtrue
   }}%
\endgroup

\theoremstyle{upshape}

\newtheorem{zadacha}{Задача}[section]

\begingroup
\gdef\th@generic{\normalfont
  \def\@begintheorem##1##2{%
        \item[\hskip\labelsep \theorem@headerfont ##1\ ##2.]
     }%
\def\@opargbegintheorem##1##2##3{%
   \item[\hskip\labelsep \theorem@headerfont ##1\ ##2\ (##3).]
    }}
\endgroup

\theoremstyle{generic}

\newtheorem{opredelenie}{Определение}[section]
\newtheorem{zamechanie}{Замечание}[section]

\begingroup
\gdef\th@upshapenonumber{\normalfont
  \def\@begintheorem##1##2{%
        \item[\hskip\labelsep \theorem@headerfont ##1.]}%
\def\@opargbegintheorem##1##2##3{%
   \item[\hskip\labelsep \theorem@headerfont ##1\ (##3).]}}
\endgroup

\theoremstyle{upshapenonumber}

\newtheorem{ukazanie}{Указание}[section]

\renewcommand{\labelenumi}{\ralph{enumi}.}
\newcommand{\subs}[1]{{\bigskip \bf\large {\centerline {#1}}\bigskip}}
\newcommand{\sttr}{{\bf(*)}}
\newcommand{\shrk}{{\bf(!)}}
\newcommand{\doublesttr}{{\bf(**)}}

\newcommand{\listok}[2]{%
\setcounter{page}{1}
\lhead{ \scriptsize #2 }
\section*{#2}
\refstepcounter{section}
\setcounter{section}{#1}
\writevedomost{\string & \string \multicolumn{3}{|c|} { \string \scriptsize
{ дата выдачи: %
   \firstdate}}\string \\ \string \hline} %
\renewcommand{\theequation}{\thesection.\arabic{equation}}
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% VEDOMOST GENERATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newwrite\Vedomost
\immediate\openout\Vedomost = \jobname.vdm
\newcommand{\writevedomost}[1]{\immediate\write\Vedomost{ #1 }}

\newcommand{\NewVedomost}%
{\writevedomost{\string\end{tabular} \string & \string\vedomostsize %
\string\begin{tabular}[t]{|c|c|@{}c@{}|@{}c@{}|} %
\string\hline %
\string\mc{$N^0$}\string&\string\dtt\string&\string\pdp\string\\ \string\hline %
}}

\def\grd{\psboxit{box .7 setgray fill}{\phantom{\dtt}}\vphantom{666}}
\def\grp{\psboxit{box .7 setgray fill}{\phantom{\pdp}}\vphantom{666}}


\makeatother

\def\бф{\bf}
\def\ем{\em}
\def\ит{\it}
\def\задача{\begin{zadacha}}
\def\ез{\end{zadacha}}
\def\замечание{\begin{zamechanie}}
\def\еза{\end{zamechanie}}
\def\указание{\begin{ukazanie}}
\def\еу{\end{ukazanie}}
\def\eu{\end{ukazanie}}
\def\определение{\begin{opredelenie}}
\def\ео{\end{opredelenie}}
\def\eo{\end{opredelenie}}
\def\goth{\mathfrak}
\def\енум{\begin{enumerate}} 
\def\ее{\end{enumerate}}
\def\ee{\end{enumerate}}


\newcommand{\итем}[1][{}]{\item %
    \ifthenelse { \equal {#1} {} } 
    { \ifshaded
          {\writevedomost{\string & \ralph{enumi}#1 \string & \string \grd \string & \string\grp
   \string \\ \string \hline }}
      \else
        \writevedomost{\string & \ralph{enumi} \string &\string & \string \\ \string \hline } 
      \fi 
    }
    { (#1) \writevedomost{\string & \ralph{enumi}#1 \string & \string \grd \string & \string\grp
   \string \\ \string \hline } }
}
