comparison docs/_latex/my-doc-style.sty @ 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 b607543d6a8d
children 0114842950c4
comparison
equal deleted inserted replaced
254:b87564351eda 255:fac80ec8e752
56 % (compare with the \titleformat calls in sphinxlatexstyleheadings.sty). 56 % (compare with the \titleformat calls in sphinxlatexstyleheadings.sty).
57 % 57 %
58 % \EndSuppressNumbering ends exactly one preceding 58 % \EndSuppressNumbering ends exactly one preceding
59 % \SuppressSubsectionNumbering or \SuppressSubsubsectionNumbering. 59 % \SuppressSubsectionNumbering or \SuppressSubsubsectionNumbering.
60 % 60 %
61
62 %
63 % A counter to store the current (Sphinx-set) tocdepth.
64 % Needed because counters are global in LaTeX.
65 %
66 \newcounter{@mds@stored@tocdepth}
67
61 \def\SuppressSectionNumbering{% 68 \def\SuppressSectionNumbering{%
62 \begingroup 69 \begingroup
63 \renewcommand\thesection{\hspace{-0.5em}} 70 \setcounter{@mds@stored@tocdepth}{\value{tocdepth}}
71 \addtocontents{toc}{\setcounter{tocdepth}{0}}% No \section in ToC
72 \renewcommand\thesection{\hspace{-0.5em}}
64 \renewcommand\thesubsection{\hspace{-0.5em}} 73 \renewcommand\thesubsection{\hspace{-0.5em}}
65 \renewcommand\thesubsubsection{\hspace{-0.5em}} 74 \renewcommand\thesubsubsection{\hspace{-0.5em}}
66 \renewcommand\theparagraph{\hspace{-0.5em}} 75 \renewcommand\theparagraph{\hspace{-0.5em}}
67 \renewcommand\thesubparagraph{\hspace{-0.5em}} 76 \renewcommand\thesubparagraph{\hspace{-0.5em}}
68 } 77 }
78
69 \def\SuppressSubsectionNumbering{% 79 \def\SuppressSubsectionNumbering{%
70 \begingroup 80 \begingroup
81 \setcounter{@mds@stored@tocdepth}{\value{tocdepth}}
82 \addtocontents{toc}{\setcounter{tocdepth}{1}}% Allow \section in ToC
71 \renewcommand\thesubsection{\hspace{-0.5em}} 83 \renewcommand\thesubsection{\hspace{-0.5em}}
72 \renewcommand\thesubsubsection{\hspace{-0.5em}} 84 \renewcommand\thesubsubsection{\hspace{-0.5em}}
73 \renewcommand\theparagraph{\hspace{-0.5em}} 85 \renewcommand\theparagraph{\hspace{-0.5em}}
74 \renewcommand\thesubparagraph{\hspace{-0.5em}} 86 \renewcommand\thesubparagraph{\hspace{-0.5em}}
75 } 87 }
76 \def\SuppressSubsubsectionNumbering{% 88 \def\SuppressSubsubsectionNumbering{%
77 \begingroup 89 \begingroup
90 \setcounter{@mds@stored@tocdepth}{\value{tocdepth}}
91 \addtocontents{toc}{\setcounter{tocdepth}{2}}% Allow \subsection in ToC
78 \renewcommand\thesubsubsection{\hspace{-0.5em}} 92 \renewcommand\thesubsubsection{\hspace{-0.5em}}
79 \renewcommand\theparagraph{\hspace{-0.5em}} 93 \renewcommand\theparagraph{\hspace{-0.5em}}
80 \renewcommand\thesubparagraph{\hspace{-0.5em}} 94 \renewcommand\thesubparagraph{\hspace{-0.5em}}
81 } 95 }
96
82 \def\EndSuppressNumbering{% 97 \def\EndSuppressNumbering{%
98 % Reset the tocdepth to the previous value
99 \addtocontents{toc}{\setcounter{tocdepth}{\the@mds@stored@tocdepth}}% Default
83 \endgroup 100 \endgroup
84 } 101 }
85 102
86 \endinput 103 \endinput