Vector in LaTeX
Put an arrow over a letter with \vec{v}, or over several letters with \overrightarrow{AB}. Many books print vectors in bold instead: \mathbf{v} for Latin letters and \boldsymbol{\omega} for Greek. A column vector is a one-column matrix: \begin{bmatrix} x \\ y \end{bmatrix}.
Vector notation
\vec{v}Arrow over one letter.
\overrightarrow{AB}Arrow over several letters, such as a segment.
\mathbf{v}Upright bold vector (Latin letters).
\boldsymbol{\omega}Bold that keeps italics and works for Greek (amsmath).
\hat{\mathbf{n}}Unit vector with a hat.
\hat{\imath}, \; \hat{\jmath}, \; \hat{k}Unit vectors i, j, k without the dots on i and j.
\begin{bmatrix} x \\ y \end{bmatrix}Column vector (amsmath).
\begin{pmatrix} x & y & z \end{pmatrix}Row vector.
\langle 1, 2, 3 \rangleAngle-bracket component form.
\lVert \vec{v} \rVertLength (norm) of a vector.
Try it live
Change the formula and the preview redraws as you type. Copy the LaTeX, download a PNG or SVG, copy it for Word, or use Edit here on any example below to load it.
Vector examples
Each result below is drawn from the LaTeX under it. Copy the code, edit it on this page, or open it in the full editor.
Component form
LaTeX\vec{v} = \langle 3, -1, 2 \rangle = 3\hat{\imath} - \hat{\jmath} + 2\hat{k}Column vector
LaTeX\mathbf{x} = \begin{bmatrix} x_1 \\ x_2 \\ \vdots \\ x_n \end{bmatrix}Segment vector
LaTeX\overrightarrow{AB} = B - AMagnitude
LaTeX\lVert \vec{v} \rVert = \sqrt{v_1^2 + v_2^2 + v_3^2}Unit vector
LaTeX\hat{\mathbf{u}} = \frac{\mathbf{v}}{\lVert \mathbf{v} \rVert}Dot product
LaTeX\vec{a} \cdot \vec{b} = \lVert \vec{a} \rVert \lVert \vec{b} \rVert \cos \thetaBold Greek vector
LaTeX\boldsymbol{\tau} = \mathbf{r} \times \mathbf{F}Transpose of a row
LaTeX\mathbf{x} = (x_1, x_2, x_3)^{\mathsf{T}}
Arrow or bold?
\vec is quick for handwritten-style notation and for short names. Its arrow is sized for one character, so for two or more letters use \overrightarrow, which stretches.
Printed textbooks and most physics journals use bold. \mathbf{v} makes Latin letters bold and upright, but it leaves lowercase Greek letters unchanged in LaTeX; \boldsymbol{\omega} (amsmath) or \bm{\omega} (bm package) bolds them. MathJax supports \boldsymbol but not \bm.
If you might switch styles later, define a macro such as \newcommand{\vect}[1]{\boldsymbol{#1}} and use \vect{v} everywhere.
Column and row vectors
A column vector is a matrix with one column: separate entries with \\. A row vector separates entries with &. Brackets come from the environment name: bmatrix for [ ], pmatrix for ( ).
To save vertical space in text, write the column vector as a transposed row: (x_1, x_2, x_3)^{\mathsf{T}}.
\[
\mathbf{v} = \begin{bmatrix} 1 \\ 0 \\ -2 \end{bmatrix}
\qquad
\mathbf{w} = \begin{pmatrix} 1 & 0 & -2 \end{pmatrix}
\]Common mistakes
\vecdraws a short arrow for one character; over two letters it sits off-center.Instead of\vec{AB}Write\overrightarrow{AB}In LaTeX
\mathbfdoes not bold lowercase Greek letters.Instead of\mathbf{\alpha}Write\boldsymbol{\alpha}A hat over i keeps the dot underneath;
\imathis the dotless i meant for accents.Instead of\hat{i}Write\hat{\imath}The bm package is LaTeX-only; MathJax and KaTeX do not know
\bm.Instead of\bm{v} (on a web page)Write\boldsymbol{v}
In Overleaf, MathJax and Word
Overleaf and pdfLaTeX
\vec,\overrightarrow,\mathbfand\hatneed nothing;\boldsymboland the matrix environments need amsmath,\bmneeds the bm package.MathJax and KaTeX
MathJax and KaTeX handle
\vec,\overrightarrow,\mathbf,\boldsymbolandbmatrix.\bmis not supported, so use\boldsymbolin Markdown and on the web.Microsoft Word
Word has its own accent and matrix tools, but pasted LaTeX is not converted reliably. Write the vector here and use Copy for Word to paste it as an editable Word equation.
Vector in LaTeX: questions
- How do I put an arrow over a letter in LaTeX?
- Use
\vec{v}for one letter and\overrightarrow{AB}for several letters. - How do I write a bold vector?
- Use
\mathbf{v}for Latin letters and\boldsymbol{\omega}for Greek letters or when you want bold italics. - How do I write a unit vector?
- Put a hat on it:
\hat{\mathbf{u}}. For the standard basis write\hat{\imath},\hat{\jmath},\hat{k}so the i and j lose their dots. - How do I write a column vector?
- As a one-column matrix:
\begin{bmatrix} x_1 \\ x_2 \\ x_3 \end{bmatrix}, with amsmath loaded.
Related LaTeX reference
- Matrix in LaTeXpmatrix, bmatrix, vmatrix and friends: rows with \\, columns with &, plus 2x2, 3x3, augmented and n×n examples.
- Dot Product in LaTeX\cdot between vectors, bold or arrow notation, ⟨u, v⟩ with \langle and \rangle, and the usual dot product formulas.
- Hat in LaTeX\hat and \widehat accents, hats with subscripts, dotless i and j, and how to print the ^ character itself.
- LaTeX equation editorSymbol panel, live preview, and PNG, SVG, MathML or Word export.
- All LaTeX reference pagesSymbols, math structures and text formatting in one list.
Have the formula as a picture?
Paste a screenshot or photo of the equation and get its LaTeX, ready to copy or open in the editor.
Convert an image to LaTeX