Is it possible to define a new matrix environment with a parameter function at the end?
This is the enviorment I am trying to use
\newenvironment{amatrix}[2]{%
$\left[\begin{array}{@{}*{#1}{c}|c@{}}
}{%
\end{array}\right]}
\stackrel{#2}{\rightarrow}$}
So that I can type this simple matrix.
\begin{amatrix}{3}{r_1\leftrightarrow r_3}
-R_1 & R_2 & 0 & E_2-E_1 \\
0 & R_2 & R_3 & E_2 \\
1 & 1 & -1 & 0 \\
\end{amatrix}
and get this result.
I know that I can define the environment and the command separately as
\newenvironment{amatrix}[2]{%
$\left[\begin{array}{@{}*{#1}{c}|c@{}}
}{%
\end{array}\right]}
\newcommand{\arr}{$\stackrel{#2}{\rightarrow}$}
then I just need to type
\begin{amatrix}{3}
-R_1 & R_2 & 0 & E_2-E_1 \\
0 & R_2 & R_3 & E_2 \\
1 & 1 & -1 & 0 \\
\end{amatrix}
\arr{r_1\leftrightarrow r_3}
but is it possible to combined this into one environment, and how would I do this?


