7

I'd like to create a matrix like this:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$$ \begin{bmatrix}
    a & b' \\
    b & D
\end{bmatrix} $$
\end{document}

but I'd like to indicate that the size of vector b and put it like on two fields, horizontally or vertically. The same with matrix D which I'd like to put like a 2×2 matrix with a name in the center.

Goal

lelel
  • 73

2 Answers2

8

I pretend that the second item in the first row is as wide as two normal columns. Similarly, the second item in the second row is as tall as two normal rows.

\documentclass{article}
\usepackage{amsmath,mathtools}

\begin{document}

[ \sbox0{$\begin{matrix} D & D\end{matrix}$} \left[\begin{array}{c|c} a & \mathmakebox[\wd0]{b'} \ \hline b & \vphantom{\begin{matrix} D \ D \end{matrix}} D \end{array}\right] ]

\end{document}

enter image description here

Added December 2022

A much better tool has appeared, namely nicematrix.

\documentclass{article}
\usepackage{amsmath}
\usepackage{nicematrix}

\begin{document}

[ \begin{bNiceArray}{c|w{c}{3em}}[margin] a & b' \ \hline \Block{2-1}{b} & \Block{2-1}{D} \ & \end{bNiceArray} ]

\end{document}

enter image description here

egreg
  • 1,121,712
1

An alternative with tabularray:

\documentclass{article}
\usepackage{tabularray}
\UseTblrLibrary{amsmath}
\begin{document}
\[
\begin{+bmatrix}[
    vline{2} = {1}{abovepos = -1},
    vline{2} = {2}{belowpos = -1},
    colspec={cm{3em}},
    rowspec={Q[m]|m{3em}},
    ]
    a & b' \\
    b & D
\end{+bmatrix}
\]
\end{document}

enter image description here

I set abovepos and belowpos to -1 to shorten the vertical line, because I don't like it when it is higher than the parenthesis. If you like it, you can remove that setting, of course.

CarLaTeX
  • 62,716