[Tex/LaTex] Aligning Systems of Equations

alignmath-mode

I'm trying to line up the variables of systems of equations. The following code:

$$\left\\{
\begin{aligned}
&\alpha + 2&\beta + &\gamma & = 0 \\\\
3&\alpha + 7&\beta + 5&\gamma & = 1
\end{aligned}
\right.$$

produces the following image:

enter image description here

I want the Greek letters and the math symbols to be aligned, with appropriate spacing in between coefficients. I've tried using \begin{aligned} \end{aligned} and \begin{array}{ll} \end{array}{ll} as well, but they also don't provide the desired outcome.

Would anyone be kind enough to help me out? Thank you.

Best Answer

First of all, do not use $$ ... $$, which is plain TeX, use the LaTeX construct [ ... \].

Second, 4 alignment points require 7 ampersands, not 4: each new column of alignment has to be introduced by an ampersand. So n alignment points require 2n–1 ampersands.

Last: use alignat (or alignedat) to have full control on the spacing between columns of alignment.

Here is a possible code:

\[ \left\{
\begin{alignedat}{4}
&\alpha &{} + 2&\beta + {} & &\gamma & & = 0 \\\\
3&\alpha &{} + 7&\beta + 5 & &\gamma & & = 1
\end{alignedat}

However, using the systeme package makes it simpler to type:

\[ \systeme[\alpha\beta\gamma]{\alpha + 2\beta +\gamma = 0, 3\alpha + 7\beta + 5\gamma = 1} \]

enter image description here

Related Question