Textual subscripts like in W_{total}
should be typeset in an upright text font (so that code isn't good practice), as has been discussed in various questions here. Now there are several ways to achieve this, and I'm somewhat confused which I should use:
-
W_{\rm total}
is nice and short, and appears to work in all circumstances, but I expect LaTeX people will frown upon it:-)
Is there any good reason against this? -
W_{\mathrm{total}}
– is this the LaTeX equivalent of the\rm
approach? -
W_{\textnormal{total}}
sounds reasonable astotal
is text and not math … -
In this answer, Ulrike Fischer suggests a more complicated approach.
-
Even
W_{\operatorname{total}}
appears to work, but it seems inappropriate.
Note: I always assume here that amsmath
is loaded.
I've already asked some questions above, but my main question is: which of these options is the best practice for textual subscripts?
Let me point out why I haven't mentioned \text
, \textrm
or \textup
above. Those commands (mostly) keep the font of the context they're used in, e.g., in an italic context, \text
and \textrm
would give italic subscripts, and all three yield bold subscripts in a bold context.
Final note: This question is similar to, but not the same as all those questions about the differences between \mbox
, \text
, \textrm
, \mathrm
, \operatorname
that have been asked before. Maybe it's still a duplicate …
Best Answer
First of all, the problem presents for textual subscripts, such as those used in physics to distinguish between vectors with the same name (say a force) by a subscripted label that should go in upright type. Textual subscripts are used in many other fields.
In what follows,
amsmath
is assumed.$W_{\rm total}$
is totally wrong as it relies on a deprecated command that classes don't need to define (and indeed some don't).$W_{\mathrm{total}}$
is the correct form of the above. Limitations: spaces are gobbled and hyphens become minus signs.$W_{\textnormal{total}}$
uses the main roman font of the document, no matter the context; the argument is typeset as text at the correct size.$W_{\mathup{total}}$
(with Ulrike Fischer's definition) has one advantage over\mathrm
, since it uses\familydefault
, but the same limitations.$W_{\operatorname{total}}$
is like using a sledgehammer for killing a fly. It's the same as\mathrm
, but hyphens don't become minus signs.$W_{\text{total}}$
might seem ideal, but it changes font according to the context, so the subscript would appear in italics in a theorem statement.Therefore, form 3 seems the most natural. Notice that braces are not really necessary, except in case 5.
To be honest, for single words
\mathrm
(or\mathup
) is more efficient, as\textnormal
uses\mathchoice
and typesets four times the subscript in different sizes. However, the overhead is almost negligible with modern machines and uniformity is to be preferred to efficiency, when it doesn't slow the workflow in a significant way.If, for some reasons, one wants that textual subscripts are typeset in upright type, but keeping the current font family, for instance because some parts of the document use sans serif type also for math (which I don't agree with), a modified version of
\textnormal
can be used:Here
\f@encoding
and\f@family
are the current output font encoding and font family, as stored by LaTeX at each (text) font change; with font seriesm
and font shapen
we're choosing upright medium type.Of course, a more meaningful name for
\textnormalf
should be chosen according to its usage and semantics.