blob: cfbebf66e4b335c937191ab276cf292ea69e7407 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
%% LaTeX2e file `etocsnippet-21-A.tex'
%% generated by the `filecontentshere' environment
%% from source `etoc' on 2021/07/13.
%%
% it will be easy to globally shift the TOC horizontally if needed
\def\TOCleftmargin {0pt}
\def\TOCrightmargin {2.55em}% like LaTeX's \@tocrmarg
% this is for dotted leaders
\newbox\TOCleaderbox
\def\TOCleaderboxwidth {0.7777em}% about like what standard classes do
% vertical spacing
\def\TOCverysmallvskip {0pt plus .2pt}
\def\TOCmedvskip {1em plus 1pt}
\def\TOCbigvskip {2.25em plus 1pt}
% the ``numwidths'' for typesetting the numbering of division units.
% I don't recall exactly how (and for which fonts) these figures were chosen.
% They quickly prove too small if using Roman numerals (as do too the book
% class defaults even though they are a bit larger).
\def\TOCnumwidthB {1.5em} % chapter
\def\TOCnumwidthC {2.278em}% section, I think default is 2.3em
\def\TOCnumwidthD {3.056em}% analog in standard class is 3.2em
\def\TOCnumwidthE {3.833em}% analog in standard class is 4.1em
\def\TOCnumwidthF {4.611em}% analog in standard class is 5em
\def\TOCnumwidthG {5.389em}% analog in standard class is 6em
% The code for the ``global toc style''.
\newcommand*\TOCglobalstyle {%
\etocsettocstyle
{\if@twocolumn \@restonecoltrue \onecolumn \else \@restonecolfalse \fi
\parindent\z@ \leftskip\z@skip \rightskip \z@skip
\setbox\TOCleaderbox\hbox to \TOCleaderboxwidth{\hss.\hss}%
\chapter *{\noindent\kern\TOCleftmargin\relax % uses "pt"...
\contentsname
\@mkboth {\MakeUppercase \contentsname}{\MakeUppercase \contentsname}}%
\rightskip \TOCrightmargin\relax
\parfillskip -\rightskip % or a smaller value if desired
\leftskip \TOCleftmargin \relax }
{\if@restonecol \twocolumn \fi\cleardoublepage}%
%
\etocsetstyle{part}
{}
{\addpenalty {-\@highpenalty}%
\addvspace \TOCbigvskip
\leavevmode
{\large \bfseries % use a group to limit font change
\interlinepenalty\@M
\etocifnumbered{\etocnumber\hspace{1em}}{}%
\etocname
\nobreak\hfil\makebox[-\parfillskip][r]{\etocpage}}\par
\nobreak
}
{}
{}%
%
\etocsetstyle{chapter}
{\advance\leftskip\TOCnumwidthB\relax}
{\addpenalty {-\@highpenalty }%
\vskip \TOCmedvskip\relax
\leavevmode
{\interlinepenalty\@M
\etocifnumbered
{\llap{\makebox[\TOCnumwidthB][l]{\bfseries\etocnumber}}}
{\advance\leftskip-\TOCnumwidthB\relax}%
\bfseries\etocname
\nobreak\hfil\makebox[-\parfillskip][r]{\etocpage}\par }%
\penalty \@highpenalty
}
{}
{\advance\leftskip-\TOCnumwidthB\relax}%
%
\TOCsetlinestyle {section} {\TOCnumwidthC}%
\TOCsetlinestyle {subsection} {\TOCnumwidthD}%
\TOCsetlinestyle {subsubsection}{\TOCnumwidthE}%
\TOCsetlinestyle {paragraph} {\TOCnumwidthF}%
\TOCsetlinestyle {subparagraph} {\TOCnumwidthG}%
}% end of \TOCglobalstyle
%The common code for line styles is abstracted into a macro:
\newcommand\TOCsetlinestyle [2]{% #1= unit, #2= numwidth as macro
\etocsetstyle{#1}
{\advance\leftskip#2\relax}
{\vskip \TOCverysmallvskip\relax
\leavevmode
{\interlinepenalty\@M
\etocifnumbered
{\llap{\makebox[#2][l]{\etocnumber}}}{\advance\leftskip-#2\relax}%
\etocname
\nobreak\leaders \copy\TOCleaderbox
\hfil\makebox[-\parfillskip][r]{\etocpage}%
\par }%
}
{}
{\advance\leftskip-#2\relax}%
}
\makeatother
|