I always use align in my documents, and avoid equation. Is there anything wrong with that? My reasoning behind this: align > equation, so why not use it?
-
3Related Why should I ever use equation when I can always use align? – Dec 14 '12 at 13:03
5 Answers
While not exactly a bad idea in principle, unfortunately it is a bad idea in practise because align doesn't have the same feature as equation whereby less vertical space is added if a small equation is displayed after a paragraph that ended early on the line. For example, consider
\documentclass[twocolumn]{article}
\usepackage{amsmath}
\begin{document}
hello
\[
a+b=c
\]
hello
\begin{align}
a+b&=c
\end{align}
\end{document}
You should easily be able to see the extra space after the second ‘hello’.
- 105
- 73,872
-
What are you supposed to do though if you need to use an
alignenvironment (i.e., if typeseting anequationenvironment with analignedinside is not sufficient)? – mSSM May 21 '12 at 13:11 -
3If you need to use
alignthen you just usealign:) Just be aware of the difference, that's all. – Will Robertson May 22 '12 at 02:01 -
1I've tried this code with the
[fleqn]option and\setlength{\mathindent}{0pt}and they look exactly the same. – Geoff Pointer Sep 04 '17 at 00:26 -
equation "squeezes" the math (i.e. uses less white space between symbols) in order to avoid badboxes but align does not.
\documentclass[11pt,draft]{article}
\usepackage{amsmath}
\begin{document}
Using ``equation'':
\begin{equation*}
1+2+3+4+5+6+7+8+9+10
= 11+12+13+14+15+16+17+18+19+20+21
\end{equation*}
Using ``align'':
\begin{align*}
1+2+3+4+5+6+7+8+9+10
= 11+12+13+14+15+16+17+18+19+20+21\\
\end{align*}
\end{document}

