changeset 786:5f0ee44825b1

Update to my-doc-style.sty v0.3.1. Fixes ToC entry handling of sections with suppressed numbers.
author Franz Glasner <fzglas.hg@dom66.de>
date Sun, 17 May 2026 13:08:45 +0200
parents 42f7caa89253
children 615b7e1b80d2
files docs/_latex/my-doc-style.sty
diffstat 1 files changed, 19 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/docs/_latex/my-doc-style.sty	Sun May 17 11:42:40 2026 +0200
+++ b/docs/_latex/my-doc-style.sty	Sun May 17 13:08:45 2026 +0200
@@ -4,7 +4,7 @@
 %
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesPackage{my-doc-style}[%
-  2026/05/17 v0.3 (Franz Glasner) Some style customizations (title et al.)]
+  2026/05/17 v0.3.1 (Franz Glasner) Some style customizations (title et al.)]
 \RequirePackage{xkeyval}
 
 % A key compatible with options processing but bool (because DeclareBoolOptionX)
@@ -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
 }