5

I am writing a report with figures that have (often voluminous) notes. Currently I am writing the notes under the figure.

\documentclass{scrreprt}
\usepackage[demo]{graphicx}

\usepackage{lipsum}

\newcommand{\notes}[1]{\textbf{Notes:}~\footnotesize{\textit{#1}}}

\begin{document}
\lipsum[1]
\begin{figure}[h]
\caption{Main caption}
\includegraphics[width=\linewidth]{}
\notes{\lipsum[1-2]}
\end{figure}
\lipsum[1]

\begin{figure}[h]
\caption{Other caption}
\includegraphics[width=\linewidth]{}
\notes{Foobar}
\end{figure}


\end{document}

But I would prefer that the \notes are not printed within the figure float (where it takes up too much room) but are printed as endnotes in their own table. Edit That is, I would like a command \printfigurenotes that prints a list with the contents of the notes:

List of Figure notes:

Figure 1:  \lipsum[1-2]

Figure 2:  Foobar.

How can I achieve this?

The closest existing structure I could find is to put the contents of the notes within the optional argument to \caption and produce a list of figures at the end of the document, but this seems to be conceptually backward and would require a lot of work to get the formatting correct (as well as losing the list of figures proper).

I could also write something like (say, using enotez):

\newcommand{\notes}[1]{Notes:\endnote{#1}}

but I'd like:

  1. not have endnotes within the float (where the numbering can be out of order). Edit That is, when I use \endnote, the numbering for the endnote in the float can be out of order with endnotes in the body; and
  2. to have a separate notes field.
  • please can you explain a bit what do you mean by are printed as endnotes in their own table – touhami May 17 '16 at 11:08
  • Hi does my edit answer your question – Hugh May 17 '16 at 11:08
  • and but I'd like to not have endnotes within the float (where the numbering can be out of order) and I'd like to have a separate notes field. – touhami May 17 '16 at 11:08
  • Ok, great will see – touhami May 17 '16 at 11:10
  • I still can't understand the 1 st point That is, when I use \endnote, the numbering for the endnote in the float can be out of order with endnotes in the body; and I see the problem but not sure what do you want. should figurenotes be numbered independent of other notes? if they share same numbering there is no way to preserve the order. – touhami May 17 '16 at 17:27
3
+50

Disclaimer: This is a derivative of touhami's answer. As mentioned above, this is also a poor way of doing it, but it works none-the-less.

One problem with touhami's second solution is that if a figure has no notes, the ordering of the endnotes goes out of whack. For the past hour, I've been trying to get LaTeX to compile the values of the notes to the endnotes rather than their command forms (e.g. If you write \lipsum[1-2], the endnotes also get \lipsum[1-2] instead of the text Lorem ipsum dolor sit amet, consectetuer...). This is particularly annoying for any method relying on counters, as the counters will also be calculated as commands hence why touhami's answer originally produced only "Figure 2" for all entries as it was the highest numbered figure when called.

So, to overcome this, we can link the figures and endnotes using references. In this instance, I am making use of the hyperref package for nicer hyperlinks. Calls can easily be 'dumbed' down to \ref instead with the appropriate changes.

Usage

\notes{<figlabel>}{<notecontents>}

MWE

\documentclass{scrreprt}
\usepackage[demo]{graphicx}

\usepackage{lipsum}
\usepackage{hyperref}

% Negates \phantomsection when hyperref isn't loaded.
\providecommand\phantomsection{} 
% Creates labels/references from code without annoying IDEs
\newcommand{\dynamiclabel}[1]{\csname label\endcsname{#1}} 
\newcommand{\dynamicref}[2]{\csname hyperref\endcsname[#1]{#2}}

\newcommand\figurenotes{%
    \begingroup
    \section*{\listfigurename{} notes}
    \setlength\leftmargini{4.5em}
    \begin{itemize}}

    \newcommand*{\printfigurenotes}{%
        \figurenotes\end{itemize}\endgroup}

% Key component:
\makeatletter
\newcommand{\notes}[2]{%
    \dynamicref{#1:note}{See notes.}%
    \g@addto@macro\figurenotes{\item[\phantomsection\dynamicref{#1}{Fig.\ \ref*{#1}}] \dynamiclabel{#1:note} #2}}
\makeatother
%for other endnotes
\usepackage{enotez}
\setenotez{counter-format = Alph}


\begin{document}
    \chapter{Introduction}
    bla bla\endnote{\lipsum[1]}
    \lipsum[1]
    \begin{figure}[h]
        \caption{Main caption}
        \label{fig:1}
        \includegraphics[width=\linewidth]{}
        \notes{fig:1}{\textbf{First} \lipsum[1-2]}
    \end{figure}
    \begin{figure}[h]
        \caption{Main caption}
        \includegraphics[width=\linewidth]{}
    \end{figure}
    \begin{figure}
        \caption{Main caption}
        \label{fig:2}
        \includegraphics[width=\linewidth]{}
        \notes{fig:2}{\textbf{Second} \lipsum[1-2]}
    \end{figure}
    \lipsum[1]

    \printfigurenotes

    \printendnotes

\end{document}

Fun fact: Appending \ to an abbreviation full-stop prevents bad spacing , e.g. as in ...{Fig.\ \re... above.

Edit: Added \phantomsection as suggested by Hugh in the comments. I didn't know this existed and it works quite nicely. Added \providecommand\phantomsection{} for good measure (even though it does nothing when hyperref is present).

  • 1
    Very nice! And I hadn't noticed the bug you picked up when the notes are absent for some figures. I'd probably prefer \item[\phantomsection\dynamicref{#1}{Fig.\ \ref*{#1}}] so the hyperlink hits the notes rather than the list, but that's a matter of style. – Hugh May 18 '16 at 6:29
3

Is this what you look for?

\documentclass{scrreprt}
\usepackage[demo]{graphicx}

\usepackage{lipsum}

\usepackage{enotez}
\setenotez{list-name = {List of Figure notes:}}
\DeclareInstance{enotez-list}{itemize}{list}{number =Figure \enmark{#1},list-type = itemize}

\newcommand{\notes}[1]{Notes:\endnote{#1}}

\begin{document}
\lipsum[1]
\begin{figure}[h]
\caption{Main caption}
\includegraphics[width=\linewidth]{}
\notes{\textbf{First} \lipsum[1-2]}
\end{figure}X
\begin{figure}
\caption{Main caption}
\includegraphics[width=\linewidth]{}
\notes{\textbf{Second} \lipsum[1-2]}
\end{figure}
\lipsum[1]

\setlength\leftmargini  {4em}
\printendnotes[itemize]

\end{document}

Update Here is an idea how one can define figurenotes that's numbered independent of other notes and printed in own list. (not the best way but does the job)

\documentclass{scrreprt}
\usepackage[demo]{graphicx}
\usepackage{hyperref}

\usepackage{lipsum}

\newcounter{fnote}

\newcommand\figurenotes{%
\begingroup
\setcounter{fnote}{0}
\section*{\listfigurename{} notes}
\setlength\leftmargini{4.5em}
\begin{itemize}}

\newcommand*{\printfigurenotes}{%
\figurenotes\end{itemize}\endgroup}

\makeatletter
\newcommand{\notes}[2]{%
\refstepcounter{fnote}%
% Appearance of notes under the figure
% e.g. place `Notes:' with a superscript. 
%   Notes:\footnotemark[\thefnote]%
% or
%   put italic text at the bottom right of the figure with 
%   a pagereference. \phantomsection to ensure hyperref points accurately.
\phantom{.}\hfill\textit{See figure note on page~\pageref{#2}.}%
\g@addto@macro\figurenotes{\stepcounter{fnote}\item[Figure \thefnote.] \phantomsection\label{#2}#1}}
\makeatother
%for other endnotes
\usepackage{enotez}
% The following might be necessary if the Notes: looks too
% much like the default in enotez.
%\setenotez{counter-format = Alph}


\begin{document}
bla bla\endnote{\lipsum[1]}
\lipsum[1]
\begin{figure}[h]
\caption{Main caption}
\includegraphics[width=\linewidth]{}
\notes{\textbf{First} \lipsum[1-2]}{lipsum1}
\end{figure}
\begin{figure}
\caption{Main caption}
\includegraphics[width=\linewidth]{}
\notes{\textbf{Second} \lipsum[1-2]}{lipsum2}
\end{figure}

\begin{figure}
\caption{Main caption}
\includegraphics[width=\linewidth]{}
\notes{\textbf{Third} \lipsum[1-2]}{lipsum3}
\end{figure}

\begin{figure}
\caption{Main caption}
\includegraphics[width=\linewidth]{}
\notes{\textbf{Fourth} \lipsum[1-2]}{lipsum4}
\end{figure}

\lipsum[1]

\printfigurenotes

\printendnotes

\end{document}
  • No, I should still be able to use \endnote outside figures (and endnotes for those should appear as a separate list). – Hugh May 17 '16 at 11:54
  • @Hugh will see, let's hope i understand. – touhami May 17 '16 at 13:16
  • Hmm, this is pretty close. Except the notes in \printfigurenotes are all labeled "Figure 2". – Hugh May 18 '16 at 0:33
  • @Hugh answer updated (fixed) – touhami May 18 '16 at 5:25
  • Fantastic! You say it's not the best way but does the job. Is there any 'danger' in using this, or do you just suspect there's another way? – Hugh May 18 '16 at 5:51

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.