答案1
解决办法是:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix,fit}
\begin{document}
\pgfdeclarelayer{background}
\pgfsetlayers{background,main}
\begin{tikzpicture}
\matrix[matrix of math nodes,left delimiter = (,right delimiter = ),row sep=10pt,column sep = 10pt] (m)
{
1 &3 &-8\\
2 &0 &1\\
-7 &9 &1\\
};
\begin{pgfonlayer}{background}
\node[inner sep=3pt,fit=(m-1-1)] (1) {};
\node[inner sep=3pt,fit=(m-1-2) (m-2-3)] (2) {};
\node[inner sep=3pt,fit=(m-3-3)] (3) {};
\draw[rounded corners,dotted,fill=green!50!white,inner sep=3pt,fill opacity=0.1] (1.north west) -- (2.north east) |- (3.south west) |- (2.south west) |- (1.south west) -- cycle;
\end{pgfonlayer}
\end{tikzpicture}
\end{document}
答案2
您可以使用 color 或 xcolor 包,并以其他颜色打印某些条目。例如,
\begin{pmatrix}
q_{11} & q_{12} & q_{13} \\
\color{gray} q_{21} & q_{22} & q_{23} \\
\color{gray} q_{31} & \color{gray} q_{32} & q_{33}
\end{pmatrix}
答案3
与和 TikZ{pNiceMatrix}
一起使用nicematrix
。
\documentclass{article}
\usepackage{nicematrix,tikz}
\begin{document}
$Q =
\begin{pNiceMatrix}[margin]
\CodeBefore
\tikz \fill [blue!10,rounded corners] (1-|1) |- (2-|2) |- (3-|3) |- (4-|4) -- (1-|4) -- cycle ;
\Body
q_{11} & q_{12} & q_{13} \\
q_{21} & q_{22} & q_{23} \\
q_{31} & q_{32} & q_{33} \\
\end{pNiceMatrix}$
\end{document}
您需要多次编译。