3

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

js bibra
  • 21,280
  • https://tex.stackexchange.com/a/533996/197451 --- https://tex.stackexchange.com/a/554906/197451 – js bibra Jan 13 '22 at 16:35
  • I have seen these but can't seem to get the vertical line to work, I've updated the post with what I have managed to get if there's anything you can suggest. – Isobel Baddeley Jan 13 '22 at 16:55

2 Answers2

3

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}

js bibra
  • 21,280
2

A solution with {pNiceArray}.

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

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

\begin{document}

    $\begin{pNiceArray}[first-col,last-col]{cccc|c}
    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{pNiceArray}$

\end{document}

Output of the above code

F. Pantigny
  • 40,250