不同 tcolorbox 定理的计数器相同

不同 tcolorbox 定理的计数器相同

我有两种不同类型的 tcbtheorems:定理和引理,定义如下。

\newtcbtheorem[number within=section]{theorem}{Theorem}{some config options}{thm}
\newtcbtheorem[number within=section]{lemma}{Lemma}{some config options}{lem}

如果我在我的文档中某处有

\begin{theorem}{}{}
theorem
\end{theorem}

\begin{lemma}{}{}
lemma
\end{lemma}

它产生“定理 1.1”和“引理 1.1”,而我希望它产生“定理 1.1”然后“引理 1.2”。

答案1

use counter from=theorem只需在定义新词干时添加选项\newtcbtheorem

\documentclass{article}
    \usepackage{tcolorbox}
    \tcbuselibrary{theorems}
    \newtcbtheorem[number within=section]{theorem}{Theorem}{}{thm}
    \newtcbtheorem[number within=section,
                  use counter from=theorem % <----------------
                  ]{lemma}{Lemma}{}{lem}

\begin{document}
\section{title section}
\begin{theorem}{}{}
theorem
\end{theorem}

\begin{lemma}{}{}
lemma
\end{lemma}
\end{document}

在此处输入图片描述

相关内容