# brackets inside matrix / matrices inside a matrix

I would like to make something that looks like this:

I don't know how to get the brackets inside the matrix to line up in the right spots. I don't need them to be red; I just added that to emphasize what I want.

Here is what I used to make this (sans red brackets):

\begin{bmatrix}
I_p \\
& \ddots \\
&& I_p \\
& I_p \\
&& \ddots \\
&&& I_p \\
&&& \vdots & \ddots \\
&&& \ddots & \vdots \\
&&&& I_p \\
&&&&& \ddots \\
&&&&&& I_p
\end{bmatrix}


EDIT: See this followup question for the solution I went with.

## 1 Answer

Use blkarray

\documentclass{article}
\usepackage{blkarray}
\begin{document}
$\left[ \begin{blockarray}{ccccccc} \begin{block}{[ccc]cccc} I_p \\ & \ddots \\ & & I_p \\ \end{block} \begin{block}{c[ccc]ccc} & I_p \\ & & \ddots \\ & & & I_p \\ \end{block} & & & \vdots & \ddots \\ & & & \ddots & \vdots \\ \begin{block}{cccc[ccc]} & & & & I_p \\ & & & & & \ddots \\ & & & & & & I_p \\ \end{block} \end{blockarray} \right]$
\end{document}


• Pretty good! Do you know how to adjust it so that the spacing at the top and the bottom is more even? That is the only thing I don't like about this solution as it is. – teerav42 Feb 22 '19 at 18:12
• I fixed it. See this post. – teerav42 Feb 22 '19 at 21:22