我想突出显示矩阵块,它由其前 3 行和列组成。为了做到这一点,我考虑在前 3 列上放置一个过度支撑,如下图所示:
但我还想指定要为哪些列或行扩展矩阵的外部支撑。如何使用 nicematrix 包来实现?下面,它遵循基本的 MWE 来制作我想要的矩阵。
\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{nicematrix}
\usetikzlibrary{matrix}
\begin{document}
\begin{small}
% \begin{subequations}
\begingroup
\allowdisplaybreaks
\begin{gather}
\begin{aligned}
\boldsymbol{\mathcal{F}}^{i} & = %
\begingroup
\begin{bNiceMatrix}[%
margin,
nullify-dots,
]
\mathtt{f}_{1\,1} & \Cdots & \mathtt{f}_{1\,\varpi} & \mathtt{f}_{1\,(\varpi+1)} & \Cdots & \mathtt{f}_{1\,\eta} %
\\
\Vdots & \Ddots & \Vdots & \Vdots & & \Vdots %
\\
\mathtt{f}_{\varpi\,1} & \Cdots & \mathtt{f}_{\varpi\,\varpi} & \mathtt{f}_{\varpi\,(\varpi+1)} & \Cdots & \mathtt{f}_{\varpi\,\eta} %
\\
\noalign{\kern2mm}
\mathtt{f}_{(\varpi+1)\,1} & \Cdots & \mathtt{f}_{(\varpi+1)\,\varpi} & \mathtt{f}_{(\varpi+1)\,(\varpi+1)} & \Cdots & \mathtt{f}_{(\varpi+1)\,\eta} %
\\
\Vdots & & \Vdots & \Vdots & \Ddots & \Vdots %
\\
\mathtt{f}_{\eta\,1} & \Cdots & \mathtt{f}_{\eta\,\varpi} & \mathtt{f}_{\eta\,(\varpi+1)} & \Cdots & \mathtt{f}_{\eta\,\eta} %
\end{bNiceMatrix}%
\endgroup%
\end{aligned}
\end{gather}
\endgroup
% \end{subequations}
\end{small}
\end{document}
答案1
您可以使用code-after
钩子来添加支架。
\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{nicematrix}
\usetikzlibrary{decorations.pathreplacing,calligraphy}
\begin{document}
\begin{small}
% \begin{subequations}
\begingroup
\allowdisplaybreaks
\begin{gather}
\begin{aligned}
\boldsymbol{\mathcal{F}}^{i} & = %
\begingroup
\begin{bNiceMatrix}[%
margin,
nullify-dots,
code-after = {\begin{tikzpicture}[
decoration={calligraphic brace, amplitude=6pt,raise=2pt}]
\draw[decorate,thick] (1-1.north west) -- (1-3.north east)
node[midway,above=1.5ex]{$\scriptstyle\mathcal{F}_N^i$};
\end{tikzpicture}}
]
\mathtt{f}_{1\,1} & \Cdots & \mathtt{f}_{1\,\varpi} & \mathtt{f}_{1\,(\varpi+1)} & \Cdots & \mathtt{f}_{1\,\eta} %
\\
\Vdots & \Ddots & \Vdots & \Vdots & & \Vdots %
\\
\mathtt{f}_{\varpi\,1} & \Cdots & \mathtt{f}_{\varpi\,\varpi} & \mathtt{f}_{\varpi\,(\varpi+1)} & \Cdots & \mathtt{f}_{\varpi\,\eta} %
\\
\noalign{\kern2mm}
\mathtt{f}_{(\varpi+1)\,1} & \Cdots & \mathtt{f}_{(\varpi+1)\,\varpi} & \mathtt{f}_{(\varpi+1)\,(\varpi+1)} & \Cdots & \mathtt{f}_{(\varpi+1)\,\eta} %
\\
\Vdots & & \Vdots & \Vdots & \Ddots & \Vdots %
\\
\mathtt{f}_{\eta\,1} & \Cdots & \mathtt{f}_{\eta\,\varpi} & \mathtt{f}_{\eta\,(\varpi+1)} & \Cdots & \mathtt{f}_{\eta\,\eta} %
\end{bNiceMatrix}%
\endgroup%
\end{aligned}
\end{gather}
\endgroup
% \end{subequations}
\end{small}
\end{document}
如果您还想像屏幕截图中那样添加 pmatrix 括号,可以执行以下操作。
\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{nicematrix}
\usetikzlibrary{decorations.pathreplacing,calligraphy}
\tikzset{block matrix/.style={path picture={
\draw ([xshift=#1,yshift=\pgflinewidth/2]path picture bounding box.south west)
-| ([xshift=\pgflinewidth/2,yshift=-\pgflinewidth/2]path picture bounding box.north west)
-- ++ (#1-\pgflinewidth/2,0)
([xshift=-#1,yshift=\pgflinewidth/2]path picture bounding box.south east)
-| ([xshift=-\pgflinewidth/2,yshift=-\pgflinewidth/2]path picture bounding box.north east)
-- ++ (-#1+\pgflinewidth/2,0);
}},block matrix/.default=0.8ex}
\begin{document}
\begin{small}
% \begin{subequations}
\begingroup
\allowdisplaybreaks
\begin{gather}
\begin{aligned}
\boldsymbol{\mathcal{F}}^{i} & = %
\begingroup
\begin{bNiceMatrix}[%
margin,
nullify-dots,
code-after = {\begin{tikzpicture}[
decoration={calligraphic brace, amplitude=6pt,raise=2pt}]
\node[inner xsep=1ex,fit=(1-1) (3-3),block matrix,thick](block){};
\draw[decorate,thick] (block.north west) -- (block.north east)
node[midway,above=1.5ex]{$\scriptstyle\mathcal{F}_N^i$};
\end{tikzpicture}}
]
\mathtt{f}_{1\,1} & \Cdots & \mathtt{f}_{1\,\varpi} & \mathtt{f}_{1\,(\varpi+1)} & \Cdots & \mathtt{f}_{1\,\eta} %
\\
\Vdots & \Ddots & \Vdots & \Vdots & & \Vdots %
\\
\mathtt{f}_{\varpi\,1} & \Cdots & \mathtt{f}_{\varpi\,\varpi} & \mathtt{f}_{\varpi\,(\varpi+1)} & \Cdots & \mathtt{f}_{\varpi\,\eta} %
\\
\noalign{\kern2mm}
\mathtt{f}_{(\varpi+1)\,1} & \Cdots & \mathtt{f}_{(\varpi+1)\,\varpi} & \mathtt{f}_{(\varpi+1)\,(\varpi+1)} & \Cdots & \mathtt{f}_{(\varpi+1)\,\eta} %
\\
\Vdots & & \Vdots & \Vdots & \Ddots & \Vdots %
\\
\mathtt{f}_{\eta\,1} & \Cdots & \mathtt{f}_{\eta\,\varpi} & \mathtt{f}_{\eta\,(\varpi+1)} & \Cdots & \mathtt{f}_{\eta\,\eta} %
\end{bNiceMatrix}%
\endgroup%
\end{aligned}
\end{gather}
\endgroup
% \end{subequations}
\end{small}
\end{document}
答案2
6.4 版nicematrix
(2021/11/23) 提供了新的命令\OverBrace
和\UnderBrace
可用于\CodeAfter
解决这种情况。括号是标准 LaTeX 的括号(即用当前数学字体构造的括号),而不是 Tikz 的括号。
\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{nicematrix}
\begin{document}
\begin{small}
\begin{equation*}
\newcommand{\ff}{\mathtt{f}}
\boldsymbol{\mathcal{F}}^{i} =
\begin{bNiceMatrix}[margin,nullify-dots]
\ff_{1\,1} & \Cdots & \ff_{1\,\varpi} & \ff_{1\,(\varpi+1)} & \Cdots & \ff_{1\,\eta} \\
\Vdots & \Ddots & \Vdots & \Vdots & & \Vdots \\
\ff_{\varpi\,1} & \Cdots & \ff_{\varpi\,\varpi} & \ff_{\varpi\,(\varpi+1)} & \Cdots & \ff_{\varpi\,\eta} \\
\noalign{\kern2mm}
\ff_{(\varpi+1)\,1} & \Cdots & \ff_{(\varpi+1)\,\varpi} & \ff_{(\varpi+1)\,(\varpi+1)} & \Cdots & \ff_{(\varpi+1)\,\eta} \\
\Vdots & & \Vdots & \Vdots & \Ddots & \Vdots \\
\ff_{\eta\,1} & \Cdots & \ff_{\eta\,\varpi} & \ff_{\eta\,(\varpi+1)} & \Cdots & \ff_{\eta\,\eta}
\CodeAfter
\SubMatrix[{1-1}{3-3}][slim,extra-height=-1mm,xshift=1mm]
\OverBrace{1-1}{3-3}{\scriptstyle\mathcal{F}_N^i}[shorten,yshift=1mm]
\end{bNiceMatrix}
\end{equation*}
\end{small}
\end{document}
与往常一样nicematrix
,您需要进行多次编译。