# \imat

Short alias for generating the entries of an n×n identity matrix from a dimension argument, typically inside a matrix or array context.

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

## 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: `m:I`

Short alias for generating the entries of an n×n identity matrix from a dimension argument, typically inside a matrix or array context.

## Examples

```latex
\begin{matrix}\imat{2}\end{matrix}
```

[Open in Playground](https://play.texform.dev/?input=%5Cbegin%7Bmatrix%7D%5Cimat%7B2%7D%5Cend%7Bmatrix%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
\imat{n}
```

→

```latex
1 & 0 & ... \\ 0 & 1 & ... \\ ...
```

Expands directly into matrix rows and columns

## See also

- [\\identitymatrix](https://texform.dev/latex/commands/identitymatrix)

## Test cases

### physics

| Input | Case | MathJax | KaTeX | XeTeX |
| --- | --- | --- | --- | --- |
| \imat{1} | Positive: baseline | Pass | Fail | Pass |
| \imat 1 | Positive: bare[0] | Pass | Fail | Pass |
| \imat{a} | Negative: neg:I[0] | Fail | Fail | Fail |
