-
Notifications
You must be signed in to change notification settings - Fork 0
/
etocsnippet-25.txt
96 lines (96 loc) · 3.67 KB
/
etocsnippet-25.txt
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
%% -*- mode: latex -*-
%% LaTeX2e file `etocsnippet-25.tex'
%% generated by the `filecontentshere' environment
%% from source `etoc' on 2024/01/12.
%% EDITED - to remove KOMA dependency
%% - to use \@gobbletodot with \ifnum due to section number format in
%% report class
%%
%% NOTE: this is a very subtle TOC which uses at the same time some styles
%% as in "Another compatibilty mode", \l@section, \l@subsection so
%% "inline tagging" must be off, but also (and in dynamically decided manner!)
%% it uses normal custom user styles, so here "inline tagginge" MUST be ON.
%%
%% NOTE: after adding suitable user mark-up there remains the problem
%% that any printing done in <start> or <finish> of custom line styles
%% is directly in <TOC> struct, not <TOCI> which is only open to enclose
%% <prefix><contents>. A separate issue will be opened about that.
%%
%% NOTE: it uses a global TOC, but chapter style is not defined, so
%% it uses fall-back chapter style of package, and we see an indentation
%% problem in output to be investigated separately.
\makeatletter
\def\@gobbletodot#1.{}
\newcommand*{\MyQuasiStandardTOC}[2][]{%
% #1 is an optional "\ref{somelabeltoanothertoc}" %%%%%%%% UNUSED here
% #2 is the number of some exceptional section
\begingroup
\etocsetlinestyle{section}
{}%
{\etociffirst{% Suppress display of subsections for the first section!
\etocsetlevel{subsection}{\etocthemaxlevel}}
{\etocsetlevel{subsection}{2}}
\ifnum\expandafter\@gobbletodot\etocthenumber=#2 % Handle especially section number #2 !
\etocsetlinestyle{subsection}
{%
%%%%%%%%>>>>
\etoctaggingon
%%%%%%%%<<<<
\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)}}
%%%%%%%%>>>>
%%%% ATTENTION "FINISH" PART IS DIRECTLY UNDER TOC, NO <TOCI> OPENED YET
%%%% cf location of \Etoc@doendsandbegin
{.\par \upshape My AI counted circa \foo\space subsections,
was it right?\par
\endgroup
%%%%
\etoctagginginlineoff
%%%%
}%
%%%%%%%%<<<<
\else
\ifnum\expandafter\@gobbletodot\etocthenumber>#2 % Only count subsections in those sections !
\etocsetlinestyle{subsection}
{\def\foo{}}%
{\edef\foo{\the\numexpr\foo+1}}%
{}%
%%%%%%%%>>>>
%%%% ATTENTION "FINISH" PART IS DIRECTLY UNDER <TOC>, NO <TOCI> OPENED YET
%%%% cf location of \Etoc@doendsandbegin. So the \emph causes a problem
%%%% \emph replaced by \textit to make this pass.
%%%% (we can not have a <P> as subthing of <TOC>..., but a <P> would be
%%%% necessaire for <Em> from an \emph)
{\leftskip2em \textit{There are \foo\space subsections here,
but I will need payment to display them.}\par}%
%%%%%%%%<<<<
\else
\etocsetlinestyle{subsection}
{}%
{}%
{\l@subsection{\numberline{\etocnumber}\etocname}{\etocpage}}%
{}%
\fi
\fi
}%
{% Display in a special color the number of the special section!
\l@section{\numberline{{\ifnum\expandafter\@gobbletodot\etocthenumber=#2
\color{red}\else\color{cyan}\fi\etocthenumber}}%
\etociffirst{\etocname\space (SUBSECTIONS SKIPPED)}{\etocname}}
{\etocpage}}%
{}%
\etocclasstocstyle % will use the ambient document class
\etocsetnexttocdepth {subsection}%
%%%%%%%%>>>>
\etoctagginginlineoff
%%%%%%%%<<<<
\tableofcontents #1%
\endgroup
}
\makeatother