Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to put a matrix in a figure caption. The following example demonstrates the idea:

\documentclass{amsart}
\usepackage{graphics,  epsfig, psfrag}  

\begin{document}

\begin{figure}
\begin{picture}(0,0)(-72,-75)
\put(12,-68){\small$\alpha_2$}
\put(-15,-71){\small$\alpha_1$}
\put(-50,-60){\small$-\alpha_1$}
\put(-47,-44){\small$2\alpha_1+\alpha_2$}
\put(-60,-10){\small$-2\alpha_1-\alpha_2$}
\end{picture}
\caption{Some roots, associated to the Cartan matrix $\left(\begin{smallmatrix}2&-2\\-1&2\end{smallmatrix}\right)$.}
\end{figure}

\end{document}

Trying to compile this produces

Argument of \@caption has an extra }

I assume this means I shouldn't use the \} character in captions. But how can I make a matrix without one?

The actual figure is much more complicated and invokes the named packages as well as the picture environment, which is why I included them; the image here has no mathematical meaning.

share|improve this question
2  
Just a quick hint: You'll make your small matrix much more readable, and your code easier to read/debug in the process, if you define the matrix as a macro of the form, say, \newcommand\cartanmatrix{\ensuremath{\textstyle\big({\begin{smallmatrix}\phanto‌​m{-}2& -2 \\-1&\phantom{-}2\end{smallmatrix}}\big)}} and then refer to it later as \cartanmatrix. :-) –  Mico Nov 10 '11 at 17:41
add comment

2 Answers

up vote 8 down vote accepted

Boxing the smallmatrix first also solves the problem. For this, you have to define a box using \newsavebox{<box>} and store the contents using \savebox{<box>}{<stuff>}:

\newsavebox{\smlmat}% Box to store smallmatrix content
\savebox{\smlmat}{$\left(\begin{smallmatrix}2&-2\\-1&2\end{smallmatrix}\right)$}

Here is a complete minimal example:

enter image description here

\documentclass{amsart}
\begin{document}

\newsavebox{\smlmat}% Box to store smallmatrix content
\savebox{\smlmat}{$\left(\begin{smallmatrix}2&-2\\-1&2\end{smallmatrix}\right)$}

\begin{figure}
\begin{picture}(0,0)(-72,-75)
\put(12,-68){\small$\alpha_2$}
\put(-15,-71){\small$\alpha_1$}
\put(-50,-60){\small$-\alpha_1$}
\put(-47,-44){\small$2\alpha_1+\alpha_2$}
\put(-60,-10){\small$-2\alpha_1-\alpha_2$}
\end{picture}
\caption{Some roots, associated to the Cartan matrix~\usebox{\smlmat}.}
\end{figure}

\end{document}​
share|improve this answer
    
This will fail if a List of Figures needs to be produced. –  Gonzalo Medina Nov 10 '11 at 17:47
    
@GonzaloMedina: You are correct. –  Werner Nov 10 '11 at 17:53
1  
Moving the lines \newsavebox{...}, \savebox{...} to the preamble solves the problem with \listoffigures. –  Gonzalo Medina Nov 10 '11 at 18:14
add comment

You can use the optional argument of \caption:

\caption[Roots associated to the Cartan matrix]{Some roots, associated to the Cartan matrix $\left(\begin{smallmatrix}2&-2\\-1&2\end{smallmatrix}\right)$.}

After all, the matrix wouldn't look good in a list of figures.

Another way of avoiding the error is to load the caption package an using the singlelinechek=off option; this approach, however, will fail if a List of Figures needs to be produced:

\documentclass{amsart}
\usepackage{graphics,  epsfig, psfrag}  
\usepackage{caption}

\begin{document}

\begin{figure}
\captionsetup{singlelinecheck=off}
\begin{picture}(0,0)(-72,-75)
\put(12,-68){\small$\alpha_2$}
\put(-15,-71){\small$\alpha_1$}
\put(-50,-60){\small$-\alpha_1$}
\put(-47,-44){\small$2\alpha_1+\alpha_2$}
\put(-60,-10){\small$-2\alpha_1-\alpha_2$}
\end{picture}
\caption{Some roots, associated to the Cartan matrix $\left(\protect\begin{smallmatrix}2&-2\\-1&2\protect\end{smallmatrix}\right)$.}
\end{figure}

\end{document}
share|improve this answer
    
Thanks! Could you explain why I should have expected that to work? –  David Speyer Nov 10 '11 at 17:28
2  
@DavidSpeyer: The explanation is somehow involved, but you can read the first lines of Appendix A.4 Errors of the documentation of the caption package, and the links therein provided. –  Gonzalo Medina Nov 10 '11 at 17:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.