8

I'm using aligned inside align as follows


\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
x =&22+2 \nonumber\\
  =& \begin{aligned}[t]
    &5+3\\
    &-3+4\\
    &+15-0
  \end{aligned}
\end{align}
\end{document}

I want to have just one equation number after the very last line. However, I'm getting the number at the beginning of the first split line (after the second = ),

and I cannot figure out how to move this equation number to the bottom. Any help will be appreciated.

  • 1
    Note that you need to use &=, not =&. – Werner Apr 10 '15 at 17:03
  • 1
    \begin{aligned}[t]--->\begin{aligned}[b] – touhami Apr 10 '15 at 17:11
  • Actually, the way the OP is trying to use aligned can only put the equation number on the same line as the equals sign. At least one of them will be misplaced. See below for a solution. – Niel de Beaudrap Apr 10 '15 at 17:20
8

You may want to use split, along with the tbtags option to amsmath.

\documentclass{article}
\usepackage[tbtags]{amsmath}

\begin{document}

\begin{equation}
\begin{split}
x ={} & 22+2 \\
  ={} &5+3\\
      &-3+4\\
      &+15-0
\end{split}
\end{equation}

\end{document}

enter image description here

If you want two numbers, then use split inside align: the alignment point will be inherited in the inner environment:

\documentclass{article}
\usepackage[tbtags]{amsmath}

\begin{document}

\begin{align}
x ={} & 22+2 \\
\begin{split}
  ={} & 5+3\\
      &-3+4\\
      &+15-0
\end{split}
\end{align}

\end{document}

enter image description here

| improve this answer | |
  • This looks as though it would be handy in simple use-cases in documents where you want to have good numbering either on the left or on the right (e.g. in conjunction with leqno). – Niel de Beaudrap Apr 10 '15 at 20:32
  • @NieldeBeaudrap Yes: tbtags places equation tags/numbers at the bottom of a split if they are at the right, or at the top if they are at the left (leqno). – egreg Apr 10 '15 at 20:34
  • Would you recommend any techniques for answering the OP's follow up question (in a comment on my answer: "what would be the best way then to have a number on the first line as well")? – Niel de Beaudrap Apr 10 '15 at 20:49
  • @NieldeBeaudrap Yes, I would. ;-) – egreg Apr 10 '15 at 20:57
  • [slaps head] Well, that should have been obvious! @LuisFelipe: I recommend you accept this answer instead. – Niel de Beaudrap Apr 10 '15 at 22:20
2

I would change the way that you're using aligned: specifically, if there's no equation number on the first line, you should lump in the first line with the rest of the material in the aligned environment, with the [b] option to get the alignment of the equation number with the bottom line, as follows.

(Note the usage of ={}& which ensures proper spacing around the = symbol, while aligning everything on the RHS fully to the right of the = sign. The aligned environment assumes that the = sign usually comes after the &, and does some maniuplation of space to do so: having an empty group to enforce \mathrel spacing around the =, before the &, has a similar effect.)

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\begin{aligned}[b]
    x
={}&
    22 + 2
\\={}&
    5+3
\\&
   -3+4
\\&
   +15-0
\end{aligned}
\end{equation}
\end{document}

Edited equation putting all content into the <code>aligned</code> environment

| improve this answer | |
  • Now, what would be the best way then to have a number on the first line as well? – Luis Felipe Apr 10 '15 at 17:54
  • @LuisFelipe: I don't have as clever a trick for that. My solution would be \begin{align} x ={}& 22 + 2 \\={}& 5+3 \notag\\& -3+4 \notag\\& +15-0 \end{align} (note the use of \notag before each line break which is not meant to generate an equation number). – Niel de Beaudrap Apr 10 '15 at 17:57
  • Yes, that would be the most straightforward solution for that. Thank you! – Luis Felipe Apr 10 '15 at 18:03
0

Another way to do the same is the following

\documentclass{article}
\usepackage{amsmath}

\begin{document}
%------------------------------
%-- Use of \hspace with same set length
%------------------------------
x &= 22+2 \nonumber\\
&= 5 + 3 \nonumber\\
& \hspace{5mm} -3 + 4 \nonumber\\
& \hspace{5mm} + 15 - 0 \\
%------------------------------
%-- Use of phantom
%------------------------------
&= 5 + 3 \nonumber\\
& \phantom{{} = {}} -3 + 4 \nonumber\\ 
& \phantom{{} - {}} + 15 - 0 \\
%------------------------------
%-- Use of \hspace for various lengths
%------------------------------
&= 5 + 3 \nonumber\\
& \hspace{15mm} - 3 + 4 \nonumber\\
& \hspace{30mm} + 15 - 0

\end{document}

Three variations

| improve this answer | |
  • Wouldn't \phantom{{}={}} be better to get the exact spacing? – Niel de Beaudrap Apr 10 '15 at 20:09
  • @NieldeBeaudrap Using phantom spacing still lines the values on the right side of the = mark. As the OP's work looks and shift is needed from the first position. By using \hspace any amount of space can be placed to shift the start of the line. – Leucippus Apr 10 '15 at 20:16
  • To clarify what I meant, I mean e.g. &\phantom{{}={}} -3 + 4 \nonumber\\ . This will still shift the material on the RHS to the right of the equality symbol, and furthermore will do it by exactly the right amount, by construction. – Niel de Beaudrap Apr 10 '15 at 20:27
  • As demonstrated in the updated code and output: \phantom is similar to use of \hspace{5mm}, but an advantage of \hspace is variation – Leucippus Apr 10 '15 at 20:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.