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.


About The Mitr

I am The Mitr, The Friend
This entry was posted in latex and tagged , , , , . Bookmark the permalink.

One Response to Citation inside a Caption – LaTeX

  1. Odín says:

    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

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s