2

I am using the thmtools package to produce a list of theorems at the end of my document. I am also using several different theorem headings (proposition, lemma, definition, etc...), which are not numbered independently. The numbering is done according to section.

Before implementing the thmtools package I could get the section numbering to work for all theorem styles by just including

\setcounter{theorem}{0}
\numberwithin{theorem}{section}

after the first section title.

After implementing the thmtools package, this does not seem to work, and only numbers the theorems correctly. I now have to add a separate line

\numberwithin{foo}{section}

for each foo in definition, lemma, fact, exercise, etc...

Is there a way to not have to add a separate line for each theorem style, and instead have one line that will cover all styles at once (even if I add some new ones later)?


Edit: Here is an example of what I mean.

My original code (before needing a list of theorems)

\documentclass{article}
\usepackage{amsmath, amssymb}
\usepackage[mathscr]{eucal}
\usepackage{amsthm}
\usepackage{amscd}

\newtheorem{theorem}{Theorem}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{corollary}[theorem]{Corollary}
\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}

\begin{document}

\section{Some Results}
\setcounter{theorem}{0}
\numberwithin{theorem}{section}

\begin{lemma}
Here is a lemma.
\end{lemma}

\begin{definition}
Here is a definition.
\end{definition}

\begin{theorem}
Here is a theorem.
\end{theorem}

\begin{theorem}
Here is another theorem.
\end{theorem}

\begin{corollary}
Here is a corollary.
\end{corollary}

\end{document}

If you compile this, you'll see that the results are listed as Lemma 1.1, Definition 1.2, Theorem 1.3, Theorem 1.4, Corollary 1.5. This is what I want.

Then, I decide I need a list of theorems. So I add the \usepackage{thmtools} and the \listoftheorems command (at the end of the body).

So now I get the list of theorems, but the numbering is wrong. In particular, the results are numbered Lemma 1, Definition 2, Theorem 1.3, Theorem 1.4, Corollary 5. So only the theorems are inheriting the section numbering. The only way I know to fix it is to add

\numberwithin{lemma}{section}
\numberwithin{corollary}{section}
\numberwithin{definition}{section}

below the \numberwithin{theorem}{section} line. It would be nice to not have to do this. Especially when I inevitably decide to add facts, examples, propositions, exercises, etc...

2
  • this question is tagged amsthm but you don't mention that package in the question. do you, or do you not, \usepackage{amsthm}? (a compilable example would really help us to help you.) Jan 21, 2015 at 19:28
  • I've edited with an example. The amsthm package is tagged because there seems to be something about thmtools that is interfering with how the numbering works when just using amsthm. Jan 21, 2015 at 19:58

1 Answer 1

2

You want

\newtheorem{theorem}{Theorem}[section]

not \numberwithin. I added thmtools and \listoftheorems to the example.

\documentclass{article}
\usepackage{amsmath, amssymb}
\usepackage[mathscr]{eucal}
\usepackage{amsthm,thmtools}
\usepackage{amscd}

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

\begin{document}

\section{Some Results}

\begin{lemma}
Here is a lemma.
\end{lemma}

\begin{definition}
Here is a definition.
\end{definition}

\begin{theorem}
Here is a theorem.
\end{theorem}

\begin{theorem}
Here is another theorem.
\end{theorem}

\begin{corollary}
Here is a corollary.
\end{corollary}

\listoftheorems

\end{document}

enter image description here

3
  • Thanks! Bonus question: In the real world I have \newtheorem{theorem}{Theorem} and subsequent lines for definition, lemma, etc... in my macro file. Is there a way to add the [section] part locally in each individual tex file, in case I want to use the same macro file for another document, but use a different numbering style? Jan 22, 2015 at 15:07
  • @Gabe I'm not sure I understand.
    – egreg
    Jan 22, 2015 at 15:08
  • I went ahead a made a new question: tex.stackexchange.com/questions/224405/… Jan 22, 2015 at 15:21

You must log in to answer this question.

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