This might be a simple question but it's weird that I couldn't find the answer anywhere on the internet.

If I set as


then I get the numbering as Theorem [section.subsection.thm number], so I always need to specify the chapter, but the problem is that the chaptering is likely to change until the final stage. Otherwise, if I were to set as


then I only get Theorem [chapter.thm number] so that sectional structure is lost and the numbering becomes very unclear and inefficient.

At first, this seems very simple but it's funny that I could not find the answer. Is there any way of doing this only with AMSthm package? If it is not, it's still okay, and any solution on this would be very much appreciated.

  • 1
    Hi annoyed, welcome to TeX.sx. I've put your code into code blocks. This is done with four spaces to indent, or there is also the {} button in the editor. In addition, I've removed the thanks. This is just the style here, and thanks is best expressed as up votes for answers that help you.
    – qubyte
    Feb 22 '12 at 1:17

The amsmath package provides the command numberwithin- it can be used as demonstrated in the MWE below.

Note that the numberwithin command can be used on pretty much any environment that has a number (tables, figures, etc).



\usepackage{amsmath} % provides numberwithin (and lots more)
\usepackage{lipsum}  % for sample text

\numberwithin{mytheorem}{subsection} % important bit


\chapter{My theorems}


  • 4
    It may be worth adding that the \numberwithin command can operate not only on theorem-like environments, but also on just about any environment that's normally numbered incrementally, including figure and table floating environments.
    – Mico
    Feb 22 '12 at 1:29
  • @cmhughes @Mico This works with \documentclass{report} but not with \documentclass{amsbook}. With report class, I can't use something like \swapnumbers and \newtheoremstyle. How can I fix this?
    – HBS
    Feb 22 '12 at 1:53
  • 1
    @hbshim: On p. 11 of the AMS-issued manual "Instructions for Preparation of Papers and Monographs," it says that "The amsbook document class resets figure and table numbers automatically [at the beginning of each chapter], but does not include the chapter number in the printed caption. To add the chapter number [to the caption], place these lines in the preamble of the driver file: \numberwithin{figure}{chapter} and \numberwithin{table}{chapter}."
    – Mico
    Feb 22 '12 at 2:12
  • @hbshim: Further to your comments that you can't seem to use \swapnumbers and \newtheoremstyle with the report doc class: Did you remember to load either the amsthm or the ntheorem package, as well as the amsmath package, prior to executing these commands?
    – Mico
    Feb 22 '12 at 2:17
  • 1
    @hbshim this serves as a good reminder to provide a MWE- I couldn't have predicted which documentclass you were using. If my answer has helped, don't forget to accept it by clicking on the green check mark
    – cmhughes
    Feb 22 '12 at 3:23

Alternatively, you can do


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.