答案1
这是来自 latex.ltx 的标准定义\dottedtocline
:
\def\@dottedtocline#1#2#3#4#5{%
\ifnum #1>\c@tocdepth \else
\vskip \z@ \@plus.2\p@
{\leftskip #2\relax \rightskip \@tocrmarg \parfillskip -\rightskip
\parindent #2\relax\@afterindenttrue
\interlinepenalty\@M
\leavevmode
\@tempdima #3\relax
\advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
{#4}\nobreak
\leaders\hbox{$\m@th
\mkern \@dotsep mu\hbox{.}\mkern \@dotsep
mu$}\hfill
\nobreak
\hb@xt@\@pnumwidth{\hfil\normalfont \normalcolor #5}%
\par}%
\fi}
我们需要在这里每隔一行移动一次。一种方法是引入一个标志(例如\ifshiftdots
),并使其\dottedtocline
切换。如果切换为真,我们将点移动半个周期,否则我们不移动:
\makeatletter
\newif\ifshiftdots
\shiftdotsfalse
\def\@dottedtocline#1#2#3#4#5{%
\ifnum #1>\c@tocdepth \else
\vskip \z@ \@plus.2\p@
{\leftskip #2\relax \rightskip \@tocrmarg \parfillskip -\rightskip
\parindent #2\relax\@afterindenttrue
\interlinepenalty\@M
\leavevmode
\@tempdima #3\relax
\advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
{#4}\nobreak
\ifshiftdots
\global\shiftdotsfalse
\leaders\hbox{$\m@th\mkern \@dotsep mu
\mkern \@dotsep mu\hbox{.}$}\hfill
\else
\global\shiftdotstrue
\leaders\hbox{$\m@th\mkern \@dotsep mu
\hbox{.}\mkern \@dotsep mu$}\hfill
\fi
\nobreak
\hb@xt@\@pnumwidth{\hfil\normalfont \normalcolor #5}%
\par}%
\fi}
\makeatother