When using enotez, one can assign labels to an endnote and refer to them. However, I have found that hyperref links to unexpected targets.



% This code by Andrew Swann (https://tex.stackexchange.com/questions/395662)
% makes \cref recognize counter `endnote`
\cs_set_protected:Npn \enotez_endnote_mark:n #1
    \int_gincr:N \g__enotez_endnote_id_int
    \quark_if_no_value:nTF {#1}
        \refstepcounter {endnote}
          { \int_use:N \g__enotez_endnote_id_int }
          { \theendnote }
        \cs_gset:cpn {@currentlabel} {#1}
        \enotez_write_mark:xn { \int_use:N \g__enotez_endnote_id_int } {#1}
    \bool_if:NT \l__enotez_disable_bool
        \int_gdecr:N \g__enotez_endnote_id_int
        \addtocounter {endnote} {-1}


This is an endnote with a labeldefinition inside the note.\endnote{Label in endnote\label{labelin}}
This endnote refers to the one with the labeldefinition inside.\endnote{See \cref{labelin}}

This is an endnote with a label defined after the note.\endnote{Label after endnote}\label{labelafter}
This endnote refers to the one with a following labeldefinition.\endnote{See \cref{labelafter}}


Wrong references in notes 2 and 4

As you can see in the picture, the link from endnote 2 to endnote 1 is obviously wrong. It seems that if the label is placed inside of \endnote{}, it will always point to the last endnote.

The link in endnote 4 seems to be correct on first sight. However, I expected the link would point directly to endnote 3 (on the second page, under "Notes"). Unfortunately, it points back to page 1, where the endnote has been set.

Is there any way I could link to the actual text of an endnote instead of the endnote definition?

  • A look into the relevant .aux file after the compilation shows that the labels defined at the end appear first in the .aux file, so this is main culprit – user31729 Oct 12 '17 at 20:00
  • @ChristianHupfer So there is nothing I could do about it (except filing a bug against enotez) -- right? – Andreas Oct 13 '17 at 12:03
  • In a nutshell: Yes ;-) It depends whether it is a feature or a bug – user31729 Oct 13 '17 at 22:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.