[Tex/LaTex] Numbering depth in appendix


I have a long (mathematical) document with parts, sections, subsections and paragraphs. The theorems etc. in the parts are numbered

Theorem 1.2.3

where the first number corresponds to the section, the second number to the subsection and the third to the number of the theorem, example, etc.

In the appendix (and only in the appendix), I will only use sections, no subsections. By default, a lemma in the appendix is numbered as

Lemma A.0.1

for the first lemma in the first appendix. I would like to suppress the subsection number (only in the appendix), so that the first lemma in the first appendix is numbered as

Lemma A.1

I have tried to add \setcounter{secnumdepth}{1} after the \appendix command, but nothing changed.

Best Answer

If your lemmas use the theorem counter as in the MWE below, you can insert the line


just after the \appendix command. Note that you have to load the package chngcntr to be able to use \counterwithin.



\usepackage{lipsum}  % just for the example



\section{1st section}
\subsection{1st subsection}

\section{2nd section}
\subsection{2nd subsection}

\section{Appendix section}



enter image description here

If your lemmas use a different counter, e.g. lemma, you have to change the mentioned line to, e.g.