[Tex/LaTex] Using the itemize environment inside a caption

captionsfloatsitemizelists

The following code does not compile. However, if I remove the itemize environment it does. I googled for this problem, and found suggestions that using the caption package would solve the problem, though I did not find any clear description of why the problem occurred in the first place. See for example

http://www.latex-community.org/forum/viewtopic.php?f=45&t=8774

I'm using Debian squeeze with TeX Live 2009-11. The included version of caption has

\ProvidesPackage{caption}[2009/10/09 v3.1k Customizing captions (AR)]

I also tried downloading and using the caption package from

http://www.ctan.org/tex-archive/macros/latex/contrib/caption/

but this doesn't change anything. I put the sty files in my current directory. I assume that overrides the system files. This one corresponds to

\ProvidesPackage{caption}[2010/01/09 v3.1m Customizing captions (AR)]

Error message and example file follow.

*******************************************    
ERROR: Argument of \@caption has an extra }.

--- TeX said ---
<inserted text> 
                \par 
l.13     }

--- HELP ---
From the .log file...

I've run across a `}' that doesn't seem to match anything.
For example, `\def\a#1{...}' and `\a}' would produce
this error. If you simply proceed now, the `\par' that
I've just inserted will cause me to report a runaway
argument that might be the root of the problem. But if
your `}' was spurious, just type `2' and it will go away.
******************************************************

\documentclass{article}
\usepackage{caption}
\begin{document}

\begin{figure}
    \captionsetup{singlelinecheck=off}
    \caption
    {
      foo
      \begin{itemize}
      \item bar
      \end{itemize}
    }
\end{figure}
\end{document}

Best Answer

From the caption manual:

If you want to typeset something special (like a tabular) as caption, you need to give an optional argument to \caption resp. \captionof for the List of Figures resp. List of Tables, too, even if you don’t use such list.

\documentclass{article}
\usepackage{caption}

\begin{document}

\begin{figure}
\captionsetup{singlelinecheck=off}
\caption[foo bar]{foo
  \begin{itemize}
    \item bar
  \end{itemize}}
\end{figure}

\end{document}