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}
    v →

    Arrow over one letter.

  • \overrightarrow{AB}
    A B →

    Arrow over several letters, such as a segment.

  • \mathbf{v}
    v

    Upright bold vector (Latin letters).

  • \boldsymbol{\omega}
    ω

    Bold that keeps italics and works for Greek (amsmath).

  • \hat{\mathbf{n}}
    n ^

    Unit vector with a hat.

  • \hat{\imath}, \; \hat{\jmath}, \; \hat{k}
    ı ^ , ȷ ^ , k ^

    Unit vectors i, j, k without the dots on i and j.

  • \begin{bmatrix} x \\ y \end{bmatrix}
    [ x y ]

    Column vector (amsmath).

  • \begin{pmatrix} x & y & z \end{pmatrix}
    ( x y z )

    Row vector.

  • \langle 1, 2, 3 \rangle
    ⟨ 1 , 2 , 3 ⟩

    Angle-bracket component form.

  • \lVert \vec{v} \rVert
    ‖ v → ‖

    Length (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.

Templates

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

    v → = ⟨ 3 , − 1 , 2 ⟩ = 3 ı ^ − ȷ ^ + 2 k ^
    LaTeX
    \vec{v} = \langle 3, -1, 2 \rangle = 3\hat{\imath} - \hat{\jmath} + 2\hat{k}
  • Column vector

    x = [ x 1 x 2 ⋮ x n ]
    LaTeX
    \mathbf{x} = \begin{bmatrix} x_1 \\ x_2 \\ \vdots \\ x_n \end{bmatrix}
  • Segment vector

    A B → = B − A
    LaTeX
    \overrightarrow{AB} = B - A
  • Magnitude

    ‖ v → ‖ = v 1 2 + v 2 2 + v 3 2
    LaTeX
    \lVert \vec{v} \rVert = \sqrt{v_1^2 + v_2^2 + v_3^2}
  • Unit vector

    u ^ = v ‖ v ‖
    LaTeX
    \hat{\mathbf{u}} = \frac{\mathbf{v}}{\lVert \mathbf{v} \rVert}
  • Dot product

    a → ⋅ b → = ‖ a → ‖ ‖ b → ‖ cos ⁡ θ
    LaTeX
    \vec{a} \cdot \vec{b} = \lVert \vec{a} \rVert \lVert \vec{b} \rVert \cos \theta
  • Bold Greek vector

    τ = r × F
    LaTeX
    \boldsymbol{\tau} = \mathbf{r} \times \mathbf{F}
  • Transpose of a row

    x = ( x 1 , x 2 , x 3 ) T
    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}}.

LaTeX
\[
  \mathbf{v} = \begin{bmatrix} 1 \\ 0 \\ -2 \end{bmatrix}
  \qquad
  \mathbf{w} = \begin{pmatrix} 1 & 0 & -2 \end{pmatrix}
\]

Common mistakes

  • \vec draws a short arrow for one character; over two letters it sits off-center.

    Instead of
    \vec{AB}
    Write
    \overrightarrow{AB}
  • In LaTeX \mathbf does not bold lowercase Greek letters.

    Instead of
    \mathbf{\alpha}
    Write
    \boldsymbol{\alpha}
  • A hat over i keeps the dot underneath; \imath is 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, \mathbf and \hat need nothing; \boldsymbol and the matrix environments need amsmath, \bm needs the bm package.

  • MathJax and KaTeX

    MathJax and KaTeX handle \vec, \overrightarrow, \mathbf, \boldsymbol and bmatrix. \bm is not supported, so use \boldsymbol in 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.

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