如何引用重述的 tcolorbox

如何引用重述的 tcolorbox

克里斯蒂安·赫普弗 (Christian Hupfer)如何标记重述的定理?和 Cragfelt如何让重述的 tcolorbox 出现在 tcolorboxes 列表中都用于label={dft:1-1a}重述tcolorbox,但这里指的是Subsection 1.1.2 dft:1-1

    \documentclass[11pt]{book}
    \usepackage{amsmath}
    \usepackage{makeidx}
        \makeindex
    \usepackage{tcolorbox}%---This is where the PACKAGE must be.
    \tcbuselibrary{%Begin load libraries for tcolorbox  
        skins,%
        raster,%
        breakable,%
        xparse,%
            }%End load libraries for tcolorbox      
%   \usepackage{xparse}%

%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$Begin HYPERREF
    \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{%begin colors
                   colorlinks,
                   linkcolor={red!50!black},
%                  citecolor={blue!50!black},
%                 urlcolor={blue!80!black}
                }%end colors
%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ End HYPERREF

    \usepackage{cleveref}
        \Crefname{subsection}{Subsection}{Subsection}
    \newcommand{\titleref}{\nameref}%displays title of reference as is. 

%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ Begin References
%sssssssssssssssssssssssssssssssssss Begin Sharpe Schulz (2016-02-1) for math in showid 
\let\oldopenparen\(
\let\oldcloseparen\)
\def\({\protect\oldopenparen}
\def\){\protect\oldcloseparen}
%sssssssssssssssssssssssssssssssssss End Sharpe Schulz (2016-02-1)  for math in showid
%sssssssssssssssssssssssssssssssssss Begin Hupfer code  
%============== Begin prelim
    \makeatletter
        \def\first@up#1#2\relax{\uppercase{#1}#2}%
        \newcommand{\FirstUpcase}[1]%
            {\expandafter\expandafter\expandafter\first@up#1\relax}%
    \makeatother
%---------------------
    \makeatletter
        \def\first@low#1#2\relax{\lowercase{#1}#2}%
        \newcommand{\FirstLowcase}[1]%
            {\expandafter\expandafter\expandafter\first@low#1\relax}%
    \makeatother
%============== End prelim
%============== Begin TitleRef = lower to upper 
    \NewDocumentCommand%
        {\TitleRef}{sm}%
        {%begin definition
            \IfBooleanTF{#1}%
                {%
                    \FirstUpcase{\getrefbykeydefault{#2}{name}{-1}}%
                 }% 
                {%
                    \IfRefUndefinedExpandable{#2}{}% 
                        {% begin label is defined, now get hyperlink
                            \hyperlink{\getrefbykeydefault{#2}{anchor}{-1}}%creates the link
                            {\FirstUpcase{\getrefbykeydefault{#2}{name}{-1}}}%error otherwise
                    }% end label is defined, now get hyperlink
                }%
        }%end definition
%============== End TitleRef = lower to upper
%============== Begin titleRef = upper to lower
    \NewDocumentCommand%
        {\titleRef}{sm}%
        {%begin definition
              \IfBooleanTF{#1}%
                  {%
                    \FirstLowcase{\getrefbykeydefault{#2}{name}{-1}}%
                  }% 
                  {%
                    \IfRefUndefinedExpandable{#2}{}%
                        {% begin label is defined, now get hyperlink
                            \hyperlink{\getrefbykeydefault{#2}{anchor}{-1}}%
                            {\FirstLowcase{\getrefbykeydefault{#2}{name}{-1}}}%
                         }% end label is defined, now get hyperlink
                }% end if false
        }%definition
%============== End titleRef = upper to lower
%sssssssssssssssssssssssssssssssssss End Hupfer code    
%sssssssssssssssssssssssssssssssssss Begin Andrew code for ref to indexed words
%============== Begin the Andrew code as edited Oct 27 at 17:24
    \newcommand{\INDEX}[2][]{\phantomsection%
    \if\relax\detokenize{#1}\relax\index{#2}\label{ind:#2}%
   \else\index{#2}\label{ind:#1}\fi%
    }%End INDEX
    \newcommand{\DEX}[2][]{%
   \if\relax\detokenize{#1}\relax\hyperref[ind:#2]{#2}%
   % (\Cpageref{ind:#2})%
   \else\hyperref[ind:#1]{#2}%
   %(\Cpageref{ind:#1})%
   \fi%
}%End DEX
%============== End the Andrew code as edited Oct 27 at 17:24
%============== Begin To make Cpageref work. 
\newcommand{\PGX}[2][]{%
   \if\relax\detokenize{#1}%
   \relax%
%   \hyperref[ind:#2]{#2}%
    \Cpageref{ind:#2}%
   \else%
%   \hyperref[ind:#1]{#2}%
   \Cpageref{ind:#1}%
   \fi%
}%
%End To make Cpageref work.
%sssssssssssssssssssssssssssssssssss End Andrew code for ref to indexed words
%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ End References


%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ Begin new tcolorbox - COMMANDS must be after cleveref.
\newcounter{dft}%
\newtcolorbox%
[%beginForReferences
use counter= dft,
number within=chapter,
list inside= dft,%creates the list under tcblistof 
crefname={definition}{definitions},
Crefname={Definition}{Definitions},
]%endForReferences
{efinition}%
[2][]%
{%
detach title,
coltitle=black,
nameref={#2},%
before upper={\tcbtitle\quad},%
%code={\gdef\mytitleagree{\textbf{#2}}},%%Used to include mytitle in the ``number''
title=DEFINITION \thetcbcounter \, #2,%
nameref=#2,%
list entry={DEFINITION ~\thetcbcounter ~ #2},%
#1,%Required for references.
}%
%=======Begin To restate an already stated definition STURM after YASMAR
\newtcolorbox%
[%beginForReferences
            list inside= dft,
]%endForReferences
{efinitionRphr}%
[3][]%
{%
detach title,%This prevents the top from being the color of the frame
before upper={\tcbtitle\quad},%This prevents the top from being the color of the frame
enhanced,%
arc=0.2mm,%
colback= yellow,%
colframe= black,%
coltitle=black,%
title= DEFINITION (Restated) ~\ref{#2}~\nameref{#2},%
nameref={#2},%
list entry= DEFINITION (Restated) ~\ref{#2}~\nameref{#2},
#1%
}%
%=======End To restate an already stated definition STURM after YASMAR
%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ End new tcolorbox



    \begin{document}


\chapter{ONE}\label{1-0-0}
    \newpage
\section{Height}\label{1-1-0}
    \newpage
\subsection{extremes}\label{1-1-1}

A \textbf{minimum}\INDEX[]{minimum} is an input \textbf{$\boldsymbol{x_{\text{min}}}$}\INDEX[xmin]{$x_{\text{min}}$} whose output is smaller that the outputs of nearby inputs.

\begin{efinition}[label={dft:1-1}]{Maximum}
  An input \textbf{$\boldsymbol{x_{\text{max}}}$} whose output is larger than the outputs of nearby inputs
\end{efinition}

\newpage
\subsection{far-fetched}\label{1-1-2}

\begin{efinitionRphr}[label={dft:1-1a}]{dft:1-1}{~}
The biggest of all
\end{efinitionRphr}
%

\chapter{References}\label{2-0-0}

\textbf{To avoid confusion, \emph{nameref} was RenewCommanded as \emph{titleref}.}


\emph{nameCref+labelcref+titleref}:\hspace{8mm} \nameCref{dft:1-1} \labelcref{dft:1-1}  \titleref{dft:1-1}


\emph{nameCref+labelcref+titleref}:\hspace{8mm} \nameCref{dft:1-1a} \labelcref{dft:1-1a}  \titleref{dft:1-1a}




\tcblistof[\chapter]{dft}{List of Definitions}





\phantomsection%otherwise, clicking on index in toc gets to GNU

\printindex
    \end{document}

在此处输入图片描述

答案1

在我链接的答案中,我使用了一个计数框来表示重复定理——它已被 OP 删除,因此计数器和链接信息丢失。label={foo}将只是最后一个\@currentlabel,它已在这里设置\subsection,而不是由框设置。

我重新注入了计数、说话label type=dftrepeatcrefname={definition repeated}{definitions repeated}功能。

另外,为了得到正确的重述数字,\thedftrepeat需要重新定义以提取对原始框的引用。

这是不是很糟糕?是的,因为整个设置已经堆积了大量的黑客攻击,在这里拧一个螺丝会导致需要在代码的其他地方拧 1000 个螺丝 :-(

需要 3 次编译才能使参考文献发挥作用。

\documentclass[11pt]{book}
\usepackage{amsmath}
\usepackage{makeidx}
\makeindex
\usepackage{tcolorbox}%---This is where the PACKAGE must be.
\tcbuselibrary{%Begin load libraries for tcolorbox  
  skins,%
  raster,%
  breakable,%
  xparse,%
}%End load libraries for tcolorbox      
% \usepackage{xparse}%

%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$Begin HYPERREF
\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{%begin colors
                   colorlinks,
                   linkcolor={red!50!black},
%                  citecolor={blue!50!black},
%                 urlcolor={blue!80!black}
                }%end colors
%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ End HYPERREF

                \usepackage{cleveref}
    \Crefname{subsection}{Subsection}{Subsection}
    \newcommand{\titleref}{\nameref}%displays title of reference as is. 


%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ Begin References
%sssssssssssssssssssssssssssssssssss Begin Sharpe Schulz (2016-02-1) for math in showid 
\let\oldopenparen\(
\let\oldcloseparen\)
\def\({\protect\oldopenparen}
\def\){\protect\oldcloseparen}
%sssssssssssssssssssssssssssssssssss End Sharpe Schulz (2016-02-1)  for math in showid
%sssssssssssssssssssssssssssssssssss Begin Hupfer code  
%============== Begin prelim
\makeatletter
\def\first@up#1#2\relax{\uppercase{#1}#2}%
\newcommand{\FirstUpcase}[1]%
{\expandafter\expandafter\expandafter\first@up#1\relax}%
\makeatother
% ---------------------
\makeatletter
\def\first@low#1#2\relax{\lowercase{#1}#2}%
\newcommand{\FirstLowcase}[1]%
{\expandafter\expandafter\expandafter\first@low#1\relax}%
\makeatother
% ============== End prelim
% ============== Begin TitleRef = lower to upper 
\NewDocumentCommand%
{\TitleRef}{sm}%
{%begin definition
  \IfBooleanTF{#1}%
  {%
    \FirstUpcase{\getrefbykeydefault{#2}{name}{-1}}%
  }% 
  {%
    \IfRefUndefinedExpandable{#2}{}% 
    {% begin label is defined, now get hyperlink
      \hyperlink{\getrefbykeydefault{#2}{anchor}{-1}}%creates the link
      {\FirstUpcase{\getrefbykeydefault{#2}{name}{-1}}}%error otherwise
    }% end label is defined, now get hyperlink
  }%
}%end definition
% ============== End TitleRef = lower to upper
% ============== Begin titleRef = upper to lower
\NewDocumentCommand%
{\titleRef}{sm}%
{%begin definition
  \IfBooleanTF{#1}%
  {%
    \FirstLowcase{\getrefbykeydefault{#2}{name}{-1}}%
  }% 
  {%
    \IfRefUndefinedExpandable{#2}{}%
    {% begin label is defined, now get hyperlink
      \hyperlink{\getrefbykeydefault{#2}{anchor}{-1}}%
      {\FirstLowcase{\getrefbykeydefault{#2}{name}{-1}}}%
    }% end label is defined, now get hyperlink
  }% end if false
}%definition
% ============== End titleRef = upper to lower
% sssssssssssssssssssssssssssssssssss End Hupfer code    
% sssssssssssssssssssssssssssssssssss Begin Andrew code for ref to indexed words
% ============== Begin the Andrew code as edited Oct 27 at 17:24
\newcommand{\INDEX}[2][]{\phantomsection%
  \if\relax\detokenize{#1}\relax\index{#2}\label{ind:#2}%
  \else\index{#2}\label{ind:#1}\fi%
}%End INDEX
    \newcommand{\DEX}[2][]{%
   \if\relax\detokenize{#1}\relax\hyperref[ind:#2]{#2}%
   % (\Cpageref{ind:#2})%
   \else\hyperref[ind:#1]{#2}%
   %(\Cpageref{ind:#1})%
   \fi%
}%End DEX
%============== End the Andrew code as edited Oct 27 at 17:24
%============== Begin To make Cpageref work. 
\newcommand{\PGX}[2][]{%
   \if\relax\detokenize{#1}%
   \relax%
%   \hyperref[ind:#2]{#2}%
    \Cpageref{ind:#2}%
   \else%
%   \hyperref[ind:#1]{#2}%
   \Cpageref{ind:#1}%
   \fi%
}%
%End To make Cpageref work.
%sssssssssssssssssssssssssssssssssss End Andrew code for ref to indexed words
%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ End References


%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ Begin new tcolorbox - COMMANDS must be after cleveref.

\newcounter{dft}%
\newtcolorbox%
[%beginForReferences
use counter= dft,
number within=chapter,
list inside= dft,%creates the list under tcblistof 
crefname={definition}{definitions},
Crefname={Definition}{Definitions},
]%endForReferences
{efinition}%
[2][]%
{%
detach title,
coltitle=black,
nameref={#2},%
before upper={\tcbtitle\quad},%
%code={\gdef\mytitleagree{\textbf{#2}}},%%Used to include mytitle in the ``number''
title=DEFINITION \thetcbcounter \, #2,%
nameref=#2,%
list entry={DEFINITION ~\thetcbcounter ~ #2},%
#1,%Required for references.
}%
%=======Begin To restate an already stated definition STURM after YASMAR
\newcounter{dftrepeat}

%\renewcommand{\theHdftrepeat}{dftrepeat.\thedftrepeat}
\newtcolorbox%
[%beginForReferences
use counter={dftrepeat},
list inside= dft,
crefname={definition restated}{definitions restated},
Crefname={Definition restated}{Definitions restated},
]
{efinitionRphr}%
[3][]%
{%
detach title,%This prevents the top from being the color of the frame
before upper={\tcbtitle\quad},%This prevents the top from being the color of the frame
enhanced,%
arc=0.2mm,%
colback= yellow,%
colframe= black,%
coltitle=black,%
title= DEFINITION (Restated) ~\ref{#2}~\nameref{#2},%
nameref={#2},%
list entry= DEFINITION (Restated) ~\ref{#2}~\nameref{#2},
label type={dftrepeat},
code={\renewcommand{\thedftrepeat}{\getrefnumber{#2}}},
#1%,
}%
%=======End To restate an already stated definition STURM after YASMAR
%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ End new tcolorbox



\begin{document}


\chapter{ONE}\label{1-0-0}
    \newpage
\section{Height}\label{1-1-0}
    \newpage
\subsection{extremes}\label{1-1-1}

A \textbf{minimum}\INDEX[]{minimum} is an input \textbf{$\boldsymbol{x_{\text{min}}}$}\INDEX[xmin]{$x_{\text{min}}$} whose output is smaller that the outputs of nearby inputs.

\begin{efinition}[label={dft:1-1}]{Maximum}
  An input \textbf{$\boldsymbol{x_{\text{max}}}$} whose output is larger than the outputs of nearby inputs
\end{efinition}

\newpage
\subsection{far-fetched}\label{1-1-2}

\begin{efinitionRphr}[label={dft:1-1a}]{dft:1-1}{~}
  The biggest of all
\end{efinitionRphr}
% 

\chapter{References}\label{2-0-0}

\textbf{To avoid confusion, \emph{nameref} was RenewCommanded as \emph{titleref}.}


\emph{nameCref+labelcref+titleref}:\hspace{8mm} \nameCref{dft:1-1} \labelcref{dft:1-1}  \titleref{dft:1-1}


\emph{nameCref+labelcref+titleref}:\hspace{8mm} \nameCref{dft:1-1a} \labelcref{dft:1-1a}  \fbox{\titleref{dft:1-1a}}




\tcblistof[\chapter]{dft}{List of Definitions}


\phantomsection%otherwise, clicking on index in toc gets to GNU

\printindex
\end{document}

在此处输入图片描述

\titleref 更新

为了获得框的第一个实例的名称,如果引用不可用,则使用将打印的nameref=\getrefbykeydefault{#2}{name}{UNDEFINED REFERENCE}位置(文本基本上可以被其他任何东西替换)UNDEFINED REFERENCE#2

\documentclass[11pt]{book}
\usepackage{amsmath}
\usepackage{makeidx}
\makeindex
\usepackage{tcolorbox}%---This is where the PACKAGE must be.
\tcbuselibrary{%Begin load libraries for tcolorbox  
  skins,%
  raster,%
  breakable,%
  xparse,%
}%End load libraries for tcolorbox      
% \usepackage{xparse}%

%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$Begin HYPERREF
\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{%begin colors
                   colorlinks,
                   linkcolor={red!50!black},
%                  citecolor={blue!50!black},
%                 urlcolor={blue!80!black}
                }%end colors
%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ End HYPERREF

                \usepackage{cleveref}
    \Crefname{subsection}{Subsection}{Subsection}
    \newcommand{\titleref}{\nameref}%displays title of reference as is. 


%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ Begin References
%sssssssssssssssssssssssssssssssssss Begin Sharpe Schulz (2016-02-1) for math in showid 
\let\oldopenparen\(
\let\oldcloseparen\)
\def\({\protect\oldopenparen}
\def\){\protect\oldcloseparen}
%sssssssssssssssssssssssssssssssssss End Sharpe Schulz (2016-02-1)  for math in showid
%sssssssssssssssssssssssssssssssssss Begin Hupfer code  
%============== Begin prelim
\makeatletter
\def\first@up#1#2\relax{\uppercase{#1}#2}%
\newcommand{\FirstUpcase}[1]%
{\expandafter\expandafter\expandafter\first@up#1\relax}%
\makeatother
% ---------------------
\makeatletter
\def\first@low#1#2\relax{\lowercase{#1}#2}%
\newcommand{\FirstLowcase}[1]%
{\expandafter\expandafter\expandafter\first@low#1\relax}%
\makeatother
% ============== End prelim
% ============== Begin TitleRef = lower to upper 
\NewDocumentCommand%
{\TitleRef}{sm}%
{%begin definition
  \IfBooleanTF{#1}%
  {%
    \FirstUpcase{\getrefbykeydefault{#2}{name}{-1}}%
  }% 
  {%
    \IfRefUndefinedExpandable{#2}{}% 
    {% begin label is defined, now get hyperlink
      \hyperlink{\getrefbykeydefault{#2}{anchor}{-1}}%creates the link
      {\FirstUpcase{\getrefbykeydefault{#2}{name}{-1}}}%error otherwise
    }% end label is defined, now get hyperlink
  }%
}%end definition
% ============== End TitleRef = lower to upper
% ============== Begin titleRef = upper to lower
\NewDocumentCommand%
{\titleRef}{sm}%
{%begin definition
  \IfBooleanTF{#1}%
  {%
    \FirstLowcase{\getrefbykeydefault{#2}{name}{-1}}%
  }% 
  {%
    \IfRefUndefinedExpandable{#2}{}%
    {% begin label is defined, now get hyperlink
      \hyperlink{\getrefbykeydefault{#2}{anchor}{-1}}%
      {\FirstLowcase{\getrefbykeydefault{#2}{name}{-1}}}%
    }% end label is defined, now get hyperlink
  }% end if false
}%definition
% ============== End titleRef = upper to lower
% sssssssssssssssssssssssssssssssssss End Hupfer code    
% sssssssssssssssssssssssssssssssssss Begin Andrew code for ref to indexed words
% ============== Begin the Andrew code as edited Oct 27 at 17:24
\newcommand{\INDEX}[2][]{\phantomsection%
  \if\relax\detokenize{#1}\relax\index{#2}\label{ind:#2}%
  \else\index{#2}\label{ind:#1}\fi%
}%End INDEX
    \newcommand{\DEX}[2][]{%
   \if\relax\detokenize{#1}\relax\hyperref[ind:#2]{#2}%
   % (\Cpageref{ind:#2})%
   \else\hyperref[ind:#1]{#2}%
   %(\Cpageref{ind:#1})%
   \fi%
}%End DEX
%============== End the Andrew code as edited Oct 27 at 17:24
%============== Begin To make Cpageref work. 
\newcommand{\PGX}[2][]{%
   \if\relax\detokenize{#1}%
   \relax%
%   \hyperref[ind:#2]{#2}%
    \Cpageref{ind:#2}%
   \else%
%   \hyperref[ind:#1]{#2}%
   \Cpageref{ind:#1}%
   \fi%
}%
%End To make Cpageref work.
%sssssssssssssssssssssssssssssssssss End Andrew code for ref to indexed words
%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ End References


%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ Begin new tcolorbox - COMMANDS must be after cleveref.

\newcounter{dft}%
\newtcolorbox%
[%beginForReferences
use counter= dft,
number within=chapter,
list inside= dft,%creates the list under tcblistof 
crefname={definition}{definitions},
Crefname={Definition}{Definitions},
]%endForReferences
{efinition}%
[2][]%
{%
detach title,
coltitle=black,
nameref={#2},%
before upper={\tcbtitle\quad},%
%code={\gdef\mytitleagree{\textbf{#2}}},%%Used to include mytitle in the ``number''
title=DEFINITION \thetcbcounter \, #2,%
nameref=#2,%
list entry={DEFINITION ~\thetcbcounter ~ #2},%
#1,%Required for references.
}%
%=======Begin To restate an already stated definition STURM after YASMAR
\newcounter{dftrepeat}

%\renewcommand{\theHdftrepeat}{dftrepeat.\thedftrepeat}
\newtcolorbox%
[%beginForReferences
use counter={dftrepeat},
list inside= dft,
crefname={definition restated}{definitions restated},
Crefname={Definition restated}{Definitions restated},
]
{efinitionRphr}%
[3][]%
{%
detach title,%This prevents the top from being the color of the frame
before upper={\tcbtitle\quad},%This prevents the top from being the color of the frame
enhanced,%
arc=0.2mm,%
colback= yellow,%
colframe= black,%
coltitle=black,%
title= DEFINITION (Restated) ~\ref{#2}~\nameref{#2},%
nameref={\getrefbykeydefault{#2}{name}{UNDEFINED REFERENCE}},%
list entry= DEFINITION (Restated) ~\ref{#2}~\nameref{#2},
label type={dftrepeat},
code={\renewcommand{\thedftrepeat}{\getrefnumber{#2}}},
#1%,
}%
%=======End To restate an already stated definition STURM after YASMAR
%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ End new tcolorbox



\begin{document}


\chapter{ONE}\label{1-0-0}
    \newpage
\section{Height}\label{1-1-0}
    \newpage
\subsection{extremes}\label{1-1-1}

A \textbf{minimum}\INDEX[]{minimum} is an input \textbf{$\boldsymbol{x_{\text{min}}}$}\INDEX[xmin]{$x_{\text{min}}$} whose output is smaller that the outputs of nearby inputs.

\begin{efinition}[label={dft:1-1}]{Maximum}
  An input \textbf{$\boldsymbol{x_{\text{max}}}$} whose output is larger than the outputs of nearby inputs
\end{efinition}

\newpage
\subsection{far-fetched}\label{1-1-2}

\begin{efinitionRphr}[label={dft:1-1a}]{dft:1-1}{~}
  The biggest of all
\end{efinitionRphr}
% 

\chapter{References}\label{2-0-0}

\textbf{To avoid confusion, \emph{nameref} was RenewCommanded as \emph{titleref}.}


\emph{nameCref+labelcref+titleref}:\hspace{8mm} \nameCref{dft:1-1} \labelcref{dft:1-1}  \titleref{dft:1-1}


\emph{nameCref+labelcref+titleref}:\hspace{8mm} \nameCref{dft:1-1a} \labelcref{dft:1-1a}  \titleref{dft:1-1a}




\tcblistof[\chapter]{dft}{List of Definitions}


\phantomsection%otherwise, clicking on index in toc gets to GNU

\printindex
\end{document}

不要忘记编译三次!!!!

在此处输入图片描述

相关内容