1

I have the following equation system:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
 \begin{flalign*}
  \begin{array}{lllclllr}
   & 2x &-& 9y &+& 5 &=& 0\\
   -& 2x &+& 6y &+& 20 &=& 0\\[2pt]
   \hline\\[-2\baselineskip]
   &&& -15y &-& 15 &=& 0\\
   &&&&& y &=& -1
  \end{array}&&
 \end{flalign*}
\end{document}

enter image description here

How do I get rid of the extra space after the hline? I just want 2 points of vertical space there, like I have above it.

Removing the line break completely results in the following line being way to close to the \hline, and then adding hspace has no effect, whatever the magnitude.

Note. I am using flalign* for a reason. It has to do with the rest of my document.

1
  • Off-topic: You don't appear to be making use of any of the capabilities of the flalign* environment. To reduce code clutter, I suggest you replace \begin{flalign*} and \end{flalign*} with \[ and \], respectively.
    – Mico
    Commented Jul 15, 2023 at 6:06

2 Answers 2

2

Your \\ after \hline opens a new row in the table. You can use TeX primitive \noalign just after the end of the row (i.e. just after \\ in LaTeX or \cr in the TeX primitive meaning). The parameter of the \noalign primitive includes a vertical list. In our case, it is space, line, space.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
 \begin{flalign*}
  \begin{array}{lllclllr}
   & 2x &-& 9y &+& 5 &=& 0\\
   -& 2x &+& 6y &+& 20 &=& 0\\
   \noalign{\kern2pt\hrule\kern3pt}
   &&& -15y &-& 15 &=& 0\\
   &&&&& y &=& -1
  \end{array}&&
 \end{flalign*}
\end{document}
1

I suggest you use a better tool than \hline: \midrule, which is provided by the booktabs package.

If you want to use an array environment to typeset sytems of equations, you should set \arrayrulsep -- the parameter that contruls the amount of whitespace padding at the column edges -- to 0pt.

enter image description here

\documentclass{article}

\usepackage{mathtools}% for \math[lr]lap macros
\usepackage{booktabs} % for \midrule macro
\usepackage{array}    % for \newcolumntype macro
\newcolumntype{C}{ >{{}}c<{{}} } % for mathbin and mathrel operators

\begin{document}
\[
  \setlength{\arraycolsep}{0pt}
  \begin{array}{ l rCrCrCr }
      & 2x &-&           9y &+&  5 &=&  0\\
   -( & 2x &+&           6y &+& 20 &=&  0\mathrlap{)}\\
   \midrule
     & & &  \mathllap{-15}y &-& 15 &=&  0\\
     & & &                  & &  y &=& -1
  \end{array}
\]
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .