2

I am trying to type up some linear algebra notes and I am trying to show the vertical addition of 2 equations. Right now I have

\begin{flalign*}
    && \cancel{6u} + v &= 5 && \\
    && + \quad -\cancel{6u} + 4v &= -10 && \\
    && \line(1,0){65} & \line(1,0){35}&& \\
    && 5v &= -5 &&
\end{flalign*}

which produces this result

enter image description here

which works for me, but the spacing of the line is just a little too much. Any advice on how to lessen the gap from the line would be greatly appreciated!

2 Answers2

2

Use an array to construct the addition:

enter image description here

\documentclass{article}
\usepackage{cancel,array}
\begin{document}
\[
  \begin{array}{c@{\quad}r@{}>{{}}c<{{}}@{}r@{}>{{}}c<{{}}@{}r}
      &  \cancel{6u} & + &  v & = &   5 \\
    + & -\cancel{6u} & + & 4v & = & -10 \\
    \hline
      &              &   & 5v & = &  -5
  \end{array}
\]
\end{document}

You can adjust the inter-equation spacing using some of the row-padding techniques in Column and row padding in tables.

Werner
  • 603,163
1

Since what you had almost "works for you," all I did to your MWE was to add optional spacing modifiers to your \\ macros. That and a few \phantoms.

\documentclass{article}
\usepackage{amsmath,cancel}
\begin{document}
\begin{flalign*}
    && \cancel{6u} + \phantom{0}v &= \phantom{-0}5 && \\
    && + \quad -\cancel{6u} + 4v &= -10 && \\[-12pt]
    && \line(1,0){65} & \line(1,0){35}&& \\[-4pt]
    && 5v &= \phantom{0}{-}5 &&
\end{flalign*}
\end{document}

enter image description here