我有一份包含多个章节的文档,其中大多数章节包含子章节。除了一个章节之外,我希望定理编号按section
深度进行。在某个特定章节中,我希望编号按subsection
深度进行。我可以做到这一点,但在后面的章节中(我回到section
深度),计数器出现了问题。以下是一个例子:
\documentclass[11pt]{article}
\usepackage{amsmath, amssymb,amscd,amsthm}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{proposition}[theorem]{Proposition}
\begin{document}
\section{The First Section}
\subsection{The First Subsection}
\begin{theorem}
a theorem
\end{theorem}
\begin{corollary}
a corollary
\end{corollary}
\subsection{The Second Subsection}
\begin{theorem}
a theorem
\end{theorem}
\begin{corollary}
a corollary
\end{corollary}
\section{The Second Section}
\numberwithin{theorem}{subsection}
\subsection{The First Subsection}
\begin{theorem}
a theorem
\end{theorem}
\begin{corollary}
a corollary
\end{corollary}
\subsection{The Second Subsection}
\begin{theorem}
a theorem
\end{theorem}
\begin{corollary}
a corollary
\end{corollary}
\section{The Third Section}
\numberwithin{theorem}{section}
\subsection{The First Subsection}
\begin{theorem}
a theorem
\end{theorem}
\begin{corollary}
a corollary
\end{corollary}
\subsection{The Second Subsection}
\begin{theorem}
a theorem
\end{theorem}
\begin{corollary}
a corollary
\end{corollary}
\end{document}
在此示例中,第二部分是我想要更改编号深度的部分,因此我添加了\numberwithin{theorem}{subsection}
。效果很好。
现在在第三部分中,我想将编号改回section
深度,因此我添加了\numberwithin{theorem}{section}
。深度更改正确,但计数器在每个子部分之后仍会重置。特别是,我有
3 The Third Section
3.1 The First Subsection
Theorem 3.1. a theorem
Corollary 3.2. a corollary
3.2 The Second Subsection
Theorem 3.1. a theorem
Corollary 3.2. a corollary
我想要的是:
3 The Third Section
3.1 The First Subsection
Theorem 3.1. a theorem
Corollary 3.2. a corollary
3.2 The Second Subsection
Theorem 3.3. a theorem
Corollary 3.4. a corollary
换句话说,我希望它表现得像第一部分:
1 The First Section
1.1 The First Subsection
Theorem 1.1. a theorem
Corollary 1.2. a corollary
1.2 The Second Subsection
Theorem 1.3. a theorem
Corollary 1.4. a corollary
我怎样才能解决这个问题?
答案1
您还需要删除重置。有一个专门用于此的软件包。(实际上,似乎至少有两个!)
例如:
\documentclass[11pt]{article}
\usepackage{amsmath,amssymb,amscd,amsthm,remreset}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{proposition}[theorem]{Proposition}
\makeatletter
\newcommand*\notwithin[2]{%
\@removefromreset{#1}{#2}%
}
\makeatother
\begin{document}
\section{The First Section}
\subsection{The First Subsection}
\begin{theorem}
a theorem
\end{theorem}
\begin{corollary}
a corollary
\end{corollary}
\subsection{The Second Subsection}
\begin{theorem}
a theorem
\end{theorem}
\begin{corollary}
a corollary
\end{corollary}
\section{The Second Section}
\numberwithin{theorem}{subsection}
\subsection{The First Subsection}
\begin{theorem}
a theorem
\end{theorem}
\begin{corollary}
a corollary
\end{corollary}
\subsection{The Second Subsection}
\begin{theorem}
a theorem
\end{theorem}
\begin{corollary}
a corollary
\end{corollary}
\section{The Third Section}
\numberwithin{theorem}{section}
\notwithin{theorem}{subsection}
\subsection{The First Subsection}
\begin{theorem}
a theorem
\end{theorem}
\begin{corollary}
a corollary
\end{corollary}
\subsection{The Second Subsection}
\begin{theorem}
a theorem
\end{theorem}
\begin{corollary}
a corollary
\end{corollary}
\end{document}