%% 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
