The problem
Hi. I'm currently writing my thesis and have my equations numbered within sections. I also use subequations from amsmath. When I use amsmath, hyperref and cleveref together, however, I get 2 warnings about destinations with the same identifier. The result is that \cref{eq:2a} gets the correct number in the pdf but the hyperlink points to eq:1a.
A MWE
\documentclass{book} \usepackage{amsmath} \usepackage{hyperref} \usepackage{cleveref} \numberwithin{equation}{section} \begin{document} This is a test. \section{Section 1} \begin{subequations}\label{eq:1} \begin{align} x=y\label{eq:1a} \end{align} \end{subequations} \section{An error} \begin{subequations}\label{eq:2} \begin{align} 1=2\label{eq:2a} \end{align} \end{subequations} \end{document} The aux
Sure enough,
\newlabel{eq:1}{{0.1.1}{1}{Section 1\relax }{equation.0.0.1.1}{}} \newlabel{eq:1@cref}{{[equation][1][0,1]0.1.1}{1}} \newlabel{eq:1a}{{0.1.1a}{1}{Section 1\relax }{equation.0.0.1a}{}} \newlabel{eq:1a@cref}{{[equation][1][0,1]0.1.1a}{1}} \@writefile{toc}{\contentsline {section}{\numberline {0.2}An error}{1}{section.0.2}} \newlabel{eq:2}{{0.2.1}{1}{An error\relax }{equation.0.0.1.1}{}} \newlabel{eq:2@cref}{{[equation][1][0,2]0.2.1}{1}} \newlabel{eq:2a}{{0.2.1a}{1}{An error\relax }{equation.0.0.1a}{}} \newlabel{eq:2a@cref}{{[equation][1][0,1]0.2.1a}{1}} Warnings
pdfTeX warning (ext4): destination with the same identifier (name{equation.0.0.1a}) has been already used, duplicate ignored pdfTeX warning (ext4): destination with the same identifier (name{equation.0.0.1.1}) has been already used, duplicate ignored What to do?
All packages have been updated too. So I've tried a few things that can get this to work without any warnings but none is an ideal solution from my point of view.
- Remove all
subequations - Remove line
\numberwithin{equation}{section} - Remove package
cleveref - Remove package
hyperref
This in no doubt related to Hyperref jumps to the wrong equation if the equation has a \tag and cleveref is used and also Cross-references linking to wrong equations using `hyperref` but I can't manage to use those Q&As to help me here.
I'd really appreciate it if anybody could shed some light on this issue or suggest a workaround.
Thanks in advance!
\ref,\autoref, and\crefare correct. Thus, the warning messages may be of no importance. I suspect they have something to do with what thesubequationsenvironment has to set up in order to get its job done; note that the label(s) set up by thesubequationsenvironment don't seem to be used directly by eitherhyperreforcleveref.\crefcommand works, correctly referencing the equations. However, I have noticed that the hyperlinks in the pdf point to the wrong equation. In this example, a link generated by\cref{eq:2a}points toeq:1aeven though it is correctly labelled in the pdf. It seems as though the labels are used byhyperrefbut notcleveref. I'm quite keen to know if anybody has any ideas on getting the hyperlinks working correctly.hyperrefpackage.