[Tex/LaTex] endnotes with hyperref (resetting the counter) problem

endnoteshyperref

Following with the discussion in Making endnotes clickable links with hyperref, I've the following issue.

If I try to use this method to enable hyperlinks with endnote, everything works fine. But, if in my document I reset the endnote counter to zero at some point(s) (as I'd do if I had several chapters, for instance), when clicking the endnotes inserted after resetting the counter, they get referenced to the endnote list corresponding to the first bunch of endnotes.

A MWE would be:

\documentclass[pdftex]{article}
\usepackage{endnotes}
\usepackage{hyperref}
\usepackage{hyperendnote}
\begin{document}
\noindent

FIRST ENDNOTE\endnote{blabla one}

\newpage A page between two notes. \newpage

\addtoendnotes{\newpage}% so both notes will be on separate pages for testing

\theendnotes

\setcounter{endnote}{0}

Another page with another endnote\endnote{blabla two}

\newpage blabla \newpage

\theendnotes

\end{document}

A related discussion can be found on comp.text.tex, but it seems that it was resolved for the memoir class, and using pagenotes (as supplied by the memoir class), not endnotes.

Best Answer

Making the comment of daleif to an answer

@daleif: I've ended up reimplementing it differently in memoir, i.e. is no longer using the solution from pagenote, but rather one inspired by endnotes. This version then use a unique counter and labels to provide back references. Hmm, seem to have forgotten about forward references (via hyperref), will fix that in the next release (which is not the one I just released an hour ago)

Related Question