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.

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

3 Answers 3

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}
7
  • 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. Feb 9, 2019 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? Feb 9, 2019 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. Feb 9, 2019 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.
    – user31729
    Feb 9, 2019 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) Feb 9, 2019 at 20:02
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%
    }%
}
1
  • This solution works great for me!
    – jlconlin
    Dec 29, 2021 at 4:05
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).

3
  • 3
    Welcome to TeX.SE! Sorry, the OP wants to get two lists, one list of figures as usual and a second list with the credits. I think you missunderstood the question Am I right?
    – Mensch
    Feb 9, 2019 at 3:30
  • 1
    Yeah sorry, my bad. Feb 9, 2019 at 4:06
  • @JoeThePhysWiz: Alas, I have a separate \listoffigures which is separate from the figurecredits, so your approach won't work. Sep 1, 2019 at 19:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .