Aligning Systems of Equations

Something like this?

\documentclass{article}
\usepackage{tabstackengine}
\begin{document}
\[
\left\{
\setstackgap{L}{18pt}
\Matrixstack[r]{
\alpha  +& 2\beta +&  \gamma =& 0 \\
3\alpha +& 7\beta +& 5\gamma =& 1
}
\right.
\]
\end{document}

enter image description here


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


Here's a solution that requires only the basic array package. The following code also sets up a custom array-like environment.

enter image description here

\documentclass{article}
\usepackage{array} % for "\newcolumntype" macro
\newcolumntype{C}{>{{}}c<{{}}}
%% set up a little custom enrironment:
\newenvironment{myarray}[1]{%
   \setlength\arraycolsep{0pt}
   \left\{ \begin{array}{#1}}{%
   \end{array} \right.}

\begin{document}
\[
\begin{myarray}{rCrCrCl}
 \alpha &+& 2\beta &+&  \gamma &=& 0 \\
3\alpha &+& 7\beta &+& 5\gamma &=& 1
\end{myarray}
\]
\end{document}