如何保持相同的数字重述定理?

如何保持相同的数字重述定理?

这个问题是在如何重复定理数亚斯马尔的答案适用于我的tcolorbox定理,甚至也是link实时的。但是因为亚斯马尔使用,则会amsthm丢失格式。\theoremstyleduplicatetcolorbox

以下是 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}    

输出如下:

Restated Theorem

正如我所说,几乎完成了。但是我如何获得格式tcolorbox?(当然还要去掉1parentheses?)

答案1

如果我正确理解了这个问题,你想要重述定理编号,但是将修改后的文本放入重述的定理中(如在答案中yasmar)。

也许,下面就是您正在寻找的:

\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

答案2

这是一种结合tcolorbox和的方法thmtools:我定义一个tcolorbox键,改编自mdframed键,它负责格式化包含可重述定理的框:

\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

相关内容