# bmatrix

Used for bracketed matrices in linear algebra and array notation

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

## 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 bracketed matrices in linear algebra and array notation

## Common tasks

### How to write a matrix in square brackets

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

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

### How to write a column vector in brackets

```latex
\begin{bmatrix} x \\ y \\ z \end{bmatrix}
```

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

### How to write a 1-by-n row in brackets

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

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

## Examples

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

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

## Renderer support

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

## Usage frequency

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

## In TeXForm

TeXForm reads the environment body in math mode.

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

Rewrite the fenced bmatrix environment to explicit brackets around a core matrix environment.

Level: corpus. Fidelity: render.

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

→

```latex
\left[\begin{matrix} #1 \end{matrix}\right]
```

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

→

```latex
\left[\begin{matrix} a & b \\ c & d \end{matrix}\right]
```

## See also

- [Bmatrix](https://texform.dev/latex/environments/Bmatrix)
- [cases](https://texform.dev/latex/environments/cases)
- [matrix](https://texform.dev/latex/environments/matrix)
- [pmatrix](https://texform.dev/latex/environments/pmatrix)
- [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{bmatrix} a & b \\\\ c & d \end{bmatrix} | Positive: baseline | Pass | Pass | Pass |
