Latex: Citations in Figures

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

Update 12/15/2006 04:03:46 PM

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.

Update 01/08/2007 10:05:32 AM

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.

[tags]latex, fragile commands, moving attributes, cite, caption[/tags]

This entry was posted in programming and tagged . Bookmark the permalink.

9 Responses to Latex: Citations in Figures

  1. To fix this annoying problem, load Donald Arseneau’s notoccite.sty package:


    Reply  |  Quote
  2. Luke UNITED STATES Mozilla Firefox Ubuntu Linux says:

    Heh! It seems that I was not the only person annoyed by this.

    For now I’ll stick with defining the list of figures captions separately using the square brace. It makes sense as I can provide a more detailed caption under the image, and use a shorter one for the list.

    Reply  |  Quote
  3. Steven Mozilla Firefox Windows says:

    Thanks a lot! Fixed my referencing for my masters.

    Reply  |  Quote
  4. Daniel Bradford UNITED KINGDOM Google Chrome Linux says:

    You are a hero. Thanks!

    Reply  |  Quote
  5. Luigi-kun Mozilla Firefox Windows says:

    Thanks alot man, the IEEEtran style is full of crap with these kind of things – have been at it since 05:00 this morning…

    Reply  |  Quote
  6. Greg HUNGARY Mozilla Firefox Linux says:

    Thanks! This was useful, especially the last update. :) Bye!

    Reply  |  Quote
  7. jose hernandez MEXICO Safari Mac OS says:

    Help me please,

    I cannot reference correctly figures in latex, when I write \ref{Fig2} for example i would like to see in the PDF file Figure 2., it doesn’t happen, latex prints Figure 5.

    Reply  |  Quote
  8. CharlesL UNITED STATES Google Chrome Windows says:

    @ Daniel Bradford: +1 and thank you! Absolutely blew my mind!!

    Reply  |  Quote
  9. Isnardo MEXICO Google Chrome Windows says:

    @ Michael Shell:
    Good solution, work good for me…

    Reply  |  Quote

Leave a Reply

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