Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there a reason why I find it hard to put inline lists in figure captions?

I've defined this:

\newcommand{\inlinelist}[1]{\begin{inparaenum}[(a)] #1 \end{inparaenum}}

But I can't see anything wrong with it. It only seems to be a problem in captions.

share|improve this question
2  
Most probably you are not protecting \inlinelist and probably other commands. However, I would like to see a full minimal example of your code. –  Gonzalo Medina Mar 31 '12 at 21:51
add comment

2 Answers 2

up vote 5 down vote accepted

Actually, there's nothing wrong per se with you're trying to do. The thing that's tripping you up, though, is that the argument of the \caption command can't have what LaTeX calls "moving" or "moving" parts. To make fragile commands "robust," one can prefix them with a \protect command.

A separate comment: If there's a chance that you'll need to create a "list of figures" (which can be accomplished with the \listoffigures command), you should provide a "short" version of the caption text in the optional argument of the \caption command. Otherwise, you'll get more cryptic error messages, this time of the form Argument of \@caption has an extra }. The way to get around that is to create a short version of the caption without any "moving" commands at all, as the following MWE shows.

\documentclass{article}
\usepackage{paralist}
\usepackage[demo]{graphicx}
\newcommand{\inlinelist}[1]{\begin{inparaenum}[(a)] #1 \end{inparaenum}}

\begin{document}
\listoffigures

\begin{figure}[h]
\caption[Hello and Goodbye]% 
   {\inlinelist{%
     \protect\item Hello. 
     \protect\item Goodbye.}%
   }
\centering
\includegraphics{hello.pdf}
\end{figure}
\end{document}

enter image description here

share|improve this answer
    
If the OP is using \items in the argument of \inlinelist, then \items will also have to be \protected. –  Gonzalo Medina Mar 31 '12 at 21:56
    
@GonzaloMedina -- good point. I'll be sure to mention this in an addendum to my answer. –  Mico Mar 31 '12 at 22:34
    
@Mico Addendum? I think it should be in a footnote:) –  Yiannis Lazarides Apr 1 '12 at 6:18
    
@YiannisLazarides: footnote or addendum? I've decided to bypass this deep issue by rewriting my answer entirely (now with more information on how to make the caption suitable for processing by the \listofigures command... –  Mico Apr 1 '12 at 11:09
1  
@Mico Good answers both in the main post and in the comments:) –  Yiannis Lazarides Apr 1 '12 at 11:13
add comment

You give only fragments of the information needed to answer the question. But the problem seems to be you're dealing with a lot of fragile commands in a moving argument. Try

\documentclass{article}

\usepackage{paralist}

\begin{document}
\DeclareRobustCommand{\inlinelist}[1]{\begin{inparaenum}[(a)] #1 \end{inparaenum}}

\begin{figure}
  \centering
  \caption{\inlinelist{\protect\item foo\protect\item bar}}
\end{figure}



\end{document} 
share|improve this answer
add comment

Your Answer

 
discard

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.