How to create a matrix with row labels on the outside (left and right) and a vertical line inside

matricesnicematrix

I'm trying to achieve something like the picture below, I am currently using {pNiceMatrix} and can achieve the labels but cannot seem to find a way to put a vertical line in. Any suggestions?

enter image description here

My current code and output is below:

\usepackage{nicematrix}

\NiceMatrixOptions{
code-for-first-col = \color{blue} ,
code-for-last-col = \color{blue}
}

\begin{document}

        $\begin{pNiceMatrix}[first-col,last-col]
        r_1  & 1  & 0  & 1  & 1  & 10  & 13 \\
        r_2  & 3  & 1  & 1  & 1  & 20  & 26 \\
        r_3  & 2  & -1  & 4  & -1  & 0  & 4 \\
        r_4  & 4  & 4  & 2   & -2  &6  & 11 \\
        \end{pNiceMatrix}$

\end{document}

enter image description here

Best Answer

enter image description here

\documentclass[a4paper, 12pt]{article}
\usepackage{nicematrix}
\usepackage{tikz}

\NiceMatrixOptions{
code-for-first-col = \color{blue} ,
code-for-last-col = \color{blue}
}

\begin{document}

        $\begin{pNiceMatrix}[first-col,last-col]
        r_1  & 1  & 0  & 1  & 1  & 10  & 13 \\
        r_2  & 3  & 1  & 1  & 1  & 20  & 26 \\
        r_3  & 2  & -1  & 4  & -1  & 0  & 4 \\
        r_4  & 4  & 4  & 2   & -2  &6  & 11 
        \CodeAfter
        \tikz \draw (1-|5) -- (5-|5)  ;
        \end{pNiceMatrix}$

\end{document}