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.

  • You can manually set the space between lines using the optional Argument of \\. Like \\ [12pt]. – Guilherme Zanotelli Sep 27 '16 at 12:56
  • Unfortunately the optional argument of \\ is not supported in LyX (yet?) – G.M. Sep 27 '16 at 19:48
  • 1
    @G.M. perhaps this is the corresponding ticket for lack of optional argument after \\? lyx.org/trac/ticket/1505 – scottkosty Sep 27 '16 at 22:14

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
  • where is the add line from above/below? I can't find 'Math' in Edit. I can only find 'horizontal line' under 'formatting' in 'Insert'. Btw, mine is version 2.2.0 – Physicist Sep 28 '16 at 20:21
  • I manage to add the lines by typing \hline directly. but now the problem is that if I can't number each line. If I right-click and choose 'Equation Label', then it can only label the whole aligned environment and give one equation label, but I want more than one. – Physicist Sep 28 '16 at 20:26
  • You should also be seeing "Add line from above/below" when right-clicking in a cell. My solution indeed does not work when you need individual row labelling. That was the only caveat I know of. The following suggests a problem in general with horizontal lines in the align environment: tex.stackexchange.com/questions/254261/…. You can try the \cline{1-2} solution (by hand) suggested there but it gives me a poor result. – G.M. Sep 28 '16 at 22:34
  • then what about having multiple separate align environments aligned to the same '='? This way I can have multiple equation labelling, and also sometimes I want to add some text in between the equations for explanations. But I don't know how to make those separate align environment (with some text in between) aligned to the same '=' – Physicist Sep 29 '16 at 8:20
  • My advice for such a specialised request is to ask the LaTeX people here how to best do this in LaTeX, then see how to this can be adapted to LyX. – G.M. Sep 29 '16 at 13:42

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.