2

I need to put an image "tinyimage" inside the caption of a subfloat of the subfig package.

Minimal not working example:

\documentclass{scrbook}
\usepackage{graphicx}
  \DeclareGraphicsExtensions{.pdf}
\usepackage{subfig}

\begin{document}
  \begin{figure}
    \subfloat[\includegraphics{tinyimage}]{\includegraphics{bigimage}}
  \end{figure}
\end{document}

So far I tried the following:

  • put a \protect{} around the \includegraphics{} in the caption.
  • store the \includegraphics{} in a \savebox and put \usebox in the caption.

The error I get is:

Argument of \sf@@@subfloat has an extra }. ...phics{tinyimage}]{\includegraphics{big image}}

1 Answer 1

1

Try to add all tree arguments of \subfloat[][]{} command:

\documentclass{scrbook}
\usepackage[demo]{graphicx}
  \DeclareGraphicsExtensions{.pdf}
\usepackage{subfig}

\begin{document}
  \begin{figure}
    \subfloat[][{\includegraphics{tinyimage}}]{\includegraphics{bigimage}}
  \end{figure}
\end{document}

Note that the second optional argument is {\includegraphics{tinyimage}}: extra {...} are necessary for optional argument of \includegraphics{...} command.

1
  • 1
    It is perhaps worth mentioning that the first optional argument (if present) defines the entry in the list of figures. Aug 27, 2014 at 12:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .