%% LaTeX2e file `etocsnippet-21.tex'
%% generated by the `filecontentshere' environment
%% from source `etoc' on 2026/05/05.
%%
\makeatletter
\newcommand*\TOCcompute@numwidths [2]{% #1=empty/"local", #2=minimal indent
  \begingroup
    \def\TOCnumwidthB {0pt}%
    \def\TOCnumwidthC {0pt}%
    \def\TOCnumwidthD {0pt}%
    \def\TOCnumwidthE {0pt}%
    \def\TOCnumwidthF {0pt}%
    \def\TOCnumwidthG {0pt}%
    \etocsetlinestyle{part}{}{}{}{}%
    \etocsetlinestyle{chapter}{}
      {\setbox0\hbox{\bfseries\etocthenumber\kern#2}}
      {\ifdim\wd0>\TOCnumwidthB\edef\TOCnumwidthB{\the\wd0}\fi}{}%
    \etocsetlinestyle{section}{}
      {\setbox0\hbox{\bfseries\etocthenumber\kern#2}}
      {\ifdim\wd0>\TOCnumwidthC\edef\TOCnumwidthC{\the\wd0}\fi}{}%
    \etocsetlinestyle{subsection}{}
      {\setbox0\hbox{\etocthenumber\kern#2}}
      {\ifdim\wd0>\TOCnumwidthD\edef\TOCnumwidthD{\the\wd0}\fi}{}%
    \etocsetlinestyle{subsubsection}{}
      {\setbox0\hbox{\etocthenumber\kern#2}}
      {\ifdim\wd0>\TOCnumwidthE\edef\TOCnumwidthE{\the\wd0}\fi}{}%
    \etocsetlinestyle{paragraph}{}
      {\setbox0\hbox{\etocthenumber\kern#2}}
      {\ifdim\wd0>\TOCnumwidthF\edef\TOCnumwidthF{\the\wd0}\fi}{}%
    \etocsetlinestyle{subparagraph}{}
      {\setbox0\hbox{\etocthenumber\kern#2}}
      {\ifdim\wd0>\TOCnumwidthG\edef\TOCnumwidthG{\the\wd0}\fi}{}%
    %
    \etocsettocstyle
     {}
     {\global\let\TOCnumwidthB\TOCnumwidthB
      \global\let\TOCnumwidthC\TOCnumwidthC
      \global\let\TOCnumwidthD\TOCnumwidthD
      \global\let\TOCnumwidthE\TOCnumwidthE
      \global\let\TOCnumwidthF\TOCnumwidthF
      \global\let\TOCnumwidthG\TOCnumwidthG
     }% make the found maximal widths have global scope
    \etocnopar
    \csname #1tableofcontents\endcsname
\typeout{Next TOCs will use \TOCnumwidthB\space for chapter number width}%
\typeout{Next TOCs will use \TOCnumwidthC\space for section number width}%
\typeout{Next TOCs will use \TOCnumwidthD\space for subsection number width}%
\typeout{Next TOCs will use \TOCnumwidthE\space for subsubsection number width}%
\typeout{Next TOCs will use \TOCnumwidthF\space for paragraph number width}%
\typeout{Next TOCs will use \TOCnumwidthG\space for subparagraph number width}%
  \endgroup % matches \begingroup at start of definition
}%
\newcommand*\TOCcomputenumwidths [1][0.5em]{%
  \TOCcompute@numwidths {}{#1}%
}%
\newcommand*\TOCcomputelocalnumwidths [1][0.5em]{%
  \TOCcompute@numwidths {local}{#1}%
}%
\makeatother
