# HG changeset patch # User Franz Glasner # Date 1779016125 -7200 # Node ID 5f0ee44825b1e0059ddf021970e44a764a7faac5 # Parent 42f7caa892536999f07e363ca1579616bb848e6c Update to my-doc-style.sty v0.3.1. Fixes ToC entry handling of sections with suppressed numbers. diff -r 42f7caa89253 -r 5f0ee44825b1 docs/_latex/my-doc-style.sty --- 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 }