[Tex/LaTex] Common numbering for theorems and definitions

amsmath

I use the amsmath environment and I put the following code in the preamble:

\theoremstyle{plain}
\newtheorem{thm}{Theorem}[section]
\newtheorem{lem}[thm]{Lemma}
\newtheorem{cor}{Corollary}[section]

\theoremstyle{definition}
\newtheorem{defn}{Definition}[section]
\newtheorem*{ex}{Example}

\newtheorem{prop}{Proposition}[section]
\theoremstyle{remark}
\newtheorem*{rem}{Remark}

This works very well for my theorems, proofs, etc, except that I would like to make a small modification which is easiest to clarify with an example: if I have written two theorems and one definition in chapter 3, I want the next definition to be number 3.4 instead of 3.2. In other words, I want to order my theorems, lemmas, etc, all as a single category instead of ordering each category by itself. How do I modify my code to do this?

Best Answer

For the selected structures, use as first optional argument the counter of the structure you initially subordinated to the section counter, so the selected structures will share the counter. For example, after yo do

\newtheorem{thm}{Theorem}[section]

the counter thm for the Theorem structure is subordinated to the section counter, and defining

\newtheorem{lem}[thm]{Lemma}

makes the lem counter share the counter for Theorem structure. A complete example:

\documentclass{article}
\usepackage{amsthm}

\theoremstyle{plain}
\newtheorem{thm}{Theorem}[section]
\newtheorem{lem}[thm]{Lemma}
\newtheorem{cor}[thm]{Corollary}

\theoremstyle{definition}
\newtheorem{defn}[thm]{Definition}
\newtheorem*{ex}{Example}
\newtheorem{prop}[thm]{Proposition}

\theoremstyle{remark}
\newtheorem*{rem}{Remark}

\begin{document}

\section{Test}
\begin{thm}test\end{thm}
\begin{lem}test\end{lem}
\begin{prop}test\end{prop}
\begin{defn}test\end{defn}

\end{document}

enter image description here

Related Question