[Tex/LaTex] Multiple \cline{x-y} in align environment for subtracting equations

alignalignatequations

I'm trying to make a solution sheet for a student of mine and want to write it in a similar way as I would do when writing per hand. In this case I wanted to have 4 columns of equations (I know that in reality there are 14 columns in the align environment).
My code looks like this:


\begin{alignat*}{14} 
    12a     &+ 4b       &&+ c   &&={}& -3   &\qquad&    12a     &+ 2b   &&={}& 0    &\\
    -27a    &- 6b   &&- c       &&={}& 0    &\qquad&    -15a    &- 2b   &&={}& -3   &\\[-1.2em]
    \cline{1-7} \\[-2.5em]
    -15a    &- 2b   &&          &&={}& -3   &\qquad&    -3a     &       &&={}& -3   &\\
            &       &&          &&{}&       &\qquad&            &       &a&={}& -1  &
\end{alignat*}

result without second cline


\begin{alignat*}{14} 
    12a     &+ 4b       &&+ c   &&={}& -3   &\qquad&    12a     &+ 2b   &&={}& 0    &\\
    -27a    &- 6b   &&- c       &&={}& 0    &\qquad&    -15a    &- 2b   &&={}& -3   &\\[-1.2em]
    \cline{1-7} \cline{9-13}\\[-2.5em]
    -15a    &- 2b   &&          &&={}& -3   &\qquad&    -3a     &       &&={}& -3   &\\
            &       &&          &&{}&       &\qquad&            &       &a&={}& -1  &
\end{alignat*}

result with second cline


I want to have \cline{1-7} \cline{9-13} without a line break, I want them to be in the same line. Is that possible with align or alignat?

Furthermore I tried to make a tikz-arrow in a soft S-shape from the end of the last line in column #1 to the start of the second line of column #2, but failed. So if you are skilled with that kind of thing, I'd really appreciate your help! =)

Best Answer

I'd use a simple array environment:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\[\arraycolsep=1.4pt\def\arraystretch{1.3}
\begin{array}{rcr p{1cm} rcr} 
    12a + 4b + c  &=& -3    &&     12a + 2b  &=&  0 \\
   -27a - 6b - c  &=&  0    &&    -15a - 2b  &=& -3 \\
    \cline{1-3} \cline{5-7}
    -15a - 2b \phantom{\,-\,c\,} &=& -3  & &     -3a  \phantom{\,-\,2b\,} &=& -3  \\
                           & &      &&                     a  &=& -1  
\end{array}
\]

\end{document}

enter image description here

For the arrow you can define two nodes with TikZ or PSTricks.

Related Question