The difference between \mkern
and \mskip
is only that the latter can have stretchability and shrinkability. For instance, the spacing between an ordinary symbol and a relation symbol is obtained by \mskip\thickmuskip
(TeX automatically does it); conversely \joinrel
, which is internally used for joining dashes in order to build a longer arrow, is \mathrel{\mkern-3mu}
, so it will give a fixed (negative) spacing independent on the stretching or shrinking the line will be subject to for justification.
The two commands must be followed by length specifications in mu
units (but the stretch or shrink components of a \mskip
can be expressed in fil(l)(l)
units): 18mu is the em width of the current math symbol font (TeXnically, the font in family 2). Thus 1mu in a superscript will be smaller than 1mu in normal size.
Another usage of \mkern
is in \pmod
that's used in contexts such as
$42 \equiv 2 \pmod{5}$
that gives
42 ≡ 2 (mod 5)
The definition is
\def\pmod#1{%
\allowbreak\mkern18mu({\operator@font mod}\,\,#1)}
Why is this notable? Because it shows an important feature: TeX only breaks lines inside math formulas only at penalties that it usually adds automatically after relation or operation symbols, but can be inserted manually as in this case. Since \allowbreak
means \penalty 0
, TeX is allowed to break before the space preceding the open parenthesis. The mkern, if a break is taken there, will disappear.
Actually, saying \mskip18mu
instead of \mkern18mu
would be the same, as the glue has no stretchability. So the choice between \mkern
and \mskip
is more conceptual than practical. If logically there should be a kern, use \mkern
: this is more efficient (very slightly, to be honest) when macro expansion is concerned, because when TeX has seen the mu
unit that ends the specification it won't expand tokens in search for a plus
or minus
component.
TeX has three "muskip" parameters: \thinmuskip
, \medmuskip
and \thickmuskip
, whose values are usually assigned by
\thinmuskip=3mu
\medmuskip=4mu plus 2mu minus 4mu
\thickmuskip=5mu plus 5mu
If one says \mkern\medmuskip
the stretch and shrink components are ignored, just like it happens when a glue parameter is used as argument to \kern
.
TeX has also 256 "mskip" registers \muskip0
to \muskip255
, but these are rarely used.