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?