我正在使用proof
环境 fromamsthm
来键入证明。有些证明很长,因此最好将它们分成编号的部分。proofpart
为此,我定义了新的定理环境 called。
问题是proofpart
计数器不会在新的证明中重置,而是继续增长。所以我想知道在这种情况下如何重置计数器。
示例文件:
\documentclass{article}
\usepackage{amsthm}
\theoremstyle{definition}
\newtheorem{proofpart}{Part}
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{theorem}
Some theorem
\end{theorem}
\begin{proof}
Proof of some theorem
\begin{proofpart} % 1
First part
\end{proofpart}
\begin{proofpart} % 2
Second part
\end{proofpart}
\end{proof}
\begin{theorem}
Another theorem
\end{theorem}
\begin{proof}
Proof of another theorem
\begin{proofpart} % 3, but should be 1
First part
\end{proofpart}
\begin{proofpart} % 4, but should be 2
Second part
\end{proofpart}
\end{proof}
\end{document}
答案1
一种选择是使用\@addtoreset
:
\documentclass{article}
\usepackage{amsthm}
\theoremstyle{definition}
\newtheorem{proofpart}{Part}
\newtheorem{theorem}{Theorem}
\makeatletter
\@addtoreset{proofpart}{theorem}
\makeatother
\begin{document}
\begin{theorem}
Some theorem
\end{theorem}
\begin{proof}
Proof of some theorem
\begin{proofpart} % 1
First part
\end{proofpart}
\begin{proofpart} % 2
Second part\qedhere
\end{proofpart}
\end{proof}
\begin{theorem}
Another theorem
\end{theorem}
\begin{proof}
Proof of another theorem
\begin{proofpart} % it is 1
First part
\end{proofpart}
\begin{proofpart} % it is 2
Second part\qedhere
\end{proofpart}
\end{proof}
\end{document}
摘自以下简短描述source2e
:
\@addtoreset{foo}{bar} : Adds counter
footo the list of counters
\cl@barto be reset when counter
bar` 是阶梯式的。
另一种选择(由沃纳\newtheorem
)将在定义中使用第二个可选参数proofpart
(这需要定义此结构后环境theorem
)以及对相关计数器表示的重新定义:
\documentclass{article}
\usepackage{amsthm}
\theoremstyle{definition}
\newtheorem{theorem}{Theorem}
\newtheorem{proofpart}{Part}[theorem]
\renewcommand\theproofpart{\arabic{proofpart}}
\begin{document}
\begin{theorem}
Some theorem
\end{theorem}
\begin{proof}
Proof of some theorem
\begin{proofpart} % 1
First part
\end{proofpart}
\begin{proofpart} % 2
Second part\qedhere
\end{proofpart}
\end{proof}
\begin{theorem}
Another theorem
\end{theorem}
\begin{proof}
Proof of another theorem
\begin{proofpart} % it is 1
First part
\end{proofpart}
\begin{proofpart} % it is 2
Second part\qedhere
\end{proofpart}
\end{proof}
\end{document}
\newtheorem{env-name}{doc-name}[counter]
,其中counter
是现有的或先前定义的计数器,env-name
每当父计数器counter
增加时,都会重置计数器;但是,标签将在 counter
前面添加数字,因此需要重新定义表示以抑制前面添加的字符串。
我也曾经\qedhere
校正过结束标记的位置。