Vectors in LaTeX
A vector in LaTeX is marked with an arrow (\vec{v}) or set in bold (\mathbf{v}), written as a column of numbers in brackets (bmatrix or pmatrix), or, in many US calculus courses, as with \langle and \rangle. Its length is \lVert \mathbf{v} \rVert.
LaTeX command
\vec{v}Which vector notation?
| Looks like | LaTeX | Use it for |
|---|---|---|
\vec{v} | An arrow over one letter: school maths and physics | |
\overrightarrow{AB} | An arrow over two or more letters, such as the vector from A to B | |
\mathbf{v} | Upright bold, the usual style in printed books and papers | |
\boldsymbol{\omega} | Bold italic; also the way to make a Greek letter bold | |
\langle 3, -1 \rangle | Components in angle brackets, as in US calculus courses | |
\begin{bmatrix} 3 \\ -1 \end{bmatrix} | A column vector in square brackets (pmatrix gives round ones) | |
\lVert \mathbf{v} \rVert | The magnitude, or length, of a vector | |
\hat{\mathbf{u}} | A unit vector (length 1) |
Not the symbol you meant? Draw it to find the command →
Typing up handwritten notes? Convert a whole page of handwriting to LaTeX →
There is no single vector notation. Most people draw an arrow by hand, so \vec{v} is the usual choice in school maths and physics; printed textbooks and papers mostly use bold, \mathbf{v}; linear algebra lists the components in a column. Choose one and keep it for the whole document.
What needs a package: the column environments (bmatrix, pmatrix), \boldsymbol and \lVert need amsmath; \vv needs esvect and \bm needs bm. \vec, \overrightarrow, \mathbf, \hat and \langle are built into LaTeX. Everything on this page except \vv also works in KaTeX.
Operations read naturally once the vectors are marked: \mathbf{a} \cdot \mathbf{b} is the dot product, \mathbf{a} \times \mathbf{b} the cross product and \lVert \mathbf{a} \rVert the length. The examples below show each one with the code to copy.
Vector arrows: \vec, \overrightarrow and \vv
\vec{v} draws a small arrow over one letter. Over two letters it does not stretch and sits in the middle, so for the vector from A to B use \overrightarrow{AB}, which reaches across both.
Many people find the standard arrow too small. The esvect package draws a larger one with \vv{v}, and \vv{AB} stretches over several letters. Load it in the preamble with \usepackage{esvect}; KaTeX does not have \vv.
\vec{v}\overrightarrow{AB}\usepackage{esvect}\vv{v} \quad \vv{AB}More on this: Vector arrow (v⃗) in LaTeX
Bold vectors: \mathbf, \boldsymbol and \bm
\mathbf{v} gives an upright bold letter, the style most textbooks print. It works on Latin letters and digits only: in \mathbf{\omega} the Greek letter stays as it was.
\boldsymbol{v} gives bold italic, the usual slanted letter made heavier, and it also makes Greek letters and symbols bold, as in \boldsymbol{\omega}. The bm package's \bm{v} does the same; many people use it for a whole document.
\mathbf{v}\boldsymbol{\omega}\usepackage{bm}\bm{v}More on this: Bold and italic in math mode in LaTeX
Column and row vectors: bmatrix and pmatrix
A column vector is a matrix with one column. bmatrix puts it in square brackets and pmatrix in round ones; \\ after each entry starts a new row, so the components stack. Both need amsmath.
A row vector is a single row with & between the entries, and a T for the transpose turns it into a column. Inside a line of text, write the column with smallmatrix so it does not push the lines apart (the last code box).
\begin{bmatrix} 1 \\ 2 \\ 3 \end{bmatrix}\begin{pmatrix} 1 \\ 2 \\ 3 \end{pmatrix}\begin{bmatrix} 1 & 2 & 3 \end{bmatrix}^{\mathsf{T}}\left[\begin{smallmatrix} 1 \\ 2 \end{smallmatrix}\right]More on this: Matrices in LaTeX
Angle bracket vectors: ⟨a, b⟩
Many US calculus courses write a vector as its components in angle brackets: . Type the brackets with \langle and \rangle. The < and > keys give less-than and greater-than signs instead, which are too flat and get the spacing of a comparison.
For tall entries such as fractions, let the brackets grow with \left\langle and \right\rangle. The same brackets also write an inner product, .
\langle 3, -1 \rangle\left\langle \frac{1}{2}, 4 \right\rangleMore on this: Inner product (⟨u, v⟩) in LaTeX, Brackets and delimiters in LaTeX
Magnitude ‖v‖ and unit vectors
The magnitude (length) of a vector goes between double bars. \lVert \mathbf{v} \rVert gives the bars the right spacing on both sides; \| \mathbf{v} \| also works. Some courses use single bars, as for an absolute value.
A unit vector has length 1 and wears a hat: . For the unit vectors along the axes use the dotless letters, \hat{\imath} and \hat{\jmath}, so the hat does not sit on a dot.
\lVert \mathbf{v} \rVert\hat{\mathbf{u}} = \frac{\mathbf{v}}{\lVert \mathbf{v} \rVert}\hat{\imath} + 2\hat{\jmath} - \hat{k}More on this: Norm (‖x‖) in LaTeX, Hat / circumflex (x̂) in LaTeX
Other forms
\mathbf{v}bold vector\begin{pmatrix} x \\ y \\ z \end{pmatrix}a column vectorExamples
$\vec{v} = \begin{pmatrix} 1 \\ 2 \\ 3 \end{pmatrix}$an arrow-marked column vector
$\mathbf{a} \cdot \mathbf{b}$a dot (scalar) product in bold notation
$\mathbf{a} \times \mathbf{b}$a cross product
$\hat{\imath} + 2\hat{\jmath} - \hat{k}$unit vectors with hats (\imath has no dot)
$\overrightarrow{AB} = \vec{b} - \vec{a}$the vector from A to B
$\mathbf{v} = \langle 3, -1, 2 \rangle$a vector in angle bracket notation
$\lVert \mathbf{v} \rVert = \sqrt{3^2 + (-1)^2 + 2^2} = \sqrt{14}$the magnitude of that vector
Tips and common mistakes
\vec{v}suits one letter; over two or more use\overrightarrow{AB}, or\vv{AB}with the esvect package.\mathbfwill not make a Greek letter bold; use\boldsymbol{\omega}or\bm{\omega}.- Type angle brackets with
\langleand\rangle, never with the < and > keys. - For unit vectors along the axes,
\hat{\imath}and\hat{\jmath}use dotless letters so the hat sits cleanly. - Pick one notation, arrows or bold, and use it for the whole document.
Working from handwritten notes?
LatexNotes turns a photo or PDF of handwritten mathematics into LaTeX, graphs and all. It is built with real pdflatex before you see it, and the .tex file is yours to edit or take to Overleaf. Free to try, no sign-up.
See how handwriting to LaTeX works, step by step, or go from GoodNotes to LaTeX if you write on an iPad (Notability works the same way).
Convert your maths to LaTeX →FAQ
How do I put an arrow over a vector in LaTeX?
Use \vec{v} for one letter and \overrightarrow{AB} for two or more. For a larger arrow, load the esvect package and write \vv{v}.
How do I write a column vector?
Use a one-column matrix: \begin{bmatrix} x \\ y \\ z \end{bmatrix} for square brackets, or pmatrix for round ones. Both need amsmath.
How do I make a bold vector?
Use \mathbf{v} for upright bold. For bold italic, or a bold Greek letter, use \boldsymbol{\omega}, or \bm{\omega} with the bm package.
How do I write a vector with angle brackets, like ⟨a, b⟩?
Use \langle and \rangle: \langle a, b \rangle. The < and > keys give less-than and greater-than signs, which look and space wrongly.
How do I write the magnitude of a vector?
Put it between double bars: \lVert \mathbf{v} \rVert (amsmath) or \| \mathbf{v} \|.