13

I use amsthm for my theorems, lemmas etc.

I'd like their numbering to look like that:

Theorem 1.1.1
Lemma 1.1.2
Definition 1.1.3
Theorem 1.2.1
Definition 1.2.2
Corollary 1.2.3
Theorem 2.1.1
etc.

To make the numbering "per-section" I did

\newtheorem{defi}{Definition}[section]

But then each theorem type I defined had its own counter. So I tried

\newtheorem{defi}[somecounter]{Definition}

But then the numbers are just plain, section part disappears!

So I'd like to write something like

\newcounter{somecounter}[section]
\newtheorem{defi}[somecounter]{Definition}[section]

But this doesn't work :(

How can I achieve such effect?

1
  • I think you have a typo: Definition 1.1.2 should be 1.1.3.
    – Ryan Reich
    May 6, 2011 at 21:02

2 Answers 2

10

You need to make a "dummy" theorem and make all the others subordinate to that. For example:

\documentclass{article}
\usepackage{amsthm,amsmath}
% \newtheorem{dummy}{Dummy}[section]
\newcounter{dummy} \numberwithin{dummy}{section}
\newtheorem{thm}[dummy]{Theorem}
\newtheorem{defn}[dummy]{Definition}
\begin{document}

\section{First}

 \begin{thm}
 \end{thm}

 \begin{defn}
 \end{defn}

\section{Second}

 \begin{thm}
 \end{thm}

 \begin{defn} 
 \end{defn}

\end{document}

Either the commented \newtheorem line or the \newcounter line works; the \numberwithin command is defined by amsmath, but if you are using amsthm you are probably using that too. If not, then the \newtheorem line works just with amsthm.

6
  • 1
    Instead of adding a dummy counter, I usually do \numberwithin{equation}{section} and then \newtheorem{theorem}[equation]{Theorem}, etc. (I like having displayed equations numbered with the same scheme as theorems, etc.) May 6, 2011 at 21:51
  • @John: that's quite reasonable, especially if your equations are all pretty important statements. I myself tend to scatter displayed equations, often with numbering for easy reference, just to keep the text clean, so numbering them with theorems would be awkward. The other alternative to the dummy is @Gonzalo's answer, but I forgot about it because I'm hung up on symmetry.
    – Ryan Reich
    May 6, 2011 at 21:54
  • when I'm reading a book or paper, I sometimes find it frustrating searching for Equation (1.2.5) if it's nowhere near Lemma 1.2.4, but instead is part of the proof of Theorem 1.2.13. So I like everything numbered sequentially, if I'm going to number equations at all. (Often I just need to refer to equations in nearby text and label them with (*) or something like that. If I don't number any equations, then it just acts like a dummy counter anyway.) May 6, 2011 at 22:40
  • Works! The \numberwithin is exactly what I was looking for. The dummy theorem method seems like a hacky trick :) @John: And that brings even more consistency! Thanks guys!
    – Jasiu
    May 7, 2011 at 8:00
  • Dear Ryan, how would I go about numbering my theorems, propositions and lemmas without reference to the section? So to have, for instance, Section 1 : Lemma 1, Lemma 2, Theorem 3; Section 2 : Lemma 1, Lemma 2, Lemma 3, Theorem 4, Corollary 5 ? Dec 23, 2013 at 16:36
6

Perhaps this is what you are trying to achieve:

\documentclass{book}
\usepackage{amsthm}

\newtheorem{theo}{Theorem}[section]
\newtheorem{lemm}[theo]{Lemma}
\newtheorem{coro}[theo]{Corollary}

\begin{document}

\chapter{Test chapter}
\section{Test section}

\begin{theo}
test
\end{theo}

\begin{coro}
test
\end{coro}

\begin{lemm}
test
\end{lemm}

\end{document}

The first declaration indicates that the counter for theo environments will be reset to 0 whenever the parent counter section is incremented, and the theorem label will have the section number prepended. The other declarations simply subordinate their counter to the one just declared.

You must log in to answer this question.

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