# Destination with the same identifier name {xtheorem.1}

I have the warning

destination with the same identifier (name{xtheorem.1}) has been already used, duplicate ignored \relax l.31 \begin{definition}[DefinitionInChapterTwo]

Although there are many questions about "destination with the same identifier", I could not find one according to the identifier xtheorem.

The problem only occurs when I use \begin{definition} in more than one chapter so I think within one chapter, the identifiers are unique but not in the whole document...

Here is my MWE:

\documentclass[twoside, openright, 12pt]{book}

\usepackage[plainpages=false,pdfpagelabels]{hyperref}

\usepackage[titles]{tocloft}
\newlistof[chapter]{theorems}{lthm}{\theoremsname}

\refstepcounter{theorems}
}

\newenvironment{definition}[1][]{%
\begin{xdefinition}[#1]%
}{\end{xdefinition}}

\begin{document}

\chapter{Title1}
\section{Section 1-1}

\begin{definition}[DefinitionInChapterOne]
\end{definition}

\chapter{Title2}
\section{Section 2-1}

\begin{definition}[DefinitionInChapterTwo]
\end{definition}

\end{document}


Could you please tell me where I have to make changes to get this issue working?

Update: I figured out that it has something to do with line \newshadetheorem{xtheorem}{Satz}[chapter] This gives me (chapter number).(counter per chapter). But in my mind, this is unique!?! Isn't it? If I change chapter to section, I got a theorem number like 1.1.1 what obviously means (chapter number).(section number).(counter per section)

Instead of shadethm I'd give a look at tcolorbox. Anyway, you just need to define \theHxtheorem, which hyperref will use for setting anchors.

Load hyperref last.

\documentclass[twoside, openright, 12pt]{book}

\usepackage[titles]{tocloft}

\usepackage[plainpages=false,pdfpagelabels]{hyperref}

\newlistof[chapter]{theorems}{lthm}{\theoremsname}

\newcommand\addtotheorems[2]{% <-- don't forget
\refstepcounter{theorems}% <-- don't forget
\addcontentsline{lthm}{theorems}{\protect\numberline{\thetheorems}\textbf{#1:} #2}% <-- don't forget
}

% keep hyperref happy
\newcommand{\theHxtheorem}{\thechapter.\arabic{xtheorem}}

\newenvironment{definition}[1][]
{\end{xdefinition}}

\begin{document}

\chapter{Title1}
\section{Section 1-1}

\begin{definition}[DefinitionInChapterOne]
\end{definition}

\chapter{Title2}
\section{Section 2-1}

\begin{definition}[DefinitionInChapterTwo]
\end{definition}

\end{document}

• First of all, thank you very much! I really appreciate your help. :-) But I do not understand the actual problem. I've read about, that if \xtheorem is a counter, \thextheorem gives me its current value. But what is \theHxtheorem ? And furthermore: Do I have to check my already existing references because of any possible side effects? – lukasl1991 Apr 5 '17 at 10:56
• @lukasl1991 I didn't look at what \newshadedtheorem does. Apparently it doesn't behave with hyperref even if loaded before it. Anyway, if foo is a counter and the command \theHfoo is defined, hyperref will use it for the sole purpose of setting the internal anchor. – egreg Apr 5 '17 at 11:46
• What are these "% <-- don't forget" for? – lukasl1991 Apr 5 '17 at 12:00
• @lukasl1991 Avoid spurious spaces in the output. – egreg Apr 5 '17 at 12:10