How one can create the following matrix?
-
tex.stackexchange.com/questions/8947/submatrix-in-latex#8991Benjamin McKay– Benjamin McKay2016-05-07 08:37:33 +00:00Commented May 7, 2016 at 8:37
-
1I have already seen this post. My question is different with this post.Math-Data– Math-Data2016-05-07 09:14:50 +00:00Commented May 7, 2016 at 9:14
3 Answers
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}
-
2+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 theblkarrayenvironment and (b){\,3\,}instead of "just"3.Mico– Mico2016-05-07 10:54:50 +00:00Commented May 7, 2016 at 10:54 -
2@Mico: Done, Mylord! Hope it's clear enough for no-experts.Bernard– Bernard2016-05-07 12:28:11 +00:00Commented 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
\Largezero.) i'd be inclined to center at least the left large 0 horizontally; an\llapcould be used for this.barbara beeton– barbara beeton2016-05-07 15:55:07 +00:00Commented 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?Bernard– Bernard2016-05-07 16:18:57 +00:00Commented 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}


