3

I am trying to add a horizontal line between aligned equations.

I have tried using \rule command, but then the problem is that it itself takes that command as an equation, since I am using \\ before and after this command, otherwise it is not aligning the equations correctly. With these, it uses unnecessary spaces above and below the horizontal rule. I want the output to be such that the equations are aligned as expected from the align* environment, with a horizontal line 'externally inserted' between two equations.

\begin{align*}
    y_2\times (y_2''+Py_2'+Qy_2) &=0\\
    -y_1\times (y_1''+Py_1'+Qy_1) &=0\\
    \rule{4.7cm}{1pt}&\rule{1cm}{1pt}\\
    y_1y_2''-y_1''y_2+P(y_1y_2'-y_1'y_2) &= 0\\
\end{align*}

The above is what I wrote, but it shows too much space above and below the horizontal rule. Even if I shift this rule 3mm upwards, the space below the rule increases and the problem remains same. Is there any way to add a horizontal rule whose space below and above can also be controlled?

Please help.

3
  • Could you please add a small example showing what you tried soe far? A sketch of the desired output could also help clarify. – leandriis Apr 15 '20 at 7:11
  • @leandriis, added the code segment which I wrote. Desired output I don't have, since I could not display what I want. – Martund Apr 15 '20 at 7:31
  • Please make your code complete, starting with \documentclass and ending with \end{document}. The following may help: \[ \begin{aligned} y_2\times (y_2''+Py_2'+Qy_2) &=0\\ -y_1\times (y_1''+Py_1'+Qy_1) &=0\\ \hline y_1y_2''-y_1''y_2+P(y_1y_2'-y_1'y_2) &= 0\\ \end{aligned} \] – frougon Apr 15 '20 at 8:22
5

With the help of an array instead of align*:

enter image description here

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
\setlength{\arraycolsep}{0pt}
\begin{array}{rl}
     y_2\times (y_2''+Py_2'+Qy_2) &{}=0\\
    -y_1\times (y_1''+Py_1'+Qy_1) &{}=0\\
    \hline
     y_1y_2''-y_1''y_2+P(y_1y_2'-y_1'y_2) &{}= 0\\
\end{array}
\]
\end{document}
4
  • Thank You very much! – Martund Apr 15 '20 at 11:16
  • 1
    There's too much space before the =. Within that equation, insert \setlength{\arraycolsep}{0pt} just after \[. You may also have to enter the equal signs as {}=. (Not tested.) – barbara beeton Apr 15 '20 at 18:15
  • @barbarabeeton: Thanks for pointing this out. I have corrected my answer accordingly. – leandriis Apr 19 '20 at 12:47
  • 1
    Just a bit more ... you really should enter the equal signs as {}=; this will ensure that the space on both sides is the same. (It's too narrow on the left otherwise.) – barbara beeton Apr 19 '20 at 13:10
4

You can use aligned and \midrule from booktabs.

\documentclass{article}
\usepackage{amsmath,booktabs}

\begin{document}

\begin{equation*}
\begin{aligned}
    y_2\times (y_2''+Py_2'+Qy_2) &=0\\
    -y_1\times (y_1''+Py_1'+Qy_1) &=0\\
    \midrule
    y_1y_2''-y_1''y_2+P(y_1y_2'-y_1'y_2) &= 0\\
\end{aligned}
\end{equation*}

\end{document}

enter image description here

1
  • Thank you very much! – Martund Apr 15 '20 at 11:16

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.