Adding a caption to an equation in LaTeX

前端 未结 3 1808
你的背包
你的背包 2020-12-24 05:04

Well, it seems simple enough, but I can\'t find a way to add a caption to an equation. The caption is needed to explain the variables used in the equation, so some kind of t

3条回答
  •  一向
    一向 (楼主)
    2020-12-24 05:42

    You may want to look at http://tug.ctan.org/tex-archive/macros/latex/contrib/float/ which allows you to define new floats using \newfloat

    I say this because captions are usually applied to floats.

    Straight ahead equations (those written with $ ... $, $$ ... $$, begin{equation}...) are in-line objects that do not support \caption.

    This can be done using the following snippet just before \begin{document}

    \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
    }
    

    and when adding an equation use something like

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

提交回复
热议问题