Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
    
Thanks for providing a MWE. But the above does not compile for me. –  Peter Grill Oct 7 '11 at 19:08
    
then you did something wrong ... –  Herbert Oct 7 '11 at 19:19
1  
If you're just interested in typesetting matrices, then see: Where is the \matrix command? –  Werner Oct 7 '11 at 19:23
    
@Herbert: I believe that the MWE has been modified since I posted the comment. We should probably remove these comments as they maybe confusing to future visitors... –  Peter Grill Oct 7 '11 at 20:00

2 Answers 2

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 ...

share|improve this answer
    
Or: \makeatletter, \edef\g@prae{\hfil$}, \edef\g@post{$}, \makeatother in the preamble for even & right-aligned columns. –  Mico Oct 8 '11 at 2:10
    
@N3buchadnezzar I'm curious, was this what you wanted? –  Torbjørn T. Oct 9 '11 at 15:29
\documentclass[10pt,a4paper]{article}
\usepackage{mathtools}
\begin{document}

\begin{align*}
X\begin{bmatrix*}[r]
  - 1 &         0     &     1 \\
    1 &   \frac{3}{4} &     0 \\
    3 &         1     &  -  1 
\end{bmatrix*}
\\
(a)
X\begin{bmatrix*}[r]
 -1 &   0 &     1 \\
   1 &   1 &     0 \\
    3 &   1 &     -1 
\end{bmatrix*}
\end{align*}
\end{document}

enter image description here

share|improve this answer
    
Problem is I need the extra features. I will update the first post to display some of these. –  N3buchadnezzar Oct 7 '11 at 19:29
    
@Herbert ... is the minus the right size? It looks like a dash! –  Yiannis Lazarides Oct 7 '11 at 19:44
    
the matrix is set in math mode, so it is the right character –  Herbert Oct 7 '11 at 19:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.