# How to produce nested matrix with labels just using the amsmath package?

I am trying to create this matrix in Microsoft word 2010 with mathtype and since mathtype just uses the amsmath package, I should only use this pckage in my latex code. Can anyone tell me what code should I use?

You can, with some tricks:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

$\boldsymbol{O}_{4}(2\phi)= \begin{bmatrix} 1 & \mspace{-12mu} \begin{matrix} 0 & 0 & 0 \end{matrix} \\ \begin{matrix} 0 \\ 0 \\ 0 \end{matrix} & \mspace{-12mu} \begin{bmatrix} \vphantom{\begin{matrix} 0 \\ 0 \\ 0 \end{matrix}} \boldsymbol{O}_{3}(2\phi) \end{bmatrix} \end{bmatrix}$

\end{document}


The main trick is nesting matrices; but it's also necessary to compensate the space of the inner left bracket, which I do with the \mspace{-12mu} commands.

• can you please explain more about this line? \vphantom{\begin{matrix} 0 \\ 0 \\ 0 \end{matrix}} what does vphantom do? also from \begin{matrix} 0 \\ 0 \\ 0 \end{matrix} seems that you have created a 3x1 matrix as the inner matrix not a 3x3 matrix?!!! – Sepideh Abadpour Aug 15 '15 at 9:44
• @sepideh The phantom makes the inner bmatrix as high as the column of zeros; the outer bmatrix has two columns. – egreg Aug 15 '15 at 11:19
• I mean the inner bmatrix has just 1 column – Sepideh Abadpour Aug 15 '15 at 11:20
• @sepideh Yes, of course: you just want one object in it, don't you? – egreg Aug 15 '15 at 11:26

Here is a solution, based on blkarray, multirow and \bigstrut:

\documentclass{book}
\usepackage{amsmath, bm}
\usepackage{blkarray, multirow, bigstrut}

\newcommand\mystrut[1][0.6ex]{\setlength\bigstrutjot{#1}{\bigstrut[t]}}
\usepackage{bm}
\begin{document}

$\bm{O}_4(2\phi) = \begin{bmatrix} \!\!\!\begin{blockarray}{c c c c} 1 & 0 & 0 & 0 \mystrut\\ \begin{block}{c [c c c]} 0 & \BAmulticolumn{3}{c}{\multirow{3}{*}{\bm{O}_3(2\phi)}}\\ 0 & \\ 0 &\\ \end{block} \end{blockarray} \!\vspace{-1.8ex} \end{bmatrix}$

\end{document}