# Nested endnotes

How can one include an endnote within another endnote? The desired output would be one endnote structure with all endnotes appearing in the order in which they are invoked (i.e., a nested [child] endnote would have a number preceding that of a non-nested endnote occurring subsequent to the parent endnote). The following syntax is not valid but may give an idea of the desired output. I imagine the solution may be similar to the use of the \footnotemark and \footnotetext commands for achieving nested footnotes.

\documentclass{article}
\usepackage{endnotes}
\begin{document}
Attempt to nest endnotes%
\endnote{First note\endnote{Second note.}\endnote{Third note.}.}.%
\theendnotes
\end{document}


The content of this question is similar to Converting footnotemarks to endnotes, the difference being that it seeks to directly nest endnotes rather than achieve the same effect via conversion from a document containing nested footnotes.

Ideally, a solution would be compatible with nesting of an arbitrary number of notes and to arbitrary depth of endnote "generation."

-
Have you considered to change the inner \endnote level to \footnote? (Yes, that works.) –  lockstep May 3 '12 at 20:13
Thanks @lockstep. What you propose is a good idea, and one I will use if there turns out to be no simple means of nesting endnotes. The only problem is that I would like all the notes to appear in a single structure, rather than be spread across two structures. –  user001 May 3 '12 at 20:21

Use \footnote instead of \endnote for the inner note level. To avoid mixing up end- and footnotes, consider also to use symbols for footnotes (and make the footnote "numbering" per-page).

\documentclass{article}
\usepackage{endnotes}
\usepackage{perpage}
\MakePerPage{footnote}
\renewcommand*{\thefootnote}{\fnsymbol{footnote}}
\begin{document}
\null\vfill% just for the example
Attempt to nest endnotes%
\endnote{First note\footnote{Second note.}\footnote{Third note.}.}.%
\theendnotes
\end{document}


UPDATE: As egreg has pointed out, the recently released enotez package supports nested endnotes:

\documentclass{article}
\usepackage{enotez}
\begin{document}
\null\vfill% just for the example
Attempt to nest endnotes%
\endnote{First note\endnote{Second note.}\endnote{Third note.}.}.%
\printendnotes
\end{document}


-
Just today (2012-07-08) the new package enotez has been announced; it should allow nested endnotes. –  egreg Jul 8 '12 at 9:29