changeset 255:fac80ec8e752

FIX: Need to manipulate tocdepth to also suppress ToC entries for sections without numbers
author Franz Glasner <fzglas.hg@dom66.de>
date Sun, 17 May 2026 13:06:50 +0200
parents b87564351eda
children 0114842950c4
files docs/_latex/my-doc-style.sty
diffstat 1 files changed, 18 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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
 }