3

The amsthm documentation states:

If any theorem elements are numbered by section, and (in a book) the first such element in a chapter comes before the first section, numbering will continue from the previous chapter. In such a case, reset the counter by invoking this command before the affected element:

\setcounter{thm}{0}

However, I run the following MWE

\documentclass[openany]{book} \usepackage{amsthm} \theoremstyle{definition} \newtheorem{dfn}{Definition}[section] \begin{document} \chapter{Elio} \begin{dfn} content \end{dfn} \section{Bach} \begin{dfn} content \end{dfn} \chapter{Oliver} \begin{dfn} content \end{dfn} \end{document} 

and find that dfn in the second chapter is correctly numbered as 2.0.1 despite not using \setcounter{dfn}{0}.

What is going on here?

5
  • The book class defines the section counter to be within chapter, \newcounter{section}[chapter] (l. 271 of book.cls). Is this what you are asking? Commented Jan 23, 2024 at 10:37
  • Your instruction \newtheorem{dfn}{Definition}[section] overrides the default for the book document class, which (in essence) is \newtheorem{dfn}{Definition}[chapter]. Since a \chapter directive resets the section counter to 0, it should come as no surprise that the first dfn environment is numbered 2.0.1. Commented Jan 23, 2024 at 10:38
  • 1
    @Mico then before 2015 it would have been a surprise that you wouldn't have got that:-) Commented Jan 23, 2024 at 10:40
  • @DavidCarlisle - My memory of pre-2015 settings is rather hazy... Commented Jan 23, 2024 at 10:41
  • 1
    @Mico 1993 seems like yesterday Commented Jan 23, 2024 at 10:43

1 Answer 1

8

The AMS documentation is not taking in to account a 2015 improvement in \stepcounter

the latex format sources (ltcounts.dtx) say:

% \changes{v1.1h}{2015/01/10}{Reset all within counters in one go (latexrelease)} % % Rather than resetting the ``within'' counter to zero we set it to % $-1$ and then run |\stepcounter| that moves it to $0$ and also % initiates resetting the next level down. 

It now correctly resets nested counters even if one level is "omitted" the "initiates resetting the next level down." is the new feature added at that time.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.