# Which command should I use for displayed equations?

But I'm still confused by the conflicting suggestions that have been given so far. So I'm trying again.

Which should be the preferred command to produce a displayed equation in my LaTeX documents?

So far the suggestions indicate that one should use $...$, maybe \begin{equation*} ... \end{equation*}, or maybe even the gather* or align* environments from amsmath.

And one should definitely avoid using either $$...$$ or the eqnarray environment.

Now I have to say that, from a language perspective, I have a strong preference for the equation* environment because it is less cryptic than the $...$ notation and it is semantically the most accurate.

So, is it fine to use equation*? Maybe only after loading amsmath? Or should the equation/equation* environment be redefined to something else so that spacing, package support, or whatever is improved?

-
This is wishful thinking, but I would so very much like the different displayed equation environments to all be the same environment with different arguments. So, $${centered}...$$, \begin{equation*}{aligned}...\end{equation*}, etc. Then if I want alignment I have only to change one word. –  Ryan Reich Aug 20 '10 at 19:07
@ryan: It's not exactly what you're asking for, but I think you would like the breqn package. –  Will Robertson Sep 8 '10 at 10:12
amsmath.sty contains these lines: \DeclareRobustCommand{$}{\begin{equation*}} \DeclareRobustCommand{$}{\end{equation*}}. So $…$ is exactly identical to the equation* environment when the amsmath package is loaded. –  Philipp Sep 9 '10 at 11:49
@Jaun: Can you elaborate why one should not use $$...$$ or eqnarray in specifics. What are the pros...cons. Thanks –  night owl May 31 '11 at 5:38
@night: as far as I know, they tend to have problems with spacing. You can find more info about this on the answers bellow, or the links on my question. –  Juan A. Navarro May 31 '11 at 9:21

You should use the environments from amsmath. In practice, equation and align are all you usually need.

• If you have a single equation, use equation. (Or equation* if you don't want it numbered. Most of the other environments below also have similar * variants.)

• If you have a single equation spanning multiple lines, you can either use multline, or use split (inside equation) to have the parts aligned.

• If you have multiple equations and you want them to be aligned, use align (or align*).

• If you simply want to typeset multiple equations independently (with no alignment), use gather.

There are also flalign and alignat, for some special cases. See the Short Math Guide for LaTeX or texdoc amsldoc (PDF) for more documentation on these environments.

 simply says "set the following in a math display", like plain TeX 's  (which you should not use), and is equivalent to displaymath. You can use it if you want an unnumbered equation and are too lazy to type (not good practice, semantically speaking), or, I guess, when you're simply "displaying" some long bit of mathematics that isn't an actual equation. And never use eqnarray. - Sounds good! This is pretty much what I already do. So is there any reason one should want to use \[ instead of equation*? Or is it better just to forget about \[ altogether? – Juan A. Navarro Aug 5 '10 at 20:58 When you're too lazy to type equation*, I guess. :-) Or when something you want "displayed" isn't an actual equation. I added this to the answer, but it's probably fine in practice to simply forget about \[ altogether. – ShreevatsaR Aug 5 '10 at 21:06 Emacsen (with AUCTeX) autocomplete many environments, so you can be lazy and still use equation* :) – José Figueroa-O'Farrill Aug 6 '10 at 3:52 Don't forget about the -ed versions of the environments. The aligned environment, in particular is extremely useful for numbering a group of equations with a single alignment with a single number. – TH. Aug 27 '10 at 11:13 \[ is just the same as equation* environment with amsmath, or displaymath without amsmath. It's safe and convenience to use them. With proper code formatting,  is also quite readable. On the other hand, $$ should be forgot. – Leo Liu May 31 '11 at 4:55 The equation environment cannot be compared to $...$ because it's numbered. The equivalent to $...$ is the displaymath environment. So you may use that for unnumbered equations. Though amsmath redefines equation to allow a starred version. As using amsmath is always recommended, using equation and equation* might be more consistent. $$ and eqnarray are out of question, whereas gather, align and the like are designed for multi-line formulas, I wouldn't misuse them for single-line equations.

-
I was trying to save on *'s on the question, and that's why I added a note, but yes I mean equation*. In any case, what about the issues raised here? –  Juan A. Navarro Aug 5 '10 at 19:25
If gather or align could replace equation completely, why doesn't amsmath replace equation... On the other hand, amsmath introduces a different spacing for multi-line equations, not for single-line equations. There might be a reason. If a multi-line equation like gather/align is opened, amsmath adds slightly more space expecting more lines. Writing just a single line denies that expectation. –  Stefan Kottwitz Aug 5 '10 at 19:39
So the answer to that question is that one should use equation and not any replacement? (none of the answers to that question have been up-voted yet) –  Juan A. Navarro Aug 5 '10 at 20:56

full disclosure: i have a built-in bias towards amsmath.

although in most cases, $...$ is comparable to the equation* environment, there's one place where it isn't. if you are using an ams document class, a qed marker is automatically placed by the \end{proof}. if the proof ends with some other environment -- a display or list -- the qed marker is placed all by itself on the line below.

if your proof ends with an unnumbered display, you probably want the qed marker to be placed on the same line as the display. \qedhere, placed just before the \end{...} environment for the display will move the qed marker up into the scope of the display. but it won't work for $...$, and it won't work for \begin{eqnarray}...\end{eqnarray}. (it will also work for \end{enumerate} and \end{itemize}, but that wasn't the question here.)

-
\qedhere seems to work with proof + $...$. Could you perhaps give an example that shows how it fails? –  Jukka Suomela Aug 6 '10 at 19:14
@Jukka: If you use amsmath then it has to work; see Philipp's comment to the question. –  Hendrik Vogt Nov 1 '10 at 14:01
i was wrong about \qedhere not working with $...$ -- sometimes the brain just takes a vacation. apologies for the confusion. –  barbara beeton Nov 1 '10 at 17:25