# [Xy-pic] Typesetting row operations in matrices

Matthew Leingang leingang at math.harvard.edu
Fri Mar 24 21:21:25 CET 2006

Hello list,

I'm preparing notes for a linear algebra class in which we do a lot of
Gaussian Elimination of matrices.  Every time I do this I fret about the
best way to indicate row operations in TeX.

When I'm talking at the board and I want to say "we're going to transpose
row 1 and row 3 of this matrix", I draw a double-ended arrow on the
right-hand side of the matrix, pointing to the first and third row.  If I
want to represent the row operation "add -2 times the first row to the
second row", I draw an arrow from the right side of row 1 to the right side
of row 2, decorated with a "-2".

I'd like to get the same thing in my TeX-ed notes.  The only way I know how
to do curved arrows is in Xy-Pic.  I can do something like

\xymatrix{1 & 1 & 1 & 1 & 0 \\ 0 & 1 & -1 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0
\ar@/_3ex/[uu]_{-1}}

Which is pretty close.  You can set the row and column separation parameters
so the spacing is just like it is in LaTeX matrices.

But usually matrices are delimited by something, like square brackets or
parentheses.  I want the numbers part of the matrix to go inside the
delimiters but the curved arrows to go outside the delimiter on the RHS.
Putting \left[...\right] about the above, predictably, puts the delimiter
outside the arrows.  But unpredictably, this extends the delimiter about 2/3
higher than the visible natural height of the matrix.  You get giant
delimiters with a normal-size matrix nestled at the bottom.

---
\usepackage[all]{xy}

\xymatrixrowsep={0pt}
\xymatrixcolsep={3pt}

\begin{document}
$\left[\xymatrix{ 1 & 1 & 1 & 1 & 0 \\ 0 & 1 & -1 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 \ar@/_3ex/[uu]_{-1}}\right]$
\end{document}

---

I've also tried some hacks like using a regular matrix environment with an
xymatrix next to it, containing no visible entries and just the arrows.  But
the regular matrix's bottom gets vertically aligned with the xymatrix's
middle.  The only way I know how to fix that is to move up the xmymatrix,
creating monstrosities like

\left[\begin{matrix}1 & 1 & 1 & 1 & 0 \\ 2 & 0 & 4 & 2 & 0 \\ 1 & 1 & 1 & 3
& 0 \end{matrix}\right]
\hspace{-1.5ex}{\raisebox{4.3ex}{\xymatrix{
{\mathstrut} \ar@/^3ex/[d]_{-2} \ar@/^4ex/[dd]^{-3} \\ {\mathstrut}\\
{\mathstrut} }}}

This does "work" but if the matrix environment changes the xymatrix kludge
matrix has to change, too.  I'd be OK with that if I could get the
two-matrix approach to line up without entering in dimensions by hand.

Does anybody have an elegant solution to this problem?

TIA,
Matt

--
Matthew Leingang
Preceptor in Mathematics
Harvard University

URL: http://www.math.harvard.edu/~leingang/
vCard: http://www.math.harvard.edu/~leingang/vCard.vcf



More information about the xy-pic mailing list