5

I have tried to applied following solution How can I prevent new-line after all items in enumeration? inside a caption of a figure, but I am having an error as follows:

! Missing number, treated as zero.
<to be read again>
                   \c@*

My example code:

\documentclass{article}
\usepackage{tikz}
\usepackage[inline]{enumitem}
\usetikzlibrary{shapes}
\usetikzlibrary{calc}
\begin{document}
\pagestyle{empty}
\begin{figure}
\begin{tikzpicture}
    \node[text width=1cm,text centered] (A) [cylinder, shape border rotate=90, draw,minimum height=0.5cm,minimum
        width=0.5cm, shape
        aspect=0.4,execute at begin node=\setlength{\baselineskip}{8pt}]{\scriptsize{Cloud Storage}};
    \end{tikzpicture}
    \caption{Hello:
        \begin{enumerate*}[label=(\arabic*),itemjoin=\quad]
            \item[(\textit{i})] The first item
            \item[(\textit{ii})] Second item
            \item[(\textit{iii})] Third item
            \item[(\textit{iv})] Third item.
        \end{enumerate*}
    }
\end{figure}
\end{document}

when I comment out following lines it works fine:

        \begin{enumerate*}[label=(\arabic*),itemjoin=\quad]
            \item[(\textit{i})] The first item
            \item[(\textit{ii})] Second item
            \item[(\textit{iii})] Third item
            \item[(\textit{iv})] Third item.
        \end{enumerate*}

Is it possible to use enumerate inside a caption of a figure?

5
  • 1
    \usepackage[inline]{enumitem} is missing from your code. Aug 6 at 10:10
  • I have added \usepackage[inline]{enumitem} but I am still having the same error
    – alper
    Aug 6 at 10:13
  • 1
    unrelated, but why use math italic for roman numerals? That is very weird Aug 6 at 10:31
  • @DavidCarlisle there is no specific reason, I think my advisor used this way and I stick with it. Do you advice any better approach for this, should I just use (i) or \textit{(iv)}? I think I did not want to keep brackets italic
    – alper
    Aug 6 at 10:34
  • 1
    i or \textit{i} a matter of style choice. $i$ is simply wrong. Aug 6 at 10:37

1 Answer 1

5

The mandatory argument to \caption (delimited with curly brackets) will not only be printed at the relevant position, but it will also be stored to be used at other places in your document, for example in the table of contents or for the bookmarks of the PDF. Therefore, you need to be cautious when inserting macros here.

You can provide a non-macro version of the caption which is used at the other places in the document by using the optional argument (delimited with square brackets) of the \caption macro:

\documentclass{article}
\usepackage[inline]{enumitem}
\usepackage{tikz}
\usetikzlibrary{shapes}

\begin{document}
\pagestyle{empty}
\begin{figure}
\begin{tikzpicture}
    \node[text width=1cm,text centered] (A) [cylinder, shape border rotate=90, draw,minimum height=0.5cm,minimum
        width=0.5cm, shape
        aspect=0.4,execute at begin node=\setlength{\baselineskip}{8pt}]{\scriptsize{Cloud Storage}};
    \end{tikzpicture}
    \caption[Hello: An inline description of the list.]{Hello:
        \begin{enumerate*}[label=(\textit{\roman*}),itemjoin=\quad]
            \item The first item
            \item Second item
            \item Third item
            \item Third item.
        \end{enumerate*}
    }
\end{figure}
\end{document}

enter image description here

4
  • 2
    \textit{(iv)} ? Aug 6 at 10:32
  • Better even, use label=(\roman*) (or similar) and don’t put labels explicitly. Aug 6 at 10:42
  • @JasperHabicht I wanted to use label=(\roman*) but some cases I had to do (ii-v) to cover multiple roman numbers that's why I was not able to stick with label=(\roman*)
    – alper
    Aug 6 at 10:50
  • 1
    You can set the counter. See tex.stackexchange.com/q/142/47927 Aug 6 at 10:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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