Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
What text do you want above the equal sign? –  Gonzalo Medina Sep 25 '12 at 23:55

2 Answers 2

up vote 20 down vote accepted

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.

share|improve this answer
    
Wouldn't be \mbox better than \text in this case, so that the def is still upshape even e.g. in theorem? –  tohecz Sep 26 '12 at 6:43
    
@tohecz -- if upshape is always desired, then the expression (as in this case) is probably an operator name, so that approach would be better. –  barbara beeton Sep 26 '12 at 12:44
    
@tohecz yes; I updated my answer. Thanks you. –  Gonzalo Medina Sep 26 '12 at 14:47
    
I'd prefer \overset to \stackrel; instead of \mbox I'd use \mathrm or \textnormal. –  egreg Sep 26 '12 at 15:52
    
@egreg; right; I've added an example with \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). –  Gonzalo Medina Sep 26 '12 at 17:23
$\stackrel{sometext}{=}$

greets

share|improve this answer
    
Is it possible to change the size and fonts of the text? I tried {\small sometext|, but it didn't work. Also the syntax isn't working very well in \begin{align}...\end{align} environment –  sidht Sep 25 '12 at 23:36
1  
@jak: Please include a minimal working example (MWE) that shows your current usage and highlight clearly what you want or need changed. Do so via an edit to your post. –  Werner Sep 25 '12 at 23:55
    
@jak: You can't use \small in mathmode. Have a look at Gonzalo's answer, he successfully uses \tiny there... –  Tom Bombadil Sep 26 '12 at 1:19

Your Answer

 
discard

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.