# Matrix horizontal alignment

I am trying to use the Gauss TeX package to display matrices. I have two problems with the following code (not so important):

    \usepackage{amsmath}
\usepackage{gauss}
\begin{document}
$$\begin{gmatrix}[b] 1 & 0 & 0 & 0 & \frac{4}{5} & \text{\small{-}}\frac{3}{5} & \frac{2}{5} & \text{\small{-}}\frac{1}{5} \\ 0 & 1 & 0 & 0 & \text{\small{-}}\frac{3}{5} & \frac{6}{5} & \text{\small{-}}\frac{4}{5} & \frac{2}{5} \\ 0 & 0 & 1 & \frac{3}{4} & \frac{1}{4} & \text{\small{-}}\frac{1}{2} & \frac{3}{4} & 0 \\ 0 & 0 & 0 & 1 & \text{\small{-}}\frac{1}{5} & \frac{2}{5} & \text{\small{-}}\frac{3}{5} & \frac{4}{5} \rowops \add[\cdot ({-}\frac{3}{4})]{3}{2} \end{gmatrix} \cong \begin{gmatrix}[b] 1 & 0 & 0 & 0 & \frac{4}{5} & \text{\small{-}}\frac{3}{5} & \frac{2}{5} & \text{\small{-}}\frac{1}{5} \\ 0 & 1 & 0 & 0 & \text{\small{-}}\frac{3}{5} & \frac{6}{5} & \text{\small{-}}\frac{4}{5} & \frac{2}{5} \\ 0 & 0 & 1 & 0 & \frac{2}{5} & \text{\small{-}}\frac{4}{5} & \frac{6}{5} & \text{\small{-}}\frac{3}{5} \\ 0 & 0 & 0 & 1 & \text{\small{-}}\frac{1}{5} & \frac{2}{5} & \text{\small{-}}\frac{3}{5} & \frac{4}{5} \end{gmatrix}$$
\end{document}


It looks like this:

I bypassed the alignment a bit by using "\text{\small{-}}" in stead of "-", to make the fractions appear under each other, but they still don't line up quite nicely and the matrix need more vertical space but I cannot seem to figure out how to do this. Any help would be appreciated :-)

-

The gauss package seems to impede easy answers. Here's a solutions that isn't great but works: Replace all your \text{\small{-}} with \llap{-} (this will yield the alignment you desire), and add a strut to each row:

\documentclass{article}
\usepackage{amsmath}
\usepackage{gauss}
\newcommand\mystrut{\rule{0pt}{2.5ex}}
\begin{document}
$$\begin{gmatrix}[b] 1 & 0 & 0 & 0 & \frac{4}{5} & \llap{-}\frac{3}{5} & \frac{2}{5} & \llap{-}\frac{1}{5} \mystrut \\ 0 & 1 & 0 & 0 & \llap{-}\frac{3}{5} & \frac{6}{5} & \llap{-}\frac{4}{5} & \frac{2}{5} \mystrut \\ 0 & 0 & 1 & \frac{3}{4} & \frac{1}{4} & \llap{-}\frac{1}{2} & \frac{3}{4} & 0 \mystrut \\ 0 & 0 & 0 & 1 & \llap{-}\frac{1}{5} & \frac{2}{5} & \llap{-}\frac{3}{5} & \frac{4}{5} \mystrut \rowops \add[\cdot ({-}\frac{3}{4})]{3}{2} \end{gmatrix} \cong \begin{gmatrix}[b] 1 & 0 & 0 & 0 & \frac{4}{5} & \llap{-}\frac{3}{5} & \frac{2}{5} & \llap{-}\frac{1}{5} \mystrut \\ 0 & 1 & 0 & 0 & \llap{-}\frac{3}{5} & \frac{6}{5} & \llap{-}\frac{4}{5} & \frac{2}{5} \mystrut \\ 0 & 0 & 1 & 0 & \frac{2}{5} & \llap{-}\frac{4}{5} & \frac{6}{5} & \llap{-}\frac{3}{5} \mystrut \\ 0 & 0 & 0 & 1 & \llap{-}\frac{1}{5} & \frac{2}{5} & \llap{-}\frac{3}{5} & \frac{4}{5} \mystrut \end{gmatrix}$$
\end{document}


(The builtin \strut is a bit too small, so I defined a larger \mystrut.)

-
Thank you so much! :-) –  user1912 Nov 15 '10 at 18:23
@user1912: You might want to check back; it could happen that tomorrow someone has a better answer. –  Hendrik Vogt Nov 15 '10 at 18:25
Yea I will surely do that, however, your answer perfectly does the job and all looks fine. I don't care if the underlying code is a bit "hacky" as noone but me sees it –  user1912 Nov 15 '10 at 18:30

One way to get more vertical space is to use \extrarowheight, in the array package. The syntax is \setlength{\extrarowheight}{x}, where x is a measure (e.g., 2pt, 3pt, etc). The effect only occurs if its value plus \baselineskipx\arraystretch is larger than the actual height of the cell. I usually add two or three points, and that makes the fractions come out suitably separated.

-
unfortunately this doesn't work with the gauss package which I need to display the steps I am doing. –  user1912 Nov 15 '10 at 17:10
@user1912: fair enough. –  Arturo Magidin Nov 15 '10 at 21:34