我正在使用IEEEtran
類別和\usepackage{amsthm}
.如何為定理設定一個獨立於各部分的計數器?假設我的第一個定理有三個部分,第二個定理有兩個部分。我怎樣才能生成?
定理1.1
定理1.2
定理1.3
定理2.1
定理2.2
答案1
我建議您建立一個專用的計數器變數(例如mythmcounter
,稱為),並建立一個專用的類似定理的環境(例如mythm
,稱為),其編號從屬於 的值mythmcounter
。\stepcounter{mythmcounter}
根據需要運行指令。
\documentclass{IEEEtran}
\usepackage{amsthm}
\newcounter{mythmcounter}
\newtheorem{mythm}{Theorem}[mythmcounter]
\begin{document}
\stepcounter{mythmcounter}
\begin{mythm} abc \end{mythm}
\begin{mythm} def \end{mythm}
\stepcounter{mythmcounter}
\begin{mythm} ghi \end{mythm}
\begin{mythm} jkl \end{mythm}
\begin{mythm} mno \end{mythm}
\end{document}
答案2
我不確定我是否完全理解了這個問題,但應該subtheorems
有一個定理和一個子定理數。最簡單的方法是定義一個subtheorem
使用theorem
計數器作為驅動程式計數器的新環境。
第一次出現這樣的子定理需要 a \setcounter{theorem}{1}
,下一個(如果直接跟隨子定理)需要 a\stepcounter{theorem}
來強制重置子定理計數器。
\documentclass{IEEEtran}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}
\newtheorem{subtheorem}{Subtheorem}[theorem]
\begin{document}
\section{Foo section}
\setcounter{theorem}{1}
\begin{subtheorem}{Part one}
\end{subtheorem}
\begin{subtheorem}{Part two}
\end{subtheorem}
\begin{subtheorem}{Part three}
\end{subtheorem}
\stepcounter{theorem}
\begin{subtheorem}{Part one}
\end{subtheorem}
\begin{subtheorem}{Part two}
\end{subtheorem}
\end{document}
答案3
借用subequations
自amsmath
:
\documentclass{IEEEtran}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}
\makeatletter
\newcounter{parenttheorem}
\newenvironment{subtheorems}{%
\refstepcounter{theorem}%
\protected@edef\theparenttheorem{\thetheorem}%
\setcounter{parenttheorem}{\value{theorem}}%
\setcounter{theorem}{0}%
\def\thetheorem{\theparenttheorem.\arabic{theorem}}%
\ignorespaces
}{%
\setcounter{theorem}{\value{parenttheorem}}%
\ignorespacesafterend
}
\makeatother
\begin{document}
\begin{theorem}
This has no parts.
\end{theorem}
\begin{subtheorems}
\begin{theorem}
First part 2
\end{theorem}
\begin{theorem}
Second part 2
\end{theorem}
\end{subtheorems}
\begin{theorem}
This has no parts.
\end{theorem}
\begin{subtheorems}
\begin{theorem}
First part 4
\end{theorem}
\begin{theorem}
Second part 4
\end{theorem}
\begin{theorem}
Third part 4
\end{theorem}
\end{subtheorems}
\begin{theorem}
This has no parts.
\end{theorem}
\end{document}