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:
\makeatletter
\DeclareRobustCommand{\textnormalf}[1]{% f for "keep the family
\text{\usefont{\f@encoding}{\f@family}{m}{n}#1}%
}
\makeatother
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 series m
and font shape n
we're choosing upright medium type.
Of course, a more meaningful name for \textnormalf
should be chosen according to its usage and semantics.
A blank line in TeX input is a command it is equivalent to \par
so you should not put it in places where you don't want to start a new paragraph. Like any command, if you want to put it in the source file for some reason, but don't want it to be executed, then you need to comment it out, but generally it's simpler not to put it there in the first place:-)
Best Answer
In package/class files and in your preamble, paragraph breaks do not have any special meaning so empty lines are innocuous. Use them generously to structure your code. Important caveat: even in the preamble, when you define a macro the newlines inside the definition will be interpreted in the context of their expansion so if you are going to use them in the body, the rules below apply. When catcodes are changed (for example by use of
\obeylines
) there are no general rules and you need to examine the active character's definitions in that context.In the body of the document some care should be taken. As mentioned in the comments, an empty line, in the body, is a paragraph break. You should use them to mark the end of paragraphs.
Note however, that consecutive multiple empty lines constitute a single paragraph break and thus they can be used to separate portions of code without inserting extra space apart from that single break.
Some commands, such as sectioning commands, already take care of spacing and insert paragraphs breaks when necessary before the section, so empty lines preceding them will not harm.
Other commands/environments like equations, itemizes or tables, instead are sensitive to the presence of paragraph breaks around them and you should put some care in deciding whether you want that break or not. In case you don't but want to keep some vertical space in code, you can always escape the line with
%
.In math mode white space is generally discarded but empty line still generate paragraph breaks which are not allowed, so you should always escape them.
There are similar issues within some environments as tabular, where paragraph breaks are not allowed without extra care (e.g. by using
\parbox
).