This is difficult for me to explain, but how do I put words over a symbol? For instance, I want to add words over an equal sign. Anyone know the command/syntax for that?
Also adding ^
doesn't cut it..., I want the text to appear ON TOP.
This is difficult for me to explain, but how do I put words over a symbol? For instance, I want to add words over an equal sign. Anyone know the command/syntax for that?
Also adding ^
doesn't cut it..., I want the text to appear ON TOP.
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}
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}
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}
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.
\mbox
better than \text
in this case, so that the def
is still upshape even e.g. in theorem?
\overset
to \stackrel
; instead of \mbox
I'd use \mathrm
or \textnormal
.
\overset
; thank you. I kept the \mbox
since I wanted to illustrate changes to the font for the text (which the OP seems to want to apply according to a comment to the other answer).
Commented
Sep 26, 2012 at 17:23
$\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
\small
in mathmode. Have a look at Gonzalo's answer, he successfully uses \tiny
there...
Commented
Sep 26, 2012 at 1:19
\text
inside, you can use any text command you want ;)
Commented
Feb 18, 2016 at 15:54
\underset
instead of \stackrel
, because the former is "obsolete".
$\overset{\mathrm{def}}{=}$
\overset
is available in amsmath
package.
Good luck.
\underset
option, this the simplest answer.
Commented
Jan 13, 2018 at 0:51
\overset
and \stackrel
here.
Commented
Jun 11 at 9:49
All answers here suppose that you are using LaTeX (??). If it is not true then there is standard plain TeX macro \buildrel
for doing this. The syntax is \buildrel (what above) \over (relation)
$a \buildrel \rm def \over = b$
\bye