I would like to label my matrices with row operations. I am aware that this exists, but I am looking specifically for the style below.
My current code is as follows:
\documentclass{article}
\usepackage{amssymb}
\usepackage{amsmath}
\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}
\end{align*}
\end{document}
Clarification: I am looking for code which reproduces the image above. I have updated the code to reflect this.