# Understanding Warning 'Destination with the same identifier has been already used' caused by Theorems

In the following mwe I get two warnings: LaTeX Warning: Citation 'foo' on page 2 undefined on input line 29. and pdfTeX warning (ext4): destination with the same identifier (name{definition.1}) has been already used, duplicate ignored.

While the first is obvious I don't see where the second would come from. The second warning disappears if, e.g. the \newpage is removed or the wrong citation is removed or corrected or cleveref is removed. It also disappears if I use \newtheorem instead of thmtools and \declaretheorem.

Can somebody explain me why that warning occurs? I started out with a big document which contained all these things, hence my desire to know.

I researched similar questions like this, this, this and this but it seems to be something different. Also I respect the order of loading packages.

## The MWE

\documentclass{scrbook}

\usepackage{amsmath}
\usepackage{amsthm}

\usepackage{thmtools}
\declaretheorem[style=plain,parent=section]{theorem}
\declaretheorem[style=definition,qed=$\triangle$,sibling=theorem]{definition}

% \newtheorem{theorem}{Theorem}[section]
% \newtheorem{definition}[theorem]{Definition}

\usepackage{hyperref}

\usepackage{cleveref}

\begin{document}

\chapter{chap}

\section{Sec1}

\begin{definition}
Text
\end{definition}

\newpage

\section{Sec2}

The reference \cite{foo} is undefined.
\begin{definition}
Text
\end{definition}
\end{document}

• The two \declaretheorem directives should occur after hyperref and cleveref are loaded. Make this change irrespective of any \newpage directives in the body of the document. – Mico Jan 29 at 1:28
• Arg.. thanks! :-) Could you post this as answer, then I can accept. – Heinrich Ody Jan 29 at 10:01
• @Mico Do you know if it is documented that theorems should be declared after loading all packages? Asking cause I could not find anything – Heinrich Ody Jan 29 at 10:30

The immediate cause of the problem is the fact that the two \declaretheorem directives are currently placed before rather than after the hyperref and cleveref packages are loaded.
Do change the placement of the two directives, irrespective of any \newpage directives that may be present in the body of the document.
To answer your follow-up question: The user guide of the cleveref package does mention that while all theorem-related packages -- such as amsthm and thmtools -- should be loaded before cleveref, statements of the \newtheorem and \declaretheorem variety should occur only after cleveref is loaded. (For more detail, see the final sentence in the second bullet point in section 14.1 on page 25 of the package's user guide.)