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.

How can I get matrices that are side by side? Currently I have the following:

\[
\begin{pmatrix}[ccc|c]
1&2&0&0\\
-1&1&2&0\\
1&0&1&5\\
0&-2&1&4
\end{pmatrix}
\]
\[
\begin{pmatrix}[ccc|c]
1&2&0&0\\
0&3&2&0\\
0&-2&1&5\\
0&-2&1&4
\end{pmatrix}
\]

What I want is the matrices to go across the paper with row equivalence signs on them (I am showing a reduced echelon form matrix)

share|improve this question
add comment

3 Answers 3

up vote 3 down vote accepted

Are you looking for \sim ("row equivalence sign")? (Also: *matrix doesn't take an optional parameter.)

Code

\documentclass{article}
\begin{document}
\[
\left(\begin{array}{@{}ccc|c@{}}
     1 &  2 & 0 & 0 \\
    -1 &  1 & 2 & 0 \\
     1 &  0 & 1 & 5 \\
     0 & -2 & 1 & 4
\end{array}\right)
\sim
\left(\begin{array}{@{}ccc|c@{}}
    1 &  2 & 0 & 0 \\
    0 &  3 & 2 & 0 \\
    0 & -2 & 1 & 5 \\
    0 & -2 & 1 & 4
\end{array}\right)
\]
\end{document}

Output

enter image description here

Improvement

If you use those matrices more than once you can define a new environment that does this for you:

\documentclass{article}
\newenvironment{rowequmat}[1]{\left(\array{@{}#1@{}}}{\endarray\right)}
\begin{document}
\[
\begin{rowequmat}{ccc|c}
     1 &  2 & 0 & 0 \\
    -1 &  1 & 2 & 0 \\
     1 &  0 & 1 & 5 \\
     0 & -2 & 1 & 4
\end{rowequmat}
\sim
\begin{rowequmat}{ccc|c}
    1 &  2 & 0 & 0 \\
    0 &  3 & 2 & 0 \\
    0 & -2 & 1 & 5 \\
    0 & -2 & 1 & 4
\end{rowequmat}
\]
\end{document}
share|improve this answer
add comment

Don't use two separate environments for displyed math. As Mico has suggested in his answer, it's better to use array environments.

In the following example I defined two environments, one for the matrices and another one for the elementary row operations; I also defined two commands for two of the row operations. Using an alignat environment you can align the matrices and their operations:

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}

\newenvironment{redmatrix}
  {\left(\array{@{}rrr|c@{}}}
  {\endarray\right)}
\newenvironment{ropmatrix}
  {\array{@{}c@{}}}
  {\endarray}
\newcommand\opone[2]{\xrightarrow{(#1)\times r_#2}}
\newcommand\optwo[3]{\xrightarrow{r_#1{}+{} #2r_#3}}

\begin{document}
\begin{alignat*}{5}
&
\begin{redmatrix}
1&2&0&0\\
-1&1&2&0\\
1&0&1&5\\
0&-2&1&4
\end{redmatrix}
&
\begin{ropmatrix}
\optwo{1}{}{2}
\end{ropmatrix}
&
\begin{redmatrix}
1&2&0&0\\
0&3&2&0\\
0&-2&1&5\\
0&-2&1&4
\end{redmatrix}
&
\begin{ropmatrix}
\opone{1/3}{2}
\end{ropmatrix}
&
\begin{redmatrix}
1&2&0&0\\
0&1&2/3&0\\
0&-2&1&5\\
0&-2&1&4
\end{redmatrix}\\
&&
\begin{ropmatrix}
\optwo{3}{2}{2}\\
\optwo{4}{2}{2}\\
\end{ropmatrix}
&
\begin{redmatrix}
1&2&0&0\\
0&1&2/3&0\\
0&0&7/3&5\\
0&0&7/3&4
\end{redmatrix}
&
\begin{ropmatrix}
\opone{3/7}{3}
\end{ropmatrix}
&
\begin{redmatrix}
1&2&0&0\\
0&1&2/3&0\\
0&0&1&15/7\\
0&0&7/3&4
\end{redmatrix}
\end{alignat*}

\end{document}

enter image description here

share|improve this answer
add comment

I suggest you use array instead of pmatrix environments, as arrays give you more flexibility with regard to the positioning of the elements of a column, and also let you insert vertical bars. Separately, don't specify two separate display math environments, but only one. Here's an MWE:

\documentclass{article}
\usepackage{array}
\begin{document}
\[
\left(\begin{array}{@{}rrr|c@{}}
1&2&0&0\\
-1&1&2&0\\
1&0&1&5\\
0&-2&1&4
\end{array}\right)
\quad
\left(\begin{array}{@{}rrr|c@{}}
1&2&0&0\\
0&3&2&0\\
0&-2&1&5\\
0&-2&1&4
\end{array}\right)
\]
\end{document}

enter image description here

share|improve this answer
add comment

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.