LaTeX command for block diagonal matrix

diagramsmatrices

Block diagonal matrix

The code:

$$[T]_{\beta}=\begin{bmatrix}
c_{1}&&\\
        &\ddots& \\
          &&c_{1}
\end{bmatrix}
$$

I am trying with this code but ended up having a normal diagonal matrix. I want a block diagonal matrix that is drawn in the picture. A block diagonal matrix is a matrix whose diagonal entries consist of small n-order matrix. This is actually what the matrix should look like this but I have no idea how to do it. I attached the code here and I will attach my file screenshot.

enter image description here

There is no error in my code but the problem is I have no idea to make this type of matrix. I saw many examples online and in tex exchange but they are not useful for me.

Best Answer

With {bNiceMatrix} of nicematrix.

\documentclass{article}
\usepackage{nicematrix}

\setcounter{MaxMatrixCols}{20}

\begin{document}

\setlength{\arraycolsep}{4pt}

$\begin{bNiceMatrix}[margin]
\Block[borders={bottom,right}]{4-4}{}
c_1\\
   &c_1\\
   &   &\Ddots\\
   &   &      &c_1&\Block[l]{1-4}{\scriptstyle d_1\times d_1}\\
   &   &      &   &\Block[draw]{4-4}{}
                   c_2\\
   &   &      &   &   &c_2\\
   &   &      &   &   &   &\Ddots\\
   &   &      &   &   &   &      &c_2&\Block[l]{1-4}{\scriptstyle d_2\times d_2}\\\\
   &   &      &   &   &   &      &   &\ddots\\
   &   &      &   &   &   &      &   &      &\Block[draw]{4-4}{}
                                             c_n\\
   &   &      &   &   &   &      &   &      &   &c_n\\
   &   &      &   &   &   &      &   &      &   &   &\Ddots\\
   &   &      &   &   &   &      &   &      &   &   &      &c_n&\scriptstyle d_n\times d_n \\
\end{bNiceMatrix}$

\end{document}

Output of the above code

Related Question