Latex: Citations in Figures
Wednesday, July 26th, 2006For some unknown, mysterious reason you can’t put a \cite command as an argument of the \caption statement. I stumbled upon this today when I was trying to attribute an image that I shamelessly snurched from the web.
Apparently, the cause is not as mysterious as I thought. If you want to know why this happens, do some research on fragile commands and moving arguments. Do you need to understand these things throughly? Probably not. You just need to remember that you may sometimes need to protect a \cite when it is an attribute of something else:
\caption{Very Stupid Image \protect\cite{source}}
So here is a new rule of thumb: if you nest a command in an attribute of another command and latex freaks out, you might be dealing with a fragile command inside of a moving attribute. Sticking a \protect in front of the command is a good place to start troubleshooting the problem.
One caveat here - if you put citations in image captions, then they will show up in your list of figures. This looks a little ugly, and it can mess up your citation order. For example, if you use IEEEtran.bst for your BibTex formating, then the first cited source should be [1], second source should be [2] and etc… Unfortunately if your list of figures is on page 3, then the first citation on that page will be counted as [1] even if the actual image does not show up till page 64.
So be careful with these.
I figured out the caption and the list of figures issue. It turns out that \caption can take an optional parameter which is the text for the list like so:
\caption[Stupid Image]{Stupid Image \protect\cite{source}}
If you use it this way the citation only shows up under the figure, but not in the LoF and thus the order of references is preserved.

