# \dmat

Used as a short alias for building a diagonal matrix from a comma-separated list of entries, typically inside \mqty{...}.

https://texform.dev/latex/commands/dmat

## Metadata

| Field | Value |
| --- | --- |
| Topic | [Physics: matrices](https://texform.dev/latex/topics/physics-matrices) |
| Packages | physics |
| Allowed mode | math |
| Tags |  |
| Commonality | low |
| Kind | prefix |

## Syntax

### physics

Argument specification: `g`

Used as a short alias for building a diagonal matrix from a comma-separated list of entries, typically inside \mqty{...}.

## Examples

```latex
\dmat
```

[Open in Playground](https://play.texform.dev/?input=%5Cdmat)

```latex
\mqty{\dmat{a,b}}
```

[Open in Playground](https://play.texform.dev/?input=%5Cmqty%7B%5Cdmat%7Ba%2Cb%7D%7D)

## Renderer support

| Package | MathJax | KaTeX | XeTeX |
| --- | --- | --- | --- |
| physics | full | none | full |

## In TeXForm

TeXForm parses this entry as prefix syntax; the package determines its argument specification.

### Expands to (physics)

```latex
\dmat{#1,#2}
```

→

```latex
\mqty{#1} \\ & \mqty{#2}
```

Expands to a diagonal arrangement of \mqty-wrapped elements separated by & and \\.

## Equivalent forms

```latex
\diagonalmatrix{...}
```

exact. Long form provided by the same physics package with identical parsing and behavior.

## See also

- [\\admat](https://texform.dev/latex/commands/admat)
- [\\antidiagonalmatrix](https://texform.dev/latex/commands/antidiagonalmatrix)
- [\\diagonalmatrix](https://texform.dev/latex/commands/diagonalmatrix)

## Test cases

### physics

| Input | Case | MathJax | KaTeX | XeTeX |
| --- | --- | --- | --- | --- |
| \dmat | Positive: baseline | Pass | Fail | Pass |
| \dmat{a} | Positive: vary:g[0] | Pass | Fail | Pass |
