[Tex/LaTex] How to make equation numbering dependent on theorem numbering


I ask a variation of some questions previously posed.

What I have now is this:

This is what I have

I want the equation numbers to follow the same numbering scheme as the theorems and definition. That is, I want the equation to be labelled (1.3) and the definition after it be labelled (1.4).

To further clarify, if we were in subsection 1.1, instead of section 1, I want to have theorem 1.1.1, theorem 1.1.2, equation 1.1.3 and definition 1.1.4.

Right now, the screenshot I posted uses the solution presented here.

I've also looked at this post. I tried to do that, but it completely ignored the "sectioning" I've done with the theorem numbers. Everything became 1, 2, 3… instead of 1.1, 1.2, 1.3, …

Moreover, it makes the theorem numbers depend on the equation numbers, which is the opposite of what I want. I want the equation numbering to follow the theorem numbering. This is because I've already "fixed" the theorem numbering to how I want it. However, I'm open to more out-of-the-box suggestions.

The following is the code for the screenshot.

\usepackage{amsmath, amsthm}



\section{Section Title}



x^2 + y^2 = z^2



Best Answer

The \newtheorem command has an optional argument in which you can specify an already existing counter to be used for numbering the theorems. This counter can be any LaTeX counter, including equation. So, for instance,

\numberwithin{equation}{section} % or whatever you prefer

\swapnumbers % I prefer this


\newtheorem{num}[equation]{} % a bit strange, but I do use it!

defines a whole series of “theorem-like” environments all of which are numbered in the same sequence as equations.