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

numberingtheorems

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

\newtheorem{-}{-}[section]

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

\newtheorem{*}{*}[chapter]

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).

screenshot

\documentclass{report}

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

\newtheorem{mytheorem}{Theorem}
\numberwithin{mytheorem}{subsection} % important bit

\begin{document}

\chapter{My theorems}

\section{Section}
\subsection{Subsection}
\begin{mytheorem}
\lipsum[1]
\end{mytheorem}

\end{document}
Related Question