🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text.tex
Article #810

Re: flushright in eqnarray*

#810
From: David M. Jones
Date: Wed, 08 Apr 1992 14:43
63 lines
3362 bytes
In article <1992Apr8.060332.7259@uokmax.ecn.uoknor.edu>, wszczepo@uokmax (Witold Szczeponik) writes:

>In an eqnarray* environment I want to have all equations flushed right (in
>particular the left hand sides).  I've tried to change \@eqnsel but this
>didn't help either.  If someone out there can help me, I'd appreciate it
>very much.

I assume that you mean you want your eqnarray's to come out like this:

                              x     = 2
                              x + y = 3

rather than
                                  x = 2
                              x + y = 3

This is indeed a bug in the way the eqnarray environment, since
according to the documentation in latex.tex (which you obviously
read), the first example is supposed to be the default and setting
\@eqnsel=\hfil is supposed to give the second example.  However,
because the definition of \eqnarray contains the line

        \halign to \displaywidth{\@eqnsel\hskip\@centering

it doesn't matter what value \@eqnsel has, since the \hskip\@centering
forces the left-hand side of the equation to be flushright.

The solution -- which I came across some time ago, but haven't tested
extensively -- is to remove the superfluous \hskip\@centering:

\def\eqnarray{\stepcounter{equation}\let\@currentlabel=\theequation
\global\@eqnswtrue
\global\@eqcnt\z@\tabskip\@centering\let\\=\@eqncr
$$\halign to \displaywidth\bgroup\@eqnsel
  $\displaystyle\tabskip\z@{##}$&\global\@eqcnt\@ne 
  \hskip 2\arraycolsep \hfil${##}$\hfil
  &\global\@eqcnt\tw@ \hskip 2\arraycolsep $\displaystyle\tabskip\z@{##}$\hfil 
   \tabskip\@centering&\llap{##}\tabskip\z@\cr}

This restores the documented behaviour, i.e., \let\@eqnsel\relax (the
default definition) will result in the left-hand sides being flushleft
and \let\@eqnsel=\hfil will make them flushright.

Incidentally, a further slight modification will get rid of the
obscene amount of space that eqnarray puts around the relation symbol:

\def\eqnarray{\stepcounter{equation}\let\@currentlabel=\theequation
\global\@eqnswtrue
\global\@eqcnt\z@\tabskip\@centering\let\\=\@eqncr
$$\halign to \displaywidth\bgroup\@eqnsel
  $\displaystyle\tabskip\z@{##}$&\global\@eqcnt\@ne 
  \hfil${{}##{}}$\hfil
  &\global\@eqcnt\tw@  $\displaystyle\tabskip\z@{##}$\hfil 
   \tabskip\@centering&\llap{##}\tabskip\z@\cr}

\def\lefteqn#1{\hbox to 4\arraycolsep{$\displaystyle #1$\hss}}

(The redefinition of \lefteqn is necessary to put the extra space back
in.  By the way, does anyone know why the original definition had
\hskip 2\arraycolsep rather than \tabskip=2\arraycolsep?)

David M. Jones                              "Trifles! Trifles light as air!"
dmjones@theory.lcs.mit.edu                              -- the Hystricide
Technical Details
Message-ID: <1992Apr8.144352.20749@mintaka.lcs.mit.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!swrinde!gatech!bloom-beacon!mintaka.lcs.mit.edu!news
References: <1992Apr8.060332.7259@uokmax.ecn.uoknor.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!swrinde!gatech!bloom-beacon!mintaka.lcs.mit.edu!news
From: dmjones@theory.lcs.mit.edu (David M. Jones)
Newsgroups: comp.text.tex
Subject: Re: flushright in eqnarray*
Message-ID: <1992Apr8.144352.20749@mintaka.lcs.mit.edu>
Date: 8 Apr 92 14:43:52 GMT
References: <1992Apr8.060332.7259@uokmax.ecn.uoknor.edu>
Sender: news@mintaka.lcs.mit.edu
Reply-To: dmjones@theory.lcs.mit.edu (David M. Jones)
Organization: Laboratory for Computer Science, MIT
Lines: 63
In-Reply-To: wszczepo@uokmax.ecn.uoknor.edu (Witold Szczeponik)