
我想產生一個 3x3 塊矩陣,其佈局如下左圖所示。此矩陣由行向量d-e-f
和列向量分割b-e-h
(因此e
表示 1x1 子矩陣)。我想加入兩條水平線和兩條垂直線來分隔 9 個區塊(4 個矩陣、4 個向量、1 個標量)。
我正在使用NiceArray
的命令nicematrix
包裹,如果我使用兩行區塊,它會按預期工作(請參見下面的左側矩陣)。但是,當我嘗試d-e-f
使用單行區塊排版行向量(即更改\Block{2-2}{d}
為\Block{1-2}{d}
等)時,垂直線會中斷(請參見右側的範例)。新增/刪除\hline
指令對垂直線沒有影響。我使用的是 TeX Live 2019nicematrix
版本 3.7。
有沒有一種方法可以e
在不使用兩行塊的情況下保留子矩陣周圍的垂直線?
\documentclass{article}
\usepackage{nicematrix}
\begin{document}
\[
\begin{pNiceArray}{cc|c|cc}[margin]
\Block{2-2}{a} & & \Block{2-1}{b} & \Block{2-2}{c} & \\
& & & & \\\hline
\Block{2-2}{d} & & \Block{2-1}{e} & \Block{2-2}{f} & \\
& & & & \\\hline
\Block{2-2}{g} & & \Block{2-1}{h} & \Block{2-2}{i} & \\
& & & & \\
\end{pNiceArray}
\quad
\begin{pNiceArray}{cc|c|cc}[margin]
\Block{2-2}{a} & & \Block{2-1}{b} & \Block{2-2}{c} & \\
& & & & \\
\Block{1-2}{d} & & \Block{1-1}{e} & \Block{1-2}{f} & \\\hline
\Block{2-2}{g} & & \Block{2-1}{h} & \Block{2-2}{i} & \\
& & & & \\
\end{pNiceArray}
\]
\end{document}
更新:最終,我想用表示子矩陣的公式替換a
... ,例如,等。i
A_{00}
a_{01}^\mathsf{T}
a
i
c
g
以下是具有實際值的範例輸出:
\documentclass{article}
\usepackage{nicematrix}
\begin{document}
\setlength{\extrarowheight}{1mm}
\setlength{\arraycolsep}{8pt}
\[
\begin{pNiceArray}{ccc|c|ccccc}[margin]
\Block{3-3}{A_{00}} & & & \Block{3-1}{a_{01}} & \Block{3-4}{A_{20}^\mathsf{T}} & & & \\
& & & & & & & \\
& & & & & & & \\ \hline
% I'd like to use the following line but it doesn't work as expected:
%\Block{1-3}{a_{01}^\mathsf{T}} & & & \Block{1-1}{0} & \Block{1-4}{a_{21}^\mathsf{T}} & & & \\
% two-row blocks are fine:
\Block{2-3}{a_{01}^\mathsf{T}} & & & \Block{2-1}{0} & \Block{2-4}{a_{21}^\mathsf{T}} & & & \\
& & & & & & & \\ \hline
\Block{4-3}{A_{20}} & & & \Block{4-1}{a_{21}} & \Block{4-4}{A_{22}} & & & \\
& & & & & & & \\
& & & & & & & \\
& & & & & & & \\
\end{pNiceArray}
\]
\end{document}
答案1
與@leandriis 在他的評論中建議的類似。您的區塊在子矩陣周圍有更多空間進行模擬:
編輯:
考慮您在編輯問題中提供的矩陣內容
\documentclass{article}
\usepackage{array,
makecell} % new
\begin{document}
\[\setcellgapes{3pt}
\makegapedcells
\left(
\begin{array}{ccc|c|ccc}
& && && & \\
& A_{00} && a_{01} && A_{20}^T & \\
& && && & \\ \hline
& a_{01}^T && 0 && f & \\ \hline
& && && & \\
& A_{20} && a_{21} && A_{22}^T & \\
& && && & \\
\end{array}\right)
\]
\end{document}
注意:新增空白行和空列是為了強調維度子矩陣大於 的地方1 x 1
。如果沒有必要,只需將它們刪除即可。
答案2
事實證明這是當前版本的軟體包中的一個錯誤nicematrix
。此問題已在版本 3.8 (2020-01-02) 中修復,並可在 CTAN 上找到。
\vline
如果由於某種原因您堅持使用舊版本,可以透過在受影響的儲存格末尾添加來解決該錯誤。將其應用於最小工作範例會得到所需的輸出:
\documentclass{article}
\usepackage{nicematrix}
\begin{document}
\setlength{\extrarowheight}{1mm}
\setlength{\arraycolsep}{8pt}
\[
\begin{pNiceArray}{ccc|c|ccccc}[margin]
\Block{3-3}{A_{00}} & & & \Block{3-1}{a_{01}} & \Block{3-4}{A_{20}^\mathsf{T}} & & & \\
& & & & & & & \\
& & & & & & & \\ \hline
\Block{1-3}{a_{01}^\mathsf{T}} & & \vline & \Block{1-1}{0} \vline & \Block{1-4}{a_{21}^\mathsf{T}} & & & \\\hline
\Block{4-3}{A_{20}} & & & \Block{4-1}{a_{21}} & \Block{4-4}{A_{22}} & & & \\
& & & & & & & \\
& & & & & & & \\
& & & & & & & \\
\end{pNiceArray}
\]
\end{document}