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.

For my text-in-mathmode needs in LaTeX, I use \mbox. However, it does not seem to behave well in subscripts. How can I write text that adjusts its height?

$ 3 \mbox{dB} = f_{ 3 \mbox{dB} } $

compiles to

example

share|improve this question
1  
see the FAQ: tex.ac.uk/cgi-bin/texfaq2html?label=mathstext –  Philipp Mar 7 '11 at 1:35
    
@Philipp: Thanks, I hadn't read that. –  Tim N Mar 7 '11 at 1:43
add comment

1 Answer

up vote 13 down vote accepted

Use the \text macro of the amsmath package instead of \mbox for general text in mathmode. It takes care of these issues.

Note that for units in math- or textmode the use of the siunitx package is highly recommended.

share|improve this answer
    
Thanks. Should I always use \text instead of \mbox? –  Tim N Mar 6 '11 at 23:01
    
@Tim: For text inside mathmode yes, but not in textmode. –  Martin Scharrer Mar 6 '11 at 23:06
4  
I do not quite agree, say you want to specify the radius of a circular lake, then $R_{\textup{lake}}$ would be a better choice. Why try setting it in an italic context. So for named indices I'd use \textup, one could use \mathrm or \textrm, but then what if one is using a sans serif context, so in these cases \textup (i.e. non italic text font) is better. But for general comments in math, \text is the right choice –  daleif Mar 6 '11 at 23:13
    
@daleif: I didn't know about \textup which seems to be a nice alternative to \text. I was talking more about the general case in \mbox vs. \text where \text (or its friends) should always be used. –  Martin Scharrer Mar 6 '11 at 23:19
    
@daleif: Good point, thanks! –  Tim N Mar 6 '11 at 23:20
show 7 more comments

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.