🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text.tex
Article #11042

Re: row vector times matrix alignment

#11042
From: Daniel H. Luecking
Date: Thu, 07 Jan 1993 22:47
99 lines
3168 bytes
> From: mclean@math.tamu.edu (Robert Mclean)
>
> In article <1ifgo0INN20p@tamsun.tamu.edu> mclean@math.tamu.edu (Robert Mclean)
writes:
> > ...
> >I would like to have a row vector times a matrix to look like this:
> >
> >(x,y,z) (a1,a2,a3)
> >        (a4,a5,a6)
> >        (a7,a8,a9)
> >
> >rather than how TeX usually spits it out as:
> >
> >        (a1,a2,a3)
> >(x,y,z) (a4,a5,a6)
> >        (a7,a8,a9)
> >
> >Any, suggestions how to get it to align them at the top?
> >
>
> I received two suggestions on how to do this: (1) Use LaTeX or AMS-LaTeX
> where this is an option for the array environment. (I use AMS-TeX.)
> (2) Look at the plain.tex file's \matrix command and change a \vcenter
> to \vtop. Here's the modified code:
>
>    <code deleted>
>
> Unfortunately, this produces:
>
>         (        )
>         (        )
>         (        )
> (x,y,z) (a1,a2,a3)
>         (a4,a5,a6)
>         (a7,a8,a9)
>
> Aack! Any suggestions.
>

Yes. The problem is that the delimiters are constructed to be
symmetric above and below the math axis. Putting the array in a
\vtop  causes the math axis of the whole matrix to be in the top
row.  This is correct for aligning the two matrices at their
top rows, but not for the variable delimiters.

The following macro works by putting the array in a  \vtop, then
unboxing it into a  \vcenter  with the parenthesis and spacing
added.  This is done inside math mode with  \displaystyle  set,
inside an  \hbox  inside a  \vbox  to the height of the original
\vtop. This worked in simple examples, but can probably be
defeated by more complicated ones.  Two successive  \tpmatrix's
will align at their first rows.

\catcode`@=11
\def\tpmatrix#1{
  \setbox\z@=\vtop{\normalbaselines\m@th
    \ialign{\hfil$##$\hfil&&\quad\hfil$##$\hfil\crcr
      \mathstrut\crcr
      \noalign{\kern-\baselineskip}
      #1\crcr
      \mathstrut\crcr
      \noalign{\kern-\baselineskip}
    }
  }
  \dimen\z@=\dp\z@
  \setbox\z@=\vbox to \ht\z@{
    \hbox{$\displaystyle \left(\,\vcenter{\unvbox\z@}\,\right)$}
    \vss
  }
  \dp\z@=\dimen\z@
  \box\z@
}
\catcode`@=12
$$
\pmatrix{x & y & z}
\tpmatrix{a_1 & a_2 & a_3 \cr
          a_4  & a_5 & a_6 \cr
          a_7  & a_8 & a_9 \cr
}
$$
\bye

Another possibility is to use the  \bordermatrix  macro of plain
TeX, which normally is used to produce
               A B C
           D ( 1 2 3 )
           E ( 4 5 6 )
           F ( 7 8 9 ),
but with the  "D"  position holding the vector (and other
border positions empty).  This will not work if the vector is
replaced with a matrix required to be aligned at the top row
with the second.

I hope this helps.

> robert mclean

Dan Luecking
Technical Details
Message-ID: <9985180@MVB.SAIC.COM>
Path: arc1-ca.pugleaf.net!sparky!uunet!elroy.jpl.nasa.gov!usc!news.service.uci.edu!unogate!mvb.saic.com!info-tex

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!elroy.jpl.nasa.gov!usc!news.service.uci.edu!unogate!mvb.saic.com!info-tex
From: "Daniel H. Luecking" <DL24794%UAFSYSB.BITNET@SHSU.edu>
Newsgroups: comp.text.tex
Subject: Re: row vector times matrix alignment
Message-ID: <9985180@MVB.SAIC.COM>
Date: Thu, 07 Jan 93 16:47:44 CST
Organization: Info-Tex<==>Comp.Text.Tex Gateway
X-Gateway-Source-Info: Mailing List
Lines: 99