# Reset equation numbering after each section

I would like to reset equation numbering after each section or subsection. Right now I use

\setcounter{equation}{0}


I saw in another page you could also reset it by adding the following line to the preamble.

\numberwithin{equation}{subsection}
\renewcommand\theequation{\arabic{equation}}


But this doesn't seem to work. The equation counters just increment across subsections. It's the same across sections if we changed the preamble to

\numberwithin{equation}{section}

• "doesn't work" isn't very informative, do you get an error? Have you got \subsections (the above won't reset at a \section) Oct 16 '14 at 20:00
• Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. A suggestion: Do us a favour and change your username to something more telling than "user1234". Oct 16 '14 at 20:06
• I don't get an error. It just increments the counter even when moving across a new subsection. Oct 18 '14 at 4:11
• This question is not a duplicate of Number equations like subsections. The earlier posting was concerned with setting up equation numbers so that they contain the section number automaticallz. This new question is about something different: How to execute the (equivalent of the) instruction \setcounter{equation}{0} every time a \section or \subsection directive is encountered.
– Mico
Oct 18 '14 at 9:58
• If I understand your posting correctly, you may achieve your objective -- not having to manually execute \setcounter{equation}{0} at the start of each section and subsection -- by adding the following four instructions to the preamble: \makeatletter \@addtoreset{equation}{section} \@addtoreset{equation}{subsection} \makeatother. Note that this operation is quite different from what's achieved by executing \numberwithin{equation}{section} or \numberwithin{equation}{subsection}.
– Mico
Oct 18 '14 at 12:23

Tell LaTeX to reset the equation number whenever section or subsection is stepped:

\documentclass{article}

\usepackage{chngcntr}

\counterwithin*{equation}{section}
\counterwithin*{equation}{subsection}

\begin{document}
\section{One}
$$2+2=3.99$$
$$\pi^2=9.86$$

\section{Two}
$$E=mc^2$$
$$v=\frac{e}{t}$$

\subsection{Two \& One}
$$2+2=22$$
\end{document}


The instruction \counterwithin* is (almost) an interface to \@addtoreset (which is better not used if a higher level command provided by a package is available). With \counterwithin (without *) the counter's representation would be changed, which isn't with the *-form.

• Is something like this also possible within \align environments? Jun 8 '16 at 9:04
• @Taunch It should work out of the box Jun 8 '16 at 9:58
• @egreg How would you reset the counter for \subsubsection*? Aug 29 '16 at 6:23
• @YagnaPatel Not something that can go in a comment. Please, ask a new question with all details. Aug 29 '16 at 7:15
• this don't work in the "report" environment how to do ? @egreg Feb 25 '19 at 20:34