🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text.tex
Article #11050

Re: Row vector times a matrix alignment, followup

#11050
From: Donald Arseneau
Date: Fri, 08 Jan 1993 05:22
88 lines
3880 bytes
In article <1ihqh2INNqd1@tamsun.tamu.edu>, mclean@math.tamu.edu (Robert Mclean) writes...
>>Howdy, (requisite Aggie salutation.) I have a question which I probably
>>shouldn't be worrying about. TeX is good at making us worry about little
>>texnicalities.
>>
>>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)
>>
>  [or as]
> 
>        (        )
>        (        )
>        (        )
>(x,y,z) (a1,a2,a3)
>        (a4,a5,a6)
>        (a7,a8,a9)
> 

I remember doing this long long ago soon after learning TeX.  I found
this response in TeXhax 1987, number 82:

-------- old TeXhax article, header and all! ----------
Date:  6 Oct 87  9:49 -0800
From: Donald Arseneau <asnd%dac.triumf.cdn%ubc.csnet@RELAY.CS.NET>
To: texhax@SCORE.STANFORD.EDU
Subject: top-aligned matrices

Dfr@usna.arpa doean't seem to work for me, the conection fails
at usna.mil  so here is my response to the question about matrices
aligned at the top:

% Hello;  I gave your problem a bit of thought, and what I thought
% was that \vtop would easily do the trick.  That is true if you only
% need the naked array normally provided by \matrix --- simply change
% the \vcenter to \vtop in the definition of \matrix in the TeXbook---
% but with parentheses, of course, there is a problem.  When I tried
% it out the matrix contents lined up well but \pmatrix gave
% parentheses centered on the line as in:
%                           |       |
%                           |       |
%                       Z = | 0 0 0 |
%                           | 0 0 0 |
%                           | 0 0 0 |
% ... and un-centering the parentheses is a real problem.
%
%     Well here is my solution using explicit measurements to remember
% where the proper baseline of the inner matrix is:
%
\catcode`\@=11
\newbox\matbox
\def\topmatrix#1{\setbox\matbox=\vtop{\normalbaselines\m@th % set the matrix in
    \ialign{\hfil$##$\hfil&&\quad\hfil$##$\hfil\crcr       % a \vtop so the
    \mathstrut\crcr\noalign{\kern-\baselineskip}           % first baseline
    #1\crcr\mathstrut\crcr\noalign{\kern-\baselineskip}}}  % lines up.
% get twice difference between baseline and centerline of inner matrix:
    \dimen255=\dp\matbox \advance\dimen255 by -\ht\matbox
% Center matrix and surround with parentheses:
    \setbox\matbox=\hbox{$\left( \,\vcenter{\box\matbox}\,\right)$}
% Correct for difference between baseline and centerline of parentheses:
    \advance\dimen255 by -\dp\matbox \advance\dimen255 by \ht\matbox
% Lower centered matrix back to its proper baseline:
    \lower0.5\dimen255\box\matbox
}
\catcode`\@=12
One identity matrix is:
$I_4=\topmatrix{1&0&0&0\cr
                0&1&0&0\cr
                0&0&1&0\cr
                0&0&0&1\cr}$,
and the top row should line up with the line of text.


\bye          %    Donald Arseneau  (asnd@triumfcl.bitnet)
---------- end included ------------------

This story is still true.  The email addresses are history!

\bye  %   Donald Arseneau        asnd@reg.triumf.ca
                                (asnd@triumfcl.bitnet still works)
Technical Details
Message-ID: <7JAN199321222700@msr.triumf.ca>
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!cs.utexas.edu!rutgers!micro-heart-of-gold.mit.edu!uw-beaver!cs.ubc.ca!unixg.ubc.ca!msr.triumf.ca!asnd
References: <1ifgo0INN20p@tamsun.tamu.edu> <1ihqh2INNqd1@tamsun.tamu.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!cs.utexas.edu!rutgers!micro-heart-of-gold.mit.edu!uw-beaver!cs.ubc.ca!unixg.ubc.ca!msr.triumf.ca!asnd
From: asnd@msr.triumf.ca (Donald Arseneau)
Newsgroups: comp.text.tex
Subject: Re: Row vector times a matrix alignment, followup
Message-ID: <7JAN199321222700@msr.triumf.ca>
Date: 8 Jan 93 05:22:00 GMT
References: <1ifgo0INN20p@tamsun.tamu.edu> <1ihqh2INNqd1@tamsun.tamu.edu>
Organization: TRIUMF: Tri-University Meson Facility
Lines: 88
NNTP-Posting-Host: msr.triumf.ca
News-Software: VAX/VMS VNEWS 1.41