[Tex/LaTex] adding a horizontal line in align environment in lyx


I use the AMS align environment to write some algebraic steps which have many lines of equations. I want to add some space (or preferably horizontal) after each line of equation with =. How can I do that?

So what I want to achieve is:

a = 1x2+3
  = 2+3
  = 5

Or other visually pleasing way to separate multiple lines of equations.

Best Answer

Adding horizontal lines in AMS align in LyX

Use the menu element Edit > Math > Add Line Above/Below. This inserts \hline between the desired lines.

However for AMS align this produces a line that starts at the left margin, which is probably not what you wish for. The solution is to replace the align environment with an aligned environment, in which the \hline seems to be better behave.

Detailed instructions: Create a new display math inset (Ctrl+Shift+M), and inside it type \aligned. This creates a aligned inset, in which you add as many columns and rows as desired. You can now cut-paste from your align environment to your new aligned environment. Now, use Edit > Math > Add Line Above/Below to add lines where desired.

Result in the code preview pane:

\begin{aligned}a & =1\times2+3\\
\hline  & =2+3\\
\hline  & =5

Increase spacing between lines in AMS align

Define a math macro \linespacing with contents \rule[-#1]{0pt}{0pt} and use it to increase spacing with the next line.

Result in the code preview pane:

a & =1\times2+3\linespacing{2ex}\\
 & =2+3\linespacing{2ex}\\
 & =5
Related Question