11

In the following MWE, I receive a warning and a reference points to the wrong element.

\documentclass{article}
\usepackage{hyperref}
\usepackage{amsmath}
\begin{document}
    \begin{equation}
        \label{eq1}
    \end{equation}

    \begin{equation}\tag{\ref*{eq1}b}
        \label{eq1b}
    \end{equation}

    \begin{equation}
        \label{eq2}
    \end{equation}

This reference is incorrect: \ref{eq2} points to 1b. Also, this warnings appear:
\begin{verbatim}
        pdfTeX warning (ext4): destination with the same identifier
        (name{equation.0.2}) has been already used, duplicate ignored
    \end{verbatim}
\end{document}

In this variant with equation*, the latter problem is fixed, but a new one introduced. A link that was fine before is now wrong:

\documentclass{article}
\usepackage{hyperref}
\usepackage{amsmath}
\begin{document}
    \begin{equation}
        \label{eq1}
    \end{equation}

    \begin{equation*}\tag{\ref*{eq1}b}
        \label{eq1b}
    \end{equation*}

    \begin{equation}
        \label{eq2}
    \end{equation}

    This reference is incorrect: \ref{eq1b} points to 1. No warning.
\end{document}

How can I get all references correct?

These questions are similar, but don't help:

Incorrect Reference Link

Hyperlinking problems when using subequations, hyperref and cleveref

Hyperref jumps to the wrong equation if the equation has a \tag and cleveref is used

0
11

As stated in the answer to Hyperref jumps to the wrong equation if the equation has a \tag and cleveref is used by CyberSingularity, the starred environment should be used. If you do it and load hyperref after amsmath all links are correct:

\documentclass{article}

\usepackage{amsmath}
\usepackage{hyperref}

\begin{document}
Some text
\begin{equation}
0=0 \label{eq1}
\end{equation}
other text
\begin{equation*}\tag{\ref*{eq1}b}
1=1 \label{eq1b}
\end{equation*}
other text
\begin{equation}
2=2 \label{eq2}
\end{equation}

These references are correct: \ref{eq1}, \ref{eq1b} and \ref{eq2}.
\end{document}

Note that this holds only for equation (it might be a feature request to Heiko Oberdiek making \tag work properly in equation). For align and the other multiline environments there's no problem:

\documentclass{article}

\usepackage{amsmath}
\usepackage{hyperref}

\begin{document}

\begin{align}
0&=0 \label{eq1} \\
1&=1 \tag{\ref*{eq1}b} \label{eq1b} \\
2&=2 \label{eq2}
\end{align}

These references are correct: \ref{eq1}, \ref{eq1b} and \ref{eq2}.

\end{document}
1
  • 1
    Thanks! I had tried the starred variant as you see from my original question, but "...and load hyperref after amsmath" is key here. – bers Nov 4 '14 at 16:44

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.