0

My issue concerns numbering within subsections using the hyperref package. I have found that referencing equations prints the right number but goes to the wrong location when clicked. I found that this could be fixed by adding the option

hypertexnames = false

when loading hyperref. But I am wondering why this issue should exist in the first place (and if adding "hypertexnames = false", which I do not understand, might create other issues)?

Example below, with references going to the wrong location when clicked. It should go to "Second Equation" but instead goes to "First equation".

This example can be fixed by loading \usepackage[hypertexnames = false]{hyperref} instead of \usepackage{hyperref}.

\documentclass{article}

\usepackage{amsmath}

\numberwithin{equation}{subsection}

\usepackage{hyperref}

\title{Equation numbering troubleshooting}
\author{Author}
\date{September 2022}

\begin{document}

\maketitle

\section{}
\subsection{}
    \begin{equation}
        First equation
    \end{equation}

\newpage    
\subsection{}
    \begin{equation}\label{equation}
        Second equation
    \end{equation}
Equation \eqref{equation}. Equation \ref{equation}.

\end{document}

1 Answer 1

2

The problem is that in your code \numberwithin is used before loading hyperref instead of after loading hyperref.

This is also the reason why with your code you get many warnings on the console and into the .log-file:

pdfTeX warning (ext4): destination with the same ident
ifier (name{equation.1.1}) has been already used, duplicate ignored
<to be read again> 
                   \relax 
l.25     \begin{equation}
                         \label{equation}pdfTeX warning (ext4): destination wit
h the same identifier (name{equation.1.1}) has been already used, duplicate ign
ored
<to be read again> 
                   \relax 
l.25     \begin{equation}
                         \label{equation}pdfTeX warning (ext4): destination wit
h the same identifier (name{equation.1.1}) has been already used, duplicate ign
ored
<to be read again> 
                   \relax 
l.25     \begin{equation}
                         \label{equation}pdfTeX warning (ext4): destination wit
h the same identifier (name{equation.1.1}) has been already used, duplicate ign
ored
<to be read again> 
                   \relax 
l.25     \begin{equation}
                         \label{equation} [2] (./test.aux) )
(see the transcript file for additional information)<

As a rule of thumb make sure \numberwithin (and anything else that affects infrastructure of LaTeX-counters) is carried out after loading the package hyperref—this way hyperref's \theH...-macros for delivering names of named destinations are adjusted, too:

\documentclass{article}
\usepackage{amsmath}
\usepackage{hyperref}

\numberwithin{equation}{subsection}

\title{Equation numbering troubleshooting}
\author{Author}
\date{September 2022}

\begin{document}

\maketitle

\section{}
\subsection{}
    \begin{equation}
        First equation
    \end{equation}

\newpage    
\subsection{}
    \begin{equation}\label{equation}
        Second equation
    \end{equation}
Equation \eqref{equation}. Equation \ref{equation}.

\end{document}
1
  • Fantastic, thank you! At some point I had learned to load hyperref as late as possible, and didn't realize that this would be the issue.
    – 351910953
    Commented Sep 13, 2022 at 0:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .