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 Linear 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 poweredSumulat ng LaTeX gamit ang AI

Pinakamahusay na AI LaTeX Editor, Alternatibo sa Overleaf

Tinutulungan ng Octree ang mga researcher mula sa 15+ na unibersidad na sumulat ng research papers nang mas mabilis gamit ang AI

  • Gumawa ng magagandang TikZ diagrams gamit ang AI
  • Mag-upload ng larawan at i-convert ito sa LaTeX nang walang problema
  • Makakuha ng instant na tulong sa pagsulat at pag-format ng research papers