使用常规定理环境和 tcolorbox 定理

使用常规定理环境和 tcolorbox 定理

我正在使用 tcolorbox 为我的定理绘制彩色框,但是对于诸如注释或示例之类的东西,我希望拥有通常的 amsthm 类型的环境,而没有任何彩色框。

如果我尝试将这两个环境结合起来,正如您在下面的 MWE 中看到的那样,如果我根据定理让注释计数,我就无法正确得到计数器。

我应该对此评论提出什么反驳来解决这个问题?

在此处输入图片描述

\documentclass{article}

\usepackage[theorems]{tcolorbox}
\usepackage{amsmath}

\newtcbtheorem[number within=section]%
{theorem} % \begin..
{Theorem} % Title
{} % Style - default
{theo} % label prefix; cite as ``theo:yourlabel''

\usepackage{amsthm}
\theoremstyle{remark}
\newtheorem{remark}[]{Remark}          % <- This will work
\newtheorem{remark2}[theorem]{Remark2} % <- This won't work

\begin{document}
\section{The section}
\begin{theorem}{The title}{mylabel}
This is a theorem.
\end{theorem}

Counting remarks with respect to the section:
\begin{remark}
Counter is okay
\end{remark}

Counting remarks with respect to the theorem:
\begin{remark2}
\textbf{Problem:} counter is missing and there is
not even a break line.
\end{remark2}

\end{document}

答案1

我不确定您想要什么计数器,但会为每个框tcolorbox创建一个计数器\tcbcounter,以供以后参考。

\documentclass{article}

\usepackage[theorems]{tcolorbox}
\usepackage{amsmath}

\newtcbtheorem[number within=section]%
{theorem} % \begin..
{Theorem} % Title
{} % Style - default
{theo} % label prefix; cite as ``theo:yourlabel''

\usepackage{amsthm}
\theoremstyle{remark}
\newtheorem{remark}[]{Remark}          % <- This will work
\newtheorem{remark2}[\tcbcounter]{Remark2} % <- This won't work

\begin{document}
\section{The section}
\begin{theorem}{The title}{mylabel}
This is a theorem.
\end{theorem}

Counting remarks with respect to the section:
\begin{remark}
Counter is okay
\end{remark}

Counting remarks with respect to the theorem:
\begin{remark2}
\textbf{Problem:} counter is missing and there is
not even a break line.
\end{remark2}

\end{document}

在此处输入图片描述

相关内容