[Tex/LaTex] Common, per-section numbering of theorems, lemmas etc.

numberingtheorems

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?

Best Answer

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.