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

6
  • 3
    Welcome to TeX.SX! Could you please complete your code in order to make a minimal working example (MWE) that inlcudes the relevant packages as well as the documentclass? Could you please also include a sketch of the output you'd like to achieve?
    – leandriis
    Mar 2, 2019 at 14:26
  • 1
    Now it is good that you already provided an MWE, so I upvoted your question, but I can't still get it. Please add a sketch showing what you want.
    – user156344
    Mar 2, 2019 at 14:36
  • Thank you for helping me with my first post. I have some experience at other community where it would automatically compile. Polish one.
    – lelel
    Mar 2, 2019 at 14:40
  • You remember that $$...$$ is TeX primitive syntax.
    – Sebastiano
    Mar 2, 2019 at 16:56
  • @Sebastiano what does it mean?
    – lelel
    Mar 2, 2019 at 17:24

2 Answers 2

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

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .