# Arrows for Matrix Row Operations

How do you create the arrows indicating matrix row operations in a non-array environment? I'm trying to have the same output as: I currently have

\item
$\begin{bmatrix} 1 & 7 & 3 & -4 \\ 0 & 1 & -1 & 3 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & -2 \end{bmatrix} \begin{bmatrix} 1 & 7 & 3 & -4 \\ 0 & 1 & -1 & 3 \\ 0 & 0 & 1 & -2 \\ 0 & 0 & 0 & 1 \end{bmatrix}$


and I want to place the arrow in between.

## 2 Answers

You can use \xrightarrow, with some help in order to equalize the widths.

\documentclass{article}
\usepackage{amsmath,mathtools}

\newenvironment{sysmatrix}
{\left(\begin{array}{@{}#1@{}}}
{\end{array}\right)}
\newcommand{\ro}{%
\xrightarrow{\mathmakebox[\rowidth]{#1}}%
}
\newlength{\rowidth}% row operation width
\AtBeginDocument{\setlength{\rowidth}{3em}}

\begin{document}

\begin{alignat*}{2}
\begin{sysmatrix}{rrr|r}
1 &  2 & 0 & 0 \\
-1 &  1 & 2 & 0 \\
1 &  0 & 1 & 5 \\
0 & -2 & 1 & 4
\end{sysmatrix}
&\!\begin{aligned}
&\ro{r_2+r_1}\\
&\ro{r_3-r_1}
\end{aligned}
\begin{sysmatrix}{rrr|r}
1 &  2 & 0 & 0 \\
0 &  3 & 2 & 0 \\
0 & -2 & 1 & 5 \\
0 & -2 & 1 & 4
\end{sysmatrix}
&&\ro{(1/3)r_2}
\begin{sysmatrix}{rrr|r}
1 &  2 &   0 & 0 \\
0 &  1 & 2/3 & 0 \\
0 & -2 &   1 & 5 \\
0 & -2 &   1 & 4
\end{sysmatrix}
\\
&\!\begin{aligned}
&\ro{r_3+2r_2}\\
&\ro{r_4+2r_2}
\end{aligned}
\begin{sysmatrix}{rrr|r}
1 &  2 &   0 & 0 \\
0 &  1 & 2/3 & 0 \\
0 &  0 & 7/3 & 5 \\
0 &  0 & 7/3 & 4
\end{sysmatrix}
&&\ro{(3/7)r_3}
\begin{sysmatrix}{rrr|r}
1 &  2 &   0 & 0 \\
0 &  1 & 2/3 & 0 \\
0 &  0 &   1 & 15/7 \\
0 &  0 & 7/3 & 4
\end{sysmatrix}
\end{alignat*}

\end{document} Here a minimal MWE, \documentclass[a4paper,12pt]{article}
\usepackage{mathtools}
\begin{document}
$$\begin{pmatrix} 3 & 3& 3\\ 3& 3& 3\\ 3& 3& 3 \end{pmatrix} \overset{r_1+r_2}{\longrightarrow} \begin{pmatrix} 3 & 3& 3\\ 3& 3& 3\\ 3& 3& 3 \end{pmatrix} \underset{\overset{r_1-4r_2}{\longrightarrow}}{\overset{r_1+r_2}{\longrightarrow}}$$
\end{document}


or you see at

Formatting arrows between rows of corresponding matrices

Side by Side matrices

• how about \xrightarrow so that it stretches. – barbara beeton Dec 21 '16 at 21:41
• I have tried placing \xrightarrow[r_3 r_4] but I get errors on the next matrix: Argument of \begin has an extra }. <inserted text> \par l.29 \begin {bmatrix} – Sentient Dec 21 '16 at 21:44