Matrix within a matrix

matrices

I'm looking to make something like this: enter image description here

I can only create a matrix on one entry so far. How would one do this?

Muchos gracias!

Best Answer

With {pNiceMatrix} of nicematrix.

\documentclass[12pt]{article}
\usepackage{nicematrix}

\begin{document}

\[\begin{pNiceMatrix}
X_{11} & X_{12} & \Cdots &  X_{1n} \\
X_{21} & \Block{3-3}<\Large>{B} \\
\Vdots \\
X_{1n} \\
\CodeAfter
  \SubMatrix[{2-2}{4-4}][xshift=-1ex,extra-height=-1ex]
\end{pNiceMatrix}\]

\end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes under the hood).

Output of the above code

Related Question