Here, I wish to draw a rectangle around the principal diagonal elements (red colored) of the below matrix.
MWE:
\documentclass{article}
\usepackage{amsmath,xcolor}
\begin{document}
Here, I wish to draw a rectangle around the principal diagonal elements
(red colored) of the below matrix.
\[
A = \begin{bmatrix}
\textcolor{red}{1} & 2 & 3 & 4\\
1 & \textcolor{red}{2} & 3 & 4\\
1 & 2 & \textcolor{red}{3} & 4\\
1 & 2 & 3 & \textcolor{red}{4}
\end{bmatrix}
\]
\end{document}
Best Answer
Like this?
With use of
nicematrix
package you obtain above result after two compilation ot he following MWE:or like this: