[Tex/LaTex] Matrix gauss package problem with alignment

horizontal alignmentmatrices

So far I am using the gauss document package, because it offers to show row operations. Now If i try to add fractions inside the matricies, or – signs things gets messy…

The text will not align vertically. Although I have found a semifix for this, is there a cleaner and easier way?

So far a minimal example looks like this

\documentclass[10pt,a4paper]{article}
\usepackage{gauss}
\usepackage{mathtools}
\newcommand{\m}{\llap{-}}
\begin{document}

\begin{align*}
\intertext{Wrong} \\
X\begin{gmatrix}[b]
  - 1 &         0     &     1 \\
    1 &   \frac{3}{4} &     0 \\
    3 &         1     &  -  1 
    \end{gmatrix}
    \\
    (a)
X\begin{gmatrix}[b]
   - 1 &   0 &     1 \\
     1 &   1 &     0 \\
     3 &   1 &  -  1 
\end{gmatrix}
\end{align*}
\\
Almost correct
\\
\begin{align*}
X\begin{gmatrix}[b]
\; \m 1 &         0     &      1 \\
\;    1 &   \frac{3}{4} &      0 \\
\;    3 &         1     &  \m  1 
\end{gmatrix}
\\
(a)
X\begin{gmatrix}[b]
\;  \m 1 &   0 &      1 \\
\;     1 &   1 &      0 \\
\;     3 &   1 &  \m  1 
\end{gmatrix}
\end{align*}
\\
Another example \\
\\
\begin{align*}
&\begin{gmatrix}[b]
1 &   2 &      -3     & 4 \\
3 &  -1 &       5     & 2 \\
4 &   1 &   (a^2-2)   & a+4 
\rowops
\add[-3]{0}{1}
\add[-4]{0}{2}
\end{gmatrix}
&& \sim && 
\begin{gmatrix}[b]
1 &   2 &       -3      & 4 \\
0 &  -7 &       14      & -10 \\
0 &  -7 &   (a^2+10)    & a-12 
\rowops
\add[-1]{1}{2}
\mult{1}{-\cdot \frac{1}{7}}
\end{gmatrix} \\
&\begin{gmatrix}[b]
1 &  2 &      -3      & 4 \\
0 &  1 &      -2      & \frac{10}{7} \\
0 &  0 &   (a^2-4)    & a-2
\rowops
\add[-2]{1}{0}
\end{gmatrix} 
&& \sim && 
\begin{gmatrix}[b]
1 &  0 &       1      & \frac{8}{7} \\
0 &  1 &      -2      & \frac{10}{7} \\
0 &  0 &   (a^2-4)    & a-2
\rowops
\mult{2}{\cdot \frac{1}{a^2-4}}
\end{gmatrix}
\\
&\begin{gmatrix}[b]
1 &  0 &       1      & \frac{8}{7} \\
0 &  1 &      -2      & \frac{10}{7} \\
0 &  0 &       1      & \frac{a-2}{a^2-4}
\rowops
\add[2]{2}{1}
\add[-1]{2}{0}
\end{gmatrix}
&& \sim &&
\begin{gmatrix}[b]
1 &  0 &  0    &  \frac{1}{7} \frac{8a+ 9}{a+2} \\
0 &  1 &  0    &  \frac{2}{7} \frac{5a+17}{a+2} \\
0 &  0 &  1    &   \frac{1}{a+2}
\end{gmatrix}
    \end{align*}
    \end{document}

Any better ways to do this? I also think this is a tedious way to write matricies… I have to perhaps write 25-50 of these a week

Best Answer

A (perhaps ugly) way of making the cells right aligned is to add

\makeatletter
  \edef\g@post{\relax$}
\makeatother

to the preamble, after \usepackage{gauss}. This is just a redefinition of a line from the package, removing an \hfil. The last example of yours will then look like this: enter image description here

Not sure if this is exactly what you're after though ...

Related Question