[Tex/LaTex] Theorem numbering as chapter.section.subsection.theorem number


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.

Best Answer

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}


Related Question