# How to use the same numbering counter for everything?

When writing a book, with \documentclass{book}.

Like (where 1 before the dot denote the section number in each chapter, but chapter number doesn't appear)

1.1 Definition
1.2 Lemma
1.3 Theorem
1.4 Equation
1.5 Equation
1.6 Remark
1.7 Equation
1.8 Equation
1.9 Exercise


and so on, everything shares the same counter, with the number on the left. In particular, equations and theorem-like environments share the same counter.

• \numberwithin{<theorem>}{section} where <theorem> is your theorem.
– user121799
Commented Jul 1, 2019 at 4:16
• Please advise if the "1" in "1.1, "1.2" etc is a section- or chapter-related prefix and if the numbering should restart at the beginning of each section (or chapter).
– Mico
Commented Jul 1, 2019 at 5:06
• @marmot - Your suggestion subordinates the theorem counter to the section counter, but does not force, say, theorem and lemma environments to share the same (subordinated) counter.
– Mico
Commented Jul 1, 2019 at 5:41

You need to load the amsthm environment and issue the instruction \swapnumbers, so that the numbers are placed before the headers of the theorem-like environments. Then, issue the instructions

\newtheorem{thm}[equation]{Theorem}
\newtheorem{lem}[equation]{Lemma}
\newtheorem{rem}[equation]{Remark}
\newtheorem{exe}[equation]{Exercise}
\newtheorem{defn}[equation]{Definition}


to assure that all theorem-like environments share the same counter, viz., the equation counter.

A full MWE (minimum working example):

\documentclass{article}

\usepackage{chngcntr}
\counterwithin{equation}{section}

\usepackage{amsthm}
\swapnumbers
\newtheorem{thm}[equation]{Theorem}
\newtheorem{lem}[equation]{Lemma}
\newtheorem{rem}[equation]{Remark}
\newtheorem{exe}[equation]{Exercise}
\newtheorem{defn}[equation]{Definition}

\begin{document}
\setcounter{section}{1} % just for this example
\begin{defn}Bla bla bla \end{defn}
\begin{lem} Bla bla bla \end{lem}
\begin{thm} Bla bla bla \end{thm}
$$1+1=2$$
$$$$$$0+0=0$$$$$$
\begin{rem} Bla bla bla \end{rem}
$$$$$$0+0=0$$$$$$
$$$$$$0+0=0$$$$$$
\begin{exe} Bla bla bla \end{exe}
\end{document}


Addendum to address the OP's follow-up question: Suppose the book document class is in use and the counter of the equation and theorem-like environments is supposed to be subordinated to the section rather than to the chapter counter variable. In that case, I suggest you replace \counterwithin{equation}{section} with the following code:

\renewcommand{\theequation}{\arabic{section}.\arabic{equation}}
\makeatletter
\makeatother


There may be more efficient (or, at least, less wordy) methods to achieve your formatting goal, but the code shown above gets the job done.

• To place the equation numbers on the left as well, just specify the document class option leqno.
– Mico
Commented Jul 1, 2019 at 5:04
• Nice job! One more question, if the documentclass is book, instead of article, how to delete the chapter-related prefix in 1.1.2 theorem, chap.sect.theorem, just keep the section-related prefix 1.2 theorem, section.theorem? Commented Jul 1, 2019 at 9:14
• @C.Davide - If your document has chapter-level dividers, as is the case with the book document class, I would simply change \counterwithin{equation}{section} to \counterwithin{equation}{chapter}. If you were to insist on subordinating the equation (and other) numbers to the section, you'd get ambiguous (and hence highly confusing) cases of several equations numbered, say, "(2.2)".
– Mico
Commented Jul 1, 2019 at 9:37
• @Miko - Thanks again for your advice. Yeah, there are ambiguous issues if one insists on the section-prefix numbering in a book. But, technically, is it possible to do so? Commented Jul 1, 2019 at 11:35
• @Miko - Great answer, I have been stuck on this problem for a long time, now everthing seems so clear, Thank You So Much ! Commented Jul 1, 2019 at 12:07

Try with the below tags:

\documentclass{book}
\newtheorem{theorem}{Theorem}[chapter]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{remark}[theorem]{Remark}%%just define the remaining as like as the same
\begin{document}

\chapter{Test}

\begin{theorem}
Test
\end{theorem}

\begin{lemma}
Test
\end{lemma}

\end{document}

• This setup doesn't enforce the requirement that the numbering of the theorem-like environments should be linked to the numbering of equations.
– Mico
Commented Jul 1, 2019 at 4:58
• @Mico but in his MWE, hope he mentioned that he didn't mention about the display equation number, I thought he mentioned the text Equation as like as other heading, etc. Commented Jul 1, 2019 at 5:00
• The OP did write "In particular, equations and theorem-like environments share the same counter."
– Mico
Commented Jul 1, 2019 at 5:01