Closed UlyssesZh closed 3 years ago
\thesection
is supposed to be an expandable command so assignments normally don't work (the basic \setcounter
works but more by chance). mathools
loads calc
package so that changes \setcounter
to be a slightly more complicated assignment and that then breaks. Try
\renewcommand\thesection{\protect\setcounter{equation}{0}}
instead.
Use \counterwithin{equation}{section}
if you want to reset the equation counter at sections instead of misusing \thesection.
Try
\renewcommand\thesection{\protect\setcounter{equation}{0}}
@FrankMittelbach that gives an rather interesting label: \newlabel{abc}{{\setcounter {equation}{0}}{1}}
;-) (without the protect and calc it is naturally not better).
You get the same label form the example if calc is not loaded (without the protect) and as far as I can see that works (even though it is not really meant to be and sort of by chance) but yes, the correct solution is your suggestion of resetting the counter per section counter.
As already mentioned this is not really related to mathtools
but rather to the fact that it loads the calc
package.
Additionally as others have mentioned, you should use the proper methods if you want to reset a counter at certain points. \thesection
should not have any sideeffects like you introduce here.