1

Page 2 of the enotez package documentation says that

\endnote works fine inside tables, minipages, floats and captions.

However, labelled endnotes seem to cause a problem. Attempts to reference the figure end up with a reference to the note in the caption. Is there any workaround for this? As a bonus problem, is there a way to avert disaster if a labelled endnote appears in an equation (commented out in the MWE)?

\documentclass{article}
\usepackage{amsmath}
\usepackage{enotez}
\begin{document}
\section{This is a section}
\label{sec}
The quick brown fox jumps over the lazy 
dog.\endnote[a]{Actually, the dog is dead.}\label{nt1}

The section: \ref{sec}
The note: \ref{nt1}

\begin{figure}
\rule{4cm}{4cm}
\caption{Here is some modern art{\endnote[b]{How much would you like to 
 pay for it?}\label{nt2}}}
\label{fig:modern_art}
\end{figure}
The figure: \ref{fig:modern_art}
The note: \ref{nt2}

%% \begin{equation}\label{eqn}                                                                                                               
%% A = B \endnote[c]{This is a really tricky equation}\label{nt3}                                                                            
%% \end{equation}                                                                                                                            
%% The equation number: \ref{eqn}                                                                                                            
%% The note: \ref{nt3}                                                                                                                       

\printendnotes

\end{document}

end note

2

The \label macro uses values set in the last call to \refstepcounter. In this case, the last call to \refstepcounter before \label{fig:modern_art} was made by \endnote, not \caption.

This solution uses a savebox to keep the two \refstepcounter \label pairs separate.

Since these values are set locally, it should be possible to use groups to keep them in order, but my experiments with groups so far have not worked. In fact, it appears that \endnote is saving these values globally.

\documentclass{article}
\usepackage{amsmath}
\usepackage{enotez}
\begin{document}
\section{This is a section}
\label{sec}
The quick brown fox jumps over the lazy 
dog.\endnote[a]{Actually, the dog is dead.}\label{nt1}

The section: \ref{sec}
The note: \ref{nt1}

\begin{figure}
\rule{4cm}{4cm}
\sbox0{Here is some modern art{\endnote[b]{How much would you like to 
 pay for it?}\label{nt2}}}%
\caption{\usebox0}
\label{fig:modern_art}
\end{figure}
The figure: \ref{fig:modern_art}
The note: \ref{nt2}

%% \begin{equation}\label{eqn}                                                                                                               
%% A = B \endnote[c]{This is a really tricky equation}\label{nt3}                                                                            
%% \end{equation}                                                                                                                            
%% The equation number: \ref{eqn}                                                                                                            
%% The note: \ref{nt3}                                                                                                                       

\printendnotes

\end{document}

Another solution is to place the \label inside the caption in front of \endnote:

\caption{\label{fig:modern_art}Here is some modern art{\endnote[b]{How much would you like to 
 pay for it?}\label{nt2}}}
  • Interesting. I discovered the \label inside caption solution myself, but this didn't solve the problem with my actual document. Your \sbox solution did, so it saved me a lot of work in trying to create another MWE from a rather complicated docuent. – Ian Thompson Mar 26 '18 at 20:55

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.