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
-------------- by addtion
  x + y = 3                z = 3
--------------------------------- by addition
       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.

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


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

  \setbox2=\hbox{~by #3}%
  \Shortstack[c]{\copy0 \rule[2.3pt]{\wd0}{.5pt}\rlap{\copy2} $#4$}%

enter image description here

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.


text...\\ \\
x = 1, y = 2
\\------------ by addition\\
x + y = 3


Output example:

Add line break and horizontal line in equation/math

  • It seems similar. But I am trying to have it in a math environment so that I don't need to align everything by myself. – czheo Jan 31 '17 at 7:18
  • Then you should be more specific in your question. Your MWE is too vague. – Jimmy Westberg Jan 31 '17 at 7:22
  • Thx. Just added. – czheo Jan 31 '17 at 7:25
  • But still, what are you trying to get. Left or right alignment? Please post what ever code you have so I understand what you're aiming for here. As far as I can tell my example gives you what you want (left alignment). – Jimmy Westberg Jan 31 '17 at 7:43
  • You might consider reading through this post: Align equation left – Jimmy Westberg Jan 31 '17 at 7:47

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.