TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Similar to putting a tikzpicture inside a \caption{}, I would like to insert an external icon inside figure captions, something like:

\caption{text with \includegraphics{icon} somewhere inside}

How might this be done?

share|improve this question
Can you please post an image of a sample of what you want to achieve? – Yiannis Lazarides May 2 '12 at 5:21
up vote 15 down vote accepted

You need to protect \includegraphics inside \caption; this, however, will add the image also to a possible list of figures, so perhaps you would rather use the optional argument of \caption; in this case, no protection is needed. The following example code shows both alternatives:

\usepackage[demo]{graphicx}% demo option just for the example



  \caption{text with \protect\includegraphics[height=1cm]{icon} somewhere inside}

  \caption[text for the LoF]{text with \includegraphics[height=1cm]{icon} somewhere inside}


enter image description here

share|improve this answer
that answers my question perfectly. Both options worked, either using the \protect command or including the \caption[LoF]{} format. Thanks! – proge May 2 '12 at 14:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.