Here is a general kernel question. I am wondering why the leader dots are typeset in math mode.

While experimenting with my own sectioning commands, I had alignment issues with the dots. Does it have something to do with alignment?

            \mkern \@dotsep mu\hbox{.}\mkern \@dotsep

Anyway, I tried it like

            \kern .8em\hbox{.}\kern .8em}\hfill

and it seems pretty decent.

From the kernel latex.ltx:

  \ifnum #1>\c@tocdepth \else
    \vskip \z@ \@plus.2\p@
    {\leftskip #2\relax \rightskip \@tocrmarg \parfillskip -\rightskip
     \parindent #2\relax\@afterindenttrue
     \@tempdima #3\relax
     \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
        \mkern \@dotsep mu\hbox{.}\mkern \@dotsep
     \hb@xt@\@pnumwidth{\hfil\normalfont \normalcolor #5}%

Note that tocloft keeps this

    \leaders\hbox{$\m@th\mkern #1 mu\hbox{\cftdot}\mkern #1 mu$}\hfill
  • The leader dots are not really typeset in math mode, since the \hbox escapes it to text mode (in the current font). – Werner May 8 '18 at 22:03
  • 1
    Read p 371 of source2e.pdf. – Werner May 8 '18 at 22:04

This goes back to plain TeX and \dotfill which is defined as

\def\dotfill{\cleaders\hbox{$\m@th \mkern1.5mu.\mkern1.5mu$}\hfill}

LaTeX2.09 used the same definition, as did the first couple of releases of 2e. Then:

% \changes{v1.1u}{1996/10/28}{Removed math mode}

The current 2e definition is

  \cleaders \hb@xt@ .44em{\hss.\hss}\hfill

In LaTeX \@dottedtocline is a kind of extended \dotfill the 2.09 defintion used math mode as in the original \dotfill. In 2e though here we removed the math setting of the actual . but left the muskip spacing, probably so that the existing \@dotsep parameter still worked.

%  \item[|\@dotsep|] Separation between dots, in mu units.
%                  Should be |\def|'d to a number like 2 or 1.7

The removal of math mode . was even earlier than in \dotfill:

% \changes{v1.0k}{1995/04/25}{Added \cs{hbox} around dots.}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.