2

The following matrix is my desired matrix form :

enter image description here

I attempted to use the nice matrix environment since it offers a solution encircling/squaring rows and elements as seen in this photo above. The only problem is that I couldn't find a way to obtain the blocked partition as seen in the photo and I have scanned this manual https://ctan.math.illinois.edu/macros/latex/contrib/nicematrix/nicematrix.pdf and their partitioning of the matrix would look like two lines intersecting each other different from what I need here in this photo. Therefore, I would hope someone could assist me in writing a code to obtain this matrix as it is in this photo and I would be very much thankful.

  • Welcome to the TeX.SE community. You can use nicematrix package with tikz (see the manual 16.5 How to highlight cells of a matrix, or to use \fbox{}. – Sebastiano Jan 09 '21 at 21:03
  • 1
    Hello, thank you very much! – user232641 Jan 09 '21 at 21:05
  • There are into this community many examples. For example: https://tex.stackexchange.com/questions/441674/encircle-several-submatrices-where-some-circles-are-within-others; – Sebastiano Jan 09 '21 at 21:11
  • 2
    Thank you once more for the related link. The issue I had was trying to search similar questions to see what users might have asked. I had hard time finding any similar questions initially. – user232641 Jan 09 '21 at 21:12

1 Answers1

1

Here is a solution with nicematrix and Tikz.

\documentclass{article}
\usepackage{nicematrix}
\usepackage{tikz}
\usetikzlibrary{fit}

\begin{document}

$\begin{bNiceMatrix}[right-margin,cell-space-limits=3pt] 1 & -1 & 2 & 1 \ \fbox{3} & 5 & -5 & 1 \ \fbox{5} & \fbox{13/5} & 9 & -23/5 \ \fbox{4} & \fbox{6/5} & 3 & -11/5 \CodeAfter \tikz \draw (5-|2) |- (2-|5) ; \tikz \node [draw, rounded corners = 2pt, inner sep=1pt ,fit=(2-2)(2-4)] {} ; \end{bNiceMatrix}$

\end{document}

Output of the above code

F. Pantigny
  • 40,250