I have a matrix in latex and I want to put a box around the first column and another box around the first row to highlight them. Additionally it should be possible to give the highlighted fields a name.
The names should be displayed on the right side for the highlited first row and below the highlighted column.
\begin{align}
m =
\left( \begin{array}{ccc}
1 & \dots & 3 \\
\vdots & ~ & \vdots \\
4 & \dots & 5 \\
\end{array} \right)
\end{align}
Best Answer
You can use
nicematrix
which will create the Tikz nodes for you. Then, you draw the box around the cells with the Tikz libraryfit
.The option
right-margin
is used to add space before the right parenthese.In recent version of
nicematrix
, it's also possible to use the built-in command\Block
(and you don't have to use explicitely Tikz).The output is not exactly the same.