You can’t blindly use text within a math environment like you normally would. This has been discussed numerous times now. That’s what makes this math mode special!

There are, however, certain simple elements you can add to characters (or strings of characters) to change their meaning in an important way. Very much like _accents) do to regular text.

Example

Adding an arrow above a letter communicates it’s a vector. Adding a hat on top of a letter usually means it’s some modified version of the original variable. A bar over something can mean its complimentary set.

I like to call these math accents. This chapter provides all of them, ordered by their type

Real Accents

These look the most like accents you’re used to. They are typically used on a single character, to place something above it.

They can be used on multiple characters, but might need their wide counterpart to do so properly. If you use the regular command on multiple characters, it simply places the accent in regular single size above it, centred.

Regular CommandWide CommandDescription
\vec{}\overrightarrow{}Adds an arrow from left to right
-\overleftarrow{}Adds an arrow from right to left
\hat{}\widehat{}Adds a hat, or “rooftop”
\tilde{}\widetilde{}Adds a tilde, or “wavy line”
\dot{}-Adds a single dot
\ddot{}-Adds a double dot
\check{}-Adds a reverse hat, or check symbol
\breve{}-Adds a breve, or “cup”
\acute{}-Adds an accent acute
\grave{}-Adds an accent grave
\bar{}-Adds a bar, or “overline”

These can also be composed/nested. Using multiple after each other will keep adding them on top of one another. Not necessarily recommended, though 😉

 1\begin{gather*}
 2    \vec{x} - \overrightarrow{xyz} - \overleftarrow{xyz} \\
 3    \hat{x} - \widehat{xyz} \\
 4    \tilde{x} - \widetilde{xyz} \\
 5    \dot{x} \\
 6    \ddot{x} \\
 7    \check{x} \\
 8    \breve{x} \\
 9    \acute{x} \\
10    \grave{x} \\
11    \bar{x}
12\end{gather*}
Code left > output right
Code left > output right

One-Argument Commands

These are somewhat like accents, but have no wide counterpart. Stacking ability is reserved for overlines and underlines. (As they are above and below things, which means they have space to grow.)

CommandDescription
\not{}Slashes diagonally through the character, used mostly for turning an equal sign into a not-equal sign, and similar operations. Errors if you give it more than a single character.
\cancel{}Also slashes diagonally through its argument, but from bottom left to top right. Requires the cancel package.
\overline{}Adds a line above it
\underline{}Adds a line underneath it
1\usepackage{cancel}
2
3\begin{document}
4    $\not=  \quad  \cancel{XYZ}  \quad  \overline{XYZ}  \quad  \underline{XYZ}$
5\end{document}
Code left > output right
Code left > output right

Two-Argument Commands

These accept two arguments of arbitrary length, and place the text from one of the arguments above or below the other. They are automatically centred, and the first two have their brace automatically stretched to the correct length.

CommandDescription
\overbrace{arg1}^{arg2}Places arg2 above arg1, using a brace to group arg1
\underbrace{arg1}_{arg2}Places arg2 below arg1, using a brace to group arg1
\overset{arg1}{arg2}Places arg1 above arg2
\underset{arg1}{arg2}Places arg1 below arg2
1\begin{gather*}
2    \overbrace{a + \ldots + a}^{n \times a} \
3    \underbrace{a + \ldots + a}_{n \times a} \
4    a \overset{def}{=} b \
5    a \underset{def}{=} b
6\end{gather*}
Code left > output right
Code left > output right
Continue with this course
Support me and this website!

Want to support me?

Buy one of my projects. You get something nice, I get something nice.

Donate through a popular platform using the link below.

Simply giving feedback or spreading the word is also worth a lot.