![Como ter ambientes reajustáveis do teorema do tcolorbox, evitando que os rótulos sejam definidos de forma múltipla](https://rvso.com/image/475705/Como%20ter%20ambientes%20reajust%C3%A1veis%20%E2%80%8B%E2%80%8Bdo%20teorema%20do%20tcolorbox%2C%20evitando%20que%20os%20r%C3%B3tulos%20sejam%20definidos%20de%20forma%20m%C3%BAltipla.png)
Tenho um documento onde gostaria de definir um teorema desde o início e, em seguida, reafirmar o mesmo teorema mais tarde, quando chegar a hora de prová-lo.
Normalmente isso poderia ser feito usando o thm-restate
pacote. No entanto, os teoremas do meu documento usam um ambiente tcolorbox, então tentei usar a abordagem sugerida emesta resposta.
Essa abordagem funciona para reafirmar teoremas, mas o LaTeX gera avisos sobre os rótulos serem "definidos multiplicadamente". Devido a esse erro, não consigo fazer referência correta aos teoremas reformulados.
Minha pergunta:como posso reafirmar os teoremas do tcolorbox, sem me deparar com um problema de duplicação de rótulos?
Aqui está um exemplo mínimo mostrando a configuração e o problema:
\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}
Responder1
Isso usa [nophantom] para criar a caixa recuperável, mas não a original. Ainda gera um aviso sobre hipertargets duplicados, além de um sobre a caixa de envio. \Cref
não funciona, mesmo que um theorem:coollabel@cref
rótulo tenha sido criado.
\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}