tcolorbox 上的奇怪扩展

tcolorbox 上的奇怪扩展

我不明白为什么以下代码会失败并出现错误

ERROR: File ended while scanning use of \thmt@collect@body.

确实当我定义

before upper={\begin{thm}[my title]}

它有效,但是当我使用

before upper={\begin{restatable}[my title]{thm}{myrestatecommand}}

它失败了,而代码应该是等效的。知道为什么吗?

梅威瑟:

\documentclass{article}

\usepackage{mathtools}
\usepackage{amssymb, amsthm, amsmath, thm-restate}
\usepackage{thmtools} %%
\usepackage{hyperref}

\newtheorem{thm}{Theorem}[section]
\providecommand*\thmautorefname{Theorem}
\newtheorem{corollary}[thm]{Corollary}
\providecommand*\corollaryautorefname{Corollary}
\newtheorem{lemma}[thm]{Lemma}
\providecommand*\lemmaautorefname{Lemma}

\usepackage{lipsum}
\usepackage[most]{tcolorbox}

% Works:
\NewTColorBox[auto counter, number within=section]{theorem}{}{ %
    blank,
    breakable,
    before upper={\begin{thm}[my title]},
      after upper={\end{thm}},
}

% Fails:
\NewTColorBox[auto counter, number within=section]{theoremRestate}{}{ %
    blank,
    breakable,
    before upper={\begin{restatable}[my title]{thm}{myrestatecommand}},
      after upper={\end{restatable}},
}

\begin{document}

%% Works:
\begin{restatable}[my title]{thm}{myrestatecommanda}
  This theorem works
\end{restatable}

%% Works:
%% Does not work:
\begin{theorem}
  This theorem does not work
\end{theorem}

%% Does not work:
\begin{theoremRestate}
  This theorem does not work
\end{theoremRestate}

\end{document}

相关内容