10

diagonal matrix

Could anyone give me code for this matrix generation?

1
  • 2
    Do you want a generic command which autogenerates this, or do you just want to know how to produce it? \begin{bmatrix}d_{1} & & \\ & \ddots & \\ & & d_{r}\end{bmatrix} would do
    – Au101
    Nov 5, 2016 at 20:23

1 Answer 1

17

You can do this very simply with a bmatrix and \ddots for the diagonal dots. The b in bmatrix is for the (square) brackets. pmatrix would give you parentheses, Bmatrix would give you braces and vmatrix and Vmatrix give you single and double vertical lines (respectively).

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\[
  D =
  \begin{bmatrix}
    d_{1} & & \\
    & \ddots & \\
    & & d_{r}
  \end{bmatrix}
\]

\end{document}

enter image description here

1
  • 1
    I will add here as well that, although not everyone loves its use, the physics package allows you to generate such an output by writing: D=\mqty[\dmat[0]{d_1,\ddots,d_r}]
    – Kraigolas
    Mar 25, 2020 at 20:45

You must log in to answer this question.

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