2

I frequently use the aligned math environment in LyX to typeset my equations. However, if I want to save space on the page and set two equations simultaneously in the same aligned math environment, the second equation fails to "stay" straight (see image below).

enter image description here

What do I need to do in order to set the equalities in the right equation in a straight line, like the ones in the left equation?

I've tried the following: using other math environments, inserting blank spaces, adding more columns.

  • Which other math environments have you used? This sounds like something that the alignat or alignat* environments would be good for. – Arun Debray Dec 25 '15 at 16:57
  • @luspada I think that you describe the bug mentioned in my answer which has now been fixed in the 2.3 and 2.2.2 branches of LyX (unfortunately not 2.2.0). Do you have any feedback? – G.M. Apr 27 '16 at 17:55
2

This is precisely what the alignat and alignat* environments are designed for: they allow you to vertically align multiple columns. (Just as with align and align*, alignat numbers each equation and alignat* doesn't number them.)

To align n columns, place them in \begin{alignat*}{n}...\end{alignat*}, and align each column with an & as usual. However, you also need an & to separate each column (as in an array or table), and in the first row, you should insert any extra space you need before this separator.

Here's the LaTeX code I have:

\documentclass{article}
\usepackage{amsmath}
% \dr{F}{x} produces δF/δx
% \hdr{2}{F}{x} produces δ²F/δ²x
\newcommand{\dr}[2]{\frac{\delta #1}{\delta #2}} 
\newcommand{\hdr}[3]{\frac{\delta^{#1} #2}{\delta^{#1} #3}}
\begin{document}
\begin{alignat*}{2}
% set spacing between columns in the first row
\dr{F}{x} &= ye^{x+y} + y^3 + 2xy - 1 \qquad\qquad & \dr{F}{y} &= ye^{x+y} + e^{x+y} + 3xy^2+ x^2\\
\hdr{2}{F}{x} &= ye^{x+y} + 2y                     & \hdr{2}{F}{y} &= ye^{x+y} + 2e^{x+y} + 6xy\\
\hdr{3}{F}{x} &= ye^{x+y}                          & \hdr{3}{F}{y} &= ye^{x+y} + 3e^{x+y}+ 6x\\
\hdr{4}{F}{x} &= ye^{x+y}                          & \hdr{4}{F}{y} &= ye^{x+y}+ 4e^{x+y}\\
&\vdots                                            & \vdots\\
\hdr{r}{F}{x} &= ye^{x+y}                          & \hdr{r}{F}{y} &= ye^{x+y} + re^{x+y}
\end{alignat*}
\end{document}

And here's the result.

enter image description here

  • "and in the first row, you should insert any extra space you need before this separator." Can negative space be allocated? Obviously, in a usual example this would make the corresponding adjacent columns to overlap, but in the case I am working I need this. – Matemáticos Chibchas May 28 '16 at 3:46
1

This alignment issue in the LyX display is probably the bug http://www.lyx.org/trac/ticket/9908 for which there is a proposed patch for LyX 2.2.0

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.