7

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?

6

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}

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.