How do I put text over symbols?

$\stackrel{sometext}{=}$

if sometext is not intended to be in math mode then write \text{sometext} within. (\text is available in amsmath package)

$\stackrel{\text{sometext}}{=}$

blessings


You can use a combination of \stackrel and \mathclap (from the mathtools package):

\documentclass{article}
\usepackage{mathtools}

\newcommand\myeq{\stackrel{\mathclap{\normalfont\mbox{def}}}{=}}

\begin{document}

\begin{align*}
a &\myeq b \\
  &=c \\
  &= d.
\end{align*}

\end{document}

enter image description here

If using mathtools is not an option, you can use a \makebox of width 0pt:

\documentclass{article}
\usepackage{amsmath}

\newcommand\myeq{\mathrel{\stackrel{\makebox[0pt]{\mbox{\normalfont\tiny def}}}{=}}}

\begin{document}

\begin{align*}
a &\myeq b \\
  &=c \\
  &= d.
\end{align*}

\end{document}

enter image description here

Even better, if amsmath has been loaded, is to use \overset instead of \stackrel; a little example using \tiny\sffamily for "def" :

\documentclass{article}
\usepackage{amsmath}

\newcommand\myeq{\mathrel{\overset{\makebox[0pt]{\mbox{\normalfont\tiny\sffamily def}}}{=}}}

\begin{document}

\begin{align*}
a &\myeq b \\
  &=c \\
  &= d.
\end{align*}

\end{document}

enter image description here

Inside the argument for \mbox one can use some of the font modifiers, as I did in my second and third examples.

Particularly, I don't like this kind of notation (it's not really necessary); you should consider if you really need the text above the equal sign.


$\overset{\mathrm{def}}{=}$

\overset is available in amsmath package.

Good luck.

Tags:

Syntax