Matrix in LaTeX (\begin{bmatrix} a & b \\ c & d \end{bmatrix})

[abcd]\begin{bmatrix} a & b \\ c & d \end{bmatrix}
LaTeX command
\begin{bmatrix} a & b \\ c & d \end{bmatrix}
Package
Add to your preamble:\usepackage{amsmath}
Mode
Math mode only

Where it is used

bmatrix environment typesetting a matrix in square brackets, with & between columns.

Entries in a row are separated by &, rows end with \\, and the brackets size themselves to the content, so no \left[ is required. Sibling environments change only the delimiters: pmatrix uses parentheses, vmatrix vertical bars for determinants, Vmatrix double bars, and plain matrix none at all. The array environment is the older alternative; it needs a column specification like {cc} but allows vertical rules and per-column alignment. For generic matrices, fill gaps with \cdots, \vdots and \ddots, as in a_{11} & \cdots & a_{1n}. Inline, smallmatrix inside \bigl[ \bigr] avoids stretching the line.

Minimal compilable example

Paste this into an empty .tex file and compile it with pdfLaTeX, XeLaTeX or LuaLaTeX.

[1234]\begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}
\documentclass{article}
\usepackage{amsmath}
\begin{document}
Matrix: $\begin{bmatrix} a & b \\ c & d \end{bmatrix}$

\[ \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} \]
\end{document}

Related symbols

All Lineaire Algebra →

Frequently asked questions

How do I write Matrix in LaTeX?
Type \begin{bmatrix} a & b \\ c & d \end{bmatrix} in math mode, for example $\begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}$. Load amsmath first with \usepackage{amsmath}.
Which package do I need for \begin{bmatrix} a & b \\ c & d \end{bmatrix}?
\begin{bmatrix} a & b \\ c & d \end{bmatrix} needs amsmath: add \usepackage{amsmath} to your preamble before the document starts.
Can I use \begin{bmatrix} a & b \\ c & d \end{bmatrix} in text mode, or only in math mode?
Only in math mode. Outside $...$ LaTeX stops with "Missing $ inserted", so write $\begin{bmatrix} a & b \\ c & d \end{bmatrix}$ in running text.
Math poweredSchrijf LaTeX met AI

Beste AI LaTeX Editor, Overleaf Alternatief

Octree helpt onderzoekers van 15+ universiteiten sneller onderzoeksartikelen schrijven met AI

  • Genereer mooie TikZ-diagrammen met AI
  • Upload afbeelding en converteer naadloos naar LaTeX
  • Krijg directe hulp bij het schrijven en opmaken van onderzoeksartikelen