[Tex/LaTex] How to put symbol around the equal sign


In the question Latex Math Symbol: Vitanyi puts a tiny plus symbol over his equals. How do I do that?, there was an answer to how to place additional sign over the equal sign.

And my question is, what if I also want to have some symbol/text under the equal sign?
Or if I want to use \stackrel to label my equal sign that follows an tab alignment character (&=)?

Best Answer

The amsmath package provides the \overset and \underset macros that can be used to place one symbol above or below another. If you want text above and below, you could use \DeclareMathOperator* (also from amsmath).

\underset{b}{=} \quad  \eq^a_b

There shouldn't be any problems using this in amsmath environments such as align.

A  &\eq^b_a B \\
   &\eq^b_a C

However, if you use it in the middle column of an eqnarray or eqnarray* (which are generally considered to be obsolete), then you will need \displaystyle before \eq.

All of the above applies to egreg's suggestion of defining \eq via


which seems to improve the spacing (and may be better in other ways as well).