I want to number theorems in the form "Theorem 1.4.26", such that the first two numbers are the chapter and section numbers and the last one is the number of the theorem in the whole book. That is, the counter for the last one does not reset through sections and chapters.
1 Answer
Assuming no package concerning theorem-like environments is loaded, the counter associated with a theorem environment is incremented monotonically unless a final optional argument of the \newtheorem
command is provided. I.e.,
\newtheorem{mytheorem}{Theorem}
defines a theorem environment and an associated counter, both named mytheorem
. In contrast,
\newtheorem{mytheorem}{Theorem}[chapter]
would define the same environment, but with the mytheorem
counter being reset every time the counter named chapter
is changed.
The final thing to solve is the way the counter variable associated with the theorem environment is displayed. Your formatting objective may be acheived by issuing the instruction \renewcommand{\themytheorem}{\thesection.\arabic{mytheorem}}
in the preamble.
\documentclass{book}
\newtheorem{mytheorem}{Theorem}
\renewcommand{\themytheorem}{\thesection.\arabic{mytheorem}}
\begin{document}
\chapter{First}
\section{First}
\begin{mytheorem}
Foo
\end{mytheorem}
\chapter{Second}
\section{First in Second}
\begin{mytheorem}
Foobar
\end{mytheorem}
\end{document}
-
@egreg: True, I confused the additions of
amsthm
with the standard environment. Removed the reference toamsthm
. Thanks– user31729Commented Mar 16, 2016 at 7:21 -
-
@Mico: Hm, was it really necessary?– user31729Commented Mar 16, 2016 at 17:37
-
I may have gotten carried away a bit. :-( Sorry. Feel free to revert.– MicoCommented Mar 16, 2016 at 18:11
amsthm
orntheorem
? Which numbering system is being employed currently?