我正在使用和\documentclass{book}
包。每章都是一篇独立的论文,所以我希望每章中的定理都从 1 开始。我该怎么做?amsmath
amsthm
这是 MWE。
\documentclass[printer]{book}
\usepackage{amsmath}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}
\begin{document}
\chapter{Blahblah}
\begin{theorem}{This is Theorem 1 as it should be}
\end{theorem}
\begin{theorem}{This is Theorem 2 as should be}
\end{theorem}
\chapter{Blibli}
\begin{theorem}{I need this to be Theorem 1!}
\end{theorem}
\end{document}
答案1
如果不想\setcounter{theorem}{0}
每次都手动写,可以这样做:
\documentclass{book}
\usepackage{amsmath}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}[chapter]
\renewcommand{\thetheorem}{\arabic{theorem}}
\begin{document}
\chapter{Blahblah}
\begin{theorem}
This is Theorem 1 as it should be
\end{theorem}
\begin{theorem}
This is Theorem 2 as should be
\end{theorem}
\chapter{Blibli}
\begin{theorem}
I need this to be Theorem 1!
\end{theorem}
\end{document}
答案2
这可以实现您对该包的使用要求chngcntr
。请再次阅读包手册。
% thmcntrprob.tex SE 646889
\documentclass[printer]{book}
\usepackage{amsmath}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}
\usepackage{chngcntr}
\counterwithin*{theorem}{chapter}
\begin{document}
\chapter{Blahblah}
\begin{theorem}{This is Theorem 1 as it should be} \end{theorem}
\begin{theorem}{This is Theorem 2 as should be} \end{theorem}
\chapter{Blibli}
\begin{theorem}{I need this to be Theorem 1!} \end{theorem}
\end{document}