\newcommand{\@mop}[1]{
  \ifmath\@itemdisplay\fi%
  \@print{<mo> &}\@subst{#1}\@print{; </mo>}%
  \ifmath\@itemdisplay\fi}
\newcommand{\@mopop}[1]{\@print{<mo> &}\@subst{#1}\@print{; </mo>}}
\newcommand{\@mid}[1]{
  \ifmath\@itemdisplay\fi%
  \@print{<mi> &}\@subst{#1}\@print{; </mi>}%
  \ifmath\@itemdisplay\fi}
\newcommand{\@mfun}[1]{\@print{<mo> }\@subst{#1}\@print{ </mo>}}

%% Symboles mathematiques
%% classes dans le meme ordre que
%% dans le livre LaTeX, de Leslie Lamport.


%% overline, underline et Cie

\renewcommand{\stackrel}[2]{\ifdisplay
\@print{
<mover>}%
\@open{DISPLAY}{}#2\@close{DISPLAY}{}

\@open{DISPLAY}{}#1\@close{DISPLAY}{}%
\@print{
</mover>}
\else
\textstackrel{#1}{#2}\fi}

\renewcommand\overline[1]{\ifdisplay
\@print{
<mover accent="true">}%
\@open{DISPLAY}{}#1\@close{DISPLAY}{}%
\@print{<mo> &horbar; </mo>
</mover>}
\else\textoverline{#1}\fi}

\renewcommand\underline[1]{\ifdisplay
\@print{
<munder accentunder="true">}%
\@open{DISPLAY}{}#1\@close{DISPLAY}{}%
\@print{<mo> &horbar; </mo>
</munder>}
\else\textunderline{#1}\fi}


% Roots
\newcommand{\sqrt}[2][!*!]{\ifthenelse{\equal{#1}{!*!}}%
{\@print{<msqrt>
}%
#2\@print{
</msqrt>}%
}{\@print{<mroot>
}\@open{DISPLAY}{}%
#2
\@close{DISPLAY}{}%
\@open{DISPLAY}{}%
#1%
\@close{DISPLAY}{}%
\@print{
</mroot>
}}}

% Ellipsis
\renewcommand{\ldots}{\ifmath\@mop{TripleDot}\else{...}\fi}
\renewcommand{\cdots}{\@mop{ctdot}}
\renewcommand{\ddots}{\@mop{dtdot}}
\renewcommand{\vdots}{\@mop{ratio}}
%vdots is not the true symbol, but i didn't
%find a better one..

%% Greek Letters
\newcommand{\alpha}{\@mid{alpha}}
\newcommand{\beta}{\@mid{beta}}
\newcommand{\gamma}{\@mid{gamma}}
\newcommand{\delta}{\@mid{delta}}
\newcommand{\epsilon}{\@mid{epsi}}
\newcommand{\varepsilon}{\@mid{epsiv}}
\newcommand{\zeta}{\@mid{zeta}}
\newcommand{\eta}{\@mid{eta}}
\newcommand{\theta}{\@mid{theta}}
\newcommand{\vartheta}{\@mid{vartheta}}
\newcommand{\iota}{\@mid{iota}}
\newcommand{\kappa}{\@mid{kappa}}
\newcommand{\lambda}{\@mid{lambda}}
\renewcommand{\mu}{\@mid{mu}}
\newcommand{\nu}{\@mid{nu}}
\newcommand{\xi}{\@mid{xi}}
\newcommand{\pi}{\@mid{pi}}
\newcommand{\varpi}{\@mid{piv}}
\newcommand{\rho}{\@mid{rho}}
\newcommand{\varrho}{\@mid{rhov}}
\newcommand{\sigma}{\@mid{sigma}}
\newcommand{\varsigma}{\@mid{sigmav}}
\newcommand{\tau}{\@mid{tau}}
\newcommand{\upsilon}{\@mid{upsi}}
\newcommand{\phi}{\@mid{phi}}
\newcommand{\varphi}{\@mid{phiv}}
\newcommand{\chi}{\@mid{chi}}
\newcommand{\psi}{\@mid{psi}}
\newcommand{\omega}{\@mid{omega}}

\newcommand{\Gamma}{\@mid{Gamma}}
\newcommand{\Delta}{\@mid{Delta}}
\newcommand{\Theta}{\@mid{Theta}}
\newcommand{\Lambda}{\@mid{Lambda}}
\newcommand{\Xi}{\@mid{Xi}}
\newcommand{\Pi}{\@mid{Pi}}
\newcommand{\Sigma}{\@mid{Sigma}}
\newcommand{\Upsilon}{\@mid{Upsi}}
\newcommand{\Phi}{\@mid{Phi}}
\newcommand{\Psi}{\@mid{Psi}}
\newcommand{\Omega}{\@mid{Omega}}

%% Binary Operation Symbols
\renewcommand{\pm}{\@mop{PlusMinus}}
\newcommand{\mp}{\@mop{mp}}
\renewcommand{\times}{\@mop{times}}
\renewcommand{\div}{\@mop{div}}
\renewcommand{\ast}{\@mop{ast}}
\renewcommand{\star}{\@mop{star}}
\newcommand{\circ}{\@mop{circ}}
\renewcommand{\bullet}{\@mop{Bull}}
\renewcommand{\cdot}{\@mop{cdot}}
\newcommand{\cap}{\@mop{cap}}
\newcommand{\cup}{\@mop{Cup}}
\newcommand{\uplus}{\@mop{UnionPlus}}
\newcommand{\sqcap}{\@mop{SquareIntersection}}
\newcommand{\sqcup}{\@mop{SquareUnion}}
\newcommand{\vee}{\@mop{Or}}
\newcommand{\wedge}{\@mop{And}}
\renewcommand{\setminus}{\@mop{setminus}}
\newcommand{\wr}{\@mop{wr}}
\newcommand{\diamond}{\@mop{diamond}}
\newcommand{\bigtriangleup}{\@mop{bigtriangleup}}
\newcommand{\bigtriangledown}{\@mop{dtri}}   %bigtriangledown}}
\newcommand{\triangleleft}{\@mop{triangleleft}}
\newcommand{\triangleright}{\@mop{triangleright}}
\newcommand{\lhd}{\@mop{LeftTriangle}}
\newcommand{\rhd}{\@mop{RightTriangle}}
\newcommand{\unlhd}{\@mop{LeftTriangleEqual}}
\newcommand{\unrhd}{\@mop{RightTriangleEqual}}
\newcommand{\oplus}{\@mop{CirclePlus}}
\newcommand{\ominus}{\@mop{CircleMinus}}
\newcommand{\otimes}{\@mop{CircleTimes}}
\newcommand{\oslash}{\@mop{oslash}}
\newcommand{\odot}{\@mop{CircleDot}}
\renewcommand{\bigcirc}{\@mop{bigcirc}}
\newcommand{\dagger}{\@mop{dagger}}
\newcommand{\ddagger}{\@mop{ddagger}}
\newcommand{\amalg}{\@mop{amalg}}

% Relation Symbols
\newcommand{\leq}{\@mop{leq}}
\newcommand{\prec}{\@mop{prec}}
\newcommand{\preceq}{\@mop{preceq}}
\renewcommand{\ll}{\@mop{ll}}
\newcommand{\subset}{\@mop{SubSet}}
\newcommand{\subseteq}{\@mop{SubSetEqual}}
\renewcommand{\sqsubset}{\@mop{sqsubset}}
\newcommand{\sqsubseteq}{\@mop{sqsubseteq}}
\newcommand{\in}{\@mop{Element}}
\renewcommand{\vdash}{\@mop{RightTee}}
\newcommand{\geq}{\@mop{geq}}
\newcommand{\succ}{\@mop{succ}}
\renewcommand{\gg}{\@mop{gg}}
\newcommand{\supset}{\@mop{SuperSet}}
\newcommand{\supseteq}{\@mop{SuperSetEqual}}
\renewcommand{\sqsupset}{\@mop{sqsupset}}
\newcommand{\sqsupseteq}{\@mop{sqsupseteq}}
\newcommand{\ni}{\@mop{SuchThat}}
\renewcommand{\dashv}{\@mop{LeftTee}}
\newcommand{\equiv}{\@mop{equiv}}
\renewcommand{\sim}{\@mop{Tilde}}
\renewcommand{\simeq}{\@mop{simeq}}
\newcommand{\asymp}{\@mop{CupCap}}
\newcommand{\approx}{\@mop{ap}}
\newcommand{\cong}{\@mop{TildeFullEqual}}
\newcommand{\neq}{\@mop{NotEqual}}
\renewcommand{\doteq}{\@mop{doteq}}
\newcommand{\notin}{\@mop{NotElement}}
\renewcommand{\models}{\@mop{DoubleRightTee}}
\newcommand{\perp}{\@mop{UpTee}}
\renewcommand{\mid}{\@mop{VerticalBar}}
\newcommand{\parallel}{\@mop{parallel}}
\newcommand{\bowtie}{\@mop{bowtie}}
%\newcommand{\Join}{\@mop{}}
\newcommand{\smile}{\@mop{smile}}
\newcommand{\frown}{\@mop{frown}}
\newcommand{\propto}{\@mop{Proportional}}

% Arrow Symbols
\newcommand{\leftarrow}{\@mop{LeftArrow}}
\newcommand{\Leftarrow}{\@mop{DoubleLeftArrow}}
\newcommand{\rightarrow}{\@mop{RightArrow}}
\newcommand{\Rightarrow}{\@mop{DoubleRightArrow}}
\newcommand{\leftrightarrow}{\@mop{LeftRightArrow}}
\newcommand{\Leftrightarrow}{\@mop{DoubleLeftRightArrow}}
\renewcommand{\mapsto}{\@mop{mapsto}}
\newcommand{\hookleftarrow}{\@mop{hookleftarrow}}
\newcommand{\leftharpoonup}{\@mop{leftharpoonup}}
\newcommand{\leftharpoondown}{\@mop{leftharpoondown}}
\newcommand{\rightleftharpoons}{\@mop{rightleftharpoons}}
\newcommand{\longleftarrow}{\@mop{longleftarrow}}
\newcommand{\Longleftarrow}{\@mop{Longleftarrow}}
\newcommand{\longrightarrow}{\@mop{longrightarrow}}
\newcommand{\Longrightarrow}{\@mop{Longrightarrow}}
\newcommand{\longleftrightarrow}{\@mop{longleftrightarrow}}
\newcommand{\Longleftrightarrow}{\@mop{Longleftrightarrow}}
\newcommand{\longmapsto}{\@mop{longmapsto}}
\newcommand{\hookrightarrow}{\@mop{hookrightarrow}}
\newcommand{\rightharpoonup}{\@mop{rightharpoonup}}
\newcommand{\rightharpoondown}{\@mop{rightharpoondown}}
\newcommand{\leadsto}{\@mop{zigrarr}}
\newcommand{\uparrow}{\@mop{UpArrow}}
\newcommand{\Uparrow}{\@mop{DoubleUpArrow}}
\newcommand{\downarrow}{\@mop{DownArrow}}
\newcommand{\Downarrow}{\@mop{DoubleDownArrow}}
\newcommand{\updownarrow}{\@mop{UpDownArrow}}
\newcommand{\Updownarrow}{\@mop{DoubleUpDownArrow}}
\newcommand{\nearrow}{\@mop{UpperRightArrow}}
\newcommand{\searrow}{\@mop{LowerRightArrow}}
\newcommand{\swarrow}{\@mop{LowerLeftArrow}}
\newcommand{\nwarrow}{\@mop{UpperLeftArrow}}

% Miscellaneous symbols
\newcommand{\aleph}{\@mop{aleph}}
\newcommand{\hbar}{\@mop{hbar}}
\newcommand{\imath}{\@mop{imath}}
\newcommand{\jmath}{\@mop{jmath}}
\newcommand{\ell}{\@mop{ell}}
\newcommand{\wp}{\@mop{weierp}}
\newcommand{\Re}{\@mop{Re}}
\newcommand{\Im}{\@mop{Im}}
\newcommand{\mho}{\@mop{mho}}
\newcommand{\prime}{\@mop{prime}}
\renewcommand{\emptyset}{\@mop{empty}}
\newcommand{\nabla}{\@mop{nabla}}
\newcommand{\surd}{\@mop{Sqrt}}
\newcommand{\top}{\@mop{top}}
\renewcommand{\bot}{\@mop{bot}}
\renewcommand{\|}{\@mop{DoubleVerticalBar}}
\newcommand{\angle}{\@mop{angle}}
\newcommand{\forall}{\@mop{ForAll}}
\newcommand{\exists}{\@mop{Exist}}
\renewcommand{\neg}{\@mop{Not}}
\newcommand{\flat}{\@mop{flat}}
\newcommand{\natural}{\@mop{natural}}
\newcommand{\sharp}{\@mop{sharp}}
\renewcommand{\backslash}{\@mop{Backslash}}
\newcommand{\partial}{\@mop{PartialD}}
\newcommand{\infty}{\@mop{infin}}
\newcommand{\Box}{\@mop{square}}
\newcommand{\Diamond}{\@mop{loz}}
\newcommand{\triangle}{\@mop{triangle}}
\newcommand{\clubsuit}{\@mop{clubs}}
\newcommand{\diamondsuit}{\@mop{Diamond}}
\newcommand{\heartsuit}{\@mop{hearts}}
\newcommand{\spadesuit}{\@mop{spades}}

% Variable-sized Symbols
\newcommand{\sum}{\@mopop{sum}}
\newcommand{\prod}{\@mopop{PI}}
\newcommand{\coprod}{\@mopop{Coproduct}}
\newcommand{\int}{\@mopop{int}}
\newcommand{\oint}{\@mopop{oint}}
\newcommand{\bigcap}{\@mopop{bigcap}}
\newcommand{\bigcup}{\@mopop{bigcup}}
\newcommand{\bigsqcup}{\@mopop{bigsqcup}}
\newcommand{\bigvee}{\@mopop{bigvee}}
\newcommand{\bigwedge}{\@mopop{bigwedge}}
\newcommand{\bigodot}{\@mopop{bigodot}}
\newcommand{\bigotimes}{\@mopop{bigotimes}}
\newcommand{\bigoplus}{\@mopop{bigoplus}}
\newcommand{\biguplus}{\@mopop{biguplus}}



%% Functions

\renewcommand{\arccos}{\@mfun{arccos}}
\renewcommand{\arcsin}{\@mfun{arcsin}}
\renewcommand{\arctan}{\@mfun{arctan}}
\renewcommand{\arg}{\@mfun{arg}}
\renewcommand{\cos}{\@mfun{cos}}
\renewcommand{\cosh}{\@mfun{cosh}}
\renewcommand{\cot}{\@mfun{cot}}
\renewcommand{\coth}{\@mfun{coth}}
\renewcommand{\csc}{\@mfun{csc}}
\renewcommand{\deg}{\@mfun{deg}}
\renewcommand{\det}{\@mfun{det}}
\renewcommand{\dim}{\@mfun{dim}}
\renewcommand{\exp}{\@mfun{exp}}
\renewcommand{\gcd}{\@mfun{gcd}}
\renewcommand{\hom}{\@mfun{hom}}
\renewcommand{\inf}{\@mfun{inf}}
\renewcommand{\ker}{\@mfun{ker}}
\renewcommand{\lg}{\@mfun{lg}}
\renewcommand{\lim}{\@mfun{lim}}
\renewcommand{\liminf}{\@mfun{liminf}}
\renewcommand{\limsup}{\@mfun{limsup}}
\renewcommand{\ln}{\@mfun{ln}}
\renewcommand{\log}{\@mfun{log}}
\renewcommand{\max}{\@mfun{max}}
\renewcommand{\min}{\@mfun{min}}
\renewcommand{\Pr}{\@mfun{Pr}}
\renewcommand{\sec}{\@mfun{sec}}
\renewcommand{\sin}{\@mfun{sin}}
\renewcommand{\sinh}{\@mfun{sinh}}
\renewcommand{\sup}{\@mfun{sup}}
\renewcommand{\tan}{\@mfun{tan}}
\renewcommand{\tanh}{\@mfun{tanh}}
\renewcommand{\bmod}{\@mfun{mod}}