After spending several hours tracking down an issue with wrong hyperlinks in my thesis, I managed to cook up the following MWE:

%!TEX program = pdflatex
\usepackage{thmtools} % <-- comment this out to fix the issue!

\DeclareTColorBox[auto counter,number within=section,crefname={example}{examples}]{example}{ g O{} }{%
    IfValueTF={#1}{title={example~\thetcbcounter\ (#1)}}{title=example~\thetcbcounter},#2


\chapter{First chapter}
\begin{example}[label=ex:test]{My title}

\chapter{Second Chapter}
\begin{example}[label=ex:test2]{My title}

This was \cref{ex:test2}.
The number is right, but the hyperlink leads to \cref{ex:test}.


If thmtools is loaded the hyperlink to the second example is wrong, otherwise everything works as expected. This behavior seems unwanted to me, i.e. the declarations using tcolorbox should not interfere with thmtools. Additionally the fact, that the reference is right but the hyperlink wrong is very odd.

As I am not really dependent on thmtools I have no hard time disabling it, but I am interested in the reason for this behavior and wanted to report this as a possible bug.


You should simply try to load hyperref as late as possible (rule of thumb), so the order


will not show your problem.

A possible cause could be that thmtools.sty loads thm-autoref.sty which does some hyperlink modifications cleveref or hyperref may conflict with.

  • Yes, thmtools modifies the labels – user31729 Dec 30 '17 at 21: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.