# Alignment of multiple variables in a linear system

I am trying to lay out a few linear equations, but with the different variables aligned in columns like this:

x + y       = 1  }   x = 0
y + 2z  = 1  }   y = 1
x     +  z  = 0  }   z = 0


(with a single big left } )

I have tried everything, but cannot accomplish this elegantly (without tables). Any ideas what I might try?

Here is a picture of what I am trying to achieve:

-
Welcome to TeX.SX! I'm not sure this is the best way to display such a thing. – egreg Nov 12 '13 at 13:30
@egreg Let me tell you that my Precalculus textbook displays equation systems like this (albeit with much less spacing) – Cole Johnson Nov 16 '13 at 0:55

This is an intelligent solution with systeme package. Just type each term blindly, the package will arrange them automatically. For example, if you type 3z+y=10 in the first row, the term will be aligned as shown in the output image.

\documentclass[preview,border=12pt,varwidth]{standalone}
\usepackage{systeme,mathtools}
\begin{document}
\abovedisplayskip=0pt\relax% don't use this line in your production.
\sysdelim.\}\systeme{ 3z +y = 10, x + y + z = 6, 3y - z = 13} \quad \!\begin{aligned} x &= a\\ y &= b\\ z &= c \end{aligned}
\end{document}


-
Could you add a link to more info about systeme? It's not google-friendly. – Kundor Nov 13 '13 at 0:47
@Kundor look ctan.org/pkg/systeme – leo Nov 15 '13 at 15:36
How do you make this work without the big brace on the right? The documentation is in French. – Jeff Sep 7 '15 at 3:40

Here is one suggestion using environments from amsmath:

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{equation*}
\left.
\begin{alignedat}{4}
x & {}+{} & y &       &    & = 1 \\
&       & y & {}+{} & 2z & = 1 \\
x &       &   & {}+{} & z  & = 0
\end{alignedat}
\begin{aligned}
x &= 0\\
y &= 1\\
z &= 0
\end{aligned}
\end{equation*}

\end{document}


You might consider adding \ or \quad before \right\} to get more space before the brace.

-
you don't actually need the {} before an equal sign when it comes right after an & in any alignment (as in the first three lines) since it's always a binary relation. you do need them to indicate that a plus or minus isn't unary. – barbara beeton Nov 12 '13 at 13:43
@barbarabeeton Perfectly correct - they were left over from testing something else - I have removed them from the code. – Andrew Swann Nov 12 '13 at 13:51
Thanks, this is perfect! I am quite new to latex, would you mind explaining what the {} around the + is for? – aguywithsocks Nov 12 '13 at 14:11
@aguywithsocks they ensure the spacing aroung the + is ok. In this case {} are seen as so called empty atoms. To see the difference compare $+b$ to $a+b$, the spacings around + are different – daleif Nov 12 '13 at 14:36
@Jeff Sounds like you might have written align instead of aligned. If that is not the problem, ask a new question, posting your code. – Andrew Swann Mar 4 at 8:22

Just in case the amsmath isn't available to you, you can also use a couple of array environments for this type of thing

% arara: pdflatex

\documentclass{article}

\begin{document}

$\left. \begin{array}{r@{}r@{}r@{}r@{}r@{}r@{}} x & {}+{} & y & & & {}= 1 \\ & & y & {}+{} & 2z & {}= 1 \\ x & & & {}+{} & z & {}= 0 \end{array} \right\} \qquad \begin{array}{r@{}l} x &{}= 0\\ y &{}= 1\\ z &{}= 0 \end{array}$

\end{document}

-
It seems to me a bit weird if arara is available but amsmath is not available to you. – kiss my armpit Nov 12 '13 at 19:53
@Marienplatz lol, yes indeed :) but that's one of the beauties of arara- it won't interfere if it isn't available – cmhughes Nov 12 '13 at 20:15