【问题标题】:Adding an equation or formula to a figure caption in LaTeX在 LaTeX 中为图形标题添加等式或公式
【发布时间】:2011-02-12 13:26:06
【问题描述】:

我在 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    }

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

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

另见

【问题讨论】:

  • 看起来你正在尝试做的事情看起来很丑陋。我赞成在图之前或之后单独显示方程式,并在标题中 \ref 它...

标签: latex mathematical-typesetting


【解决方案1】:

使用包“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}

\caption 后面的方括号不是可选的,但将它们去掉不会导致看起来与添加\usepackage{caption}\captionsetup{...} 之前的错误有任何不同。

【讨论】:

    【解决方案2】:

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

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

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

    【讨论】:

    • stackoverflow.com/questions/2660044/… 包含我将在标题中包含的公式类型的示例。请注意,它非常大,不应与文本内联。
    • 哦,我明白了。然后我建议为整个方程/公式定义一个\label,并使用\eqref在标题中引用它,我认为这比将这么大的公式包含在图形标题中要好。
    猜你喜欢
    • 2011-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多