10

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

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.

Sentient
  • 275

2 Answers2

9

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

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

\newenvironment{sysmatrix}[1]
 {\left(\begin{array}{@{}#1@{}}}
 {\end{array}\right)}
\newcommand{\ro}[1]{%
  \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}

enter image description here

egreg
  • 1,121,712
7

Here a minimal MWE, enter image description here

\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

Sebastiano
  • 54,118