23

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".

  • Try using the optional argument of caption. btw, except for the figure, this is a very very good mwe. – Johannes_B Feb 12 '15 at 20:41
  • @Johannes_B Tried the notoccite on the MWE but did not work. Any suggestions regarding the optional argument? – kexxcream Feb 12 '15 at 20:45
  • 1
    For lacking a better example REMOVE or KEEP the reference in the list of figures page? – Johannes_B Feb 12 '15 at 20:47
  • @Johannes_B Works like a charm, you saved my evening. Very grateful! – kexxcream Feb 12 '15 at 20:50
  • 2
    An alternative is to use \protect in front of \citeA, i.e., \protect\citeA{...}. The \label command should not be in the scope of the \caption command. Thus it should be \caption{....}\label{....}. – Guido Feb 12 '15 at 21:02
26

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.

  • 1
    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 3:01
  • 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 at 7:46
10

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

  • 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

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.