| 1 |
%% LaTeX2e file `etocsnippet-25.tex' |
| 2 |
%% generated by the `filecontentshere' environment |
| 3 |
%% from source `etoc' on 2026/05/05. |
| 4 |
%% |
| 5 |
\makeatletter |
| 6 |
\newcommand*{\MyQuasiStandardTOC}[2][]{% |
| 7 |
% #1 is an optional "\ref{somelabeltoanothertoc}" |
| 8 |
% #2 is the number of some exceptional section |
| 9 |
\begingroup |
| 10 |
\etocsetlinestyle{section} |
| 11 |
{} |
| 12 |
{\etociffirst{% Suppress display of subsections for the first section! |
| 13 |
\etocsetlevel{subsection}{\etocthemaxlevel}} |
| 14 |
{\etocsetlevel{subsection}{2}}% |
| 15 |
\ifnum\etocthenumber=#2 % Handle especially section number #2 ! |
| 16 |
\etocsetlinestyle{subsection} |
| 17 |
{\def\foo{}\par\nopagebreak\begingroup |
| 18 |
\leftskip2em \rightskip\@tocrmarg |
| 19 |
\parfillskip \@flushglue |
| 20 |
\parindent 0pt |
| 21 |
\normalfont\normalsize\rmfamily\itshape |
| 22 |
\etocskipfirstprefix} |
| 23 |
{\allowbreak\,--\,} |
| 24 |
{\edef\foo{\the\numexpr\foo+1}\etocname\ \textup{(\etocnumber)}} |
| 25 |
{.\par \upshape My AI counted circa \foo\space subsections, |
| 26 |
was it right?\par\endgroup}% |
| 27 |
\else |
| 28 |
\ifnum\etocthenumber>#2 % Only count subsections in those sections ! |
| 29 |
\etocsetlinestyle{subsection} |
| 30 |
{\def\foo{}}% |
| 31 |
{\edef\foo{\the\numexpr\foo+1}}% |
| 32 |
{}% |
| 33 |
{\leftskip2em \emph{There are \foo\space subsections here, |
| 34 |
but I will need payment to display them.}\par}% |
| 35 |
\else |
| 36 |
\etocsetlinestyle{subsection} |
| 37 |
{}% |
| 38 |
{}% |
| 39 |
{\l@subsection{\numberline{\etocnumber}\etocname}{\etocpage}}% |
| 40 |
{}% |
| 41 |
\fi |
| 42 |
\fi |
| 43 |
}% |
| 44 |
{% Display in a special color the number of the special section! |
| 45 |
\l@section{\numberline{{\ifnum\etocthenumber=#2 |
| 46 |
\color{red}\else\color{cyan}\fi\etocthenumber}}% |
| 47 |
\etociffirst{\etocname\space (SUBSECTIONS SKIPPED)}{\etocname}} |
| 48 |
{\etocpage}}% |
| 49 |
{}% |
| 50 |
\etocclasstocstyle % will use the ambient document class |
| 51 |
% special KOMA-script customization as this document uses scrartcl |
| 52 |
% and we need to enlarge numwidth for some subsections |
| 53 |
\DeclareTOCStyleEntry[numwidth=2em,indent=0pt]{tocline}{section} |
| 54 |
\DeclareTOCStyleEntry[numwidth=2.5em,indent=2em]{tocline}{subsection} |
| 55 |
\etocsetnexttocdepth {subsection}% |
| 56 |
\tableofcontents #1 |
| 57 |
\endgroup |
| 58 |
} |
| 59 |
\makeatother |