# \matrix

Typesetting a matrix without delimiters using Plain TeX syntax

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

## Metadata

| Field | Value |
| --- | --- |
| Topic | [Matrices](https://texform.dev/latex/topics/matrices) |
| Packages | base |
| Allowed mode | math |
| Tags | discouraged |
| Commonality | medium |
| Kind | prefix |

## Syntax

### base

Argument specification: `m`

Typesetting a matrix without delimiters using Plain TeX syntax

## Examples

```latex
\matrix{a & b \cr c & d}
```

[Open in Playground](https://play.texform.dev/?input=%5Cmatrix%7Ba+%26+b+%5Ccr+c+%26+d%7D)

```latex
\matrix a
```

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

## Renderer support

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

## In TeXForm

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

### Discouraged in base

Plain TeX command that has been superseded by LaTeX environments.

```latex
\begin{matrix} $1 \end{matrix}
```

Standard LaTeX (amsmath) convention which provides better error checking and consistency.

### [base/matrix-to-matrix-env](https://texform.dev/rules/base/matrix-to-matrix-env)

Rewrite plain-TeX matrix to the standard matrix environment with row breaks.

Level: authoring. Fidelity: reading.

```latex
\matrix{#1 \cr #2}
```

→

```latex
\begin{matrix} #1 \\ #2 \end{matrix}
```

```latex
\matrix{1 & x & x^2 \cr 0 & 1 & 2x \cr 0 & 0 & 1}
```

→

```latex
\begin{matrix} 1 & x & x^2 \\ 0 & 1 & 2x \\ 0 & 0 & 1 \end{matrix}
```

## See also

- [\\array](https://texform.dev/latex/commands/array)
- [\\cases](https://texform.dev/latex/commands/cases)
- [\\displaylines](https://texform.dev/latex/commands/displaylines)
- [\\eqalign](https://texform.dev/latex/commands/eqalign)
- [\\eqalignno](https://texform.dev/latex/commands/eqalignno)
- [\\leqalignno](https://texform.dev/latex/commands/leqalignno)
- [\\pmatrix](https://texform.dev/latex/commands/pmatrix)

## Test cases

### base

| Input | Case | MathJax | KaTeX | XeTeX |
| --- | --- | --- | --- | --- |
| \matrix{a} | Positive: baseline | Pass | Fail | Pass |
| \matrix a | Positive: bare[0] | Pass | Fail | Pass |
