I am writing a book in which theorems are numbered "Theorem 1", "Theorem 2", etc. in every chapter; the resetting of the Theorem counter is done using an explicit \setcounter
command. When I intend to point at Theorem 1 of any chapter using hyperref
, the link created points to Theorem 1 of Chapter 1 instead (see MWE below).
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{theorem}[First]\label{thm1}
The first.
\end{theorem}
\newpage
\setcounter{theorem}{0}
\begin{theorem}[Second]\label{thm2}
The second.
\end{theorem}
Reference to the second occurrence of Theorem 1 : \ref{thm2}.
\end{document}
I know I could certainly fix this issue by numbering theorems including a chapter number (like "Theorem 1.1"), but I like the simpler numbering better. Is there a way to convince hyperref
to distinguish between the two theorems above (and therefore to point properly to the second one) even if the numbering displayed is the same?
Thank you in advance!
Piotr
\theHtheorem
is unique for every theorem, e.g.\renewcommand\theHtheorem{\thechapter.\thetheorem}