2

i want to print the source for my used images in the list of figures. So i tried adding the \cite command to the optional paramter of \caption.

This seems to work fine, but if the cited source is not cited anywhere else in the document (as for a wikipedia image for example) then it just prints the citation key instead of the citation itself in the list of figures.

Here is a minimal working example. Uncomment the commented line and it will show the correct citation in the list of figures.

i also attached two images showcasing the 2 results.

if there is any information needed, please comment.

// Edited to clarify the question

\documentclass{article}
\usepackage{filecontents}
\usepackage[demo]{graphicx}
\usepackage{url}

\usepackage[backend=biber,style=authoryear]{biblatex}

\begin{filecontents*}{test.bib}
    @misc{test.2016,
        author = {{Test Author}},
        title = {Test Title},
        year = {2016}
    }
\end{filecontents*}

\addbibresource{test.bib}

\begin{document}

% Comment out the following line and it breaks
% Test content \cite{test.2016}

\begin{figure}[h]
    \centering
    \includegraphics[width=\textwidth]{testimage}
    \caption[Source: \cite{test.2016}]{My Caption}
\end{figure}

\listoffigures

\end{document}

only the key

correct citation (desired)

  • i found a very quick and dirty solution but would love to see a better one. \newcommand{\citecaption}[2]{\caption[Source: \cite{#1}]{#2}\phantom{\cite{#1}}\vspace{-0.4cm}}

    usage: \citecaption{cite.key}{Caption}

    – Jan Oechsler Sep 29 '16 at 13:58
  • Another work-around is to issue a \nocite before or after the \caption command. – moewe Sep 29 '16 at 14:12

1 Answers1

3

In the biblatex documentation you will find under §4.11.5 Trackers in Floats and TOC/LOT/LOF

If a citation is given in a float (typically in the caption of a figure or table), scholarly back references like ‘ibidem’ or back references based on the page tracker get ambiguous because floats are objects which are (physically and logically) placed outside the flow of text, hence the logic of such references applies poorly to them. To avoid any such ambiguities, the citation and page trackers are temporarily disabled in all floats. In addition to that, these trackers plus the back reference tracker (backref) are temporarily disabled in the table of contents, the list of figures, and the list of tables.

Apparently, biblatex goes even further: It partly disables citations by setting citerequest to false. If you cite the item another time this is not an issue.

You can get around this with

\AtEndPreamble{%
  \addtocontents{toc}{%
    \booltrue{citerequest}\relax}%
  \addtocontents{lof}{%
    \booltrue{citerequest}\relax}%
  \addtocontents{lot}{%
    \booltrue{citerequest}\relax}}

Note that this may lead to some issues for numeric styles if you don't want the LOF/LOT/... to count for the order of citations. It could also cause problems with other styles that rely heavily on citation tracking and order.

The MWE

\documentclass{article}
\usepackage{filecontents}
\usepackage[demo]{graphicx}
\usepackage{url}

\usepackage[backend=biber,style=authoryear]{biblatex}

\begin{filecontents*}{\jobname.bib}
    @misc{test.2016,
        author = {{Test Author}},
        title = {Test Title},
        year = {2016}
    }
\end{filecontents*}

\addbibresource{\jobname.bib}

\AtEndPreamble{%
  \addtocontents{toc}{%
    \booltrue{citerequest}\relax}%
  \addtocontents{lof}{%
    \booltrue{citerequest}\relax}%
  \addtocontents{lot}{%
    \booltrue{citerequest}\relax}}

\begin{document}
\begin{figure}[h]
    \centering
    \includegraphics[width=\textwidth]{testimage}
    \caption[Source: \cite{test.2016}]{My Caption}
\end{figure}
\listoffigures
\end{document}

gives

example output

moewe
  • 175,683