Where should 1em be defined - when to use lengths in "em"
When you say \setlength{\mylength}{1em}
, the real length stored in \mylength
will depend on the font that is current at the time of the assignment.
Each font defines its own em
unit; for instance it is 10pt for the usual Computer Modern Roman at 10pt; it is 19pt for \huge
(which is Computer Modern Roman at 20.7pt).
If you say \hspace{1em}
, the current size of the em
is used. For some reasons (that I don't understand), the revtex4-1
class doesn't issue the \normalsize
and \normalfont
commands, so in the preamble the current font is still the "null" one, which has all font parameters zero. Only at begin document the main document font is established.
Conversely the standard classes (not minimal
) issue the command \normalsize
after having defined it, so the em
unit will have a value. Possibly not the one for the main document font, however: some font packages delay selecting the main font at begin document.
When to choose the em
unit for setting a length? I recommend only some specific cases, that is, the lengths that should depend on the main font size. An important case is \parindent
. Great typographers recommend that the normal paragraph indent should be 1em; if you want to ensure this and not rely on the LaTeX default (for the standard classes) of 15pt, then
\AtBeginDocument{\setlength{\parindent}{1em}}
will do the right thing, provided this is issued after having loaded the font packages. Also other lengths could be set in terms of the main font's em: all those regarding list indentations, for instance, which shouldn't depend on the relative font size.
For "explicit" horizontal lengths, using em
is recommendable, but one can also choose fractions of the column width: it mostly depends on the specific application.
NOTE. The behavior of revtex4-1
is nonstandard and should be corrected, in my opinion. Some packages rely on a default em for setting their own defaults (which is a good guess in many cases). If you issue \normalsize
before doing settings that involve the em, you'll get it. Having to issue \normalsize
before loading booktabs
is to be considered a bug.
The other documentclasses fail to select fonts on loading. As the em
unit is defined in terms of the current font this can be fixed by adding the command \normalfont
before loading booktabs
(and after any font packages that might be relevant), which expects em
to be defined:
\documentclass{revtex4-1}
\normalfont
\usepackage{booktabs}
\newlength\mylength
\setlength\mylength{1em}%
\begin{document}
\begin{tabular}{ll}
\toprule
Light rule width:&\the\lightrulewidth\\
\midrule
Heavy rule width:&\the\heavyrulewidth\\
\midrule
Width of 1em:&\the\mylength \\
\bottomrule
\end{tabular}
\end{document}
When using the article
documentclass, you load article.cls
which in turn loads size10.clo
(for 10pt). This .clo
file includes the call \normalsize
which in turn includes a \selectfont
command, bringing the current font in to action.