【问题标题】:Adding a caption to an equation in LaTeX在 LaTeX 中为方程式添加标题
【发布时间】:2020-12-19 22:17:04
【问题描述】:

嗯,看起来很简单,但我找不到为方程式添加标题的方法。 需要标题来解释方程中使用的变量,所以某种类似表格的结构来保持对齐和美观会很棒。

【问题讨论】:

  • 方程,你的意思是定理吗?
  • 其实我的意思是一个公式,有一些变量,然后下面的一些文字解释了每个变量的含义。
  • 这通常是通过简单地在文本中提供解释来完成的——为此,latex 提供了内联数学模式、公式环境、定理环境等。如果你想设置你的从文本开始,使用 float 包,如下所述。

标签: latex


【解决方案1】:

\caption 命令仅限于浮点数:您需要将方程放置在图形或表格环境(或一种新的浮点环境)中。例如:

\begin{figure}
\[ E = m c^2 \]
\caption{A famous equation}
\end{figure}

浮动的重点是让 LaTeX 确定它们的位置。如果您想让方程式出现在固定位置,请不要使用浮点数。 caption package\captionof 命令可用于在浮动环境之外放置标题。它是这样使用的:

\[ E = m c^2 \]
\captionof{figure}{A famous equation}

如果您的文档有一个条目,这也会为\listoffigures 生成一个条目。

要对齐方程式的各个部分,请查看 eqnarray environmentamsmath 包的一些环境:align、gather、multiline...

【讨论】:

    【解决方案2】:

    您可能想查看http://tug.ctan.org/tex-archive/macros/latex/contrib/float/,它允许您使用\newfloat 定义新的浮点数

    我这样说是因为字幕通常应用于浮动。

    直接方程式(用$ ... $$$ ... $$begin{equation}... 编写的)是不支持\caption 的内联对象。

    这可以在\begin{document} 之前使用以下snippet 来完成

    \usepackage{float}
    \usepackage{aliascnt}
    \newaliascnt{eqfloat}{equation}
    \newfloat{eqfloat}{h}{eqflts}
    \floatname{eqfloat}{Equation}
    
    \newcommand*{\ORGeqfloat}{}
    \let\ORGeqfloat\eqfloat
    \def\eqfloat{%
      \let\ORIGINALcaption\caption
      \def\caption{%
        \addtocounter{equation}{-1}%
        \ORIGINALcaption
      }%
      \ORGeqfloat
    }
    

    当添加一个方程时,使用类似

    \begin{eqfloat}
    \begin{equation}
    f( x ) = ax + b
    \label{eq:linear}
    \end{equation}
    \caption{Caption goes here}
    \end{eqfloat}
    

    【讨论】:

      【解决方案3】:

      就像这个forum post by Gonzalo Medina一样,第三种方式可能是:

      \documentclass{article}
      \usepackage{caption}
      
      \DeclareCaptionType{equ}[][]
      %\captionsetup[equ]{labelformat=empty}
      
      \begin{document}
      
      Some text
      
      \begin{equ}[!ht]
        \begin{equation}
          a=b+c
        \end{equation}
      \caption{Caption of the equation}
      \end{equ}
      
      Some other text
       
      \end{document}
      

      更多详细信息来自包captionhere

      以上代码的输出截图:

      【讨论】:

      • 这在我的标题开头添加了“1:”,但我的等式编号为 (5)。如何从标题中删除“1:”?另外,链接失效了
      • 就是这样。而不是caption 使用caption*\caption*{Eq. 5: my text}
      • @MattS 太棒了!感谢您丰富此答案,链接现已更新!
      猜你喜欢
      • 2011-02-12
      • 2011-04-29
      • 1970-01-01
      • 2016-10-14
      • 1970-01-01
      • 2011-02-07
      • 2015-10-29
      • 1970-01-01
      • 2012-10-03
      相关资源
      最近更新 更多