45

Problem:

Getting error messages when trying to cite a reference in the figure caption. Not sure what I am doing wrong. Can't seem to find that this has been up previously either.

Minimal Working Example:

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage[pdftex]{graphicx}
\usepackage{epstopdf}
\graphicspath{{figures/}}

\usepackage{apacite}
\bibliographystyle{apacite}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{rub14,
   author = {Rubin, Jared},
   title = {Printing and {Protestants}: An empirical test of the role of printing in the {Reformation}},
   journal = {Review of Economics and Statistics},
   volume = {96},
   number = {2},
   pages = {270--286},
   year = {2014},
}
\end{filecontents}

\begin{document}
\begin{figure}[htp]
\centering
\includegraphics[width=\textwidth]{conceptdriven.eps}
\caption{\label{fig:researchscope}The process of concept-driven design approach in relation to theory and use situation, adopted from \citeA[p.~282]{rub14}} 
\end{figure}

\bibliography{\jobname}

\end{document}

Desired outcome:

The reference to be directly after the words "adopted from".

Nicolas
  • 1,844
kexxcream
  • 2,815

2 Answers2

60

The macro \citeA is "fragile", in the LaTeX-specific sense of the word. If it occurs inside a "moving argument" (more LaTeX jargon, sorry), such as the argument of a \caption instruction, one must prefix a \protect instruction:

\caption{\label{fig:researchscope}The process of concept-driven 
  design approach in relation to theory and use situation, 
  adopted from \protect\citeA[p.~282]{rub14}}

For another example of this type, see the posting Using \input{} inside caption.

Mico
  • 506,678
  • 3
    The 10th upvote of this answer, received on 20 June 2017, earned me not only a "Nice Answer" badge but also my 888th [!] badge overall on this site. Many thanks!!! – Mico Jun 20 '17 at 03:01
  • 2
    The 25th upvote of this answer, received on 17 May 2019, earned me not only a silver "Good Answer" badge but also the 1220th badge overall on this site. Many thanks!!! – Mico May 17 '19 at 07:46
  • 1
    The 40th upvote of this answer, received on 12 October 2021, earned me the 38th silver "Guru" badge (and 1,728th badge overall) on this site. Many thanks!! – Mico Oct 13 '21 at 03:47
19

There is a similar question in StackOverflow.

The problem with the \cite command in the figure caption is that it generates conflicts with the automatic creation of the List of Figures. So the first option is to put an alternative caption into brackets:

\caption[test caption]{test caption from~\cite{MyCite}}

You can also use the \protect environnement as suggested in the comments:

\caption{test caption from~\protect\cite{MyCite}}

As for your minimal working example, you could do it as follows:

\documentclass{book}
  \usepackage[utf8]{inputenc}
  \usepackage[pdftex]{graphicx}
  \usepackage{epstopdf}
  \graphicspath{{figures/}}

  \usepackage{lipsum} % just for the example

  \usepackage{apacite}
  \bibliographystyle{apacite}

  \usepackage{filecontents}
  \begin{filecontents}{\jobname.bib}
  @article{rub14,
     author = {Rubin, Jared},
     title = {Printing and {Protestants}: An empirical test of the role of printing in the {Reformation}},
     journal = {Review of Economics and Statistics},
     volume = {96},
     number = {2},
     pages = {270--286},
     year = {2014},
  }
  \end{filecontents}

  \begin{document}
    \listoffigures

    \vspace{0.5cm}
    \lipsum[3]
    \begin{figure}[htp]
      \centering
      \includegraphics[width=8cm,height=5cm]{sample_pic}%
      %\includegraphics[width=\textwidth]{conceptdriven.eps}
      \caption[The process of concept-driven design approach in relation to theory and use situation]{The process of concept-driven design approach in relation to theory and use situation, adopted from~\citeA[p.~282} 
      \label{fig:researchscope}
    \end{figure}

    \lipsum[2]
    \bibliography{\jobname}

   \end{document}

And the output would look like:

Output for MWE

Nicolas
  • 1,844
  • What advice would you give if the optional argument of \caption needs to be a bit more informative than just "test". – Mico Feb 12 '15 at 21:40
  • 2
    @Mico Just changed that in the MWE. I would simply put the same caption in the brackets without the reference: \caption[This is the caption of my figure]{This is the caption of my figure~\cite{JSmith}}. In this way, in the figure you would have the citation, but not in the list of figures (where it's useless). – Nicolas Feb 12 '15 at 21:43
  • @Mico I added the List of Figures to the MWE to emphasize the difference. – Nicolas Feb 12 '15 at 21:55
  • I just wanted to point out that this solution is the only one that works if you're in the situation where you have to cite multiple references a la <\cite{x, y}>. For some reason, <\protect> can't seem to handle it. – Anthony May 07 '20 at 14:41