# HG changeset patch # User Franz Glasner # Date 1779016010 -7200 # Node ID fac80ec8e752dff3ad29facae1e71165c2612f5e # Parent b87564351eda1f387c1653a2024da77a0ea06730 FIX: Need to manipulate tocdepth to also suppress ToC entries for sections without numbers diff -r b87564351eda -r fac80ec8e752 docs/_latex/my-doc-style.sty --- a/docs/_latex/my-doc-style.sty Sun May 17 11:41:42 2026 +0200 +++ b/docs/_latex/my-doc-style.sty Sun May 17 13:06:50 2026 +0200 @@ -58,16 +58,28 @@ % \EndSuppressNumbering ends exactly one preceding % \SuppressSubsectionNumbering or \SuppressSubsubsectionNumbering. % + +% +% A counter to store the current (Sphinx-set) tocdepth. +% Needed because counters are global in LaTeX. +% +\newcounter{@mds@stored@tocdepth} + \def\SuppressSectionNumbering{% \begingroup - \renewcommand\thesection{\hspace{-0.5em}} + \setcounter{@mds@stored@tocdepth}{\value{tocdepth}} + \addtocontents{toc}{\setcounter{tocdepth}{0}}% No \section in ToC + \renewcommand\thesection{\hspace{-0.5em}} \renewcommand\thesubsection{\hspace{-0.5em}} \renewcommand\thesubsubsection{\hspace{-0.5em}} \renewcommand\theparagraph{\hspace{-0.5em}} \renewcommand\thesubparagraph{\hspace{-0.5em}} } + \def\SuppressSubsectionNumbering{% \begingroup + \setcounter{@mds@stored@tocdepth}{\value{tocdepth}} + \addtocontents{toc}{\setcounter{tocdepth}{1}}% Allow \section in ToC \renewcommand\thesubsection{\hspace{-0.5em}} \renewcommand\thesubsubsection{\hspace{-0.5em}} \renewcommand\theparagraph{\hspace{-0.5em}} @@ -75,11 +87,16 @@ } \def\SuppressSubsubsectionNumbering{% \begingroup + \setcounter{@mds@stored@tocdepth}{\value{tocdepth}} + \addtocontents{toc}{\setcounter{tocdepth}{2}}% Allow \subsection in ToC \renewcommand\thesubsubsection{\hspace{-0.5em}} \renewcommand\theparagraph{\hspace{-0.5em}} \renewcommand\thesubparagraph{\hspace{-0.5em}} } + \def\EndSuppressNumbering{% + % Reset the tocdepth to the previous value + \addtocontents{toc}{\setcounter{tocdepth}{\the@mds@stored@tocdepth}}% Default \endgroup }