# How can you draw a horizontal line inside an align environment?

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).

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}


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}


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}