2

I am unable to figure how to set up the Corollary environment so that the counter restarts after BOTH a new theorem and a new lemma.

The environments for theorems and lemmas are defined so that they begin after each section:

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

Now I need the counter for corollary to restart after theorem as well as a lemma. So something like:

Theorem 2.2.1
Corollary 2.2.1.1
Corollary 2.2.1.2
Lemma 2.2.2
Corollary 2.2.2.1
Corollary 2.2.2.2

and so on.

I read the amsthm package document but could not find the solution there.

5
  • 4
    If theorem and lemma do not use the same counter, then theorems and lemmas with the same number can exist, probably leading to the existence of two different corollaries of same number. This in turn might technically be a problem when using hyperref. If theorem and lemma use the same counter, then find out which one it is and use \@addtoreset for having the counter for corollaries reset whenever that counter is stepped. | Alternatively the package chngcntr might be of interest to you. Commented Aug 17, 2022 at 3:08
  • Thanks a lot! It worked.
    – Tanay
    Commented Aug 17, 2022 at 3:36
  • 1
    You seem to have Lemma 2.2.2 following Theorem 2.2.1, which is not what the code you show would produce. Can you please explain?
    – egreg
    Commented Aug 17, 2022 at 9:06
  • @Tanay As egreg already pointed out: The code-snippet shown does not produce the output shown. Did you do something like \newtheorem{lemma}[theorem]{Lemma} instead of \newtheorem{lemma}{Lemma}[section] in the code used by you in "real life"? Commented Aug 18, 2022 at 1:00
  • So, I used the following lines of code: \newtheorem{theorem}{Theorem}[section] \newtheorem{lemma}[theorem]{Lemma} \newtheorem{corollary}{Corollary}[theorem] I didn't realize that lemma and theorem environments weren't using the same counters. This fixes that, and so I did not need to use \@addtoreset, but I tried it and it does allow me to do the same thing as well.
    – Tanay
    Commented Aug 18, 2022 at 19:43

1 Answer 1

1

As solved by the OP in the comments:

\documentclass{report}

\usepackage{amsthm}

\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{corollary}{Corollary}[theorem]

\setcounter{chapter}{2} % just to match OP's example

\begin{document}

\section{First section}
\section{Second section}

\begin{theorem}
text
\end{theorem}
\begin{corollary}
text
\end{corollary}
\begin{corollary}
text
\end{corollary}
\begin{lemma}
text
\end{lemma}
\begin{corollary}
text
\end{corollary}
\begin{corollary}
text
\end{corollary}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .