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

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
    It is perhaps worth mentioning that the first optional argument (if present) defines the entry in the list of figures. – Torbjørn T. Aug 27 '14 at 12:08

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.