21

Here is an MWE which shows that they seem to do the same thing. Is there any reason to prefer one over the other for typesetting groups of equations? I would prefer the align syntax because it allows intertext. In the other case, the alignment is limited to aligned environments within the larger gather environment. Any thoughts are welcome.

\documentclass{article}
\usepackage{amsmath}
\begin{document}

%==================
% gather+aligned
\begin{gather}
\begin{aligned}
x &= a + b\\
y &= c+ d
\end{aligned}
\end{gather}


%==================
% align+split
\begin{align}
\begin{split}
x &= a + b\\
y &= c+ d
\end{split}
\end{align}

\end{document}
David Carlisle
  • 757,742
tchakravarty
  • 2,427
  • 3
  • 26
  • 45
  • 6
    I gather (pun intended) that you're considering these two setups because they let you assign a single equation number to each equation pair. Note that the setup of both groups, as stated in the MWE, is currently overkill because you could actually replace all gather and align instances with equation and get the exact same outcome. To really get a chance to distinguish between the pros and cons of the two setups, you need to make their structures a bit richer. (Currently, there's really not enough there to distinguish between them.) Please consider editing your MWE accordingly. – Mico Jul 19 '12 at 15:01
  • 1
    Actually, the 2nd example would work just fine without split, and as @Mico says, the 1st one can use simple equation instead of gather. – yo' Jul 19 '12 at 16:22
  • 1
    @tohecz Without split both lines would be numbered. – egreg Jul 19 '12 at 20:06
  • @AdorableCreature "recent changes" (To the AMS alignments??) – David Carlisle Dec 30 '12 at 00:39
  • @DavidCarlisle: recent changes refer to my comment in egreg's answer. – kiss my armpit Dec 30 '12 at 01:53

2 Answers2

29

For the example alignment the following are equivalent; actually, the correct outer environment to use is equation, as the following code will show; using split or aligned for the inner environment in this case doesn't matter.

\documentclass{article}
\usepackage{amsmath,lipsum,geometry}
\geometry{margin=1cm}
\begin{document}
%\thispagestyle{empty}

\lipsum*[2]
%==================
% equation+aligned
\begin{equation}\tag{EA}
\begin{aligned}
x &= a + b\\
y &= c+ d
\end{aligned}
\end{equation}
\lipsum*[2]
%==================
% equation+split
\begin{equation}\tag{ES}
\begin{split}
x &= a + b\\
y &= c+ d
\end{split}
\end{equation}
\lipsum*[2]
%==================
% gather+aligned
\begin{gather}\tag{GA}
\begin{aligned}
x &= a + b\\
y &= c+ d
\end{aligned}
\end{gather}
\lipsum*[2]
%==================
% gather+split
\begin{gather}\tag{GS}
\begin{split}
x &= a + b\\
y &= c+ d
\end{split}
\end{gather}
\lipsum*[2]
%==================
% align+split
\begin{align}\tag{AS}
\begin{split}
x &= a + b\\
y &= c+ d
\end{split}
\end{align}
\lipsum*[2]
%==================
% align+aligned
\begin{align}\tag{AA}
\begin{aligned}
x &= a + b\\
y &= c+ d
\end{aligned}
\end{align}
\lipsum*[2]

\end{document}

In the output it's possible to see that the correct spacing is obtained with equation. Use align or gather only when there is really more than one equation to number.

One should also note that "equation+split" results in a different vertical spacing than "equation+aligned" (which isn't really expected).

enter image description here

Mars
  • 1,086
egreg
  • 1,121,712
  • 2
    So far, this is my definite guide concerning spacing around displayed math. Why is this stuff not explained somewhere? I checked amsldoc.pdf, Mathmode.pdf, and mathtools.pdf (\SwapAboveDisplaySkip), but no explanation anywhere... – mafp Dec 28 '12 at 19:33
  • aligned needs the easy-to-forget prefix \!. – kiss my armpit Jan 18 '14 at 01:55
  • What happens if one wants to tag / label multiple lines? The natural approach would be to use align, but then the spacing is inconsistent with equation... –  Dec 27 '16 at 17:45
5

split can still work with narrow spaces while aligned cannot!

enter image description here

\documentclass{article}
\usepackage[a6paper,margin=1cm,showframe]{geometry}
\usepackage{pst-node,multido}
\usepackage{amsmath}
\begin{document}
\multido{\n=0.5+0.1}{4}{%
\endgraf\noindent\pnode(.5\linewidth,0){T}
%
\begin{equation*}\!
\begin{aligned}
\framebox[\n\linewidth]{aligned \n}
\end{aligned}\tag*{Def}
\end{equation*}
%
\begin{equation*}
\begin{split}
\framebox[\n\linewidth]{split \n}
\end{split}\tag*{Def}
\end{equation*}
%
\endgraf\noindent\pnode(.5\linewidth,0){B}
\psset{linecolor=blue}
\ncline{T}{B}
\pcline[nodesep=-\dimexpr\n\linewidth/2](B)(B)}
\end{document}
  • 4
    What are we supposed to see here? – mafp Apr 17 '13 at 10:33
  • @mafp: It should be obvious. – kiss my armpit Apr 17 '13 at 10:40
  • 2
    No, I don't see it. You say aligned does not work, but the picture looks OK to me. – mafp Apr 17 '13 at 11:30
  • 1
    @mafp: With aligned the wider box is not properly aligned. – kiss my armpit Apr 17 '13 at 11:34
  • 2
    This might very well be a feature, to have sufficient space between content and tag. – mafp Apr 17 '13 at 11:36
  • I see it, but I don't understand it. What is it in the code that's causing the left-right shift in the last example? The entire example includes a very large number of unfamiliar expressions, making it difficult to understand by non-experts (and maybe some experts as well). "Unfamiliar": I admit that lots of cool LaTeX tricks are unfamiliar to me, but I do know enough to know that there's a lot here that would be unfamiliar to most users. – Mars Mar 03 '18 at 17:42