7

I'm trying to create a block diagonal matrix with labeled blocks as shown in the images below: enter image description here

I have tried:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation}
    \begin{bmatrix}
        \mathbf{D} & & & \textbf{\Huge 0} \\
        & \mathbf{S}_1\\
        &   & \ddots \\
        \textbf{\Huge0}&  &    & \mathbf{S}_r\\
    \end{bmatrix}
\end{equation}
\end{document}

enter image description here

The location of the zeros, however, is not well aligned.

4 Answers 4

7

You might check the documentation of nicematrix. Here's a “manual” implementation.

\RequirePackage{fix-cm}
\documentclass{article}
\usepackage{amsmath}

\newcommand{\topzero}{%
  \hspace*{\fill}%
  \makebox[0pt][r]{%
    \raisebox{\dimeval{\fontcharht\font`X-\height}}[\fontcharht\font`X][0pt]{%
      \normalfont\fontsize{1cm}{0pt}\bfseries 0%
    }%
  }%
}
\newcommand{\botzero}{%
  \makebox[0pt][l]{%
    \smash{\normalfont\fontsize{1cm}{0pt}\bfseries 0}%
  }%
  \hspace*{\fill}%
}

\begin{document}

\begin{equation}
\begin{bmatrix}
  \mathbf{D} &              &        & \topzero     \\
             & \mathbf{S}_1                         \\
             &              & \ddots                \\
  \botzero   &              &        & \mathbf{S}_r
\end{bmatrix}
\end{equation}

\begin{equation}
\begin{bmatrix}
  \mathbf{S}_1 &        & \topzero     \\
               & \ddots                \\
  \botzero     &        & \mathbf{S}_r
\end{bmatrix}
\end{equation}

\end{document}

enter image description here

If you use a different math font package, you don't need fix-cm. Adjust the ad hoc height of 1cm to suit your taste.

7

Something like this? (Note that I've changed bmatrix from a 4x4 to a 5x5 matrix.)

enter image description here

\documentclass{article}
\usepackage{mathtools,multirow}
\begin{document}

\begin{equation}
    \left[ \begin{array}{@{} ccccc @{}}
        \mathbf{D} & & & \multicolumn{2}{@{}c@{}}{%
        \multirow{3.5}{*}{\Huge$\mathbf{0}$}} \\
        & \mathbf{S}_1 \\
        \multicolumn{2}{@{}c@{}}{%
        \multirow{2.5}{*}{\Huge$\mathbf{0}$}} & \ddots\\
        & & & \mathbf{S}_{r\mathrlap{-1}}\\
        & & & & \mathbf{S}_r\\
    \end{array}\right]
\end{equation}

\end{document}
7

A suggestion with {bNiceMatrix} of nicematrix.

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

\begin{equation}
\begin{bNiceMatrix}[nullify-dots]
    \mathbf{D} & & \Block[r]{2-2}<\Huge>{\mathbf{0}} \\
    & \mathbf{S}_1\\
    \Block[l]{2-2}<\Huge>{\mathbf{0}} &   & \Ddots \\
    &  &    & \mathbf{S}_r\\
\end{bNiceMatrix}
\end{equation}

\end{document}

Output of the above code

1
  • Great answer! It might be more consistent to use \ddots instead of \Ddots as the question's matrix features three diagonal dots. Commented Jul 10 at 15:21
3

OpTeX users have the \puttext macro:

$$
  \def\bigzero{\typoscale[3500/]0}
  \left[\matrix{
     D &     &        & \puttext -1.5em -4.5ex \bigzero  \cr
       & S_1 &        &     \cr
       &     & \ddots &     \cr
          \puttext 0pt .5ex \bigzero
       &     &        & S_2 \cr
  }\right]
$$

\bye

You must log in to answer this question.

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