[Tex/LaTex] Writing a system of Linear Equations

alignat

I found this program and I was wondering how can I add on a left brace as in the systeme package or in the cases environment? Also is it possible to left align the right-hand side of the equal sign ?

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{alignat*}{4}
   2x & {}+{} &  y & {}+{} & 3z & {}={} & 10 \\
    x & {}+{} &  y & {}+{} &  z & {}={} &  6 \\
    x & {}+{} & 3y & {}+{} & 2z & {}={} & 13
\end{alignat*}
\end{document}

Best Answer

The \begin{alignat*}{4}[left = \empheqlbrace] solution which you employ in your own answer requires hand-editing "& 6" to "& 6\phantom{0}" in order to generate the appearance of left-alignment in the final column.

If that's too tedious and/or error-prone, do also consider the \systeme- and array-based solutions shown below.

Note that the three solutions produce the exact same output. In the end, then, your decision should be based mainly on the convenience of the input process. In my opinion, the input convenience of the systeme method is hard to beat. For sheer flexibility, though, the array-based method must be tops; however, its input overhead does exceed that of the systeme approach (and is roughly on par with the empheq appoach).

enter image description here

\documentclass{article}
\usepackage{amsmath}          % for Solution 1
\usepackage[overload]{empheq} % for Solution 2
\usepackage{systeme}          % for Solution 3
\usepackage{array}            % for Solution 4
\newcolumntype{C}{>{{}}c<{{}}} 

\begin{document}
%% Solution 1: use 'alignat*'
\begin{alignat*}{4}
   2x & {}+{} &  y & {}+{} & 3z & {}={} & 10 \\
    x & {}+{} &  y & {}+{} &  z & {}={} &  6 \\
    x & {}+{} & 3y & {}+{} & 2z & {}={} & 13
\end{alignat*}

%% Solution 2: use 'empheq' machinery and a '\phantom' directive
\begin{alignat*}{4}[left = \empheqlbrace]
   2x & {}+{} &  y & {}+{} & 3z & {}={} & 10 \\
    x & {}+{} &  y & {}+{} &  z & {}={} &  6\phantom{0} \\ % <-- note "\phantom{0}"
    x & {}+{} & 3y & {}+{} & 2z & {}={} & 13
\end{alignat*}

%% Solution 3: use 'systeme' machinery
\[
\systeme{2x+y+3z=10, x+y+z=6, x+3y+2z=13}
\]

%% Solution 4: use the basic 'array' machinery
\[
\setlength\arraycolsep{0pt}
\renewcommand\arraystretch{1.25}
\left\{
\begin{array}{*{3}{rC}l}
   2x & + &  y & + & 3z & = & 10 \\
    x & + &  y & + &  z & = &  6 \\
    x & + & 3y & + & 2z & = & 13
\end{array}
\right.
\]
\end{document}
Related Question