[Tex/LaTex] Redefining a theorem counter

countersnumberingtheorems

I have a document with a lot of lemmas and theorems. In the main part of the document there are sections and subsections, so I defined

\newtheorem{lem}{Lemma}[subsection]

to number the lemmas accordingly. But in the appendices I don't have subsections, so I figured it would be better if lemmas in the appendices are not numbered with respect to subsections, but with respect to sections. Therefore, I gave the command

\renewcommand\thelem{\thesection.\arabic{lem}}

just after opening the appendices with \appendix. But something strange happened. In appendix A I don't have lemmas. In appendix B the first lemma is numbered B.3. Could anyone explain me this behavior and suggest a solution?


Edit: If I give the command

\renewcommand\thelem{\thesection.\arabic{lem}}
\setcounter{lem}{0}

the first lemma will be numbered B.1. But I'm still confused about why it is necessary to set the counter to 0.

Best Answer

Your counter resets at subsections not at sections, so

\makeatletter
\@addtoreset{lem}{section}
\makeatother
Related Question