6

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.

  • 1
    Try \renewcommand{\thetheorem}{\thesection.\arabic{theorem}} after you've started you Appendix. – Werner Sep 7 '13 at 13:53
  • @Werner Almost works. The numbering is carried on from the last section (presumably because the Lemma number is dependent on the subsection counter). So, if the last section had 4 lemmas, then the first lemma of the appendix is numbered Lemma A.5. Do I need to redefine all my theorems/lemmas/etc.? Is that possible outside of the preamble? – Earthliŋ Sep 7 '13 at 14:06
  • Try loading the package chngcntr and putting \counterwithin{theorem}{section} after \appendix. – karlkoeller Sep 7 '13 at 14:34
  • Obviously, if theorem is not your counter, replace it with the one you-re using, e.g. lemma. – karlkoeller Sep 7 '13 at 14:46
  • @karlkoeller That works, thank you very much. Could you post your solution as an answer? – Earthliŋ Sep 7 '13 at 15:24
5

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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.