# Reset counter in new \chapter before the first \section

\newtheorem{lemma}{Lemma}[section]

\chapter{First chap}
\section{First sec}
\begin{lemma}
this one is correct.
\end{lemma}

\chapter{Second chap}
\begin{lemma}
This number is wrong.
\end{lemma}

\section{Second sec}
\begin{lemma}
this one is correct again.
\end{lemma}


Obviously I would like to have the lemma in the 2nd chapter before the Second sec to start at zero. But how?

• The number is “2.0.1”; what do you expect it to be? – egreg Sep 5 '15 at 23:10
• @egreg only in 2015 release – David Carlisle Sep 5 '15 at 23:23
• @DavidCarlisle Hidden feature! – egreg Sep 5 '15 at 23:26
• @egreg In my actual work there are some lemmas and theorems before the new chapter, so the first lemme in the new chapter has number i.e. 4.0.3 ; and this does not look fine – os23 Sep 5 '15 at 23:52

LaTeX < 2015: The number of the lemma is only reset, when section is increased, not chapter. \@addtoreset helps to reset lemma, if chapter is increased:

\newtheorem{lemma}{Lemma}[section]

\makeatletter
\makeatother


In the recent LaTeX release 2015/01/01, this is no longer necessary, because the counter reset is implemented in a transitive way.

## Number format

If the section number 0 should be suppressed, then the following redefinition of \thelemma helps:

\renewcommand*{\thelemma}{%
\ifnum\value{section}=0 %
\thechapter
\else
\thesection
\fi
.\arabic{lemma}%
}