# enotez loses an endnote placed in a figure caption when using endfloats

Issue #20 invalid
bers created an issue

My MWE is this:

\documentclass{article}
\usepackage{endfloat}
\usepackage{enotez}
\begin{document}
\endnote{First endnote}
\begin{figure}
\caption{Hi! \endnote{Second endnote}}
\end{figure}
\endnote{Third endnote}
\printendnotes
\end{document}


As you can see in the list of notes, the second endnote is missing, without any warning or error message.

1. repo owner

Besides the fact that you should probably do

\begin{figure}
\caption{Hi! \endnotemark}
\endnotetext{Second endnote}
\end{figure}


the problem is that the note in the caption is placed after the list. This problem is explicitly stated in enotez' manual in the description of the \printendnotes command:

If used without argument it prints all notes set so far with \endnote. The current list will then
be cleared. All endnotes set after it are stored again for the next usage of \printendnotes. The
starred version will print all endnotes but shouldn’t be used more than once if you have nested
endnotes.

Thus the solution is:

\documentclass{article}
\usepackage{endfloat}
\usepackage{enotez}

\begin{document}

Text\endnote{First endnote}

\begin{figure}
\caption{Hi! \endnotemark}
\endnotetext{Second endnote}
\end{figure}

Text\endnote{Third endnote}

\printendnotes*

\end{document}


2. repo owner

Not a bug

3. reporter

Thanks (so far)! Is \printendnotes*` supposed to make the second endnote appear in the list of endnotes? Because it is not doing that in your solution,

4. repo owner

Yes, it does – with the most up to date version. Your distribution most likely still has v0.9a. You should have v0.10 in a few days…

5. reporter

It does, yes - thanks. So my “invalid” bug did have some merit after all?