7

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! =)

2 Answers 2

6

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.

3
  • Yeah, I thought about using an array but I hoped for an align solution. But I think that's fine! Thank you for your quick response, Herbert! As for the TikZ-Node, I know I need a node, but everytime I try it, it's just a simple straight arrow or it bends over the equation. I couldn't figure out how to make an soft S-like shape...
    – Cheesey
    May 4, 2014 at 9:08
  • 1
    I think you can replace \phantom{\,-\,c\,} and \phantom{\,-\,2b\,} with \phantom{{}-c} and \phantom{{}-2b}, respectively.
    – Mico
    May 4, 2014 at 10:06
  • @Mico: yes, that's makes more sense.
    – user2478
    May 4, 2014 at 16:10
4

\cline is not supported by the amsmath environments. \cline ends a line to move back its height. But the ending of the line triggers code in amsmath that is used for measurements etc.

A hacky workaround would be:

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newcommand*{\StrutboxHeight}{\ht\strutbox@}
\newcommand*{\StrutboxDepth}{\dp\strutbox@}
\makeatother

\begin{document}
\begin{alignat*}{14}
    12a     &+ 4b       &&+ c   &&={}& -3   &\qquad&    12a     &+ 2b
 &&={}& 0    &\\
    -27a    &- 6b   &&- c       &&={}& 0    &\qquad&    -15a    &- 2b
    -&&={}& -3 & \\
  \noalign{\vskip-\StrutboxHeight}
  \cline{1-7}
  \noalign{\vskip\arrayrulewidth\vskip-\baselineskip}
  \cline{9-13}
  \noalign{\vskip-\StrutboxDepth}
    -15a    &- 2b   &&          &&={}& -3   &\qquad&    -3a     &
    -&&={}& -3 &\\
            &       &&          &&{}&       &\qquad&            &
 &a&={}& -1  &
\end{alignat*}
\end{document}

Result

2
  • You may have some unneeded minus signs in the set of equations on the right.
    – Mico
    May 4, 2014 at 10:09
  • This looks also quite nice, and it's still in alignat. I don't like using arrays for equations, but I want to keep my LaTeX file as clean and hackfree as possible. But thanks for your solution as well =)
    – Cheesey
    May 4, 2014 at 10:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.