![레이블이 다중 정의되는 것을 피하면서 재설정 가능한 tcolorbox 정리 환경을 갖는 방법](https://rvso.com/image/475705/%EB%A0%88%EC%9D%B4%EB%B8%94%EC%9D%B4%20%EB%8B%A4%EC%A4%91%20%EC%A0%95%EC%9D%98%EB%90%98%EB%8A%94%20%EA%B2%83%EC%9D%84%20%ED%94%BC%ED%95%98%EB%A9%B4%EC%84%9C%20%EC%9E%AC%EC%84%A4%EC%A0%95%20%EA%B0%80%EB%8A%A5%ED%95%9C%20tcolorbox%20%EC%A0%95%EB%A6%AC%20%ED%99%98%EA%B2%BD%EC%9D%84%20%EA%B0%96%EB%8A%94%20%EB%B0%A9%EB%B2%95.png)
초기에 정리를 정의하고 나중에 이를 증명할 때가 되면 동일한 정리를 다시 설명하고 싶은 문서가 있습니다.
일반적으로 이 작업은 패키지를 사용하여 수행할 수 있습니다 thm-restate
. 그러나 내 문서의 정리는 tcolorbox 환경을 사용하므로 대신에 제안된 접근 방식을 사용해 보았습니다.이 답변.
이 접근 방식은 정리를 다시 설명하는 데 효과적이지만 LaTeX에서는 레이블이 "곱하기 정의"된다는 경고를 표시합니다. 이 오류로 인해 다시 설명한 정리를 올바르게 참조할 수 없습니다.
내 질문:레이블이 중복되는 문제가 발생하지 않고 어떻게 tcolorbox 정리를 다시 기술할 수 있습니까?
다음은 설정과 문제를 보여주는 최소 예입니다.
\documentclass{article}
\usepackage{amsmath}
\usepackage[colorlinks=true, allcolors=blue]{hyperref}
\usepackage{cleveref}
\usepackage{tcolorbox}
\tcbuselibrary{theorems}
\tcbuselibrary{magazine}
\usepackage{amsthm}
\theoremstyle{definition}
% The tcolorbox theorem
\newtcbtheorem{theorem}{Theorem}{colback=gray!10,colframe=gray!40!black}{theorem}
% Commands to restate the theorem
\newcommand{\recallthm}[2][1]{\par\noindent\useboxarray[#2]{#1}}
\usepackage{environ}
\NewEnviron{restatablethm}[2]{%
\newboxarray{#2}%
\begin{theorem}[reset box array=#2, store to box array=#2]{#1}{#2}
\BODY%
\end{theorem}%
\recallthm{#2}%
}
% Other theorem environments might be on the same counter
\newtheorem{lemma}[tcb@cnt@theorem]{Lemma}
\begin{document}
% The first theorem
\begin{restatablethm}{Serious Algorithm}{coollabel}
An example boxed theorem..
\end{restatablethm}
\begin{lemma}
A simple lemma.
\end{lemma}
% The restated theorem
\recallthm{coollabel}
By \Cref{thm:collabel} we are done. % The reference here does not work (yields ??).
\end{document}
답변1
이는 [nophantom]을 사용하여 호출 가능한 상자를 생성하지만 원본은 생성하지 않습니다. 여전히 중복된 하이퍼타겟에 대한 경고와 배송 상자에 대한 경고가 생성됩니다. 라벨을 생성했는데도 \Cref
전혀 작동하지 않습니다 .theorem:coollabel@cref
\documentclass{article}
\usepackage{amsmath}
\usepackage[colorlinks=true, allcolors=blue]{hyperref}
\usepackage{cleveref}
\usepackage{tcolorbox}
\tcbuselibrary{theorems}
\tcbuselibrary{magazine}
\usepackage{amsthm}
\theoremstyle{definition}
% The tcolorbox theorem
\newtcbtheorem{theorem}{Theorem}{colback=gray!10,colframe=gray!40!black}{theorem}
% Commands to restate the theorem
\newcommand{\recallthm}[2][1]{\par\noindent\useboxarray[#2]{#1}}
\usepackage{environ}
\makeatletter
\NewEnviron{restatablethm}[2]{% print this copy
\newboxarray{#2}%
\begin{theorem}[reset box array=#2, store to box array=#2,nophantom]{#1}{#2}
\BODY%
\end{theorem}%
\addtocounter{tcb@cnt@theorem}{-1}%
\begin{theorem}{#1}{#2}
\BODY%
\end{theorem}%
%\recallthm{#2}%
}
% Other theorem environments might be on the same counter
\newtheorem{lemma}[tcb@cnt@theorem]{Lemma}
\begin{document}
% The first theorem
\begin{restatablethm}{Serious Algorithm}{coollabel}
An example boxed theorem..
\end{restatablethm}
\begin{lemma}
A simple lemma.
\end{lemma}
% The restated theorem
\recallthm{coollabel}
By \ref{theorem:coollabel} we are done. % The reference here does not work (yields ??).
\end{document}