我是 tcolorbox 的 newtcbtheorem 新手。我知道如何基于 newtcbtheorem 定义自己的定理块,但如果我使用多个 tcbtheorem,编号就会很奇怪。
我粘贴了一个工作示例,如下所示,编号在章节内有效,但数字是1.1
\documentclass[11pt, a4paper]{report}
\usepackage{tcolorbox}
\tcbuselibrary{theorems}
\newtcbtheorem[number within=chapter]{Theorem}{Theorem}{}{Th}
\newtcbtheorem[number within=chapter]{Korollar}{Korollar}{}{Kor}
\begin{document}
\chapter{A TCOLORBOX TEST}
\begin{Theorem}{}{}
We have $2 + 2 = 4$.
\end{Theorem}
\begin{Korollar}{}{}
We want to solve $2 + x = 4$.
\end{Korollar}
\begin{Theorem}{}{}
We have $2 + 2 = 4$.
\end{Theorem}
\end{document}
感谢您的提示
答案1
默认行为是为每种定理使用一个新的计数器。如果你不喜欢这样,你可以使用以下命令告诉定理使用另一个定理的计数器use counter from=Theorem
\documentclass[11pt, a4paper]{report}
\usepackage{tcolorbox}
\tcbuselibrary{theorems}
\newtcbtheorem[number within=chapter]{Theorem}{Theorem}{}{Th}
\newtcbtheorem[use counter from=Theorem, number within=chapter]{Korollar}{Korollar}{}{Kor}
\begin{document}
\chapter{A TCOLORBOX TEST}
\begin{Theorem}{}{}
We have $2 + 2 = 4$.
\end{Theorem}
\begin{Korollar}{}{}
We want to solve $2 + x = 4$.
\end{Korollar}
\begin{Theorem}{}{}
We have $2 + 2 = 4$.
\end{Theorem}
\end{document}