12

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

19

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.

  • 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
  • 1
    @daleif: \textup is also not optimal; it'll be bold in a bold context. I guess \textnormal is better. – Hendrik Vogt Feb 15 '13 at 20:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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