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

- June 30th 2010, 08: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!

- June 30th 2010, 08: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.`

- June 30th 2010, 03:53 PMwonderboy1953
- June 30th 2010, 08: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 ? - June 30th 2010, 10: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! - July 1st 2010, 12:16 AMProve It
How about...

Hmmm I guess it works differently in LaTeX... - July 2nd 2010, 12:13 AMCaptainBlack
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 - July 2nd 2010, 03:27 AMProve It
- July 2nd 2010, 03:42 AMCaptainBlack
- July 2nd 2010, 06:04 AMProve It
- July 2nd 2010, 11:22 AMCaptainBlack
- July 2nd 2010, 01: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.