\newcommand\ifpub[2]{\if\published y #1 \else #2 \fi}

\theoremstyle{plain}
\newtheorem{theorem}{Theorem}
\newtheorem{AlmostTruth}[theorem]{Almost Truth}
\newtheorem{axiom}[theorem]{Axiom}
\newtheorem{claim}[theorem]{Claim}
\newtheorem{conjecture}[theorem]{Conjecture}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{defprop}[theorem]{Definition-Proposition}
\newtheorem{dream}[theorem]{Dream}
\newtheorem{fact}[theorem]{Fact}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{principle}[theorem]{Principle}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{slogan}[theorem]{Slogan}
\newtheorem{Truth}[theorem]{Truth}

\theoremstyle{definition}
\newtheorem{convention}[theorem]{Convention}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{defwarn}[theorem]{Definition and Warning}
\newtheorem{figcap}[theorem]{Figure}
\newtheorem{image}[theorem]{Image}
\newtheorem{lemmadefinition}[theorem]{Lemma-Definition}
\newtheorem{problem}[theorem]{Problem}
\newtheorem{question}[theorem]{Question}
\newtheorem{solution}[theorem]{Solution}
\newtheorem{prize}[theorem]{Prize}

\newtheorem{comment}[theorem]{Comment}
\newtheorem{comments}[theorem]{Comments}
\newtheorem{clarification}[theorem]{Clarification}
\newtheorem{discussion}[theorem]{Discussion}
\newtheorem{example}[theorem]{Example}
\newtheorem{exercise}[theorem]{Exercise}
\newtheorem{hint}[theorem]{Hint}
\newtheorem{motivation}[theorem]{Motivation}
\newtheorem{note}[theorem]{Note}
\newtheorem{proviso}[theorem]{Proviso}
\newtheorem{remark}[theorem]{Remark}
\newtheorem{technicality}[theorem]{Technicality}
\newtheorem{warning}[theorem]{Warning}

\newcommand{\prtag}[1]{\tag*{\llap{$#1$\hskip-\displaywidth}}}

\newcommand{\mathmode}[1]{$#1$}
\newlength{\standardunitlength}
\setlength{\standardunitlength}{0.00083333in}

\newcommand{\ad}{\operatorname{ad}}
\newcommand{\adj}{\operatorname{adj}}
\newcommand{\Ad}{\operatorname{Ad}}
\newcommand{\Alt}{\operatorname{Alt}}
\newcommand{\Aut}{\operatorname{Aut}}
\newcommand{\Diff}{\operatorname{Diff}}
\newcommand{\End}{\operatorname{End}}
\newcommand{\gr}{\operatorname{gr}}
\newcommand{\im}{\operatorname{im}}
\newcommand{\mor}{\operatorname{mor}}
\newcommand{\Span}{\operatorname{span}}
\newcommand{\sign}{\operatorname{sign}}
\newcommand{\sym}{\operatorname{sym}}
\newcommand{\tr}{\operatorname{tr}}

\def\car{\reflectbox{\usym{1F697}}}
\def\rac{\usym{1F697}}

\def\qed{{\linebreak[1]\null\hfill\text{$\Box$}}}
\def\endpar#1{~\hfill\fbox{\footnotesize#1}}

\newlength{\globalparindent}
\setlength{\globalparindent}{\parindent}

%\newcommand{\udot}{{\mathaccent\cdot\cup}}

\def\proof{{\par\noindent {\em Proof. } }}

\def\arXiv#1{{\href{https://arxiv.org/abs/#1}{arXiv:\linebreak[0]#1}}}

\def\weburl{http://drorbn.net/SL2PO}
\def\web#1{\href{\weburl/#1}{\begin{greek}web\end{greek}/#1}}

\def\bbe{{\mathbb e}}
\def\bbA{{\mathbb A}}
\def\bbB{{\mathbb B}}
\def\bbC{{\mathbb C}}
\def\bbD{{\mathbb D}}
\def\bbE{{\mathbb E}}
\def\bbF{{\mathbb F}}
\def\bbH{{\mathbb H}}
\def\bbN{{\mathbb N}}
\def\bbQ{{\mathbb Q}}
\def\bbR{{\mathbb R}}
\def\bbV{{\mathbb V}}
\def\calB{{\mathcal B}}
\def\calD{{\mathcal D}}
\def\calE{{\mathcal E}}
\def\calF{{\mathcal F}}
\def\calG{{\mathcal G}}
\def\calK{{\mathcal K}}
\def\calL{{\mathcal L}}
\def\calR{{\mathcal R}}
\def\calU{{\mathcal U}}
\def\fraka{{\mathfrak a}}
\def\frakb{{\mathfrak b}}
\def\frakd{{\mathfrak d}}
\def\frakg{{\mathfrak g}}
\def\frakh{{\mathfrak h}}
\def\frakl{{\mathfrak l}}
\def\frakn{{\mathfrak n}}
\def\fraku{{\mathfrak u}}
\def\hatcalU{\hat{\mathcal U}}
\def\tilg{{\tilde{g}}}

\def\act{{\hspace{-1pt}\sslash\hspace{-0.75pt}}}

\def\Hom{\operatorname{Hom}}
\def\Id{\text{\it Id}}
\def\Kh{\text{\it Kh}}
\def\sleps{{sl_{2+}^\eps}}
\def\Vol{\text{\it Vol}}

\def\draftcut{\if\draft y \cleardoublepage \fi}
%\def\draftcut{\cleardoublepage}

\definecolor{lightred}{RGB}{255, 217, 217}
\def\lightred#1{\setlength{\fboxsep}{0pt}\colorbox{lightred}{#1}}
\def\blue{\color{blue}}
\def\gray{\color{gray}}
\def\red{\color{red}}
\def\yellowm#1{{\setlength{\fboxsep}{0pt}\colorbox{yellow}{$#1$}}}
\def\yellowt#1{{\setlength{\fboxsep}{0pt}\colorbox{yellow}{#1}}}

% Following
% http://tex.stackexchange.com/questions/23521/tabular-vertical-alignment-to-top
\def\imagetop#1{\vtop{\null\hbox{#1}}}

\def\ds{\displaystyle}

\def\eps{\epsilon}
\def\so{\mathfrak{so}}
\def\gl{\mathfrak{gl}}
\def\spl{\mathfrak{sl}}
\def\slneps{{\spl_{n+}^\eps}}
\def\glneps{{\gl_{n+}^\eps}}

% \Gint from https://tex.stackexchange.com/questions/171415/superimpose-letter-on-integral-symbol
\makeatletter
\let\DOTSI\relax % amsmath support for \dots
\newcommand*{\Gint}{%
  \DOTSI
  \mathop{%
    \mathpalette\@LetterOnInt{G}%
  }%
  \mkern-\thinmuskip % thin space is inserted between two \mathop
  \int
}
\newcommand*{\@LetterOnInt}[2]{%
  \sbox0{$#1\int\m@th$}%
  \sbox2{$%
    \ifx#1\displaystyle
      \textstyle
    \else
      \scriptscriptstyle
    \fi
    #2%
  \m@th$}%
  \dimen@=.4\dimexpr\ht0+\dp0\relax
  \ifdim\dimexpr\ht2+\dp2\relax>\dimen@
    \sbox2{\resizebox*{!}{\dimen@}{\unhcopy2}}%
  \fi
  \dimen@=\wd0 %
  \ifdim\wd2>\dimen@
    \dimen@=\wd2 %
  \fi
  \rlap{\hbox to \dimen@{\hfil
    $#1\vcenter{\copy2}\m@th$%
  \hfil}}%
  \ifdim\dimen@>\wd0 %
    \kern.5\dimexpr\dimen@-\wd0\relax
  \fi
}
\makeatother

\def\ip{{i^+}} \def\jp{{j^+}} \def\kp{{k^+}}
\def\ipp{{i^{+\!+}}} \def\jpp{{j^{+\!+}}} \def\kpp{{k^{+\!+}}}

\def\face{\input{figs/face.pdf_t}}
\def\human{\input{figs/human.pdf_t}}
\def\machine{\input{figs/machine.pdf_t}}

\ifpub{\def\cellscale{0.76}}{\def\cellscale{1}}
\newsavebox\pdfbox
\newlength{\pdfheight}

\def\nbpdfPostInput{\vskip 2mm}
\def\nbpdfInput#1{{%
  \savebox{\pdfbox}{\includegraphics[scale=\cellscale, max width=\linewidth-0.27in]{#1}}%
  \settoheight{\pdfheight}{\usebox{\pdfbox}}%
  %\uselengthunit{mm}\printlength{\pdfheight}%
  \noindent\imagetop{\ifdim\pdfheight<10mm\face\else\human\fi}\ %
  \imagetop{\usebox{\pdfbox}}%
  \nbpdfPostInput%
}}

\def\nbpdfPreOutput{~}
\def\nbpdfOutput#1{{\noindent{\imagetop{\machine}\nbpdfPreOutput\imagetop{\includegraphics[scale=\cellscale, max width=\linewidth-0.27in]{#1}}\vskip 2mm}}}

\def\nbpdfEcho#1{{\noindent{\imagetop{\machine}\ \imagetop{\includegraphics[scale=\cellscale]{#1}}\vskip 2mm}}}
\def\nbpdfMessage#1{{}}
%\def\nbpdfMessage#1{{\noindent{\imagetop{\machine}\ \imagetop{\includegraphics[scale=\cellscale]{#1}}\vskip 2mm}}}
\def\nbpdfPrint#1{{\noindent{\imagetop{\machine}\ \imagetop{\includegraphics[scale=\cellscale]{#1}}\vskip 2mm}}}