- 6,100
-
4I guess what you're showing is that an
align[*]environment, if used mindlessly (or recklessly...), more easily produces seriously overfull lines of math than does anequation[*]environment. Of course, one rather good reason for using analignenvironment to begin with is to have a method for avoiding the creation such overfull lines. – Mico Jan 20 '14 at 06:26 -
6@Mico Exactly!...which is why I was so surprised when I noticed this behavior in one of my papers. I used to be like the OP and thought
align>equationused thus usedaligneverywhere. The only argument I had seen to useequationis because you want the syntax reflect this. However, I often have multi-lined equation that need alignment and even tend to edit equation so the that the need for alignment comes and goes. I found it an annoying waste of time to change the syntax betweenalignandequation. – Tyson Williams Jan 20 '14 at 14:32 -
2Eventually are stated using
equationfor one liners just because my coauthors did. Only in the last week have I realized that there is a visible difference between these two environments (primarily this answer of mine and Will's answer about differing vertical white space before the display math). – Tyson Williams Jan 20 '14 at 14:34
Will all due respect to Will Robertson, actually I think that it is a bad idea in principle, because they mean different things and markup (be it *TeX, HTML,...) should be logical as much as possible.
If you are typesetting an equation, then use equation and if you desire alignment you can use aligned blocks inside the equation.
You can decide easily whether you are typesetting an equation or not, by thinking how to want to reference it. If you only want one equation number to be displayed and see yourself suppressing by hand any additional equation numbers, (say by using \notag) then you are typesetting an equation and your markup should reflect that.
- 4,125
- 2
- 27
- 35
-
6I see what you mean about markup being logical and do agree with you in principle, but I think in this case the typesetting of the output is far more important than whether or not we can consider a single equation to be aligned with itself (and therefore 'logical' within an
alignenvironment). The difference in behaviour outlined by Will seems to me to provide a much better answer as to the actual difference between the two environments and where you could possibly run into trouble by choosing one over the other. – Michael Underwood Jul 27 '10 at 16:39 -
8I interpret "not exactly a bad idea" as a polite way of saying not really a good idea. – Charles Stewart Jul 28 '10 at 09:24
align is unable to replicate the label behavior of equation + split, which is to have a single vertically centered label. One can suppress labels for specific lines of align using either \nonumber or \notag, but all unaltered lines get their own label.
\documentclass[twocolumn]{article}
\usepackage{amsmath}
\begin{document}
Using ``equation'':
\begin{equation}
\begin{split}
a+b
&= c\\
&= c\\
&= c\\
&= c
\end{split}
\end{equation}
Using ``align'':
\begin{align}
a+b
&= c\\
&= c \notag\\
&= c \nonumber\\
&= c
\end{align}
\end{document}

(Answer inspired by this source.)
- 6,100
-
2It's possible to use
splitinsidealigntoo. (Also, interestingly, somehow thesplits will try to align properly to the&anchors outside of them, according to one of the answers on that page.) – Evgeni Sergeev Feb 25 '16 at 09:31 -
-
1The
alignedenvironment can be used withinalignto obtain the same behavior. – jII May 18 '22 at 18:43 -
You can use use
aligned,alignedat(orsplit(*)) insideequationoralign(or evenalignedat(*)). If in you get an error in the combination marked by star, look here for howsplittries to align its&with the outer environment. In most cases I usealignedinsideequation. – minorChaos Aug 31 '23 at 14:20
if you are using both amsmath and amsthm, you end a proof with a one-line equation, and want to move the qed box up onto the line with the equation, align will happily overprint the box onto the end of the math. equation behaves. so does \[ ... \].
\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\begin{document}
\begin{proof}
one-line display with \verb+align*+
\begin{align*}
a + b = c \qedhere
\end{align*}
\end{proof}
\begin{proof}
one-line display with \verb+equation*+
\begin{equation*}
a + b = c \qedhere
\end{equation*}
\end{proof}
\begin{proof}
one-line display with \verb+\[+ \dots\verb+\]+
\[
a + b = c \qedhere
\]
\end{proof}
\end{document}
Edit: This should have been stated in the original formulation of the answer, but was overlooked.
The real problem with this use of align is that align expects and requires an odd number of &s to work properly.
Briefly, the purpose of align is to set adjacent equations so that a specified point in each (marked by &) is positioned in the same horizontal location in all lines of a multi-line display. Since more than one component equation may appear on each line, these components are in turn separated by &, hence the requirement for an odd number of them. Furthermore, align should not be used for single-line displays; that's what equation (or \[ ... \] for the unnumbered variety) is for. See the amsmath user guide for details (texdoc amsldoc).
- 88,848
-
-
-
@rubenvb
\qedhereshould be on the right hand side of the alignment, after&– David Carlisle May 11 '18 at 14:32 -
2@rubenvb I confirm:
\qedhereinalign,flalignoralignatrequires at least one&. – egreg May 11 '18 at 17:14 -
@rubenvb -- but using an environment designed for a multi-line display for a one-line display is still bad practice. – barbara beeton May 11 '18 at 17:16
-
@barbarabeeton one could also argue that designing an environment that can only handle multiline input is bad implementation. But I get your point and this discussion is becoming philosophical quite quickly :). – rubenvb May 12 '18 at 09:16
-
A colleague tells me that equation is deprecated. He is in favor of align. Is this true? – user3236841 Aug 18 '19 at 23:32
-
6
equationis absolutely not deprecated. I have no idea where your colleague got that idea. Instead,alignis deprecated for one-line displays (or at least seriously discouraged). Use ofalignfor one-liners is one of the most serious user errors that I know; having been one of the group involved in the design of the original math package, I assure you thatequationis intentionally designed to handle single-line displays as well as any conceptually "unitary" displayed structure that has a single equation number. Read theamsmathdocumentation (texdoc amsldoc). – barbara beeton Aug 19 '19 at 00:09 -
Thanks very much for this! I myself prefer equation and would have been very sad to see it go. – user3236841 Aug 19 '19 at 00:44
-
1

