1

I am using the amsmath package in latex to align three equations.

\begin{align*} 
&x_{1} - 3x_{2} + 4x_{3} = -4 \\
3&x_{1} - 7x_{2} + 7x_{3} = -8 \\
-4&x_{1} + 6x_{2} - x_{3} = 7  \\
\end{align*}

enter image description here

how do i get the output shown above to align each of the numbers in columns. I need all of the operands in the same spot and in my output the equal sign is way off.

thanks

Salim Bou
  • 17,021
  • 2
  • 31
  • 76

1 Answers1

2

The systeme package does this in a very pretty way:

\documentclass{article}
\usepackage{amsmath}
\usepackage{systeme}

\begin{document}

\[
\systeme{
   x_{1} - 3x_{2} + 4x_{3} = -4,
  3x_{1} - 7x_{2} + 7x_{3} = -8,
 -4x_{1} + 6x_{2} -  x_{3} = 7
}
\]

\end{document}

enter image description here

If you search on the site for systeme, you'll find several other examples.

For instance, in order to have the constant terms flush right, you can look at Is it possible to flushright the right-hand side with systeme without \hphantom?

\documentclass{article}
\usepackage{amsmath}
\usepackage{systeme}
\usepackage{regexpatch}

\makeatletter
\xpatchcmd{\SYS@makesyspreamble@i}
  {$##$\hfil\null}% left alignment
  {\hfil$##$\null}% right alignment
  {}{}
\makeatother

\begin{document}

\[
\systeme{
   x_{1} - 3x_{2} + 4x_{3} = -4,
  3x_{1} - 7x_{2} + 7x_{3} = -8,
 -4x_{1} + 6x_{2} -  x_{3} = 7
}
\]

\end{document}

enter image description here

egreg
  • 1,121,712
  • thanks for the help but the 7 needs to be lined up with the other items in the column that have a negative sign. how could i do this? – user3095790 Feb 03 '16 at 22:37
  • @user3095790: Use \phantom{-}7. – Werner Feb 03 '16 at 22:42
  • @user3095790 As I said, looking for systeme in the site gives an answer. – egreg Feb 03 '16 at 22:43
  • is there any way to display it without the brackets in front of the equations? – user3095790 Feb 03 '16 at 22:47
  • @user3095790 If you never want the brace, add \sysdelim{.}{.} in the preamble; or you can do it locally by placing the same command between \[ (or \begin{equation}) and \systeme; in this case it will hold only for the next system. – egreg Feb 03 '16 at 22:52