# Must be equal and other stacked math symbols

Several times already I wanted to express something like

  !
A = B


or

   n->0
X ------> oo


in a math environment. How do I achieve this?

On a related note: What is the correct term for this? Googling for ! and = unsurprisingly doesn't yield too many useful results.

-

In the code below, I create a new command, \mbeq (short for "must be equal"...), which is a "math relational" operator (same type as the "ordinary" equal sign). Using the \overset command in the definition of the \mbeq operator automatically makes the new command "inherit" the type of the second argument of the \overset command; hence, it's not necessarily to assign the type "mathrel" explicitly.

\documentclass{article}
\usepackage{amsmath}
% "mbeq": must be equal
\newcommand{\mbeq}{\overset{!}{=}}
\begin{document}
$a\mbeq b$, $x\xrightarrow{n\to 0}\infty$
\end{document}


Finally, I'm not aware of a commonly used term for the "must be equal" symbol (exclamation mark set over equality symbol). I searched detexify, and no predefined symbol came up.

-
As I said in another comment, the \mathrel here is redundant, because \overset usually guesses right. But +1 for suggesting a new command for it. –  egreg Oct 21 '11 at 23:42
Thanks, @egreg. I'll update my answer accordingly. –  Mico Oct 22 '11 at 1:13
\documentclass{article}
\usepackage{amsmath}

\begin{document}

$\overset{!}{=}\qquad x\xrightarrow{n\to 0}\infty$

\end{document}


-
Rather than \stackrel I'd recommend \overset –  egreg Oct 21 '11 at 22:42
@egreg: right. I've edited my answer, thanks. –  Gonzalo Medina Oct 21 '11 at 22:52
@egreg: In this \case, there is no difference between the visual output of \stackrel and \overset. I guess the only motivation behind it is that it has an \underset counterpart which makes it more generic in terms of usage. –  Werner Oct 21 '11 at 22:58
@Werner That's a happy case. Try with \stackrel{!}{x} and you'll see the difference. Besides, \overset tries to guess the nature of the main symbol (relation or operation), so using the correct spacing; conversely, \stackrel always creates a relation. –  egreg Oct 21 '11 at 23:05