# Show a matrix in detail

Below it is a very useful command to create a matrix. But it has a short point to me since it shows Parentheses not Square brackets. My question it how should I change this to show square brackets? I appreciate your answer. Thank you so much.

$K = \underbracket{\begin{pmatrix} K_1 & 0 & 0 \\ 0 & \ddots & 0 \\ 0 & 0 & K_n \\ \end{pmatrix}}_{d\times M}$

• \begin{bmatrix}? – egreg Oct 4 '13 at 15:13
• replace {pmatrix} with {bmatrix}. – barbara beeton Oct 4 '13 at 15:14

to replace parentheses around a matrix by square brackets, replace {pmatrix} with {bmatrix}.
this requires amsmath, but once you've done that, you also have
• Bmatrix -- curly braces
• vmatrix -- single vertical bars
• Vmatrix -- double vertical bars