[comp.text.tex] Equations in LaTeX question

ajayshah@alhena.usc.edu (Ajay Shah) (04/11/91)

I'd like to typeset equations like:

    z = (x+y)^2
      = x^2 + 2xy + y^2

The \TeX book has a nice concept called \eqalign which lines up
equations so the = comes vertically aligned.  It doesn't work in
LaTeX.

Any ideas on how it's done?

Thanks,
	-ans.

-- 
_______________________________________________________________________________
Ajay Shah, (213)734-3930, ajayshah@usc.edu
                             The more things change, the more they stay insane.
_______________________________________________________________________________

halvers@betelgeuse.crd.ge.com (Pete Halverson) (04/11/91)

In article <31808@usc> ajayshah@alhena.usc.edu (Ajay Shah) writes:
>
>I'd like to typeset equations like:
>
>    z = (x+y)^2
>      = x^2 + 2xy + y^2
>
>The \TeX book has a nice concept called \eqalign which lines up
>equations so the = comes vertically aligned.  It doesn't work in
>LaTeX.
>
>Any ideas on how it's done?

The simplest way is to use the eqnarray* environment, separating the LH,
the equals sign, and the RH with "&" and separating lines with "\\":

   \begin{eqnarray*}
   z & = & (x+y)^2 \\
     & = & x^2 + 2xy + y^2
   \end{eqnarray*}

If you need to do more interesting alignment, or embed these equations
within higher-level math constructs, you should look at the documentation
for the "array" environment, which is what eqnarray* is based on.


--
===============================================================================
Pete Halverson                        		    INET: halverson@crd.ge.com 
GE Corporate R&D Center	                      UUCP: uunet!crd.ge.com!halverson
Schenectady, NY

cnbr17@vaxa.strath.ac.uk (04/12/91)

In article <31808@usc>, ajayshah@alhena.usc.edu (Ajay Shah) writes:
> 
> I'd like to typeset equations like:
> 
>     z = (x+y)^2
>       = x^2 + 2xy + y^2
> 
> The \TeX book has a nice concept called \eqalign which lines up
> equations so the = comes vertically aligned.  It doesn't work in
> LaTeX.
> 
> Any ideas on how it's done?
> 
> Thanks,
> 	-ans.
> 
> -- 
> _______________________________________________________________________________
> Ajay Shah, (213)734-3930, ajayshah@usc.edu
>                              The more things change, the more they stay insane.
> _______________________________________________________________________________

I think you should use the LaTeX eqnarray environment (see LaTeX manual
section 3.3.5 pp 49/50):

\begin{eqnarray}
z & = & (x+y)^2\\
  & = & x^2 + 2xy + y^2
\end{eqnarray}

Hope this helps.
Peter.
-- 
================================================================================
Peter Duffy           |JANET:   p.duffy@uk.ac.strath.vaxa
EEE Dept.             |Internet:p.duffy%vaxa.strath.ac.uk@nsfnet-relay.ac.uk
Strathclyde University|BITNET:  p.duffy%vaxa.strath.ac.uk@UKACRL
Glasgow G1 1XW        |UUCP:    p.duffy%vaxa.strath.ac.uk@ukc.uucp
Scotland.             |
================================================================================