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

Create issue
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.

Comments (5)

  1. Clemens Niederberger repo owner

    Besides the fact that you should probably do

    \begin{figure}
      \addtocounter{endnote}{-1}
      \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}
      \addtocounter{endnote}{-1}
      \caption{Hi! \endnotemark}
      \endnotetext{Second endnote}
    \end{figure}
    
    Text\endnote{Third endnote}
    
    \printendnotes*
    
    \end{document}
    

  2. bers 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,

  3. Clemens Niederberger 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…

  4. Log in to comment