# Numbering subsections and subsubsections with the equation counter

I would like to number everything within a section with the same counter: theorems, definitions, equations, subsections, etc. Everything that's numbered for reference (except for floats, since they are "out of sequence".) I am using the amsbook class.

I have made a beginning to this by putting most things on the equation counter like so:

\documentclass{amsbook}

\numberwithin{section}{chapter}
\numberwithin{equation}{section}

\newtheorem{thm}[equation]{Theorem}
\newtheorem{crl}[equation]{Corollary}

\theoremstyle{definition}
\newtheorem{dfn}[equation]{Definition}

\begin{document}
\chapter{Introduction}
\section{Foo} % 1.1
\begin{thm} % 1.1.1
Some sets are finite.
\end{thm}
\begin{crl} % 1.1.2
Not all sets are infinite.
\end{crl}

\subsection{Bar} % 1.1.1
We find that
$$% 1.1.3 2 = 1 + 1.$$

\subsubsection{Baz} % 1.1.1.1
Furthermore,
$$% 1.1.4 1 + 1 = 2.$$

\section{Quux} % 1.2
Open questions remain.

\end{document}


In the example, I want subsection Bar to be numbered 1.1.3, its equation to be 1.1.4, subsubsection Baz to be 1.1.5, and its equation to be 1.1.6. Then everything resets with the new section.

• @Andrew How does that question address the issue of subsection numbering at issue here?
– cfr
Commented Mar 28, 2015 at 4:28
• Probably mixing \numberwithin and \newtheorem{}[]{} will do the job. Commented Mar 28, 2015 at 5:05
• @cfr Sorry, I missed the point of the question: I thought that the OP only wanted everything numbered within section
– user30471
Commented Mar 28, 2015 at 6:25

You can make equation an alias for the subsection counter and the same for subsubsection, but you also need to remove this counter from the reset list of subsection.

\documentclass{amsbook}
\usepackage{chngcntr}

\renewcommand{\thesection}{\thechapter.\arabic{section}}
\counterwithout{subsubsection}{subsection}
\makeatletter
\let\c@equation\c@subsection
\let\theequation\thesubsection
\let\c@subsubsection\c@subsection
\let\thesubsubsection\thesubsection
\makeatother

\newtheorem{thm}[subsection]{Theorem}
\newtheorem{crl}[subsection]{Corollary}

\theoremstyle{definition}
\newtheorem{dfn}[subsection]{Definition}

\begin{document}
\chapter{Introduction}
\section{Foo} % 1.1
\begin{thm} % 1.1.1
Some sets are finite.
\end{thm}
\begin{crl} % 1.1.2
Not all sets are infinite.
\end{crl}

\subsection{Bar} % 1.1.1
We find that
$$% 1.1.3 2 = 1 + 1.$$

\subsubsection{Baz} % 1.1.1.1
Furthermore,
$$% 1.1.4 1 + 1 = 2.$$

\section{Quux} % 1.2
Open questions remain.

\end{document}


One way is to hijack the section command with something like:

\let\realsubsection\subsection% keep a copy
\def\subsection{\setcounter{subsection}{\arabic{equation}}% sync the counters
\refstepcounter{equation}%
\realsubsection% invoke the real \section
}


What this does is make the subsection counter equal to the current value of the equation counter whenever it is used (and also increments the equation counter).

I am confused by what you want \subsubsection to do, however, as your description sounds it it should be identical to \subsection. To me it makes more sense for it to create a subsubsection with the correct label, which is what my code does:

In actual fact, I didn't use the code above and instead recast everything to use the subsection counter. The reason for this is if you hack the \subsection command then you also need to hack the \subsubsection command to get it to work properly. Instead, I hacked \equation, which starts the equation environment. Here's the full mwe:

\documentclass{amsbook}

\numberwithin{section}{chapter}
\numberwithin{equation}{section}

\newtheorem{thm}[subsection]{Theorem}
\newtheorem{crl}[subsection]{Corollary}

\theoremstyle{definition}
\newtheorem{dfn}[subsection]{Definition}

\let\realequation\equation
\def\equation{\setcounter{equation}{\arabic{subsection}}%
\refstepcounter{subsection}%
\realequation}

\begin{document}
\chapter{Introduction}
\section{Foo} % 1.1
\begin{thm} % 1.1.1
Some sets are finite.
\end{thm}
\begin{crl} % 1.1.2
Not all sets are infinite.
\end{crl}

\subsection{Bar} % 1.1.1
We find that
$$% 1.1.3 2 = 1 + 1.$$

\subsubsection{Baz} % 1.1.1.1
Furthermore,
$$% 1.1.4 1 + 1 = 2.$$

\section{Quux} % 1.2
Open questions remain.

\end{document}

• Regarding subsubsections: I'd like them to be numbered in the same sequence as subsections, but retain their different styling, showing that they're subordinate. Also, if subsections are in some table of contents or something, subsubsections would still not be. Commented Mar 28, 2015 at 18:39