答案1
这是一种使用方法tikzmark
:
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\begin{document}
\begin{equation}
\hat{A}=\begin{pmatrix}
a_{11} &\tikzmark{tl}a_{12} & a_{13} & \dots\tikzmark{tr}\\
\tikzmark{a21}a_{21} & a_{22} & a_{23} & \dots\\
a_{31} & a_{32} & a_{33} & \dots\tikzmark{dots}\\
\tikzmark{bl}\vdots & \vdots & \vdots\tikzmark{br} & \ddots
\end{pmatrix}
\end{equation}
\begin{tikzpicture}[remember picture,overlay]
\draw [blue] ([xshift=-6pt,yshift=-2pt]pic cs:bl) -- ([yshift=10pt]pic cs:a21) -- ([xshift=25pt,yshift=-2pt]pic cs:br) -- cycle;
\draw [red] ([xshift=-10pt,yshift=6pt]pic cs:tl) -- ([yshift=6pt]pic cs:tr) -- ([yshift=-10pt]pic cs:dots) -- cycle;
\end{tikzpicture}
\end{document}
答案2
与。{pNiceMatrix}
nicematrix
\documentclass{article}
\usepackage{nicematrix}
\usepackage{tikz}
\begin{document}
\begin{equation}
\hat{A} =
\begin{pNiceMatrix}
a_{11} &a_{12} & a_{13} & \dots\\
a_{21} & a_{22} & a_{23} & \dots\\
a_{31} & a_{32} & a_{33} & \dots\\
\vdots & \vdots & \vdots & \ddots
\CodeAfter
\begin{tikzpicture} [rounded corners]
\draw [blue] ([xshift=4pt,yshift=3pt]2-|1)
|- ([xshift=-4pt,yshift=3pt]last-|last) -- cycle ;
\draw [red] ([xshift=-5pt,yshift=-3pt]1-|2) -| ([xshift=-3pt,yshift=-5pt]4-|last) -- cycle ;
\end{tikzpicture}
\end{pNiceMatrix}
\end{equation}
\end{document}
由于 PGF/Tikz 节点,您需要进行多次编译。