289

I want the equation number to be shown only at the last line, or better, somewhere in the middle of all. So instead of (1), (2), ... only (1). I use \begin{align} ... \end{align}

1

4 Answers 4

270

You can use the split environment from the amsmath package:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{align}
\begin{split}
  a &= b \\
  &=c \\
  &=d \\
  &=e
\end{split}
\end{align}

\end{document}

effect of using split in align to avoid excess numbering

5
  • 141
    you could also simply put \nonumber at the end of each equation line for which you don't want an equation no. Commented May 6, 2011 at 1:44
  • 4
    You could also see this question: tex.stackexchange.com/questions/13396/…
    – Ryan Reich
    Commented May 6, 2011 at 2:04
  • 35
    @prettygully: if the number of lines is even, then \notag (or \nonumber) won't vertically center the tag. Commented May 6, 2011 at 2:06
  • 3
    @prettygully: I think you should also write your comment as an answer. @Gonzalo Medina: sometimes you want the number at the end, rather than centered; I often do so. (While the OP prefers centered, not everyone will.) Commented May 6, 2011 at 12:17
  • 9
    is there a simple way to adapt this solution for multiple alignment columns? It looks like \begin{align*}\begin{split} A &= B & C&= D \\ A &= B & C&= D \end{split}\end{align*} doesn't work.
    – phfaist
    Commented Aug 14, 2020 at 14:24
277

Use \nonumber to do so:

\begin{align}
  a & b \nonumber \\ % no number is shown
  c & d \\ % there is a number
  e & f \nonumber % no number
\end{align}

align output demonstrating use of \nonumber to avoid two of three lines getting numbered

4
  • 31
    What if I only have two lines?..
    – Cm7F7Bb
    Commented Jan 18, 2018 at 10:36
  • 2
    @Cm7F7Bb not sure if this is what you mean, but you can use \nonumber in an align environment with only two lines. Only the line without \nonumber ending it will have number in the output Commented Aug 18, 2020 at 19:47
  • 7
    @SkeletonBow - They presumably mean "how can I get the equation number vertically centered if there are only two lines (or any even number of lines)?". The split environment does this (but doesn't work with multiple alignment columns), but \nonumber does not. Commented Jul 6, 2021 at 13:58
  • 1
    It looks like \nonumber doesn't work within the \added{} command from the changes package.
    – Paul Wintz
    Commented Oct 11, 2021 at 2:06
33

You can use the aligned environment from the amsmath package:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{gather}
\begin{split}
  m &=n \\
    &=o \\
    &=p \\
    &=q
\end{split}\\
\begin{aligned}
  a &=b + 1 \\
  c &=d \\
  e &=f \\
  g &=h
\end{aligned}
\end{gather}

\end{document}

effect of gather with sub-structures using split and aligned on alignment and numbering

This is generally recommended for straightforward expressions rather than embedding a sub-structure within align. See the user's manual for amsmath (amsldoc.pdf on ctan or type texdoc amsmath if you have a tex live installation).

Edit: changed equation environment to gather to allow multiple sub-structures, and added an example of split as requested. Since single letters on either side of the equals sign will give the illusion that everything is aligned, I lengthened one line to show that the alignments of the two sub-structures are really offset from one another.

This result will get two equation numbers; either may be removed by use of \notag, but the positioning will not be optimal. Sadly, I don't have a solution for that.

3
  • 4
    Mildly ironic that in an answer to a question on alignment, you had an error in your code alignment! A case of misalliance (in tribute to Britain's answer to Tom Lehrer). Commented May 6, 2011 at 12:48
  • I think this is the right answer, but with the wrong example. To typeset a multi-line equation such as a = b = c = d = e, you should not use anything from the align family, but something like split. Could you perhaps change the example so that it is something like "a = b, c = d, e = f, g = h", so that it is clearly multiple equations that you want to align. This is not just semantics; there might be a difference in the vertical spacing, and you should use the right command for the right purpose. Commented May 6, 2011 at 12:59
  • This is exactly what I was looking for, something that has the nice symmetric labelling of split but also supports multiple columns like align. Commented Jun 27, 2019 at 18:18
16

I realize this question is now quite old, but I've found wrapping the nested equation/aligned in an environment handy since I want single numbers for multi-line equations quite a bit. One hitch is that LaTeX will add a space to the next line unless you do something about it. Here's an nalign environment that is like align but with one (centered) equation number for all the lines.

\newenvironment{nalign}{
    \begin{equation}
    \begin{aligned}
}{
    \end{aligned}
    \end{equation}
    \ignorespacesafterend
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .