# \matrixquantity

Used to typeset matrix quantities in physics notation, optionally with parentheses, brackets, braces-as-input, or vertical bars around the matrix body.

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

## Metadata

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

## Syntax

### physics

Argument specification: `s d<(,)><[,]><{,}><|,|>`

Used to typeset matrix quantities in physics notation, optionally with parentheses, brackets, braces-as-input, or vertical bars around the matrix body.

## Examples

```latex
\matrixquantity{a & b \\ c & d}
```

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

```latex
\matrixquantity(a & b \\ c & d)
```

[Open in Playground](https://play.texform.dev/?input=%5Cmatrixquantity%28a+%26+b+%5C%5C+c+%26+d%29)

```latex
\matrixquantity[a & b \\ c & d]
```

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

```latex
\matrixquantity|a & b \\ c & d|
```

[Open in Playground](https://play.texform.dev/?input=%5Cmatrixquantity%7Ca+%26+b+%5C%5C+c+%26+d%7C)

```latex
\matrixquantity*(a & b \\ c & d)
```

[Open in Playground](https://play.texform.dev/?input=%5Cmatrixquantity*%28a+%26+b+%5C%5C+c+%26+d%29)

```latex
\matrixquantity
```

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

## 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
\matrixquantity(#1)
```

→

```latex
\left(\begin{array}{} #1\end{array}\right)
```

Source constructs and reparses this macro string. Other branches use \begin{array}{} #1\end{array} for {#1}, \left[...\right] for [#1], \left|...\right| for |#1|, an empty parenthesized array when no body follows, and \lgroup/\rgroup for the starred parenthesized form.

## Equivalent forms

```latex
\mqty(#1)
```

exact. \mqty is mapped to the same MatrixQuantity implementation for the same following syntax.

## See also

- [\\mqty](https://texform.dev/latex/commands/mqty)
- [\\smallmatrixquantity](https://texform.dev/latex/commands/smallmatrixquantity)
- [\\smqty](https://texform.dev/latex/commands/smqty)

## Test cases

### physics

| Input | Case | MathJax | KaTeX | XeTeX |
| --- | --- | --- | --- | --- |
| \matrixquantity | Positive: baseline | Pass | Fail | Pass |
| \matrixquantity* | Positive: vary:s[0] | Pass | Fail | Pass |
| \matrixquantity (a) | Positive: vary:d[1] | Pass | Fail | Pass |
| \matrixquantity*(a) | Positive: maximal | Pass | Fail | Pass |
