4

I'm writing a long book with many figures, and I'd like to insert figure credit code inside each figure environment and have the associated credit text collected and printed in a Listoffigurecredits (much like a Listoffigures, Listoftables, and such) at the end of the book.

I looked into this related answer but it was rather complex and did not perform quite what I needed, for instance the automatic numbering of the credit based on the typeset figure number.

As an example, I would like a figure call with associated credit line to be of the (minimal) form:

\begin{figure}
\include{...figure file here...}
\caption{Mona Lisa by Leonardo da Vinci.}
\figurecredit{Mona Lisa by Leonardo da Vinci, reproduced by permission, The Louvre, Paris.}
\end{figure}

Then, at the end of the book I'd like to have a

\listoffigurecredits

which would print a list whose items included:

Figure 2.9: Mona Lisa by Leonardo da Vinci, reproduced by permission, The Louvre, Paris.

Notice that the "Figure 2.9" should be automatically generated, based on the actual typeset figure, and that the style should match that of listoffigures, listoftables, etc.

I'm hoping for the minimal code... the simplest approach to this admittedly tricky task.

  • The code in the linked answers isn't tricky really. There is much more trickier content on this site, of course –  Feb 09 '19 at 11:03

3 Answers3

5

enter image description here

The macro \figurecredits just writes the credit to a separate file named \jobname.fcf and \listoffigurecredits is basically nothing different than a copy of \tableofcontents, which displays the .fcf file.

\documentclass{article}

\usepackage{etoolbox}


\makeatletter
\newcommand{\figurecredit}[2][]{%
  \ifblank{#1}{%
    \addcontentsline{fcf}{figure}{\protect\numberline{\thefigure}#2}%
  }{%
    \addcontentsline{fcf}{figure}{\protect\numberline{\thefigure}#1}%
  }%
}

\newcommand{\listoffigurecredits}{%
  \begingroup
  \clearpage
  \let\old@starttoc\@starttoc
  \def\@starttoc##1{\old@starttoc{fcf}}
  \renewcommand{\contentsname}{Figure credits}
  \tableofcontents
  \endgroup
}
\makeatother

\begin{document}
\listoffigures


\begin{figure}
\caption{Mona Lisa by Leonardo da Vinci.}
\figurecredit{Mona Lisa by Leonardo da Vinci, reproduced by permission, The Louvre, Paris.}
\end{figure}

\begin{figure}
\caption{The Scream by Edvard Munch}
\figurecredit[The Scream]{The Scream by Edvard Munch}
\end{figure}


\listoffigurecredits

\end{document}
  • Thanks so very much. Let me run this later today and if (as I suspect) it works with tufte-book, I'll accept your answer. – David G. Stork Feb 09 '19 at 18:13
  • You code almost works (+1) in the tufte-book environment. It indeed lists the \figurecredit text, but it does not insert the full figure number beforehand, e.g., Figure 2.9 (which includes the chapter). I tried adding \thechapter and \thefigure inside the figurecredit text, but of course that does not give the proper listing on the Figure credits page. How to fix this? – David G. Stork Feb 09 '19 at 18:51
  • Ah... I see the problem: tufte-book numbers the figures sequentially, without regard to chapter. I'll have to change that style, and then presumably the numbering will appear proper in the Figure credits. – David G. Stork Feb 09 '19 at 19:14
  • @DavidG.Stork: Things tufte screws up are not my fault. ;-) If \thefigure is define differently you have to change it, of course. –  Feb 09 '19 at 19:58
  • Well, I wouldn't say Tufte's followers "screwed up," it is just a stylistic choice. And frankly I think Tufte's original books and several by others using tufte-book are some of the most elegant and readable in any form. Bottom line: You've done your job. Thanks so much. (accept) – David G. Stork Feb 09 '19 at 20:02
  • It works for me in this minimal example (even after switching the class to scrbook) but not inside a large scrbook document, where I get no fcf file and the standard toc being printed at \listoffigurecredits. Any idea what could be going wrong? Bonus question, I’ve read that tocbasic should be used to implement something like this, but I haven’t managed too. Did you ever look at it? – Archange Sep 01 '19 at 17:41
  • Finally found ways by myself, see https://tex.stackexchange.com/a/506607/56823 – Archange Sep 01 '19 at 20:34
3

Based on @user31729 answer as well as this other one, here is a more minimalist case that worked for me where @user31729 answer did not:

\DeclareRobustCommand{\figurecredit}[1]{\addcontentsline{fcf}{figure}{\protect\numberline{\thefigure}#1}}
\makeatletter
\newcommand{\listoffigurecredits}{%
    \begingroup
    \chapter*{Figure credits}
    \@starttoc{fcf}
    \endgroup
}
\makeatother

Now, if you use a KOMA-Script class, or even just tocbasic by itself, you can also do this:

\addtotoclist[]{fcf}
\DeclareRobustCommand{\figurecredit}[1]{\addcontentsline{fcf}{figure}{\protect\numberline{\thefigure}#1}}
\newcommand*{\listoffigurecredits}{\listoftoc[Figures credits]{fcf}}

Finally, you might want subfigures to be included and properly referenced, then swap the definition of \figurecredit with:

\DeclareRobustCommand{\figurecredit}[1]{%
    \addcontentsline{fcf}{figure}{%
        \ifnum\value{subfigure}>0
            \protect\numberline{\thefigure.\thesubfigure}
        \else
            \protect\numberline{\thefigure}
        \fi
        #1%
    }%
}
Archange
  • 1,368
0

This may not be satisfying, but the quick and dirty solution would be to put all the text inside the caption, then use the command \listoffigures which generates a list of all figures first with figure number then the caption text (separated by a colon).