2

I'm trying to format endnotes with the following features:

  • Endnote text is defined separately from the main body of the text. I will likely pull this into a separate .tex file.
  • Separate endnotes for each chapter.
  • Endnotes can be referenced more than once within a chapter.
  • Hyperlinks work, at least from the reference to the note.

I was originally working with the sepfootnotes package, but I couldn't get the hyperlinks to work with \xnotecontent, \xnote, \thexnotes.

In an effort to get hyperlinks working, I switched to enotez and I've managed to create a MWE, but I'm not thrilled with the approach of defining a new macro for every endnote. Ideally, I'd like to have a command for defining new endnotes specifically, like sepfootnote's \xnotecontent{}{}.

Is there a better way to achieve this feature set that I'm overlooking? Thanks in advance.

MWE:

\documentclass{report}
\usepackage[reset]{enotez}
\usepackage{hyperref}
\hypersetup{colorlinks=true, linkcolor=blue}

\begin{document}
\chapter{The first chapter}

\newcommand{\myendnotea}{First endnote.}

I'm about to reference an endnote\endnote{\myendnotea\label{firstendnote}}.

Now I'm going to reference the same endnote again\textsuperscript{\ref{firstendnote}}.

\clearpage
\printendnotes

\clearpage
\chapter{The second chapter}
\newcommand{\myendnoteb}{Second endnote.}

In this chapter I'm going to reference a different endnote\endnote{\myendnoteb}.

\clearpage
\printendnotes
\end{document}
0

You are making this way to complex and also misusing the reset as an option. Try this:

\documentclass{report}
\usepackage{enotez}
\usepackage{hyperref}
\hypersetup{colorlinks=true, linkcolor=blue}

\setenotez{%
reset = true,
}

\makeatletter
\def\endnotemark{\@ifnextchar[{\@endnotemark}{\@endnotemark[\theendnote]}}
\def\@endnotemark[#1]{\enotezwritemark{\enmarkstyle#1}}
\makeatother

\newcommand{\enm}[1]{\endnotemark[\ref{#1}]}

\begin{document}
\chapter{The first chapter}

I'm about to reference an endnote\endnote{First endnote}\label{firstendnote}.

Now I'm going to reference the same endnote again\enm{firstendnote}

\clearpage
\printendnotes

\clearpage
\chapter{The second chapter}

I'm about to reference an endnote\endnote{Second endnote}\label{secondendnote}.

\clearpage
\printendnotes
\end{document}

If you really want to define the endnotes separately from the text then you are going to need macro definitions or something similar like key value pairs outside the text (which seems to be your objection) - it's hard to see any way around that. If you really want to have entirely separately defined endnotes away from the text (probably a bad idea) without any macro definitions at all your could do the endnotes using a bibtex field and define them all in a bib file.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.