% Equationarray.doc % % Combine the capabilities of the eqnarray environment and the array % environment. % % Problem: The eqnarray environment is too restrictive in that it is % only prepared to accept three part equations. Some applications % require more sophisticated mathematics, so three parts aren't % enough. Simultaneously, we would like to have our equations % numbered. If the equations aren't to be numbered, then the array % environment suffices. If the equations aren't to be aligned with % each other, then the equation environment is preferred. % % Usage: % % \begin{equationarray}{rrcl} % % Equations go here, in the same format as you would use % % for arrays. % \end{equationarray} % % Written by: % Tony Li, University of Southern California, % Started 6/15/88. % Yes, I know this is a kludge. Suggestions accepted, flames to % /dev/null. I never said that I knew what I was doing. % \def\equationarray{\stepcounter{equation} \let\@currentlabel=\theequation \global\@eqnswtrue \global\@eqcnt\z@ \global\@eqargcnt \z@ \let\\=\@equationcr \let\@acol\@arrayacol \let\@classz\@eqnclassz \def\@halignto{to\displaywidth} \@equationarray} \def\@equationarray#1{\setbox\@arstrutbox=\hbox{\vrule height\arraystretch \ht\strutbox depth\arraystretch \dp\strutbox width\z@} \@mkpream{#1} \edef\@preamble{\halign \noexpand\@halignto \bgroup \tabskip\z@ \@arstrut \@preamble \hfill\tabskip\@centering &\llap{\@sharp}\tabskip\z@\cr}% \let\@startpbox\@@startpbox \let\@endpbox\@@endpbox \bgroup \let\par\relax \let\@sharp## \let\protect\relax \lineskip\z@ \baselineskip\z@ \tabskip\@centering $$ % $$ BRACE MATCHING HACK \@preamble } \def\@eqnclassz{\ifcase \@lastchclass \@acolampacol \or \@ampacol \or \or \or \@addamp \or \@acolampacol \or \@firstampfalse \@acol \fi \global\advance\@eqargcnt\@ne \edef\@preamble{\@preamble \ifcase \@chnum \hfil$\relax\displaystyle\tabskip\z@\@sharp$\hfil \or $\relax\displaystyle\tabskip\z@\@sharp$\hfil \or \hfil$\relax\displaystyle\tabskip\z@\@sharp$\fi \global\advance\@eqcnt\@ne}} \def\endequationarray{\@equationcr \egroup\global\advance\c@equation\m@ne % $$ BRACE MATCHING HACK $$\tabskip\@centering\egroup\global\@ignoretrue} \def\@equationcr{${\ifnum0=`}\fi\@ifstar{\@xequationcr}{\@xequationcr}} \def\@xequationcr{ \@ifnextchar[{\@argequationcr}{\ifnum0=`{\fi}${}\@zequationcr \global\@eqnswtrue\global\@eqcnt\z@\cr}} \def\@argequationcr[#1]{\ifnum0=`{\fi}${}\ifdim #1>\z@ \@xargequationcr{#1}\else \@yargequationcr{#1}\fi} \def\@xargequationcr#1{ \@tempdima #1\advance\@tempdima \dp \@arstrutbox \vrule \@height\z@ \@depth\@tempdima \@width\z@ \@zequationcr \global\@eqnswtrue\global\@eqcnt\z@ \cr} \def\@yargequationcr#1{ \@zequationcr \global\@eqnswtrue\global\@eqcnt\z@ \cr\noalign{\vskip #1}} \def\@zequationcr{\@wargequationcr\if@eqnsw\@eqnnum \stepcounter{equation}\global\@eqcnt\z@\fi} \def\@wargequationcr{\ifnum\@eqcnt<\@eqargcnt \@amper \@wargequationcr\fi} \def\@amper{&} \newcount\@eqargcnt