Trying to retroactively get hyperref working for my thesis.
Fun.
Encountered the following weirdness... I have the following (hard earned) minimal-ish working example:
\documentclass{article}
\usepackage{blindtext}
% LINE 0 BELOW
% \usepackage{mypackage}
\usepackage{hyperref}
% LINE 1 BELOW
\newtheorem{definition}{Definition}[section]
\begin{document}
\section{Section One}
See Definition~\ref{def:one}.
\begin{definition}\label{def:one}
\blindtext
\end{definition}
\Blindtext
\section{Section Two}
When using external \texttt{mypackage}, Definition~\ref{def:two} \texttt{hyperref}'s to Definition~\ref{def:one}---otherwise it's fine.
\begin{definition}\label{def:two}
\blindtext
\end{definition}
\end{document}
Which works fine after a couple of builds. However, if I put the newtheorem command (LINE 1) into a new custom mypackage.sty as follows:
\ProvidesPackage{mypackage}
\newtheorem{definition}{Definition}[section]
...stick it in the same directory as the main file, and toggle the comments on LINE 0 & 1 in the main file, after a couple of builds I get a warning:
pdfTex warning (ext4): destination with the same identifier (name{definition.1}) has already been used, duplicate ignored
Also, in the resulting PDF, the label for the second Definition links to the first one.
Now, I have my fix (move the newtheorem declaration into my main .tex file)...
...but I've been held hostage by hyperref for so long this time, I've developed Stockholm syndrome. (Looking back at my history with this package, it was only a matter of time.)
Can someone give me some closure and explain why hyperref cares where I put my newthereom declaration?
Otherwise, can someone point me in the direction of a hyperref victim support group?
\AtBeginDocumentto move the\newtheorembehind hyperref in your package. – Ulrike Fischer Mar 10 '11 at 08:51