1

Christian Hupfer in How to label a restated theorem? and Cragfelt in How to get a restated tcolorbox to appear in the list of tcolorboxes both used label={dft:1-1a} for the restated tcolorbox but here it refers to 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}

enter image description here

  • 2
    What is the question? You don't ever say. What output do you want from what exactly? – cfr Dec 21 '17 at 3:59
  • Sigh, again my name was spelled wrongly... and the whole document apparently building around a core of old code that the O.P. is running for years apparently but refuses to update the packages. Why is that awful index hack appearing here? Why not loading the much betterimakeidx package instead of makeidx? – user31729 Dec 21 '17 at 5:36
  • The usage of dft:1-1a was introduced by the O.P. not by me, by the way – user31729 Dec 21 '17 at 5:43
  • the nameref={#2} in the repeated box will give the restated definition the name reference of the label -- I doubt that you want to have this effect? – user31729 Dec 21 '17 at 6:25
2

In the linked answer by me I used a counted box for the repeated theorem -- this has been removed by the O.P. and therefore the counter and link information gets lost. label={foo} will just the last \@currentlabel, which has been set here by \subsection and not by the box.

I've re - injected the counting, saying label type=dftrepeat and crefname={definition repeated}{definitions repeated} etc.

In addition, to get the correct restated number, \thedftrepeat is redefined to extract the reference to the original box.

Is this an awful hack? Yes, it is, because the whole setup is piling up hacks already, turning one screw here results in the need of turning 1000 screws at other places in the code :-(

3 compilations are necessary to get the references working.

\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}

enter image description here

Update for \titleref

In order to get the name of the first instance of a box, use nameref=\getrefbykeydefault{#2}{name}{UNDEFINED REFERENCE} where UNDEFINED REFERENCE would be printed if the reference #2 is not available (the text can be replaced by basically anything else)

\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}

Don't forget to compile thrice!!!!

enter image description here

  • 1.Sorry for the Umlaut. (Je croyais bien faire.) 2. Re "piling up hacks", you are quite right of course but, I am too old to invest in really learning LaTeX and would rather spend my remaining time on writing. 3. Re. the reference. The part: Definition restated 1.1 is just right but, rather than the boxed dft:1-1, I would rather have Maximum as in the previous reference. 4. This seems to be the last thing I need with references so, henceforth, I should be able to leave you in peace. – schremmer Dec 21 '17 at 16:19
  • @schremmer: The boxed version was just a test. Now, you should see 'Maximum' with the updated version at the end of my post! – user31729 Dec 21 '17 at 20:22
  • 1. Fröhliche Weihnachten 2. Everything works. I am amazed. 3. Re. "Don't forget to compile thrice!!!!" I always do which is why I am using Latexmark---which, as I recall, you don't like. 4. Thanks again: now I can really get back to writing/editing. – schremmer Dec 25 '17 at 19:23
  • @schremmer: Merry Christmas for you too and Happy TeXing! – user31729 Dec 25 '17 at 22:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.