![如何将矩阵放入图形标题中?](https://linux22.com/image/242476/%E5%A6%82%E4%BD%95%E5%B0%86%E7%9F%A9%E9%98%B5%E6%94%BE%E5%85%A5%E5%9B%BE%E5%BD%A2%E6%A0%87%E9%A2%98%E4%B8%AD%EF%BC%9F.png)
我想将矩阵放在图标题中。以下示例演示了这个想法:
\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}
尝试编译这个产生
Argument of \@caption has an extra }
我认为这意味着我不应该\}
在标题中使用该字符。但是我如何才能制作一个没有该字符的矩阵呢?
实际的图形要复杂得多,它调用了命名的包以及picture
环境,这就是我将它们包括在内的原因;这里的图像没有数学意义。
答案1
将第一个装箱smallmatrix
也解决了这个问题。为此,您必须使用 定义一个盒子,\newsavebox{<box>}
并使用 存储内容\savebox{<box>}{<stuff>}
:
\newsavebox{\smlmat}% Box to store smallmatrix content
\savebox{\smlmat}{$\left(\begin{smallmatrix}2&-2\\-1&2\end{smallmatrix}\right)$}
这是一个完整的最小示例:
\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}
答案2
您可以使用可选参数\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)$.}
毕竟,矩阵在数字列表中看起来不太好。
避免错误的另一种方法是caption
使用选项加载包singlelinechek=off
;但是,如果需要生成图形列表,则这种方法将会失败:
\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}