# How to insert a horizontal line in align env with some text at the end of the line

I'd like to have some math induction showing as below.(In an align environment \begin{align*}...\end{align*}) How can I have the "by addition" text at the end of the line? I tried with \cline but failed to do that.

x = 1   y = 2
x + y = 3                z = 3
x + y + z = 6


Here is what I've got so far. I also wanted the equations to be centered but I found it was hard to do.

\begin{align*}
x = 1 & y = 2 \\
\cline{1-2}
x + y = 3 & & z = 3 \\
\cline{1-3}
&x + y + z = 6& \\
\end{align*}


• Welcome to TeX.SE! Please take a moment to take our Tour! You may also want to look at what makes a good Minimal Working Example (MWE) – Tavrock Jan 31 '17 at 16:59

I created \byx{<eq1>}{<eq2>}{<via>}{<eq-sum>}, which can be nested.

\documentclass[11pt]{report}
\usepackage{amsmath,stackengine}
\newcommand\byx[4]{%
\setbox0=\hbox{$~#1\qquad#2~$}%
\setbox2=\hbox{~by #3}%
\Shortstack[c]{\copy0 \rule[2.3pt]{\wd0}{.5pt}\rlap{\copy2} $#4$}%
\hspace{\wd2}%
}
\begin{document}
$\byx{% \byx{x=1}{y=2}{addition}{x+y=3} }{z=3}{addition}{x+y+z=6}$
\end{document}


Note: You can add \setstackgap{S}{<gap>} to set the vertical gap of the stack. Default gap for \Shortstack is 3pt. The value can span the positive/negative range.

Is this what you mean? \\ will add a line break.

\documentclass{article}

\begin{document}
text...\\ \\
x = 1, y = 2