# How can I write nested matrices like this? [closed]

I am reading this Wikipedia article on Kronecker product. How can I use LaTex to write this?

• Double click on the formula, and you can see the LaTeX-code. – hair-splitter Jun 11 at 9:57
• Do try to familiarize yourself with the amsmath package, which provides an environment called bmatrix (short for "matrix surrounded by square brackets, I suppose). – Mico Jun 11 at 10:30

Here's one possible way. I did it with stacks, since the row baselineskips can be tuned to make it work.

In general, (tab)stackengine constructs don't nest well, but in this case, I was able to make it work.

\documentclass{article}
\usepackage{tabstackengine}
\TABstackMath
\stackMath
\setstacktabbedgap{2ex}
\begin{document}
$\setstackgap{L}{1.2\normalbaselineskip} \bracketMatrixstack{1 & 2\\ 3 & 4} \otimes \bracketMatrixstack{0 & 5\\ 6 & 7} = \left[\stackanchor{ 1\left[\Matrixstack{0&5\\6&7}\right] }{ 3\left[\Matrixstack{0&5\\6&7}\right] } \quad \stackanchor{ 2\left[\Matrixstack{0&5\\6&7}\right] }{ 4\left[\Matrixstack{0&5\\6&7}\right] }\right] = \bracketMatrixstack{ 1\times 0 & 1\times 5 & 2 \times 0 & 2 \times 5\\ 1\times 6 & 1\times 7 & 2 \times 6 & 2 \times 7\\ 3\times 0 & 3\times 5 & 4 \times 0 & 4 \times 5\\ 3\times 6 & 3\times 7 & 4 \times 6 & 4 \times 7 } = \bracketMatrixstack{ 0 & 5 & 0 & 10\\ 6 & 7 & 12 & 14\\ 0 & 15 & 0 & 20\\ 18 & 21 & 24 & 28 }$
\end{document}


I propose to use medium-sized matrices, as defined by the nccmath package, and bigstrut for fine-tuning the matrix brackets:

    \documentclass{article}
\usepackage{amsmath, nccmath}
\usepackage{bigstrut}
\newenvironment{mbmatrix}{\begin{medsize}\begin{bmatrix}}{\end{bmatrix}\end{medsize}}

\begin{document}

\begin{align*}
\begin{bmatrix}
1 & 2 \\
3 & 4
\end{bmatrix}
\otimes
\begin{bmatrix}
0 & 5 \\
6 & 7
\end{bmatrix}
& =
\begin{bmatrix}
1 \begin{mbmatrix}
0 & 5 \\
6 & 7
\end{mbmatrix}
& 2\begin{mbmatrix}
0 & 5 \\
6 & 7
\end{mbmatrix} \bigstrutjot=2ex \bigstrut[t] \\[1.5ex]
3 \begin{mbmatrix}
0 & 5 \\
6 & 7
\end{mbmatrix}
& 4\begin{mbmatrix}
0 & 5 \\
6 & 7
\end{mbmatrix} \bigstrutjot=2ex \bigstrut[b]
\end{bmatrix}
= \begin{bmatrix}
1\times0 & 1\times5 & 2\times0 & 2\times5 \\
1\times6 & 1\times7 & 2\times6 & 2\times7 \\
3\times0 & 3\times5 & 4\times0 & 4\times5 \\
3\times6 & 3\times7 & 4\times6 & 4\times7
\end{bmatrix} \\
& =\begin{bmatrix}
0 & 5 & 0 & 10 \\
6 & 7 & 12 & 14 \\
0 & 15 & 0 & 20 \\
18 & 21 & 24 & 28
\end{bmatrix}
\end{align*}

\end{docume