A colleague has just pointed out to me that all of my hyperlinks to theorems and sections within the epilogue of this book:
www.math.jhu.edu/~eriehl/context.pdf
point to the corresponding sections in the penultimate Chapter 6, despite the fact that the internal labels are unambiguous. Presumably the issue is in the way I reset the counter for the Epilogue. Here is a minimal working example:
\documentclass[pdflatex]{amsbook}
\usepackage[pdfborder=0, hidelinks]{hyperref}
\theoremstyle{theorem}
%theorems & stuff
\newtheorem{thm}{Theorem}[section]
\begin{document}
\setcounter{tocdepth}{1}
\tableofcontents
\chapter{Chapter 1}\label{ch:one}
\section{Chapter section}\label{sec:in-chapter}
\begin{thm}\label{thm:in-chapter} Chapter theorem.
\end{thm}
Compare Theorem \ref{thm:in-chapter} found in \S\ref{sec:in-chapter} in Chapter \ref{ch:one} with Theorem \ref{thm:in-epilogue} found in \S\ref{sec:in-epilogue} in Chapter \ref{ch:epilogue}.
\chapter*{Epilogue}\label{ch:epilogue}
\setcounter{thm}{0}
\setcounter{section}{0}
\renewcommand{\thesection}{E.\arabic{section}}
\section{Epilogue section}\label{sec:in-epilogue}
\begin{thm}\label{thm:in-epilogue} Epilogue theorem.
\end{thm}
Compare Theorem \ref{thm:in-chapter} found in \S\ref{sec:in-chapter} in Chapter \ref{ch:one} with Theorem \ref{thm:in-epilogue} found in \S\ref{sec:in-epilogue} in Chapter \ref{ch:epilogue}.
\end{document}
When you compile as a PDF, the references to the Chapter and the Epilogue Chapter are correct, but the references to the theorems and sections all point within Chapter 1.
Any idea how I might fix this? Since the PDF corresponds to a published book, I'd prefer to fix the hyperlinks without changing the appearance of the labels in a printed copy.
UPDATE: As Teepeemm points out below, my current code produces an aux file that looks like this (excerpted):
\newlabel{sec:in-chapter}{{1}{3}{Chapter section}{section.1.1}{}}
\newlabel{thm:in-chapter}{{1.1}{3}{}{thm.1.1.1}{}}
\newlabel{sec:in-epilogue}{{E.1}{5}{Epilogue section}{section.1.1}{}}
\newlabel{thm:in-epilogue}{{E.1.1}{5}{}{thm.1.1.1}{}}
With Teepeemm's suggestion to add "\let\theHsection=\thesection" the last two lines of the aux file update to:
\newlabel{sec:in-epilogue}{{E.1}{5}{Epilogue section}{section.1}{}}
\newlabel{thm:in-epilogue}{{E.1.1}{5}{}{thm.1.1}{}}
This fixes the links in the minimum working example but doesn't fix the hyperlinks in the actual book.
It gives a unique identifier to the hyperlink to the epilogue chapter but the epilogue sections and theorems are still assigned duplicates of numbers from chapter 6:
\@writefile{toc}{\contentsline {chapter}{\tocchapter {Chapter}{}{Epilogue: Theorems in Category Theory}}{217}{chapter*.43}}
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\@writefile{toc}{\contentsline {section}{\tocsection {}{E.1}{Theorems in basic category theory}}{217}{section.6.1}}
\newlabel{sec:basic-theorems}{{E.1}{217}{Theorems in basic category theory}{section.6.1}{}}
\citation{maclane-natural-associativity}
\citation{maclane-natural-associativity}
\@writefile{toc}{\contentsline {section}{\tocsection {}{E.2}{Coherence for symmetric monoidal categories}}{219}{section.6.2}}
\newlabel{sec:monoidal}{{E.2}{219}{Coherence for symmetric monoidal categories}{section.6.2}{}}
\newlabel{eq:symmonisos}{{E.2.1}{219}{Coherence for symmetric monoidal categories}{equation.6.2.1}{}}
Could you suggest the more complicated solution you were alluding to? It seems I might need it here.
\letfails. Does changing the\letto\renewcommand{\theHsection}{epilog.\thesection}fix things? – Teepeemm Oct 26 '18 at 21:53