15

I need to draw a horizontal line inside an align environment. E.g., in the following MWE, I need that a line separates the third row.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
    \begin{align*}
    x &= 1\\
    y & = 2 \\
    \hline
    x + y &= 3 
    \end{align*}
\end{document}

EDIT I forgot to mention, the line should not be too long to the left (notice the attached image).

14

here is a solution

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
x &= 1\\
y & = 2 \\
 \cline{1-2}
x + y &= 3 
\end{align*}
\end{document}
4

Here's another

\documentclass{scrartcl}
\usepackage{mathtools,array}
\begin{document}
\[
  \begin{array}{>{\displaystyle{}}r@{}>{\displaystyle{}}l}
    x &= 1\\
    y & = 2 \\
     \hline
    x + y &= 3 
  \end{array}
\]
\end{document}

or may be you like the spacing of booktabs more

\documentclass{scrartcl}
\usepackage{mathtools,array,booktabs}
\begin{document}
\[
  \begin{array}{>{\displaystyle{}}r@{}>{\displaystyle{}}l}
    x &= 1\\
    y & = 2 \\
     \midrule
    x + y &= 3 
  \end{array}
\]
\end{document}
3

Not too sophisticated but you could use a simple rule here.

% arara: pdflatex

\documentclass{article}
\usepackage{mathtools}

\begin{document}
    \begin{align*}
        x &= 1\\
        y & = 2 \\[-\jot] % you may decrease the vertical space here and in the next line as well.
        \mathclap{\rule{2cm}{0.4pt}}\\
        x + y &= 3 
    \end{align*}
\end{document}

enter image description here

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.