Formatting Math Equations With Modern Tools: Moving Beyond Eqnarray In Latex

Replacing eqnarray with More Modern Tools

The eqnarray environment has been used extensively in LaTeX documents for formatting multiline equations. However, it comes with several drawbacks that have led to newer, more robust tools being introduced to replace it.

Issues with the eqnarray Environment

There are three main problems with using the eqnarray environment:

  1. Poor spacing around relation symbols like =, <, and > leading to suboptimal appearance
  2. Difficulty aligning equations at the relation symbols instead of at left or right
  3. Centering line-by-line making asymmetric equations look slightly off

These spacing and alignment issues can make eqnarray environments visually unappealing and harder to read. The individual centering of lines also does not allow spreading equations over multiple lines easily while maintaining alignment.

The align Environment for Aligning Equations

The align environment is designed specifically for aligning multiline equations horizontally at a specified point like a relation symbol. This allows avoiding poor spacing and alignment issues with eqnarray.

Basic usage is to specify alignment points using ampersands (&) and separate lines using double backslashes (\\\\):

a &= b + c \\\\
d + e &= f

Which would display properly spaced and aligned equations as:

Example align environment output

The key advantages of align over eqnarray are:

  • Correct spacing around relation symbols
  • Proper horizontal alignment at any designated point
  • No individual centering per line
  • Easier multi-line equations

The gather Environment for Gathering Equations

While align requires aligning each line at a specified marker, the gather environment simply gathers multiline equations vertically. This vertical alignment can be useful for systems of equations and inequalities.

Usage is similar to align except without any ampersands for alignment points:

a = b + c \\\\
d + e = f 

And outputs gathered equations:

Example gather environment output

Benefits of gather over eqnarray include:

  • Better spacing around relation symbols
  • Easily write systems of equations or inequalities
  • No concerns over improper single line alignments

Splitting Equations Across Multiple Lines

eqnarray also provides little support for breaking long equations across multiline displays. However, the align environment handles line splitting well through strategic placement of start (&) and end (\\\\) markers.

A long equation can be broken across two lines as:

a + b + c + {} & d + e + f + g \\\\
                  & + h + i + j  

Notice how the {} marker on the first line allows you to manually specify where line breaks should occur through the order of terms:

Example multiline equation in align

This allows splitting equations neatly across any number of lines while preserving alignment at relation symbols.

Numbering Only One Line in Multi-Line Equations

Another key difference between eqnarray and align is default equation numbering behavior. eqnarray numbers each line independently while align numbers the whole multiline equation.

Numbering can be manually specified in align using \nonumber before the end specifier (\\\\) on lines that should not be numbered:

a + b + c + d + e &\nonumber\\\\
                   &= f  

Resulting in a multi-line equation with only one number:

Example equation numbering in align

This provides clarity that the split equation is one logical statement.

Inserting Text Between Aligned Equations

Align also allows inserting text or multiline comments between equation lines which is not possible in eqnarray:

   a &= b + c \\\\
\text{because:} \\\\
   d + e &= f

Enabling annotations for aligned equations:

Example text in align environment

This is useful for explaining steps between lines.

Summary of Recommendations Beyond eqnarray

In summary, it is recommended adopting the following practices and LaTeX environments when typesetting multiline equations instead of using eqnarray:

  • Use align for horizontally aligning equations especially at relation symbols
  • Use gather for vertically gathering systems of equations/inequalities
  • Split long equations across properly aligned lines with align
  • Number entire multiline equations instead of each line
  • Insert textual annotations between aligned lines

Additional modern math environments like IEEEeqnarray, alignat, flalign, and multiline also exist for more specialized use cases. But align and gather can cover most general math typesetting needs while avoiding inherent issues with eqnarray. Consistently replacing eqnarray usage with these newer tools leads to better spacing, alignment, and readability in multiline display equations.

Leave a Reply

Your email address will not be published. Required fields are marked *