[Tex/LaTex] \subsubsubsection count not reset when starting a new section, subsection, etc

sectioningsubdividingtable of contents

I am trying to use subsubsubsection on my report, and I using a code that was given on this website.

On below my MWE :



\renewcommand\theparagraph{\thesubsubsubsection.\arabic{paragraph}} % optional; useful if paragraphs are to be numbered

{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}

  {3.25ex \@plus1ex \@minus.2ex}%
  {3.25ex \@plus1ex \@minus .2ex}%








As you will notice, the subsubsubsection is not reset between these 2 sections.

How can I fix it please ?

How can I fix it please ? Thanks in advance for your help.

Best Answer

The subsubsubsection counter is reset at subsubsection. In your example the subsubsection counter never changed. (It remains always at zero.)

(More precisely, the reset command is only triggered when \stepcounter or \refstepcounter is called on the parent counter. As no \subsubsection command was ever issued, the counter is never step-increased, and the reset command never called.)

You can see the problem even without defining your own new section level. If you compile the following MWE:


\subsection{test 5}

You will see that test2 is labeled 1.0.1 and test4 is labeled 2.0.2. But once you increment the subsection counter (when I put in test 5), the counter now behaves properly: test6 is 2.1.1.

This doesn't happen just with sectioning commands, by the way. If you use the \numberwithin command from the AMS packages to set the level for equations, or use the amsthm commands to tie theorem numbering to section levels, you should never tie the resetting to a counter that cannot be reliably incremented.

A possible work-around is given here: in your preamble add


this will make increasing sections and subsections both also trigger the reset code.