1

I want to add a column vector inside a figure's caption, but it just doesn't work. However, I could write math inside captions, normally.

\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage{amsmath}

\begin{document}

\begin{figure}
\centering
\begin{tikzpicture}[scale=1.5]
\draw [step=0.5, thin, gray!40] (-1.4,-1.4) grid (1.4,1.4);

\end{tikzpicture}
\caption{I want to add a column vector in here}
%\caption{the vector $\left(\begin{smallmatrix}k \\ m\end{smallmatrix}\right)$}
\end{figure}

\end{document}

I have commented the line which gives me the error.

  • Maybe you want $\binom{k}{m}$ command? – Sigur May 23 '18 at 13:29
  • No, I have tried that, it gives the same error. – Taha Magdy May 23 '18 at 13:34
  • I have no error here with binom. – Sigur May 23 '18 at 13:35
  • This is so strange. I get this Argument of \@caption has an extra }. after I used what you have suggested \caption{the vector $\left(\begin{smallmatrix}\binom{k}{m}\end{smallmatrix}\right)$} – Taha Magdy May 23 '18 at 13:37
  • No. Replace all math by only $\binom{k}{m}$. You don't need the matrix. – Sigur May 23 '18 at 13:40
  • Such errors may happen from a missing { some where else, for instance one mistypes { ... ) instead of { ... }. – Bernard May 23 '18 at 13:42
  • Sigur, my bad, but your way will not work if I want to use square brackets [] instead of ( ), right? – Taha Magdy May 23 '18 at 13:46
  • 1
    @TahaMagdy You can use abuse the definition of \genfrac (on which \binom is based) as \caption{the vector $\protect\genfrac[]{0pt}{}{k}{m}$}. The \protect is essential. This of course won't work with three-dimensional vectors. But as pointed out in the second answer to the duplicate question, I believe using the optional parameter is the best solution. Seeing a vector in the list of figures isn't particularly useful. And if you are not going to print a list of figures at all, using \caption[]{...} (i.e. with an empty optional argument) is even simpler. – campa May 23 '18 at 13:54

0 Answers0