May 13, 2024

How to write overhead (overline) arrows of vectors in LaTeX – \vec and \overrightarrow


In this brief LaTeX tutorial, we explain how to write vector overline arrows in LaTeX. The YouTube tutorial accompanying this post is given below.

If you write a mechanics or physics paper, book, presentation, or report, you will often have to write vectors with overhead or overline arrows. There are at least two approaches to do that in Latex. The first approach is to use “\vec”. We type

\vec{a}, \;\; \vec{b}, \;\; \vec{A},\;\; \vec{B}

In the LaTeX environment, this produces the following output

(1)   \begin{align*}\vec{a}, \;\; \vec{b}, \;\; \vec{A},\;\; \vec{B}\end{align*}

This approach has the following issue. Let us say that we want to write an overline or overhead arrow of several letters or characters. We can try this

\vec{abc}, \;\; \vec{bdf}, \;\; \vec{ABC},\;\; \vec{BSG}

As a result, we obtain the following output

(2)   \begin{align*}\vec{abc}, \;\; \vec{bdf}, \;\; \vec{ABC},\;\; \vec{BSG}\end{align*}

As we can clearly observe, the arrow does not cover all the letters and characters. We can fix this issue by using \overrightarrow :

\overrightarrow{abc}, \;\; \overrightarrow{bdf}, \;\; \overrightarrow{ABC},\;\; \overrightarrow{BSG}

This produces the following LaTeX output

(3)   \begin{align*}\overrightarrow{abc}, \;\; \overrightarrow{bdf}, \;\; \overrightarrow{ABC},\;\; \overrightarrow{BSG}\end{align*}

This produces much better-looking output than by simply using vec.

We can also type vector products in Latex by using “times”. For example, the vector product of two vectors a and b is

\vec{a}\times \vec{b}

(4)   \begin{align*}\vec{a}\times \vec{b}\end{align*}

We can also use otimes to write vector products

\vec{a}\otimes \vec{b}

(5)   \begin{align*}\vec{a}\otimes \vec{b}\end{align*}