Here's a simple way to do this. You store each big endnote in a separate file named <label>.tex
where <label>
is how you will refer to it in the command that will insert it and in any \ref
in the text. Then you create a command (I've called it \extendnote
) which takes the label as an argument and then simply uses \input
for the endnote text.
You can keep all of the external endnotes in the source file by adding them at the beginning using the {filecontents}
environment. Of course if that becomes unmanageable, you can put all the {filecontents}
environments in a separate file (e.g. bignotes.tex
) and then \input
that into your main source file.
\documentclass{article}
\usepackage{endnotes}
\usepackage{lipsum}
\begin{filecontents}[noheader,overwrite]{big.tex}
\lipsum[1-2]
\end{filecontents}
\begin{filecontents}[noheader,overwrite]{large.tex}
\lipsum[3-4]
\end{filecontents}
\newcommand{\extendnote}[1]{\endnote{\input{#1}\label{#1}}}
\begin{document}
Here is some text.\endnote{This is a small endnote\label{small}}
Here is some more text, with a big endnote.\extendnote{big} Here is some
more text.\endnote{A small endnote} and some more text.\extendnote{large}.
And here are some references to note \ref{large} and note \ref{small}.
\theendnotes
\end{document}