# [Tex/LaTex] How to create diagonal matrix with an aligned diagonal

math-modematrices

How do I display truly diagonal matrices? I want to have a diagonal bloc matrix. The solution below has several problems : the diagonal terms aren't really aligned in the first half, and the diagonal dots \ddots aren't steep enough between the zeros in the second half.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$\mathrm{Mat}(u;\mathcal{B})= \begin{pmatrix} I_{n_+}\\&-I_{n_-}\\ &&R_{\theta_1}\\ &&&R_{\theta_2}\\ &&&&\ddots\\ &&&&&R_{\theta_r}\\ &&&&&&0\\ &&&&&&&0\\ &&&&&&&&\ddots\\ &&&&&&&&&0\\ \end{pmatrix}$
\end{document}


#### Best Answer

Maybe this?

\documentclass{article}
\usepackage{amsmath,mathtools}
\DeclareMathOperator{\Mat}{Mat}
\newcommand{\diagentry}[1]{\mathmakebox[1.8em]{#1}}
\newcommand{\xddots}{%
\raise 4pt \hbox {.}
\mkern 6mu
\raise 1pt \hbox {.}
\mkern 6mu
\raise -2pt \hbox {.}
}
\begin{document}
$\Mat(u;\mathcal{B})= \begin{pmatrix} \diagentry{I_{n_+}}\\ &\diagentry{-I_{n_-}}\\ &&\diagentry{R_{\theta_1}}\\ &&&\diagentry{R_{\theta_2}}\\ &&&&\diagentry{\xddots}\\ &&&&&\diagentry{R_{\theta_r}}\\ &&&&&&\diagentry{0}\\ &&&&&&&\diagentry{0}\\ &&&&&&&&\diagentry{\xddots}\\ &&&&&&&&&\diagentry{0}\\ \end{pmatrix}$
\end{document}