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 question already has an answer here:

I was wondering whether it is possible to add some comment on top of the \approx symbol in a similar way that the command \xrightarrow{text} produces an arrow with text over it.

share|improve this question

marked as duplicate by mafp, lockstep, Claudio Fiandrino, Werner, Martin Schröder Mar 15 '13 at 15:50

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3  
See also tex.stackexchange.com/q/74125/15925 –  Andrew Swann Mar 15 '13 at 10:42
add comment

3 Answers 3

up vote 9 down vote accepted

You can use the \stackrel{}{} for this:

\documentclass[preview]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\newcommand{\approxtext}[1]{\ensuremath{\stackrel{\text{#1}}{\approx}}}
\begin{document}
    $\displaystyle
        A \stackrel{\text{text}}{\approx} B
    $, 
    $\displaystyle
        A \approxtext{test} B
    $
\end{document}

Or a small wrapper: \newcommand{\approxtext}[1]{\ensuremath{\stackrel{\text{#1}}{\approx}}}. Result:

enter image description here

share|improve this answer
    
The text above the symbol should probably treated as text, not as math. What's the purpose of the additional braces? –  egreg Mar 15 '13 at 10:33
    
Thanks for such a detailed explanation However, I don't see the difference between the different approaches? I found that I can also accommodate math in the text above by the usual prescription $mathtext$ –  pablo Mar 15 '13 at 10:54
add comment

You can use \stackrel{a=b}{\approx} or if it is real text \stackrel{\text{your text}}{\approx} if your text is not too long. The \approx symbol is rather small, so I wouldn't add too much on top to keep your equations readable.

share|improve this answer
    
That's working perfect! Thanks for the quickness! Just to know, which package does it comes from this? ams math? –  pablo Mar 15 '13 at 10:53
1  
@pablo: Actually, you don't even need amsmath for this. But amsmath has two more commands: \overset and \underset. The former does basically the same as \stackrel –  Anke Mar 15 '13 at 11:13
add comment

As already mentioned \stackrel can be used for it. I'd just recommend adding \scriptscriptstyle or, say, \tiny if it is just text, plus \smash. Otherwise one often ends up having a combined symbol that mess with the line spacing if used in the text.

\newcommand\defeq{\stackrel{\smash{\scriptscriptstyle\mathrm{def}}}{=}}

Small size to reduce the height
\smash to remove the height completely (the small size then help us not to overlap too much with the line above)

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.