0

For most of my document (using document class "report" and using the amsthm package), I am happy with the theorem numbering that \newtheorem{thm}{Theorem}[section] produces, i.e.

Theorem 1.2.3.

is the 3rd theorem in section 2 of chapter 1. However, a later chapter has no sections, and so my theorem numbering looks like

Theorem 6.0.1

The 0 bothers me :). How do I change the \newtheorem command to number according to chapter, without changing the numbering earlier in the document?

Thanks!

1 Answers1

0

Use the \counterwithin macro.

% theoremprob.tex  SE 633030

\documentclass{report} \usepackage{amsthm} \newtheorem{thm}{Theorem}[section]

%\usepackage{chngcntr} %%%% now in basic LaTeX

\begin{document}

\chapter{First} %%% default theorem number (based on current section) \section{A section} \begin{thm} maths \end{thm}

\chapter{Second} \counterwithin{thm}{chapter} % make theorem number based on current chapter \begin{thm} maths \end{thm}

\chapter{Third} \counterwithin{thm}{section} % make theorem number based on current section \section{A section} \begin{thm} maths \end{thm}

\end{document}

the \counterwithin and \counterwithout macros were originally defined by the chngcntr package but are now part of basic LaTeX. You can read the manual for these macros by texdoc chngcntr

Peter Wilson
  • 28,066