8

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}
azetina
  • 28,884
MathScholar
  • 2,513

4 Answers4

11

You're overcomplicating things:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation} \left{ \begin{alignedat}{3} % R & L & R & L & R & L 2x & +{} & y & +{} & 3z & = 10 \ x & +{} & y & +{} & z & = 6 \ x & +{} & 3y & +{} & 2z & = 13 \end{alignedat} \right. \end{equation}

\end{document}

enter image description here

Of course one might also use systeme. The alignment in the codes below is not necessary, it's used just to ease the reading of the code itself.

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

\begin{document}

\begin{equation} \systeme{ 2x + y + 3z = 10, x + y + z = 6, x + 3y + 2z = 13 } \end{equation}

\end{document}

enter image description here

If one adds \sysalign{r,r} to the document preamble, the output would be

enter image description here

A different example motivated by Displaying linear equation (variable under variable)

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

\sysalign{r,r}

\begin{document}

\begin{equation} \systeme{ 3x_1 + 2x_2 - x_3 + x_4 = -1, 2x_1 - x_3 + 2x_4 = 0, 3x_1 + x_2 + 2x_3 + 5x_4 = 2 } \end{equation}

\end{document}

enter image description here

egreg
  • 1,121,712
10

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}
Mico
  • 506,678
  • Last night I by accident found another solution to your solution #2; namely place a double ampersand, &&, in the last ampersand column so it will be right-adjusted and no column space – MathScholar Sep 15 '19 at 12:51
  • I am thinking of using the tikzmark package with one of these solutions. Not sure if systeme will allow this though. – MathScholar Sep 15 '19 at 12:54
  • @MathScholar - I'm afraid I'm not familiar with TikZ and tikzmark. – Mico Sep 15 '19 at 15:39
3

Use \usepackage[overload]{empheq} in the preamble

Adding \begin{alignat*}{4}[left = \empheqlbrace] will get the left brace.

enter image description here

I still need to align the right-hand side of the equation to the left. Not sure if this idea is more versatile than the systeme package? Can anyone advise?

azetina
  • 28,884
MathScholar
  • 2,513
  • Are you answer your own question? and then have another question? If that is the case then edit your question and wait for someone to assist you. – azetina Sep 15 '19 at 03:04
  • I answered half of it! – MathScholar Sep 15 '19 at 03:09
  • 1
    Using \begin{equation*}\left\{\begin{alignedat}{4}<same code>\end{alignedat}\right.\end{equation*} would do without the need of empheq. – egreg Sep 15 '19 at 09:39
3

Adding another ampersand to the last column right-adjusts the column after the equal sign:

\documentclass{article}
\usepackage{amsmath}
\usepackage[overload]{empheq} 

\begin{document}
\begin{alignat*}{4}[left = \empheqlbrace]
   2x & {}+{} &  y & {}+{} & 3z & {}={} && 10 \\
    x & {}+{} &  y & {}+{} &  z & {}={} && 6  \\
    x & {}+{} & 3y & {}+{} & 2z & {}={} && 13
\end{alignat*}
\end{document}

enter image description here

MathScholar
  • 2,513