# Align works well everywhere but at plus sign

I've tried aligning a linear system using this code:

\left\{ \begin{aligned} &a_{11}x_1 & + & &a_{12}x_2 & + & &a_{13}x_3 & = & &b_1 \\ & & & &a_{22}x_2 & + & &a_{23}x_3 & = & &b_2 \\ & & & & & & &a_{33}x_3 & = & &b_3 \end{aligned} \right.


Everything works well, except for those two plus signs, as you can see: can someone explain me why?

The root of the issue is the way the columns are align in the aligned structure: rlrlrlr ....

To synchronized the alignment two & are needed before the second + sign

\documentclass{article}

\usepackage{amsmath}
\begin{document}

\left\{ \begin{aligned} &a_{11}x_1 & + & &a_{12}x_2 & + & &a_{13}x_3 & = & &b_1 \\ & & & &a_{22}x_2 & + & &a_{23}x_3 & = & &b_2 \\ & & & & & & &a_{33}x_3 & = & &b_3 \end{aligned} \right.

\left\{ \begin{aligned} &a_{11}x_1 & + & &a_{12}x_2 && + & &a_{13}x_3 & = & &b_1 \\ & & & &a_{22}x_2 && + & &a_{23}x_3 & = & &b_2 \\ & & & & && & &a_{33}x_3 & = & &b_3 \end{aligned} \right.

\end{document}


See the nice answer align is a table-like structure

• The spacing around all the operators and relations are wrong/off.
– Werner
Apr 25 at 4:35
• @Werner I answered the why of the question. Sandy G is the right answer. Apr 25 at 21:04

Depending on your desired look, you can just align once at the = signs and let the natural math spacing of LaTeX take care of the rest:

\left\{ \begin{aligned} a_{11}x_1 + a_{12}x_2 + a_{13}x_3 & = b_1 \\ a_{22}x_2 + a_{23}x_3 & = b_2 \\ a_{33}x_3 &= b_3 \end{aligned} \right.


I have worked out a solution with the array package.

\documentclass{scrarticle}

\usepackage{amsmath}
\usepackage{array}

\begin{document}
\begin{equation*}
\left\{
\begin{array}{ccccccc}
a_{11}x_{1} & + & a_{12}x_{2} & + & a_{13}x_{3} & = & b_1 \\
& & a_{22}x_{2} & + & a_{23}x_{3} & = & b_2 \\
& & & & a_{33}x_{3} & = & b_3
\end{array}
\right.
\end{equation*}
\end{document}


The output looks like this If you insist on doing it with the aligned environment, this is no solution for you. But like you I often struggled with it and someone on here suggested the array package and I liked it, maybe you will too.

You can use alignedat instead, or \systeme.

\documentclass{article}
\usepackage{amsmath}
\usepackage{systeme}% for the second solution

\begin{document}

\left\{ \begin{alignedat}{3} a_{11}x_1 & +{} & a_{12}x_2 & +{} & a_{13}x_3 & = b_1 \\ & & a_{22}x_2 & +{} & a_{23}x_3 & = b_2 \\ & & & & a_{33}x_3 & = b_3 \end{alignedat} \right.

$\syssubstitute{{A}{a_{11}}{B}{a_{12}}{C}{a_{13}}{D}{a_{22}}{E}{a_{23}}{F}{a_{33}}} \systeme{ Ax_1 + Bx_2 + Cx_3 = b_1, Dx_2 + Ex_3 = b_2, Fx_3 = b_3 }$

\end{document}


• Can you please say what is the significance of {} after + in the alignedat environment? Apr 22 at 23:59
• Apr 23 at 3:45
• {} works also in the aligned environment. Apr 23 at 4:34
• @M.Logic But the spacing is wrong Apr 23 at 7:53

Here is a solution using the IEEEeqnarraybox environment from the IEEEtrantools (Appendix F of the documentation) package. This tutorial on typesetting equations also demonstrates the usage of the IEEEeqnarray environment.

\documentclass{article}

\usepackage{IEEEtrantools}

\begin{document}
$\left\{ \begin{IEEEeqnarraybox}[\relax][c]{;r'r'r'r'r'C'l} a_{11}x_1 &+& a_{12}x_2 &+& a_{13}x_3 &=& b_1 \\ & & a_{22}x_2 &+& a_{23}x_3 &=& b_2 \\ & & & & a_{33}x_3 &=& b_3 \IEEEstrut \end{IEEEeqnarraybox} \right.$
\end{document}


The separation between columns can be changed by using different glue types. Here I have used the ; glue (inserts 5/18em space) between the { and the 1st column and ' glue (inserts 1em space) between other columns. For other glue types, please refer to the documentation.

As @daleif comments, the problem could be solved easily by add a {} before & which could protect the space around symbols near &. By the way the codes could be simplified and rewritten as follows:

\left\{ \begin{aligned} a_{11}x_1 + a_{12}x_2 + {}&a_{13}x_3 = b_1 \\ a_{22}x_2 + {}&a_{23}x_3 = b_2 \\ {}&a_{33}x_3 = b_3 \end{aligned} \right.