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 table-like structure to keep it all aligned and pretty would be great.
-
By equation, do you mean a theorem? – dmckee --- ex-moderator kitten Sep 29 '08 at 16:36
-
Actually I mean a formula, with some variables, and then some text below it explained what each variable means. – Farinha Sep 29 '08 at 17:25
-
This is often accomplished by simply providing the explanation in the text---for this, latex provides in-line math mode, the formula environment, the theorem environments, etc. If you want to set your work off from the text, use the float package as explained below. – dmckee --- ex-moderator kitten Sep 29 '08 at 18:09
3 Answers
The \caption
command is restricted to floats: you will need to place the equation in a figure or table environment (or a new kind of floating environment). For example:
\begin{figure}
\[ E = m c^2 \]
\caption{A famous equation}
\end{figure}
The point of floats is that you let LaTeX determine their placement. If you want to equation to appear in a fixed position, don't use a float. The \captionof
command of the caption package can be used to place a caption outside of a floating environment. It is used like this:
\[ E = m c^2 \]
\captionof{figure}{A famous equation}
This will also produce an entry for the \listoffigures
, if your document has one.
To align parts of an equation, take a look at the eqnarray
environment, or some of the environments of the amsmath package: align, gather, multiline,...

- 8,866
- 9
- 40
- 58

- 45,466
- 8
- 54
- 65
-
Adding an unwanted entry in `\listoffigures` is a dealbreaker for this approach IMO – WolfLink Dec 13 '22 at 03:07
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}

- 1,506
- 15
- 23

- 98,632
- 24
- 142
- 234
As in this forum post by Gonzalo Medina, a third way may be:
\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}
More details of the commands used from package caption
: here.
A screenshot of the output of the above code:

- 6,455
- 5
- 45
- 52
-
1This added "1: " at the beginning of my caption, but my equation is numbered (5). How can I remove the "1: " from the caption? Also, the link is dead – MattS Sep 20 '20 at 22:24
-
1This is how. Instead of `caption` use `caption*`: `\caption*{Eq. 5: my text}` – MattS Sep 20 '20 at 22:34
-
1@MattS great! Thank you for enriching this answer and the link is now updated! – MattAllegro Sep 21 '20 at 17:21