Udostępnij za pośrednictwem


Equation Arrays

One user (Leperkawn) commented "There is basically no documentation on the \eqarray command so I'll post a quick example that I had to figure out from trial and error." Before looking at his interesting example, here's the text in Section 3.19 of the linear format paper describing how to type in equation arrays:

To align one equation relative to another vertically, one can use an equation array, such as 

which has the linear format █(10&x+&3&y=2@3&x+&13&y=4), where █ is U+2588. This character can be entered by typing \eqarray. Here the meaning of the ampersands alternate between align and spacer, with an implied spacer at the start of the line. So every odd & is an alignment point and every even & is a place where space may be added to align the equations. This convention is used in AmSTeX.

To make this a little easier to understand, we can highlight the align ampersands red and the spacers green. Then the linear format of equation above looks like

█(10&x+&3&y=2@3&x+&13&y=4

You can also use the equation array to format the "cases" construct, such as 

which has the linear format "|x| = {█ (&x" if "x ≥ 0@-&x" if "x < 0)┤" Here the two &'s align the leading x's.

Highlighting the aligns in red and the spacers in green, Leperkawn's example is (note: line breaks after the @'s are included only for readability; they should not be used inside equation arrays)

█(Z-3x_1&-5&x_2&-6&x_3&&&&=&0 @

2x_1&+&x_2&+&x_3&+x_4&&&=&4 @

x_1&+2&x_2&+&x_3&+&x_5&&=&4 @

x_1&+&x_2&+2&x_3&+&&x_6&=&4 @

x_1&+&x_2&+&x_3&+&&&x_7=&3) 

This displays as

 

It's pretty nicely aligned, but note that the first x_3 is a little to the right of the subsequent ones. A choice that aligns them accurately puts an align & immediately before each of the first three variables in each equation and puts the corresponding spacer after, rather than before, the binary operator that follows. This is the pattern used in the first example above. The linear format becomes

█(Z-3&x_1-&5&x_2-&6&x_3&&&=&0 @

2&x_1+&&x_2+&&x_3+x_4&&&=&4 @

&x_1+&2&x_2+&&x_3+&x_5&&=&4 @

&x_1+&&x_2+&2&x_3+&&x_6&=&4 @

&x_1+&&x_2+&&x_3+&&&x_7=&3)

which builds up to

 

Now all the variables are aligned correctly.

Comments

  • Anonymous
    May 31, 2011
    It would be perfect, if some future version of Office will support automatic alignment of one equation relative to another vertically (at least for variables in correct order).

  • Anonymous
    January 11, 2012
    I agree!

  • Anonymous
    February 07, 2017
    Why is it that my Word 2016 does not want to create eqarrays with more than 3 equations? My formatting is correct, but as soon as there are 4 or more equations, I close the closing brace, press space and nothing happens. I delete one equation (or as much to have at most 3 left), and it builds up the eqarray.