I am interested in typesetting a system of linear equations in a manner demonstrated below. I'm having quite a bit of trouble getting everything to line up. Any suggestions would be appreciated!
Hello,
interesting question. I know how to get the equations lined up on the "equals" sign, but I never tried to line up every term to a respective position. It doesn't work by using the & symbol repeatedly. Perhaps looking into the array environment, but this would be quite limited and ugly I guess. I'll browse the internet.
By the way, did you know it was possible to draw a smooth bracket in front of the system (so as to say it is a system), as follows :
Code:\left \{ the system \right.![]()
Yeah but that would be kind of limited and not exactly good looking would it ? Furthermore what if some variable has a two-digit coefficient in front of it, would you put 00 in front of the missing variables just to keep the alignement ? Not to mention that some numbers are larger than others ...
I'm pretty sure there is a special environment designed for this type of equations but I can't remember the name
If you are really desperate and don't have any keywords on Google you can still try looking at random mathematical papers (algebraic perhaps) and see how the authors did it in their paper by looking at the tex file ?
You can leave spaces in such a way as to align the various terms by using the \phantom command.
\begin{aligned}
x_1 + 2x_2 - x_3 \phantom{{}+2x_4} &= \phantom{-}2, \\
x_2 - x_3 + 2x_4 &= -3, \\
-x_1 - 2x_2 + x_3 + \phantom{2}x_4 &= -3.
\end{aligned}
Edit. I see that Prove_It has already suggested using \phantom. But if you do so in the aligned environment rather than the array environment, then the spacing looks much better.