# A question about typesetting a partitioned matrix

How one can create the following matrix?

Two variants. I have to use a \raisebox command, adjusted by trial and errors, because it seems blockarray environment, for some reason, is not centred on the mathaxis. The blockarray is not raised at all (0pt), but the optional arguments are here to fool LaTeX and make it believe the contents of the environment is slightly higher and less deep than it is really:

\documentclass{article}
\usepackage{amsmath}
\usepackage{blkarray}

\begin{document}

$A = \begin{bmatrix}\raisebox{0pt}[\dimexpr\height + 1ex\relax][\dimexpr\depth- 2ex\relax]{% \begin{blockarray}{c c c c} \begin{block}{[cc]cc} 1 & 2 & 0 & 0 \\ 3 & 4 & 0 & 0\\ \end{block} \begin{block}{cc[c] c} 0 & 0 & {\,3\,} & 0\\ \end{block} \begin{block}{ccc[c]} 0 & 0 & 0 & \,4\, \\ \end{block} \end{blockarray} }\! \end{bmatrix}$

$A = \begin{bmatrix}\raisebox{0pt}[\dimexpr\height + 1ex\relax][\dimexpr\depth- 2ex\relax]{% \begin{blockarray}{c c c c} \begin{block}{[cc\Right{]}{\hskip2.333em \raisebox{-0.4\height}[\height][\depth]{\rlap{\Large 0}}}cc} 1 & 2 & \\ 3 & 4 &\\ \end{block} \begin{block}{cc[c] c} & & {\,3\,} & \\ \end{block} \begin{block}{ccc[c]} \BAmulticolumn{3}{c}{\raisebox{0.2\height}[\height][\depth]{\smash[t]{\llap{\Large 0}}\enspace }} & \,4\, \\ \end{block} \end{blockarray} }\! \end{bmatrix}$

\end{document}


• +1. For the benefit of any not-yet-expert-TeXnician readers of your answer, you may want to add a couple of explanatory sentences regarding the use of (a) the \raisebox "wrapper" around the blkarray environment and (b){\,3\,} instead of "just" 3.
– Mico
May 7, 2016 at 10:54
• @Mico: Done, Mylord! Hope it's clear enough for no-experts. May 7, 2016 at 12:28
• there's a slight difference in the two results: the brackets around the "4" in the lower right corner are taller in the second version. no doubt unintended. (i haven't tested to determine why the difference, but i assume it has something to to with the height of the \Large zero.) i'd be inclined to center at least the left large 0 horizontally; an \llap could be used for this. May 7, 2016 at 15:55
• @barbara beeton: my intention was to have the Large 0s symmetrical w.r.t. [3]. I smashed and lapped 'em. Is it more to your taste? May 7, 2016 at 16:18
\documentclass{article}

\usepackage{blkarray}

\begin{document}

$\left[\begin{blockarray}{cccc} \begin{block}{[cc]cc} 1 & 2 & \cdot & \cdot\\ 3 & 4 & \cdot & \cdot\\ \end{block} \cdot & \cdot & [3] &\cdot\\ \cdot & \cdot & \cdot & [4]\\ \end{blockarray}\right]$

\end{document}


One can use \circ instead of \cdot . Nice package blkarray!

With {NiceMatrix} of nicematrix.

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

$\begin{NiceMatrix} 1 & 2 & 0 & 0 \\ 3 & 4 & 0 & 0 \\ 0 & 0 & 3 & 0 \\ 0 & 0 & 0 & 4 \CodeAfter \SubMatrix[{1-1}{2-2}] \SubMatrix[{3-3}{3-3}] \SubMatrix[{4-4}{4-4}] \SubMatrix[{1-1}{4-4}][extra-height=2mm,xshift=3pt] \end{NiceMatrix}$

\end{document}