Matrix in LaTeX (\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.
\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
- Column Vector
\begin{pmatrix} x \\ y \end{pmatrix} - Lambda
\lambda - Zero Matrix
\mathbf{0} - Identity Matrix
I_n - Kronecker Delta
\delta_{ij} - Multiplication
\times
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.
Editor LaTeX AI Terbaik, Alternatif Overleaf
Octree membantu penyelidik dari 15+ universiti menulis kertas penyelidikan dengan lebih cepat menggunakan AI
- Jana diagram TikZ yang cantik menggunakan AI
- Muat naik imej dan tukar ke LaTeX dengan lancar
- Dapatkan bantuan segera untuk menulis dan memformat kertas penyelidikan