home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / text / tex / 14730 < prev    next >
Encoding:
Internet Message Format  |  1993-01-07  |  3.0 KB

  1. Path: sparky!uunet!elroy.jpl.nasa.gov!usc!news.service.uci.edu!unogate!mvb.saic.com!info-tex
  2. From: "Daniel H. Luecking" <DL24794%UAFSYSB.BITNET@SHSU.edu>
  3. Newsgroups: comp.text.tex
  4. Subject: Re: row vector times matrix alignment
  5. Message-ID: <9985180@MVB.SAIC.COM>
  6. Date: Thu, 07 Jan 93 16:47:44 CST
  7. Organization: Info-Tex<==>Comp.Text.Tex Gateway
  8. X-Gateway-Source-Info: Mailing List
  9. Lines: 99
  10.  
  11.  
  12. > From: mclean@math.tamu.edu (Robert Mclean)
  13. >
  14. > In article <1ifgo0INN20p@tamsun.tamu.edu> mclean@math.tamu.edu (Robert Mclean)
  15. writes:
  16. > > ...
  17. > >I would like to have a row vector times a matrix to look like this:
  18. > >
  19. > >(x,y,z) (a1,a2,a3)
  20. > >        (a4,a5,a6)
  21. > >        (a7,a8,a9)
  22. > >
  23. > >rather than how TeX usually spits it out as:
  24. > >
  25. > >        (a1,a2,a3)
  26. > >(x,y,z) (a4,a5,a6)
  27. > >        (a7,a8,a9)
  28. > >
  29. > >Any, suggestions how to get it to align them at the top?
  30. > >
  31. >
  32. > I received two suggestions on how to do this: (1) Use LaTeX or AMS-LaTeX
  33. > where this is an option for the array environment. (I use AMS-TeX.)
  34. > (2) Look at the plain.tex file's \matrix command and change a \vcenter
  35. > to \vtop. Here's the modified code:
  36. >
  37. >    <code deleted>
  38. >
  39. > Unfortunately, this produces:
  40. >
  41. >         (        )
  42. >         (        )
  43. >         (        )
  44. > (x,y,z) (a1,a2,a3)
  45. >         (a4,a5,a6)
  46. >         (a7,a8,a9)
  47. >
  48. > Aack! Any suggestions.
  49. >
  50.  
  51. Yes. The problem is that the delimiters are constructed to be
  52. symmetric above and below the math axis. Putting the array in a
  53. \vtop  causes the math axis of the whole matrix to be in the top
  54. row.  This is correct for aligning the two matrices at their
  55. top rows, but not for the variable delimiters.
  56.  
  57. The following macro works by putting the array in a  \vtop, then
  58. unboxing it into a  \vcenter  with the parenthesis and spacing
  59. added.  This is done inside math mode with  \displaystyle  set,
  60. inside an  \hbox  inside a  \vbox  to the height of the original
  61. \vtop. This worked in simple examples, but can probably be
  62. defeated by more complicated ones.  Two successive  \tpmatrix's
  63. will align at their first rows.
  64.  
  65. \catcode`@=11
  66. \def\tpmatrix#1{
  67.   \setbox\z@=\vtop{\normalbaselines\m@th
  68.     \ialign{\hfil$##$\hfil&&\quad\hfil$##$\hfil\crcr
  69.       \mathstrut\crcr
  70.       \noalign{\kern-\baselineskip}
  71.       #1\crcr
  72.       \mathstrut\crcr
  73.       \noalign{\kern-\baselineskip}
  74.     }
  75.   }
  76.   \dimen\z@=\dp\z@
  77.   \setbox\z@=\vbox to \ht\z@{
  78.     \hbox{$\displaystyle \left(\,\vcenter{\unvbox\z@}\,\right)$}
  79.     \vss
  80.   }
  81.   \dp\z@=\dimen\z@
  82.   \box\z@
  83. }
  84. \catcode`@=12
  85. $$
  86. \pmatrix{x & y & z}
  87. \tpmatrix{a_1 & a_2 & a_3 \cr
  88.           a_4  & a_5 & a_6 \cr
  89.           a_7  & a_8 & a_9 \cr
  90. }
  91. $$
  92. \bye
  93.  
  94. Another possibility is to use the  \bordermatrix  macro of plain
  95. TeX, which normally is used to produce
  96.                A B C
  97.            D ( 1 2 3 )
  98.            E ( 4 5 6 )
  99.            F ( 7 8 9 ),
  100. but with the  "D"  position holding the vector (and other
  101. border positions empty).  This will not work if the vector is
  102. replaced with a matrix required to be aligned at the top row
  103. with the second.
  104.  
  105. I hope this helps.
  106.  
  107. > robert mclean
  108.  
  109. Dan Luecking
  110.