%% LaTeX2e file `etocsnippet-21-B.tex'
%% generated by the `filecontentshere' environment
%% from source `etoc' on 2022/08/31.
%%
\makeatletter
\newcommand*\TOClocalstyle {%
\etocsettocstyle
    {\if@twocolumn \@restonecoltrue \onecolumn \else \@restonecolfalse \fi
     \setbox\TOCleaderbox\hbox to \TOCleaderboxwidth{\hss.\hss}%
     \parindent\z@
     \dimen@ 2.25em % for left indenting
     \section *{\kern\dimen@ % use of \dimen@ works here by sheer luck
       \contentsname
       % un-comment this if marks are wanted:
       %\@mkboth {\MakeUppercase \contentsname}{\MakeUppercase \contentsname}%
       }% end of \section
     \parskip \z@skip
     \vspace{-1.25\baselineskip}% somewhat ad hoc
     \leftskip  2.25em
     \rightskip 4.5em
     \advance\rightskip-\TOCrightmargin\relax
     \leavevmode\leaders\hrule\@height\p@\hfill\kern\z@\par
     \rightskip 4.5em
     \parfillskip -\TOCrightmargin\relax }
    {\nobreak\vskip-.5\baselineskip
     \leavevmode\leaders\hrule\@height\p@\hfill\kern\z@\par
     \bigskip
     \if@restonecol \twocolumn \fi }%
%
\etocsetstyle{section}
 {\advance\leftskip\TOCnumwidthC\relax}
 {\addpenalty \@secpenalty
  \etociffirst{}{\addvspace{\TOCmedvskip}}%
  \leavevmode
  {\interlinepenalty\@M
   \bfseries\etocifnumbered
      {\llap{\makebox[\TOCnumwidthC][l]{\etocnumber}}}
      {\advance\leftskip-\TOCnumwidthC}%
   \etocname\nobreak\hfil\makebox[-\parfillskip][r]{\etocpage}\par }%
  \penalty \@highpenalty }
 {}
 {\advance\leftskip-\TOCnumwidthC\relax}%
% the rest is identical with code for global tocs:
 \TOCsetlinestyle {subsection}   {\TOCnumwidthD}%
 \TOCsetlinestyle {subsubsection}{\TOCnumwidthE}%
 \TOCsetlinestyle {paragraph}    {\TOCnumwidthF}%
 \TOCsetlinestyle {subparagraph} {\TOCnumwidthG}%
}% end of \TOClocalstyle
\makeatother
