7

我在 LaTeX 中有一个带有标题的图形,我需要在其中添加一个公式(equation*displaymath环境)。例如:

\documentclass[12pt]{article}
\begin{document}
\begin{figure}[tbph]
    \begin{center}
        %...
    \end{center}
    \caption{As you can see
            \begin{displaymath}4 \ne 5\end{displaymath}
    }
    \label{fig:somefig}
\end{figure}
\end{document}

这让 pdflatex 很生气,尽管它会生成 PDF。

! Argument of \@caption has an extra }.
<inserted text> 
                \par 
l.9    }

将方程式添加到图形标题的正确方法是什么?

注意:请不要建议简单地使用$ ... $数学环境;所示方程是一个玩具示例;我的真实方程式要复杂得多。

另见

4

2 回答 2

10

Using the package "caption":

\begin{figure}
\begin{center}
    ...
    \captionsetup{singlelinecheck=off}
    \caption[.]{
    \begin{displaymath}
        assoc\_meaning(\lambda x_{SBJ}. followed(x,y) \&actor(x) \nonumber \&actor(y),\lambda x_{SBJ}. maintained(x,\nonumber <(dist\_from(y),1))
    \end{displaymath}}
\end{center}
\end{figure}

The square brackets following \caption aren't optional, but leaving them off won't cause an error that looks any different than the one before you added \usepackage{caption} and \captionsetup{...}.

于 2011-06-22T22:30:24.830 回答
2

我不确定您为什么不想使用该$ ... $解决方案,因为分数?

如果是这样,您可以使用\dfrac而不是\frac.

我会尝试$ \displaystyle \dfrac{1}{2} \cdot \sum_{i=0}^n i$,即使用\displaystyle命令。

于 2010-04-26T19:28:34.763 回答