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!

Printable View

- Jun 30th 2010, 07:07 AMroninproSystem of Linear Equations
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!

- Jun 30th 2010, 07:16 AMBacterius
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.`

- Jun 30th 2010, 02:53 PMwonderboy1953
- Jun 30th 2010, 07:54 PMBacterius
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 (Lipssealed)

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 ? - Jun 30th 2010, 09:57 PMroninpro
I did run a Google search before I posted this thread. I saw a few articles on the "alignat" environment, but it still wasn't quite what I wanted.

Messy stuff! - Jun 30th 2010, 11:16 PMProve It
How about...

Hmmm I guess it works differently in LaTeX... - Jul 1st 2010, 11:13 PMCaptainBlack
Use an array:

\begin{array}{ccccccccccc}

&x_1&+&2x_2&-&x_3& & &=& &2\\

& & &x_2&-&x_3&+&2x_4&=&-&3\\

-&x_1&-&2x_2&+&x_3&+&x_4&=&-&3\\

\end{array}

gives:

CB - Jul 2nd 2010, 02:27 AMProve It
- Jul 2nd 2010, 02:42 AMCaptainBlack
- Jul 2nd 2010, 05:04 AMProve It
- Jul 2nd 2010, 10:22 AMCaptainBlack
- Jul 2nd 2010, 12:40 PMOpalg
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.