0

The question was asked in How do I repeat a theorem number and yasmar's answer there works for my tcolorbox theorem and even the link is live. But since yasmar uses amsthm's\theoremstyle, the duplicate loses thetcolorbox formatting.

Here is a MWE:

% !TEX TS-program = pdflatexmk  
\documentclass{book}
    \usepackage{makeidx}
    \usepackage[hyperfootnotes=false]{hyperref}%[pdfborder={0 0 0}]
%Begin the ``quick and dirty hack'' due to Heiko Oberdiek which loads showidx 
\makeatletter
\ifHy@hyperindex
  \def\HyInd@ParenLeft{(}%
% Hook in \HyInd@@wrindex
  \let\HyInd@showidx\@empty
% Hook in \HyInd@@wrindex for package showidx
  \def\HyInd@showidx#1{%
    \@showidx{#1}%
    \if@nobreak
      \ifvmode
        \nobrak
      \fi
    \fi
  }%
% Load package showidx
  \let\siOrg@makeindex\makeindex
  \let\siOrg@@index\@index
  \let\siOrg@@wrindex\@wrindex
  \let\siOrg@index\index
  \RequirePackage{showidx}
  \let\makeindex\siOrg@makeindex
  \let\@index\siOrg@@index
  \let\@wrindex\siOrg@@wrindex
  \let\index\siOrg@index
    % rest of hyperref part
  \@ifpackageloaded{multind}{%
    \let\HyInd@org@wrindex\@wrindex
    \def\@wrindex#1#2{\HyInd@@wrindex{#1}#2||\\}%
    \def\HyInd@@wrindex#1#2|#3|#4\\{%
      \ifx\\#3\\%
        \HyInd@org@wrindex{#1}{#2|hyperpage}%
      \else
        \def\Hy@temp@A{#3}%
        \ifx\Hy@temp@A\HyInd@ParenLeft
          HyInd@org@wrindex{#1}{#2|#3hyperpage}%
        \else
          \HyInd@org@wrindex{#1}{#2|#3}%
        \fi
      \fi
    }%
  }{%
    \def\@wrindex#1{\@@wrindex#1||\\}
    \def\@@wrindex#1|#2|#3\\{%
      \ifx\\#2\\%
        \protected@write\@indexfile{}{%
          \string\indexentry{#1|hyperpage}{\thepage}%
        }%
      \else
        \def\Hy@temp@A{#2}%
        \ifx\Hy@temp@A\HyInd@ParenLeft
          \protected@write\@indexfile{}{%
             \string\indexentry{#1|#2hyperpage}{\thepage}%
          }%
        \else
          \protected@write\@indexfile{}{%
            \string\indexentry{#1|#2}{\thepage}%
          }%
        \fi
      \fi
      \endgroup
      \HyInd@showidx{#1}%
      \@esphack
    }%
  }%
\fi
\makeatother
%End the ``quick and dirty hack'' due to Heiko Oberdiek which loads showidx
    \hypersetup{
                  colorlinks,
                   linkcolor={red!50!black},
                   citecolor={blue!50!black},
                  urlcolor={blue!80!black}
                }%end colors
\usepackage{cleveref}
\usepackage{tcolorbox}
        \tcbuselibrary{skins}
    \newcounter{thm}%[chapter] 
\newtcolorbox%
[%
use counter= thm,
number within=chapter,
number freestyle={\noexpand\thechapter.\noexpand\arabic{\tcbcounter}~\noexpand\mytitle},%
list inside= thm,%creates the list under tcblistof
list type=heorem,
crefname={Theorem}{Theorems},
Crefname={Theorem}{Theorems},
]%
{heorem}%
[2][]%
{%
detach title,%
before upper={\tcbtitle\quad},%
%breakable,%
enhanced,%
arc=0.2mm,%
%fontupper=\sffamily,
colback=green!5,%
colframe=green!35!black,%
fonttitle=\bfseries,%
coltitle=black,%
code={\gdef\mytitle{#2}},
%code={\def\mytitle{#2}},%
title=THEOREM \thetcbcounter,%
list entry={Theorem~\thetcbcounter},
#1%
}%
%Begin the Sharpe (2013-01-18) code as modified by Schulz (2016-02-1) to have math in Showindex     
\let\oldopenparen\(
\let\oldcloseparen\)
\def\({\protect\oldopenparen}
\def\){\protect\oldcloseparen}
\newcommand{\INDEX}[1]{\index{#1}}
%End the Sharpe (2013-01-18) code as modified by Schulz (2016-02-1) to have math in Showindex               
\newcommand*{\fullref}[1]{\hyperref[{#1}]{\cref*{#1} \nameref*{#1} \pageref*{#1}}}
%BeginYASMAR
%\theoremstyle{empty}%Does not work here.
\newtheorem{duplicate}{}
%EndYASMAR
\begin{document}    
\begin{heorem}[label={thm:1-1}]{~}\hspace{-4mm}
\emph{Signed addition} and \emph{signed subtraction} of the same amount undo each other.
\end{heorem}
\begin{duplicate}[Theorem~\ref{thm:1-1}]
Translations of opposite amounts undo each other.
\end{duplicate}
\end{document}    

and here is the output:

Restated Theorem

As I said, almost there. But how do I get the tcolorbox formatting? (And of course get rid of the 1 and the parentheses?)

2
  • The thmtools package, which cooperates with amsthm as well as ntheorem, offers this possibility (§ 1.4, Restatable theorems).
    – Bernard
    Jan 11, 2017 at 23:37
  • @Bernard For my purposes, the immensely versatile tcolorbox is now irreplaceable and I don't use amsthm anymore. Since \duplicate (from what package?) is working, what I need is to learn about doing with tcolorbox something like yasmar's \theoremstyle{empty} which is what he used to format the duplicate. The thmtools doc says "The major backends provide a command \theoremstyle to switch between looks of theorems" but I can't see how to do it in tcolorbox even though tcolorbox "can be used to put a box around an amsthm".
    – schremmer
    Jan 12, 2017 at 0:56

2 Answers 2

2

If I understand the problem correctly, you want to restate der theorem number, but put a modified text into the restated theorem (as in the yasmar answer).

Maybe, the following is what you are looking for:

\documentclass{book}
    \usepackage{makeidx}
    \usepackage[hyperfootnotes=false]{hyperref}%[pdfborder={0 0 0}]
%Begin the ``quick and dirty hack'' due to Heiko Oberdiek which loads showidx
\makeatletter
\ifHy@hyperindex
  \def\HyInd@ParenLeft{(}%
% Hook in \HyInd@@wrindex
  \let\HyInd@showidx\@empty
% Hook in \HyInd@@wrindex for package showidx
  \def\HyInd@showidx#1{%
    \@showidx{#1}%
    \if@nobreak
      \ifvmode
        \nobrak
      \fi
    \fi
  }%
% Load package showidx
  \let\siOrg@makeindex\makeindex
  \let\siOrg@@index\@index
  \let\siOrg@@wrindex\@wrindex
  \let\siOrg@index\index
  \RequirePackage{showidx}
  \let\makeindex\siOrg@makeindex
  \let\@index\siOrg@@index
  \let\@wrindex\siOrg@@wrindex
  \let\index\siOrg@index
    % rest of hyperref part
  \@ifpackageloaded{multind}{%
    \let\HyInd@org@wrindex\@wrindex
    \def\@wrindex#1#2{\HyInd@@wrindex{#1}#2||\\}%
    \def\HyInd@@wrindex#1#2|#3|#4\\{%
      \ifx\\#3\\%
        \HyInd@org@wrindex{#1}{#2|hyperpage}%
      \else
        \def\Hy@temp@A{#3}%
        \ifx\Hy@temp@A\HyInd@ParenLeft
          HyInd@org@wrindex{#1}{#2|#3hyperpage}%
        \else
          \HyInd@org@wrindex{#1}{#2|#3}%
        \fi
      \fi
    }%
  }{%
    \def\@wrindex#1{\@@wrindex#1||\\}
    \def\@@wrindex#1|#2|#3\\{%
      \ifx\\#2\\%
        \protected@write\@indexfile{}{%
          \string\indexentry{#1|hyperpage}{\thepage}%
        }%
      \else
        \def\Hy@temp@A{#2}%
        \ifx\Hy@temp@A\HyInd@ParenLeft
          \protected@write\@indexfile{}{%
             \string\indexentry{#1|#2hyperpage}{\thepage}%
          }%
        \else
          \protected@write\@indexfile{}{%
            \string\indexentry{#1|#2}{\thepage}%
          }%
        \fi
      \fi
      \endgroup
      \HyInd@showidx{#1}%
      \@esphack
    }%
  }%
\fi
\makeatother
%End the ``quick and dirty hack'' due to Heiko Oberdiek which loads showidx
    \hypersetup{
                  colorlinks,
                   linkcolor={red!50!black},
                   citecolor={blue!50!black},
                  urlcolor={blue!80!black}
                }%end colors
\usepackage{cleveref}
\usepackage{tcolorbox}
        \tcbuselibrary{skins}
    \newcounter{thm}%[chapter]
\newtcolorbox%
[%
use counter= thm,
number within=chapter,
number freestyle={\noexpand\thechapter.\noexpand\arabic{\tcbcounter}~\noexpand\mytitle},%
list inside= thm,%creates the list under tcblistof
list type=heorem,
crefname={Theorem}{Theorems},
Crefname={Theorem}{Theorems},
]%
{heorem}%
[2][]%
{%
detach title,%
before upper={\tcbtitle\quad},%
%breakable,%
enhanced,%
arc=0.2mm,%
%fontupper=\sffamily,
colback=green!5,%
colframe=green!35!black,%
fonttitle=\bfseries,%
coltitle=black,%
code={\gdef\mytitle{#2}},
%code={\def\mytitle{#2}},%
title=THEOREM \thetcbcounter,%
list entry={Theorem~\thetcbcounter},
#1%
}%
%Begin the Sharpe (2013-01-18) code as modified by Schulz (2016-02-1) to have math in Showindex
\let\oldopenparen\(
\let\oldcloseparen\)
\def\({\protect\oldopenparen}
\def\){\protect\oldcloseparen}
\newcommand{\INDEX}[1]{\index{#1}}
%End the Sharpe (2013-01-18) code as modified by Schulz (2016-02-1) to have math in Showindex
\newcommand*{\fullref}[1]{\hyperref[{#1}]{\cref*{#1} \nameref*{#1} \pageref*{#1}}}
%\theoremstyle{empty}%Does not work here.

\newtcolorbox%
{duplicate}%
[3][]%
{%
detach title,%
before upper={\tcbtitle\quad},%
enhanced,%
arc=0.2mm,%
colback=green!5,%
colframe=green!35!black,%
fonttitle=\bfseries,%
coltitle=black,%
code={\gdef\mytitle{#3}},
title=THEOREM~\ref{#2},%
%list entry={Theorem~\thetcbcounter},
#1%
}%

\begin{document}
\begin{heorem}[label={thm:1-1}]{~}\hspace{-4mm}
\emph{Signed addition} and \emph{signed subtraction} of the same amount undo each other.
\end{heorem}
\begin{duplicate}{thm:1-1}{~}
Translations of opposite amounts undo each other.
\end{duplicate}
\end{document}

enter image description here

1
  • @ Thomas F. Sturm I just tried it. Not "Maybe", just PERFECT. (Even the number is live.) Absolutely perfect!
    – schremmer
    Jan 14, 2017 at 15:53
2

Here is a way to combine tcolorbox and thmtools: I define a tcolorbox key, adapted from the mdframed key, which does the job of formatting the box which contains the restatable theorem:

\documentclass{book}
    \usepackage{makeidx}
    \usepackage[hyperfootnotes=false]{hyperref}%[pdfborder={0 0 0}]
%Begin the ``quick and dirty hack'' due to Heiko Oberdiek which loads showidx
\makeatletter
\ifHy@hyperindex
  \def\HyInd@ParenLeft{(}%
% Hook in \HyInd@@wrindex
  \let\HyInd@showidx\@empty
% Hook in \HyInd@@wrindex for package showidx
  \def\HyInd@showidx#1{%
    \@showidx{#1}%
    \if@nobreak
      \ifvmode
        \nobrak
      \fi
    \fi
  }%
% Load package showidx
  \let\siOrg@makeindex\makeindex
  \let\siOrg@@index\@index
  \let\siOrg@@wrindex\@wrindex
  \let\siOrg@index\index
  \RequirePackage{showidx}
  \let\makeindex\siOrg@makeindex
  \let\@index\siOrg@@index
  \let\@wrindex\siOrg@@wrindex
  \let\index\siOrg@index
    % rest of hyperref part
  \@ifpackageloaded{multind}{%
    \let\HyInd@org@wrindex\@wrindex
    \def\@wrindex#1#2{\HyInd@@wrindex{#1}#2||\\}%
    \def\HyInd@@wrindex#1#2|#3|#4\\{%
      \ifx\\#3\\%
        \HyInd@org@wrindex{#1}{#2|hyperpage}%
      \else
        \def\Hy@temp@A{#3}%
        \ifx\Hy@temp@A\HyInd@ParenLeft
          HyInd@org@wrindex{#1}{#2|#3hyperpage}%
        \else
          \HyInd@org@wrindex{#1}{#2|#3}%
        \fi
      \fi
    }%
  }{%
    \def\@wrindex#1{\@@wrindex#1||\\}
    \def\@@wrindex#1|#2|#3\\{%
      \ifx\\#2\\%
        \protected@write\@indexfile{}{%
          \string\indexentry{#1|hyperpage}{\thepage}%
        }%
      \else
        \def\Hy@temp@A{#2}%
        \ifx\Hy@temp@A\HyInd@ParenLeft
          \protected@write\@indexfile{}{%
             \string\indexentry{#1|#2hyperpage}{\thepage}%
          }%
        \else
          \protected@write\@indexfile{}{%
            \string\indexentry{#1|#2}{\thepage}%
          }%
        \fi
      \fi
      \endgroup
      \HyInd@showidx{#1}%
      \@esphack
    }%
  }%
\fi
\makeatother
%End the ``quick and dirty hack'' due to Heiko Oberdiek which loads showidx
    \hypersetup{
                  colorlinks,
                   linkcolor={red!50!black},
                   citecolor={blue!50!black},
                  urlcolor={blue!80!black}
                }%end colors
\usepackage{cleveref}
\usepackage{tcolorbox}
        \tcbuselibrary{skins}
    \newcounter{thm}%[chapter]

%Begin the Sharpe (2013-01-18) code as modified by Schulz (2016-02-1) to have math in Showindex
\let\oldopenparen\(
\let\oldcloseparen\)
\def\({\protect\oldopenparen}
\def\){\protect\oldcloseparen}
\newcommand{\INDEX}[1]{\index{#1}}
%End the Sharpe (2013-01-18) code as modified by Schulz (2016-02-1) to have math in Showindex
\newcommand*{\fullref}[1]{\hyperref[{#1}]{\cref*{#1} \nameref*{#1} \pageref*{#1}}}
%BeginYASMAR
%\theoremstyle{empty}%Does not work here.
\newtheorem{duplicate}{}
%EndYASMAR

\usepackage{amsthm, thmtools, thm-restate}%
\declaretheoremstyle[numberwithin=chapter, bodyfont=\normalfont]{mythm}
\declaretheoremstyle[
spaceabove=6pt, spacebelow=6pt,
headfont=\normalfont\bfseries,
notefont=\mdseries, notebraces={(}{)},
bodyfont=\normalfont,
postheadspace=1em,
]{mystyle}

\makeatletter
\define@key{thmdef}{tcolorbox}[{}]{%
 \thmt@trytwice{}{%
 \RequirePackage{tcolorbox}%
 \RequirePackage{thm-patch}%
\tcbset {arc=0.2mm, colback=green!5, colframe=green!35!black}
 \addtotheorempreheadhook[\thmt@envname]{%
 \begin{tcolorbox}[#1]}%
 \addtotheorempostfoothook[\thmt@envname]{\end{tcolorbox}}%
 }%
 }
\makeatother
\declaretheorem[name=THEOREM,  style=mythm,  tcolorbox]{Thm}
\usepackage{lipsum}

\begin{document}

\setcounter{chapter}{2}

\begin{restatable}{Thm}{restatetest}\label{testthm}
  \emph{Signed addition} and \emph{signed subtraction} of the same amount undo each other.
\end{restatable}

\lipsum[11]
\restatetest*

\end{document} 

enter image description here

3
  • Very nice. But, contrary to my half-baked yasmar attempt, 1. I cannot modify the text in the restate, 2. the restate number is not live. There has to be a way to do the yasmar way right but I am not up to it. Maybe I should try to get tcolorbox "to put a box around an amsthm"?
    – schremmer
    Jan 13, 2017 at 14:07
  • That's precisely whatthmtools does, with the tcolorbox key. To do what you want (introduce in the restated theorem a variant of the original theorem) one would have to hack the restatable environment.
    – Bernard
    Jan 13, 2017 at 14:48
  • Bernard, could you answer this: tex.stackexchange.com/questions/660066/…? Look only at the first MWE. Thank you
    – CarLaTeX
    Oct 8, 2022 at 22:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .