6

I'm trying to create a block matrix and surely there are hundreds of question about those already. But most of what I read so far, seems quite hackish in the end. What I have is:

\documentclass{article}

\usepackage[fleqn]{amsmath}
\usepackage{blkarray}
\usepackage{multirow}
\usepackage{mathtools}
\usepackage{graphicx}
\newcommand{\rdots}{\hspace{.2ex}\raisebox{1ex}{\rotatebox{-12}{$\ddots$}}}

\begin{document}

\begin{equation}
    \begin{blockarray}{(c@{}c@{}c|c@{}c@{}c)l}
        1&&0&\BAmulticolumn{3}{c}{\multirow{3}{*}{\huge$0$}}&\multirow{3}{*}{$\dim F\;\text{vertical}$}\\&\rdots&&&&&\\0&&1&&&&\\
        \cline{1-6}
        \BAmulticolumn{3}{c|}{\multirow{3}{*}{\huge$0$}}&\tfrac{1}{t}&&0&\multirow{3}{*}{$\dim Z\;\text{horizontal}$}\\&&&&\rdots&&\\&&&0&&\tfrac{1}{t}&\\
    \end{blockarray}
\end{equation}

\end{document}

current output

There are a lot of bits, that could be improved, but most importantly the spacing in the submatrices is too wide.

I also tried to enclose things that occur multiple times in macros

\newcommand\zeroblock[3][]{\BAmulticolumn{#2}{c#1}{\multirow{#3}{*}{\huge$0$}}}

\newcommand\position[3]{\mspace{#1}\raisebox{#2}{$\mathclap{#3}$}}
\newcommand\diagonal[1]{\begin{matrix}#1&\position{-8mu}{-2em}{\rdots}\scalebox{1.5}{0}\\\scalebox{1.5}{0}&#1\end{matrix}}

\begin{document}

\begin{equation}
    \begin{array}{c|c}
        \diagonal{1}&\zeroblock33\\
        \zeroblock33&\diagonal{\tfrac{1}{t}}
    \end{array}
\end{equation}

but \zeroblock gives me

! Misplaced \omit.
\multispan ->\omit 
                   \@multispan 
l.18        \diagonal{1}&\zeroblock33
                                \\

and diagonal, while it works inside of array, does not work in blockarray and gives

! Incompatible list can't be unboxed.
<argument> \BA@first@box 

Also it does not look good:

output of <code>\diagonal{1}</code>

So I was thinking, that certainly there must be a better way to do these things. Is there?

2
  • I think it is better to write I and 1/t times I on the diagonal. Or diag(1,1/t)\otimes I
    – percusse
    Commented Feb 21, 2013 at 11:36
  • @percuße: That is a good suggestion, but I want to put more emphasis on the multiplicity / dimensions.
    – bodo
    Commented Feb 21, 2013 at 11:40

2 Answers 2

6

use the default tabcolsep and increase the array stretch:

\documentclass{article}

\usepackage[fleqn]{amsmath}
\usepackage{blkarray}
\usepackage{multirow}
\usepackage{mathtools}
\usepackage{graphicx}
\newcommand{\rdots}{\hspace{.2ex}\raisebox{1ex}{\rotatebox{-12}{$\ddots$}}}

\begin{document}

\begin{equation}\def\arraystretch{1.5}
    \begin{blockarray}{(ccc|ccc)l}
        1&&0&\BAmulticolumn{3}{c}{\multirow{3}{*}{\huge$0$}}&\multirow{3}{*}{$\dim F\;\text{vertical}$}\\&\rdots&&&&&\\0&&1&&&&\\
        \cline{1-6}
        \BAmulticolumn{3}{c|}{\multirow{3}{*}{\huge$0$}}&\tfrac{1}{t}&&0&\multirow{3}{*}{$\dim Z\;\text{horizontal}$}\\&&&&\rdots&&\\&&&0&&\frac{1}{t}&\\
    \end{blockarray}
\end{equation}

\end{document}

enter image description here

Using a small matrix makes also sense:

\begin{equation}
 \left(
    \begin{array}{r@{}c|c@{}l}
  &    \begin{smallmatrix}
        1 & & 0 \\
          &\ddots&\\
        0 & & 1\rule[-1ex]{0pt}{2ex}
      \end{smallmatrix} & \mbox{\huge0} & \rlap{\kern5mm$\dim F$ vertical}\\\hline
  &    \mbox{\huge0} &  
       \begin{smallmatrix}\rule{0pt}{2ex}
        \frac1t & & 0 \\
          &\ddots&\\
        0 & & \frac1t
      \end{smallmatrix}    &  \rlap{\kern5mm$\dim Z$ horizontal}
    \end{array} 
\right)
\end{equation}

enter image description here

2
  • That does look a bit better, but I was asking for more compact spacing and maybe a simpler approach.
    – bodo
    Commented Feb 21, 2013 at 11:51
  • 1
    @canaaerus: see my edit. Using smallmatrix makes more sense
    – user2478
    Commented Feb 21, 2013 at 12:25
3

With {NiceArray} of nicematrix.

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

\NiceMatrixOptions{cell-space-limits=1pt}
\newcommand{\BigZero}{\Block{3-3}<\LARGE>{0}}

$\begin{pNiceArray}{ccc|ccc}[last-col]
1 & & 0 & \BigZero \\
& \Ddots & & & & & \dim F \text{ vertical} \\
0 & & 1 \\
\hline
\BigZero & & &\frac{1}{t} & & 0 \\
& & & & \Ddots & &  \dim Z \text{ horizontal} \\
& & & 0 & & \frac{1}{t}
\end{pNiceArray}$

\end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes under the hood).

Output of the above code

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .