Differences between \stackrel and \stackbin
Don't use \stackrel
or \stackbin
, they are obsolete. Use instead \underset
and \overset
from amsmath as they automatically space things correctly (whether it's a binary relation or a binary operator):
\documentclass{article}
\usepackage{amsmath}
\begin{document}
$f(x) \overset{\text{def}}{=} x \ln(1+x)$
$f(x) \underset{x \to 0}{=} x^2 + o(x^2)$
$A \underset{\text{below}}{\overset{\text{above}}{+}} C$
\end{document}
Without the stackrel
package, \stackrel
is defined in ltxmath.dtx
as
\def\stackrel#1#2{\mathrel{\mathop{#2}\limits^{#1}}}
which typesets a relational operator with a top limit (effectively placing it on top). Heiko Oberdiek's stackrel
package is said to provide an
Enhancement to the
\stackrel
command.
This "enhancement" provides an optional argument to \stackrel
for placing something below the relational operator (using a similar process as the original \stackrel
). Additionally, it provides a counterpart for binary relations called \stackbin
. The difference between the two (or when to use which one) is contained within the post What is the difference between \mathbin
vs. \mathrel
? Here is a similar take on the use of stackrel
.
\documentclass{article}
\usepackage{stackrel}
\begin{document}
\begin{tabular}{clc}
\multicolumn{3}{c}{Relations} \\[5pt]
\LaTeX & Typeset & width \\
\hline
\verb|$x=x$| & $x=x$ & \setbox0=\hbox{$x=x$} \the\wd0 \\
\verb|$x\stackbin[c]{a}{=}x$| & $x\stackbin[c]{a}{=}x$ &
\setbox0=\hbox{$x\stackbin[c]{a}{=}x$} \the\wd0 \\
\verb|$x\stackrel[c]{a}{=}x$| & $x\stackrel[c]{a}{=}x$ &
\setbox0=\hbox{$x\stackrel[c]{a}{=}x$} \the\wd0 \\[10pt]
\multicolumn{3}{c}{Binary operators} \\[5pt]
\LaTeX & Typeset & width \\
\hline
\verb|$x+x$| & $x+x$ & \setbox0=\hbox{$x+x$} \the\wd0 \\
\verb|$x\stackbin[c]{a}{+}x$| & $x\stackbin[c]{a}{+}x$ &
\setbox0=\hbox{$x\stackbin[c]{a}{+}x$} \the\wd0 \\
\verb|$x\stackrel[c]{a}{+}x$| & $x\stackrel[c]{a}{+}x$ &
\setbox0=\hbox{$x\stackrel[c]{a}{+}x$} \the\wd0
\end{tabular}
\end{document}
Note the equivalent spacing using \stackrel
with =
, while similar spacing is returned using \stackbin
and +
. In essence, use \stackrel
for relational operators, and \stackbin
for binary operators.
I personally prefer using \mathop
, because it's simpler. Instead of using nested under/oversets, you could simply write:
$A \mathop{+}_{\text{below}}^{\text{above}} C$