Each are defined as follows in the default document classes (article
, book
and report
):
\strut
\def\strut{\relax\ifmmode\copy\strutbox\else\unhcopy\strutbox\fi}
with \strutbox
defined as
\setbox\strutbox\hbox{%
\vrule\@height.7\baselineskip
\@depth.3\baselineskip
\@width\z@}%
\mathstrut
\def\mathstrut{\vphantom(}
Using \mathstrut
would be equivalent to using \vphantom(
, with \strut
sets a zero-width rule (\@width\z@
) with depth .3\baselineskip
(\@depth.3\baselineskip
) and height .7\baselineskip
(\@height.7\baselineskip
). Note that the latter is font-dependent, since it uses \baselineskip
. That is, it is modified with font change selections using \fontsize{..}{..}\selectfont
, including the use font switches like \small
, \large
, etc.
I would use \strut
within text or math, and use \vphantom
if there is anything else I want a specific height of without the horizontal displacement. For example, when breaking two lines of math with different heights but still wanting to use extensible delimiters \left
and \right
. \mathstrut
is specific to the size of (
and (quoting barbarabeeton), "\mathstrut
is often better in math than \strut
. Which one is better depends on the local context."
Loading the amsmath
redefines these boxes somewhat, although their interpretation remains the same.
The original Computer Modern Roman fonts in upright shape (cmr
) are designed only at sizes 5, 6, 7, 8, 9, 10, 12 and 17.
However the TeX Live system is able to produce on demand other sizes based on the interpolation scripts by John Sauter. So when you ask for cmr18
, the system runs the script and the font is created (a .tfm
file and a bitmap for the rendering on screen an on print, the .600pk
file).
It would be probably better to ask for
\font\fifteenrm=cmr12 at 15pt
which will scale cmr12
and you'll get a Type1 font for rendering. Similarly for cmbx
, which is available at the maximum size of 12pt (in the original form).
Best Answer
\sbox
is a short form of\savebox
in the same way that\mbox
is a short form of\makebox
for the common case where you do not need to specify any lengths and want the natural size of the box.\setbox
is the underlying TeX primitive so it does not read its arguments as a normal macro (like the comparison between\hbox
and\mbox
) and it is not safe to use with colour commands unless you take extra precautions to insert extra groups, that the LaTeX versions do automatically.Added note: One other important difference I forgot before, it is implicit in the examples below but not highlighted.
\sbox\boxa{aa}
is like\setbox\boxa\hbox{....}
so it supplies the\hbox
. So if you need to save vertical material you need to save a vbox in an hbox, whereas with\setbox
you can do\setbox\boxa\vbox{aaa \par bbb}
however there is not much difference between a vbox and an hbox containing a vbox, unless you start using unboxing primitives, so this difference isn't a major one in practice.UPDATE examples added as requested (the source is more informative than the output)