Różne równania z tym samym znacznikiem powodują błędne odniesienie

Nov 22 2020

Chciałbym osiągnąć coś bardzo podobnego do tego pytania , z tym że chciałbym również odwołać się do wspomnianych równań. Oto minimalny przykład:

\documentclass[12pt]{article}
\usepackage[hidelinks]{hyperref}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathtools}

\begin{document}
\section*{Chapter A}
\begin{equation}\label{star1}\tag{$\star$}
    a^2 + b^2 = c^2
\end{equation}
The main equation of this chapter is the Pythagorean theorem, \eqref{star1}.

\pagebreak

\section*{Chapter B}
\begin{equation}\label{star2}\tag{$\star$}
    i^2 = -1
\end{equation}
The main equation of this chapter is the definition of the imaginary unit, \eqref{star2}.
\end{document}

Problem w tym, że \eqref{star2}wskazuje na pitagorejczyka. Otrzymuję również to ostrzeżenie, które, jestem prawie pewien, jest istotne:destination with the same identifier (name{equation.0.1}) has been already used, duplicate ignored <to be read again>

Z góry dziękuję.

Odpowiedzi

3 egreg Nov 22 2020 at 22:43

Pakiet hyperrefpowinien być ładowany jako ostatni: wystarczy załadować tylko kilka pakietów po nim i żaden z nich w MWE.

Jednak to nie rozwiązuje problemu. Problemem jest sytuacja wyścigu: z equationpowiązanym licznikiem jest stopniowany, a następnie resetowany do poprzedniej wartości, jeśli \tagzostał zeskanowany wcześniej \end{equation}, ale jest za późno i hyperrefjuż dostarczył kotwicę.

Ten sam tag nie stanowi problemu, chociaż byłbym ostrożny, ponieważ prawdopodobnie wprowadza czytelnika w błąd.

Użycie equation*rozwiązuje problem.

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage[hidelinks]{hyperref}

\begin{document}

\section*{Chapter A}
\begin{equation*}\label{star1}\tag{$\star$}
    a^2 + b^2 = c^2
\end{equation*}
The main equation of this chapter is the Pythagorean theorem, \eqref{star1}.

\pagebreak

\section*{Chapter B}
\begin{equation*}\label{star2}\tag{$\star$}
    i^2 = -1
\end{equation*}
The main equation of this chapter is the definition of the imaginary unit, \eqref{star2}.
\end{document}