# pmatrix

Used for parenthesized matrices in linear algebra and systems of equations

https://texform.dev/latex/environments/pmatrix

## Metadata

| Field | Value |
| --- | --- |
| Topic | [Matrices](https://texform.dev/latex/topics/matrices) |
| Packages | ams |
| Allowed mode | math |
| Tags | matrix, nestable |
| Commonality | high |
| Body mode | math |

## Syntax

### ams

Argument specification: ``

Used for parenthesized matrices in linear algebra and systems of equations

## Common tasks

### How to write a matrix in parentheses

```latex
\begin{pmatrix} a & b \\ c & d \end{pmatrix}
```

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

### How to write a column vector in parentheses

```latex
\begin{pmatrix} x \\ y \end{pmatrix}
```

[Open in Playground](https://play.texform.dev/?input=%5Cbegin%7Bpmatrix%7D+x+%5C%5C+y+%5Cend%7Bpmatrix%7D)

### How to write a 2-by-3 matrix

```latex
\begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \end{pmatrix}
```

[Open in Playground](https://play.texform.dev/?input=%5Cbegin%7Bpmatrix%7D+1+%26+0+%26+0+%5C%5C+0+%26+1+%26+0+%5Cend%7Bpmatrix%7D)

## Examples

```latex
\begin{pmatrix} a & b \\ c & d \end{pmatrix}
```

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

## Renderer support

| Package | MathJax | KaTeX | XeTeX |
| --- | --- | --- | --- |
| ams | full | full | full |

## Usage frequency

0.86% of formulas in the measured corpus contain this entry, rank 11 of 31 entries with frequency data.

## In TeXForm

TeXForm reads the environment body in math mode.

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

Rewrite the fenced pmatrix environment to explicit parens around a core matrix environment.

Level: corpus. Fidelity: render.

```latex
\begin{pmatrix} #1 \end{pmatrix}
```

→

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

```latex
\begin{pmatrix} a & b \\ c & d \end{pmatrix}
```

→

```latex
\left(\begin{matrix} a & b \\ c & d \end{matrix}\right)
```

## See also

- [bmatrix](https://texform.dev/latex/environments/bmatrix)
- [Bmatrix](https://texform.dev/latex/environments/Bmatrix)
- [cases](https://texform.dev/latex/environments/cases)
- [matrix](https://texform.dev/latex/environments/matrix)
- [smallmatrix](https://texform.dev/latex/environments/smallmatrix)
- [subarray](https://texform.dev/latex/environments/subarray)
- [vmatrix](https://texform.dev/latex/environments/vmatrix)
- [Vmatrix](https://texform.dev/latex/environments/Vmatrix)

## Test cases

### ams

| Input | Case | MathJax | KaTeX | XeTeX |
| --- | --- | --- | --- | --- |
| \begin{pmatrix} a & b \\\\ c & d \end{pmatrix} | Positive: baseline | Pass | Pass | Pass |
