答案1
可以方便地使用 来实现这一点。它带有可避免重叠的nicematrix
键,并可用于将彩色框放在背景中。margin
create-cell-nodes
\documentclass{article}
\usepackage{nicematrix}
\usepackage{tikz}
\usetikzlibrary{fit}
\tikzset{he/.code={\node[draw,rounded corners,fill=blue!20,inner sep=2pt,fit=#1]{};}}
\begin{document}
\[
\begin{pNiceMatrix}[r,margin]
\CodeBefore[create-cell-nodes]
\begin{tikzpicture}
\tikzset{he=(1-1)(1-3)}
\end{tikzpicture}
\Body
0 & -1 & 1\\
-2 & 2 & 0
\end{pNiceMatrix}
\cdot
\begin{pNiceMatrix}[r,margin]
\CodeBefore[create-cell-nodes]
\begin{tikzpicture}
\tikzset{he=(1-1)(3-1)}
\end{tikzpicture}
\Body
-3 & 2 \\
2 & 2\\
0 & -1\\
\end{pNiceMatrix}
=
\begin{pNiceMatrix}[r,margin]
\CodeBefore[create-cell-nodes]
\begin{tikzpicture}
\tikzset{he=(1-1)}
\end{tikzpicture}
\Body
C_{11} & C_{12} \\
C_{21} & C_{22}\\
\end{pNiceMatrix}
\]
\end{document}