Let
X
Journal

How to Typeset Matrices & Vectors in LaTeX

SPECIMEN IDLETX-SPEC-LATE
DATE RECORDEDMay 4, 2026
READING COMPLEXITY2 min read
TAG INDEX
latexmathmatricestutorial
Document Abstract

To write a matrix in LaTeX, use the pmatrix, bmatrix, or vmatrix environment from amsmath. Vectors use \vec or \mathbf. Copy-paste templates for both inside.

To typeset a matrix in LaTeX, use the pmatrix, bmatrix, or vmatrix environment from the amsmath package inside math mode. Separate entries in a row with &, end each row with \\, and choose the environment by the delimiter you want: parentheses, brackets, or determinant bars. Vectors use \vec{} or bold \mathbf{}.

1. The basic matrix

\usepackage{amsmath}
...
\[
A =
\begin{bmatrix}
  1 & 2 & 3 \\
  4 & 5 & 6 \\
  7 & 8 & 9
\end{bmatrix}
\]

Every row needs the same number of &-separated entries. The matrix sits in display math (\[...\]) so it gets full vertical space.

2. Pick the right delimiter

| Environment | Delimiter | Used for | |---|---|---| | matrix | none | array of values | | pmatrix | ( ) | generic matrix | | bmatrix | [ ] | linear algebra | | vmatrix | | | | determinant | | Vmatrix | ‖ ‖ | matrix norm |

\det(A) =
\begin{vmatrix}
  a & b \\
  c & d
\end{vmatrix}
= ad - bc

3. Vectors

Two conventions, both common:

\vec{v} = \begin{pmatrix} v_1 \\ v_2 \\ v_3 \end{pmatrix}
\qquad
\mathbf{w} = (w_1, w_2, w_3)

\vec{v} adds an arrow; \mathbf{v} makes it upright bold; \bm{v} (from the bm package) keeps it italic-bold, which most journals prefer. For the full symbol list see the math symbols reference.

4. Large matrices with ellipses

For an arbitrary n×n matrix, use dots:

\begin{pmatrix}
  a_{11} & \cdots & a_{1n} \\
  \vdots & \ddots & \vdots \\
  a_{n1} & \cdots & a_{nn}
\end{pmatrix}

\cdots is horizontal, \vdots vertical, \ddots diagonal.

5. Augmented matrices and systems

For an augmented matrix (e.g. solving a linear system), use array with a vertical rule:

\left[
\begin{array}{cc|c}
  1 & 2 & 5 \\
  3 & 4 & 6
\end{array}
\right]

For multi-line work like row reduction, line steps up with the align environment — see How to Write Math Equations in LaTeX.

→ Build and preview matrices live in LetX.


Written by Shihab Shahriar Antor — AI Engineer & Founder of Shahriar Labs, maker of LetX.

Frequently Asked Questions

What is the difference between pmatrix, bmatrix, and vmatrix?

They differ only in the delimiters around the array. pmatrix uses round parentheses, the most common choice for a generic matrix; bmatrix uses square brackets, popular in engineering and linear algebra texts; vmatrix uses single vertical bars for a determinant; Vmatrix uses double bars for a norm. There is also matrix with no delimiters. All four come from the amsmath package, so load \usepackage{amsmath} first.

How do I write a column vector in LaTeX?

Use a single-column matrix: \begin{pmatrix} x \\ y \\ z \end{pmatrix}, where each \\ starts a new row. For a row vector, put the entries on one line separated by &. To denote a vector variable in text, use \vec{v} for an arrow or \mathbf{v} for bold, the convention most journals prefer. Bold via \bm{v} from the bm package keeps the symbol italic and bold together.

How do I make a large matrix with dots for omitted entries?

Use the ellipsis commands inside the matrix: \cdots for horizontal dots, \vdots for vertical dots, and \ddots for diagonal dots. A general n×n matrix typically shows the corner entries with \cdots across the top row, \vdots down the first column, and \ddots on the diagonal. This is the standard way to typeset an arbitrary-size matrix without writing every element.