Elementary Row Operation Labels for Matrices

Use nicematrix

\documentclass{article}
\usepackage{amsmath}
\usepackage{nicematrix}

\begin{document}

\[
\begin{bNiceArray}[last-col]{CCC|C}
1 &  1  &  -1 & 1 & \\
0 &  1  & k+1 & 1 & R_2 \gets R_2-2R_1 \\
0 & k-1 &  4  & 1 & R_3 \gets R_3-R_1
\end{bNiceArray}
\]

\end{document}

enter image description here

You can also get a less prominent display of the operations.

\documentclass{article}
\usepackage{amsmath}
\usepackage{nicematrix}

\begin{document}

\[
\begin{bNiceArray}[last-col,code-for-last-col=\scriptstyle]{CCC|C}
1 &  1  &  -1 & 1 & \\
0 &  1  & k+1 & 1 & R_2 \gets R_2-2R_1 \\
0 & k-1 &  4  & 1 & R_3 \gets R_3-R_1
\end{bNiceArray}
\]

\end{document}

enter image description here


Here's a solution that employs the basic LaTeX environment called array and doesn't require any additional packages.

enter image description here

\documentclass{article}
\begin{document}
\[
\sim \left[ \begin{array}{ccc|c}
       1 & 1   & -1  & 1 \\
       0 & 1   & k+2 & 1 \\
       0 & k-1 & 4   & 1 
     \end{array} \right]
     \begin{array}{l}
        \\
        R_2 \to R_2-2R_1 \\
        R_3 \to R_3- R_1
     \end{array}
\]
\end{document}

Adding a matrix* environment on the right:

\documentclass{article}
\usepackage{array}
\usepackage{amssymb}
\usepackage{mathtools}

\makeatletter
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
\hskip -\arraycolsep
\let\@ifnextchar\new@ifnextchar
\array{#1}}
\makeatother

\begin{document}

\begin{align*}
&\sim
\begin{bmatrix}[ccc|c]
1 & 1 & -1 & 1\\
0 & 1 & k+2 & 1\\
0 & k-1 & 4 & 1
\end{bmatrix}
\!
\begin{matrix*}[l]
 \\
 \scriptstyle R_{2}\to R_{2}-2R_{1} \\
\scriptstyle R_{3}\to R_{3}-R_{1}
\end{matrix*}
\end{align*}

\end{document} 

enter image description here