答案1
与。{bNiceMatrix}
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}