9

This compiles fine.

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

test: $\overleftarrow{a}$

\begin{figure}
    %\subfloat[Subcaption $\overleftarrow{a}$]{\framebox[3cm]{First}}
    \subfloat[Subcaption $b$]{\framebox[3cm]{Second}}
\end{figure}

\end{document}

I put a Math-Mode in the caption of the subfloat. In the next example I put math mode and \overleftarrow, and although it gives the right output, it produces an error.

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

test: $\overleftarrow{a}$

\begin{figure}
    \subfloat[Subcaption $\overleftarrow{a}$]{\framebox[3cm]{First}} \hfill
    \subfloat[Subcaption $b$]{\framebox[3cm]{Second}}
\end{figure}

\end{document}

Error:

ERROR: Illegal parameter number in definition of \sf@captionlist.
--- TeX said ---
<to be read again> 
               \crcr 
l.10 ...\overleftarrow{a}$]{\framebox[3cm]{First}}

Why is there an error?

1 Answer 1

7

You need to use \protect.

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

test: $\overleftarrow{a}$

\begin{figure}
    \subfloat[Subcaption $\protect\overleftarrow{a}$]{\framebox[3cm]{First}} \hfill
    \subfloat[Subcaption $b$]{\framebox[3cm]{Second}}
\end{figure}

\end{document}
2

You must log in to answer this question.

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