Citation inside a Caption – LaTeX

Recently while writing my thesis, I came across a strange error while compiling with LaTeX. The problem arose when I gave a cite command inside a caption environment. The caption was for a figure. For example
\caption{This is the caption for a figure. From  \cite{friend2005}}
This gave the following error:

! Argument of \Hy@tempa has an extra }.
<inserted text>
l.89 ...sity estimate. From  \cite{friend2005}}

Runaway argument?
\@captype {\@firstoftwo {\@ifstar {\HAR@acite }{\HAR@fcite }}}\def \reserved@b
! Paragraph ended before \Hy@tempa was complete.
<to be read again>
l.89 …sity estimate. From  \cite{friend2005}}
A little googling around I found this site which solved the problem in a second.
So the command should read like:

\caption{This is the caption for a figure. From  \protect\cite{friend2005}}

And the problem is solved. In case you are wondering what \protect does look here.

2 thoughts on “Citation inside a Caption – LaTeX

  1. Thank you very much! I’ve been dealing with the same problem for hours, in my case with \centering and \newline to break my caption in two separeted (and centered) lines.

Leave a Reply

Your email address will not be published. Required fields are marked *