![如何实现盒式矩阵条目](https://linux22.com/image/455851/%E5%A6%82%E4%BD%95%E5%AE%9E%E7%8E%B0%E7%9B%92%E5%BC%8F%E7%9F%A9%E9%98%B5%E6%9D%A1%E7%9B%AE.png)
答案1
一个解决方案是使用该tikzmark
库:
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{fit, % new
tikzmark} % new
\usepackage{lipsum}
\begin{document}
\lipsum[1][1-2]
\[
\begin{pmatrix}
~\tikzmarknode{a}{\hat{A}}
& \hat{B} & \hat{C}^{-1} & D \\
~\tilde{A} & \tilde{B} & \tikzmarknode{b}{\tilde{C}^{-1}}
& D \\
\end{pmatrix}
\]
\begin{tikzpicture}[overlay,remember picture]
\node [draw=red, semithick, inner sep=2pt, rounded corners,
fit=(a) (b), label=below:{$=\Lambda^T$}] {};
\end{tikzpicture}
\vspace{2ex}
\lipsum[1][3-4]
\end{document}
经过两次编译后得到:
编辑:
另一种可能性是将矩阵绘制为 Ti钾\vspace{2ex}
Z 矩阵。在这种情况下,您不必像第一个示例中那样为节点的标签保留垂直空间:
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{fit,
matrix}
\begin{document}
\begin{center}
\begin{tikzpicture}
\matrix (m) [matrix of math nodes,
left delimiter=(,right delimiter=)
]
{
\hat{A} & \hat{B} & \hat{C}^{-1} & D \\
~\tilde{A} & \tilde{B} & \tilde{C}^{-1} & D \\
};
\node [draw=red, semithick, inner sep=2pt, rounded corners,
fit=(m-1-1) (m-2-3), label=below:{$=\Lambda^T$}] {};
\end{tikzpicture}
\end{center}
\end{document}
经过一次编译后得到:
答案2
这是一个不需要加载任何包的解决方案。
\documentclass{article} % or some other suitable document class
\begin{document}
\[
\begin{array}{@{}c@{}}
\left(\begin{array}{@{} |ccc|c @{}}
\cline{1-3}
\hat{A} & \hat{B} & \hat{C}^{-1^{\mathstrut}} & D \\
\tilde{A} & \tilde{B} & \tilde{C}^{-1} & D \\
\cline{1-3}
\end{array}\right) \\
\Lambda^{T}~
\end{array}
\]
\end{document}
答案3
这里有一个选项nicematrix
。
\documentclass{article}
\usepackage{nicematrix}
\begin{document}
\[
\begin{pNiceMatrix}[last-row, left-margin=.5em]
\Block[draw, rounded-corners]{2-3}{}\hat{A} & \hat{B} & \hat{C}^{-1} & D\rule{0pt}{3ex}\\[1ex]
\tilde{A} & \tilde{B} & \tilde{C}^{-1} & D\\
\Block{1-3}{\Lambda^{T}{\rule{0pt}{3ex}}}
\end{pNiceMatrix}
\]
\end{document}
您可以通过设置来更改框的颜色
\Block[draw=red, rounded-corners]