# Augmented matrix with labeled rows at the right

I would like to write an augmented matrix with labeled rows out of the right bracket of the matrix, in such a way to enlight operations by row for Gaussian elimination procedure. I'm using this code for writing augmented matrices

Preamble:

\newenvironment{sysmatrix}[1]
{\left(\begin{array}{@{}#1@{}}}
{\end{array}\right)}


Result:

$$\begin{sysmatrix}{rrr|r} 1 & 2 & 0 & 0 \\ -1 & 1 & 2 & 0 \\ 1 & 0 & 1 & 5 \\ 0 & -2 & 1 & 4 \end{sysmatrix}$$


So now, how can I get labeled rows at the right? Have you some suggestions for sample codes?

Thank you

• Off-topic: You should not use $$…$$ in LaTeX. Use, e.g., $…$ instead. Commented Apr 5 at 9:03

With {pNiceArray} of nicematrix.

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

\newenvironment{sysmatrix}
{\begin{pNiceArray}[last-col]}
{\end{pNiceArray}}

$\begin{sysmatrix}{rrr|r} 1 & 2 & 0 & 0 & L_1 \\ -1 & 1 & 2 & 0 & L_2 \\ 1 & 0 & 1 & 5 & L_3 \\ 0 & -2 & 1 & 4 \end{sysmatrix}$

\end{document}


You need several compilations.

I solved by creating a matrix with

\begin{matrix}
\end{matrix}


at the right of the main one, and putting operations by rows into its elements.

Thank you anyway.