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 선형대수 →

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 poweredAI로 LaTeX 작성

최고의 AI LaTeX 편집기, Overleaf 대안

Octree는 15개 이상의 대학의 연구자들이 AI를 사용하여 논문을 더 빠르게 작성하도록 도움

  • AI로 아름다운 TikZ 다이어그램 생성
  • 이미지를 업로드하고 LaTeX로 원활하게 변환
  • 논문 작성 및 서식에 대한 즉각적인 지원 받기