I would like to produce a 3x3 block matrix with a layout shown in the left figure below. The matrix is split by a row vector d-e-f
and a column vector b-e-h
(so e
represents a 1x1 submatrix). I would like to add two horizontal and two vertical lines to separate the 9 blocks (4 matrices, 4 vectors, 1 scalar).
I am using the NiceArray
commands of the nicematrix
package, which work as intended if I use two-row blocks (see the left matrix below). However, when I am trying to typeset the row vector d-e-f
using one-row blocks (i.e. changing \Block{2-2}{d}
to \Block{1-2}{d}
and so on), the vertical lines break (see the example on the right). Adding/removing the \hline
commands has no effect on the vertical lines. I am using TeX Live 2019 with nicematrix
version 3.7.
Is there a way I can keep vertical lines around submatrix e
without using two-row blocks?
\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}
Update: ultimately, I'd like to substitute the a
...i
with formulas representing the submatrices, e.g. A_{00}
, a_{01}^\mathsf{T}
, etc.
I'd also like to illustrate that a
and i
are square matrices but c
and g
are not necessarily square ones.
Here is an example output with realistic values:
\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}
\documentclass{article} \begin{document} \[ \left( \begin{array}{c|c|c} {a} & {b} & {c} \\ \hline {d} & {e} & {f} \\ \hline {g} & {h} & {i} \\ \end{array} \right) \] \end{document}
i.stack.imgur.com/0N71i.png