Side by Side matrices
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}
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
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}
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}