[Tex/LaTex] How to get curly brace, alignment and separator line in the same equation

bracketsmath-modepositioning

enter image description here

Hi,

I already know how to get curly brace and alignment.

\[
\left\{
\begin{aligned}
8x + 6y &= 4 \\
-15x - 6y &= -3
\end{aligned}
\right.
\]

The problem is how to draw separator or sum line and how to continue alignment with side note.

Best Answer

Here I do some stacking. I had to introduce \xlu to achieve underlining on tabbed fields.

EDIT: I create \twobrak[text] as a stackable 2-row bracket element, that can be incorporated into the tabular stack.

\documentclass{article}
\usepackage{tabstackengine}
\def\xlu#1{\setbox0=\hbox{$#1{}$}%
  \stackunder[.4\baselineskip]{#1{}}{\protect\rule{\wd0}{.5pt}}%
}
\newcommand\twobrak[1][]{\raisebox{.5\dimexpr\Lstackgap}{\mbox{#1}\ttwobrak}}
\savestack\ttwobrak{$\left\{\Centerstack{\\}\right.$}
\stackMath
\setstackgap{L}{1.2\baselineskip}
\def\stacktype{L}
\setstacktabulargap{0pt}
\begin{document}
\[\TABbinary
  \tabularLongunderstack{rrl}{
            8x&        + 6y = & 4\\
    \twobrak\xlu{-15x}& \xlu{{}- 8y =}& \xlu{-3}\\
           -7x&           =   &  1\qquad\qquad\vert:(-7)\\
              &           x = & {-}1/7
  }%
\]
\end{document}

enter image description here

If one wanted a [hybrid-]right alignment on the last column, then try this:

\documentclass{article}
\usepackage{tabstackengine}
\def\xlu#1{\setbox0=\hbox{$#1{}$}%
  \stackunder[.4\baselineskip]{#1{}}{\protect\rule{\wd0}{.5pt}}%
}
\newcommand\twobrak[1][]{\raisebox{.5\dimexpr\Lstackgap}{\mbox{#1}\ttwobrak}}
\savestack\ttwobrak{$\left\{\Centerstack{\\}\right.$}
\stackMath
\setstackgap{L}{1.2\baselineskip}
\def\stacktype{L}
\setstacktabulargap{0pt}
\begin{document}
    \[\TABbinary
      \tabularLongunderstack{rrrl}{
                8x&        + 6y = & 4&\\
        \twobrak\xlu{-15x}& \xlu{{}- 8y =}& \xlu{-3}&\\
               -7x&           =   &  1&\qquad\qquad\vert:(-7)\\
                  &           x = \rlap{$-1/7$}& &
      }%
    \]
\end{document}

enter image description here

Based on my answer at What is the most elegant way to get a diagram showing elimination method to solve simultaneous equations?


Follow up:

The introduction of \twobrak[] allows a larger stack with multiple bracketed elements in a single stack.

\documentclass{article}
\usepackage{tabstackengine}
\def\xlu#1{\setbox0=\hbox{$#1{}$}%
  \stackunder[.4\baselineskip]{#1{}}{\protect\rule{\wd0}{.5pt}}%
}
\stackMath
\setstackgap{L}{1.2\baselineskip}
\def\stacktype{L}
\setstacktabulargap{0pt}
\newcommand\twobrak[1][]{\raisebox{.5\dimexpr\Lstackgap}{\mbox{#1}\ttwobrak}}
\savestack\ttwobrak{$\left\{\Centerstack{\\}\right.$}
\begin{document}
\[\TABbinary
\tabularLongunderstack{rrll}{
x        & - 2y =         & 13              &                \\
\twobrak[some text] 3x       & + y  =         & 4 \qquad\qquad  & \vert ~\cdot 2 \\
         &                &                 &                \\
x        & - 2y =         & 13              &                \\
\twobrak[more text]\xlu{6x} & \xlu{{}+ 2y =} & \xlu{8}         &                \\
7x       & =              & 21 \qquad\qquad & \vert:7        \\
         & x =            & 3               &
}
\]
\end{document}

enter image description here