15

How can I revert the action of \numberwithin{mycounter}{section} so that mycounter does not reset with a new section?

Example: (This is not exactly my case but this is easy to understand.) I would like to have equation numbered within a section in the first part of the document, so I use \numberwithin{equation}{section}. But in the next part to number it directly. Like

Section 1
  equation (1.1)
  equation (1.2)
Section 2
  equation (2.1)
  equation (2.2)
  equation (2.3)
\SomeCommandToPutHere{equation}
Section 3
  equation (1)
  equation (2)
  equation (3)
yo'
  • 51,322
  • 1
    See also http://tex.stackexchange.com/questions/28333/continuous-v-per-chapter-section-numbering-of-figures-tables-and-other-docume – lockstep Jan 25 '12 at 22:21

1 Answers1

14

The package chngcntr does exactly that:

\counterwithin{equation}{section}

\counterwithout{equation}{section}
egreg
  • 1,121,712
  • Thanks, master! Just a note, the macro \counterwithout kills the effect of both \numberwithin and \counterwithin, which is terrific! – yo' Jan 25 '12 at 21:29
  • Either use \numberwithin or \counterwithin, not both. – egreg Jan 25 '12 at 21:31
  • 1
    ... and what should I do if some package uses \numberwithin itself without giving me a chance to prevent it? And to the case, I was thinking about putting \let\numberwithin\counterwithin after loading both amsmath and chngcntr. – yo' Jan 25 '12 at 21:38
  • 3
    The difference between \numberwithin and \counterwithin is that the former does a global redefinition, it shouldn't be a problem if \numberwithin is used only in the preamble. – egreg Jan 25 '12 at 21:45