4

I heard that it is recommended to use align or array. But how should I do so to replace the use of eqnarray? Thank you very much.

Ka Wa Yip
  • 823

2 Answers2

3

With an eqnarray environment, you might write:

\begin{eqnarray}
a &=& b\\
c &=& d
\end{eqnarray}

With an align environment (be sure to load the amsmath package), you'd write

\begin{align}
a &= b\\
c &= d
\end{align}

The only significant change -- other than the change in the name of the environment, of course -- is that one writes &= (not =&!) when using an align environment in order to bring about alignment on the = symbol.

Mico
  • 506,678
  • 1
    @kwyip - I wouldn't use an array, for 3 reasons. First, the cells in an array are typeset in "text-style math" mode by default, whereas the material in an align environment is set in "display-style math" mode. Second, the spacing between rows is much tighter (too tight, in many cases) in an array. Third, with array you don't get the easy ability to number individual lines of a multi-line equation. You may also want to look into the IEEEeqnarray environment that's provided by the IEEEtrantools package. – Mico May 13 '15 at 23:20
  • I want to produce big parathesis like this http://tex.stackexchange.com/questions/122778/left-brace-including-several-lines-in-eqnarray How do I do this with "align" instead of "array"? Thanks. – Ka Wa Yip May 14 '15 at 00:58
  • @kwyip - That's a new question. Please post it as a new question, to give it a chance to be seen by more people. Thanks. – Mico May 14 '15 at 01:22
  • Could you give me advice on that new question? – Ka Wa Yip May 16 '15 at 06:19
  • @kwyip - I honestly don't know how to generate the construct mentioned in the newer posting using an align environment; align seems utterly unsuitable to the task. Why don't you want to use a cases environment for that construct? – Mico May 16 '15 at 08:35
0

You can use the equationarray environment which is loaded with the eqnarray package. It is a math environment that mimics the behavior of the array environment which is more suited for text. It also adds a different number to each equation. Unlike the eqnarray environment, you can align more than 3 columns of information.

Simply add

\usepackage{eqnarray}

to the preamble. Then you can use equationarray exactly as you would use an array:

\begin{equationarray}{rclrcl}
a &=& b & c &=& d\\
c &=& d & a &=& b
\end{equationarray}  
Meclassic
  • 1,795
  • 2
  • 18
  • 27