[Tex/LaTex] Numbering depth in appendix

appendicesnumberingsectioning

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

\counterwithin{theorem}{section}

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

MWE

\documentclass{article}

\usepackage{chngcntr}
\usepackage{lipsum}  % just for the example

\newtheorem{theorem}{Theorem}[subsection]
\newtheorem{lemma}[theorem]{Lemma}

\begin{document}

\section{1st section}
\subsection{1st subsection}
\begin{lemma}
  \lipsum[1]
\end{lemma}

\section{2nd section}
\subsection{2nd subsection}
\begin{lemma}
  \lipsum[1]
\end{lemma}

\appendix
\counterwithin{theorem}{section}
\section{Appendix section}
\begin{lemma}
  \lipsum[1]
\end{lemma}

\end{document} 

Output

enter image description here

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

\counterwithin{lemma}{section}