blob: 48c76cd32caea5bd50bdec2921ed36c990b9d541 (
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
|
%% LaTeX2e file `etocsnippet-25.tex'
%% generated by the `filecontentshere' environment
%% from source `etoc' on 2023/10/29.
%%
\makeatletter
\newcommand*{\MyQuasiStandardTOC}[2][]{%
% #1 is an optional "\ref{somelabeltoanothertoc}"
% #2 is the number of some exceptional section
\begingroup
\etocsetstyle{section}
{}
{\etociffirst{% Suppress display of subsections for the first section!
\etocsetlevel{subsection}{\etocthemaxlevel}}
{\etocsetlevel{subsection}{2}}%
\ifnum\etocthenumber=#2 % Handle especially section number #2 !
\etocsetstyle{subsection}
{\def\foo{}\par\nopagebreak\begingroup
\leftskip2em \rightskip\@tocrmarg
\parfillskip \@flushglue
\parindent 0pt
\normalfont\normalsize\rmfamily\itshape
\etocskipfirstprefix}
{\allowbreak\,--\,}
{\edef\foo{\the\numexpr\foo+1}\etocname\ \textup{(\etocnumber)}}
{.\par \upshape My AI counted circa \foo\space subsections,
was it right?\par\endgroup}%
\else
\ifnum\etocthenumber>#2 % Only count subsections in those sections !
\etocsetstyle{subsection}
{\def\foo{}}%
{\edef\foo{\the\numexpr\foo+1}}%
{}%
{\leftskip2em \emph{There are \foo\space subsections here,
but I will need payment to display them.}\par}%
\else
\etocsetstyle{subsection}
{}%
{}%
{\l@subsection{\numberline{\etocnumber}\etocname}{\etocpage}}%
{}%
\fi
\fi
}%
{% Display in a special color the number of the special section!
\l@section{\numberline{{\ifnum\etocthenumber=#2
\color{red}\else\color{cyan}\fi\etocthenumber}}%
\etociffirst{\etocname\space (SUBSECTIONS SKIPPED)}{\etocname}}
{\etocpage}}%
{}%
\etocclasstocstyle % will use the ambient document class
% special KOMA-script customization as this document uses scrartcl
% and we need to enlarge numwidth for some subsections
\DeclareTOCStyleEntry[numwidth=2em,indent=0pt]{tocline}{section}
\DeclareTOCStyleEntry[numwidth=2.5em,indent=2em]{tocline}{subsection}
\etocsetnexttocdepth {subsection}%
\tableofcontents #1
\endgroup
}
\makeatother
|