TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What are the differences between \stackrel and \stackbin? In what situations is it better to use one or the other?

share|improve this question
Effectively, this boils down to the question related to \mathbin and \mathrel which can be found in what is the difference between mathbin vs. mathrel – percusse Dec 24 '11 at 3:36
Which do I use if I just want to stack text and do not want added spacing to separate math from text? – Village Dec 24 '11 at 3:42
@Village: If you want to remove any text influence from your \stackrel (or \stackbin) choice, then you can use \usepackage{amsmath,stackrel}$a\stackrel{\text{\makebox[0pt]{abc}}}{=}b$. This typesets abc in text mode in the appropriate font size without any width, and would therefore not influence math spacing. \stackrel and \stackbin typically only have narrow entries on top of/below them. Is this what you might be after? – Werner Dec 24 '11 at 4:05
Yes, I just want three layers of stacked and centered text, without modifying any of the spacing. Would it be better if I used some other way to position the text in three levels? – Village Dec 24 '11 at 4:28
@Village: You could use any number of means. For example, typeset things in an array or tabular that is vertically centered, or use \stackrel. Either way, this seems to be a departure from your current question which relates specifically to \stackrel and \stackbin. – Werner Dec 24 '11 at 4:45
up vote 21 down vote accepted

Without the stackrel package, \stackrel is defined in ltxmath.dtx as


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.

enter image description here

\usepackage{stackrel}% http://ctan.org/pkg/stackrel
  \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

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.

share|improve this answer

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):

result of the code below




$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$

share|improve this answer

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$
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.