What is the function of \kern\z@ in the definition of \dotfill?
There are some places in TeX/LaTeX, where horizontal glue is removed, e.g.:
- At the end of a paragraph an ending space is removed by
\unskip
. - Table cells are surrounded by
\ignorespaces
and\unskip
to remove leading spaces and a trailing space.
However, \unskip
is not specific to spaces, it removes glue, which a space is.
\hfill
is another kind of glue, it is also removed. The additional \kern
at the end prevents \unskip
from seeing the glue before the \kern
and the \dotfill
stays.
If you invoke texdoc source2e
(to look at the listing for the source code for the LaTeX kernel), and search for \dotfill
, it says:
LaTeX change:
\kern\z@
added to end of\hrulefill
and\dotfill
to make them work in ‘tabular’ and ‘array’ environments. (Change made 24 July 1987).