Vectors are mathematical quantities that carry both magnitude and direction.
They are essential in physics and engineering, and LaTeX provides powerful commands to write them in a clean way.
In this tutorial, we will explore different notations for vectors, their magnitudes, unit vectors, and operations like dot and cross products.
Different Formats for Representing Vectors
There are several notations available in LaTeX. Each has its own use case depending on whether you want a quick arrow, a bold symbol, or advanced formatting with special packages.
Arrow over a letter
The simplest option is the \vec
command. It works best for single characters.
\[ \vec{p} \]
Output :
It is commonly used in equations, such as:
\[ \vec{p}=m\vec{v} \]
Output :
Problems with multiple characters
The \vec
command does not scale properly for multi-letter symbols like AB
. The arrow becomes too short.
\[ \vec{AB} \]
Output :
In such cases, you need \overrightarrow
, which stretches the arrow.
\[ \overrightarrow{AB} \]
Output :
This solves the coverage problem, but the arrow design may still feel thin and uneven when used in long expressions.
esvect package – the best solution for arrows
If you want arrows that look professional and scale gracefully, the esvect
package is the best choice.
It offers multiple arrow styles that adapt perfectly to letters, or even entire words.
\usepackage[a]{esvect} \vv{expression}
\usepackage[a]{esvect}
- This command loads the esvect package into your LaTeX document. The option inside the square brackets
[a]
specifies the arrow style.The package provides several styles like
[a]
,[b]
,[c]
, etc., which let you choose how the vector arrow looks. \vv{expression}
- This is the main command from the esvect package. It places an arrow above the argument passed inside the braces.
The
expression
can be a single letter, a symbol, or even multiple characters. Unlike\vec
, the arrow length automatically adapts to cover the full expression.
\documentclass{article}
\usepackage[a]{esvect} % option 'a' selects arrow style
\begin{document}
\[ \vv{r} \]
\[ \vv{\ddot{r}} \]
\[ \vv{r_{n}} \]
\[ \vv{xyz} \]
\[ \vv{pqr} \]
\end{document}
Unlike \vec
or \overrightarrow
, this package gives a strong and clean arrow even for multiple characters. For modern documents, esvect should be your first choice.
Other Common Notations
Bold style
Vectors can also be written in bold. For Latin letters use \mathbf
, and for Greek symbols or special characters use \bm
or \boldsymbol
.
\[ \textbf{AB}\]
Output :
Unit vectors with hat
Unit vectors are denoted with a small hat. This is written with the \hat
command.
\[ \hat{a}=\frac{\vec{a}}{ \left | \vec{a} \right | } \]
Output :
Magnitude of a Vector
The size of a vector is written with absolute value bars. Use \left|
and \right|
so the bars adjust to the content.
\[ \left| \vec{a} \right| \]
Output :
Position Vectors and Components
Position is often written using the i, j, k components:
\[ \vec{r}=x\hat{i}+y\hat{j}+z\hat{k} \]
Output :
Vector Operations
Cross product
Cross products are written using \times
.
\[ \vec{p}\times \vec{q}= |\vec{p}| |\vec{q}|\sin\theta \hat{n} \]
Output :
Dot product
Dot products are written using \cdot
.
\[ \vec{p}\cdot\vec{q}= |\vec{p}| |\vec{q}|\cos\theta \]
Output :
Using Physics Package
The physics
package simplifies vector writing with short commands.
\documentclass{article}
\usepackage{physics}
\begin{document}
\[ \va{a} \] % arrow style
\[ \va*{a} \] % alternate arrow style
\[ \vb{a} \] % bold vector
\[ \vb*{a} \] % bold with alternate style
\end{document}
Output :
It also includes vector operations.
\documentclass{article}
\usepackage{physics}
\begin{document}
\[ \vu*{a} \] % unit vector
\[ \va{p}\vdot\va{q} \] % dot product
\[ \va{p}\cp\va{q} \] % cross product
\[ \abs{\va*{a}} \] % magnitude
\end{document}
Output :
Best Practice
– Use \vec
for quick and simple notations with single letters.
– For multiple letters, \overrightarrow
is better but not always beautiful.
– The esvect package is the most powerful option. It handles short or long expressions with elegant arrows and should be the default choice for modern documents.
– For convenience in physics problems, the physics
package saves time by offering shortcuts for arrows, bold vectors, unit vectors, and operations.
very interesting and useful
Nice Work!