I am a novice of LaTeX, and I encounter the following code which I can't understand fully.
\def\@dottedtocline#1#2#3#4#5{%
\ifnum #1>\c@tocdepth tt\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 1.5mu\cdot\mkern 1.5mu$}\hfill
\nobreak
\hb@xt@\@pnumwidth{\hfil\normalfont \normalcolor #5}%
\par}%
\fi}
The first is
\leftskip #2 \relax \rightskip \@tocrmarg \parfillskip -\rightskip
\parindent #2 \relax\@afterindenttrue
Could somebody explain it to me in detail?
The second
\advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
What's the meaning of it, why using \hskip -\leftskip
and what is the meaning of \advance\leftskip \@tempdima
?
Thank you in advance!
Best Answer
The code presumably isn't intended to be read by a novice LaTeX user but...
a macro with 5 arguments
If
#1
is deeper than the limit for the table of contents depth typesettt
(a typo??) Otherwiseadd a small vertical space between 0 and .2pt
set
\leftskip
(space before left edge of paragraph) to#2
set
\rightskip
to\@tocrmarg
set
\parfillskip
(extra space at end of paragraph) to-\rightskip
so it cancels out the\rightskip
, ensuring the paragraph ends flush with the right margin.set paragraph indent to
#2
set this boolean flag to true, to control indentation of first paragraph after the heading.
prevent page breaks between lines
start a paragraph
set this temporary register to
#3
Increase the left skip by the value just stored
add an empty box to the paragraph just started
back up by the left skip so as to make the first line not be indented by
\leftskip
typeset or otherwise do whatever is in
#4
prevent a break at this point
make a row of dots
prevent a break
set
#5
in a box of fixed width\@pnumwidth
end the paragraph and the group
end the if test