22

I'd like to have multiple lines inside a single align cell like so:

\begin{alignat*}{1}
= & \begin{split}x+\\
y\end{split}
\end{alignat*}

But I get an error like:

 \end{alignat*}

\An extra & here is so disastrous that you should probably exit
 and fix things up. 

What's the correct way to achieve this?

2
  • Why do you want to use split inside alignat? Oct 4, 2010 at 23:51
  • I am showing a series of steps in modifying an equation and one of the steps produces a very long expression which I'd like to wrap around.
    – Gus
    Oct 5, 2010 at 1:00

3 Answers 3

18

I don't know what you are trying to achieve. Your error message can be bypassed if you either increase the number of reference points in the alignat

\begin{alignat*}{2}
= & \begin{split} x+ \\
y\end{split}
\end{alignat*}

or if you use aligned instead of split

\begin{alignat*}{1}
= & \begin{aligned} x+ \\
y\end{aligned}
\end{alignat*}

With split, it tries to anchor its & to line up with the ones outside (so multiple splits inside one equation will line up). So implicitly you need one extra reference point if you use split inside alignat, which is just a glorified array. (I'm doing a horrible job explaining this, am I not?) aligned doesn't try to do that (two aligned blocks inside one equation won't line up), and so you can get by with just one reference point.

In anycase, either of this sets the broken expression x+y as one unit to the right, vertically centered, against the = sign, which I suspect may not be what you want. If you want the = to line up with the x+ and with the y in a line below, you should take Lev's suggestion.

1
  • Thank you for explaining the previously mysterious error message!
    – Gus
    Oct 5, 2010 at 1:01
16

It's not clear what effect you're trying to achieve, but it is certainly possible to use split inside align, for example:

\begin{align}
  x &= a+b\\
  \begin{split}
  y &= a - b\\
    &\quad +c-d\\
    &\quad +e+f
  \end{split}\\
  z &= e-a
\end{align}
3
  • Thanks, this is exactly the effect I wanted to achieve. Unfortunately, LyX's instant preview is incorrect for this, but it does render correctly.
    – Gus
    Oct 5, 2010 at 1:07
  • 2
    It works but it seems to have a problem if you use a second ampersand or double ampersands for additional alignment.
    – Konstantin
    Dec 16, 2016 at 14:29
  • @Konstantin any fix found?
    – kando
    Jul 15, 2017 at 17:00
0

maybe that will help ... 2 columns and 4 equations but only 3 are numbered (2 of them got 1 number between them)

\begin{align}
  x &= a+b &x &=b\  \begin{split}
  y &= a - b\\
    &\quad +e+f
  \end{split}
    &
  \begin{split}
  x &= a - b\\
    &\quad +e+f
  \end{split}  \  z &= e-a &x &=b
\end{align}     
1

You must log in to answer this question.

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