Como ter ambientes reajustáveis ​​do teorema do tcolorbox, evitando que os rótulos sejam definidos de forma múltipla

Como ter ambientes reajustáveis ​​do teorema do tcolorbox, evitando que os rótulos sejam definidos de forma múltipla

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-restatepacote. 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. \Crefnão funciona, mesmo que um theorem:coollabel@crefró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}

informação relacionada