I am using \numberwithin{equation}{subsection}
to number my equations uniquely for each subsection in my article.
For example:
- Section 1 Title
1.1 Subsection 1.1 Title
a=b (1.1.1)
a+2=b+2 (1.1.2)
- Section 2 Title
r=y (1.0.1)
However, in my document, I am not getting the right equation number for the first equation in the new section. The actual equation number sequentially follows the equation from the previous section. From the example above, r=y would be numbered 1.0.3.
Equations in the subsections below section 2 (i.e. 2.1 with equation 2.1.1) are numbered correctly.
Shouldn't the sections re-set the counter automatically?
Best Answer
In addition to the instruction
you need the instructions
The first instruction,
\numberwithin{equation}{subsection}
, resets the equation counter only when a\subsection
instruction is encountered. If you have a\section
instruction but no\subsection
instruction, the counter namedequation
is not reset unless you provide an additional instruction, such as\@addtoreset{equation}{section}
.Do note that if you do want to number the equations by subsection, it's probably not a good idea to feature equations between a
\section
directive and that section's first\subsection
instruction: at that stage, thesubsection
counter is still0
(having been reset to0
by the\section
directive), leading the equation numbers to be formatted as "2.0.1" and quite likely making your readers wonder if the subsection numbered2.0
has somehow vanished mysteriously.