How to create a hat symbol in LaTeX?

# How to create a hat symbol in LaTeX?

This post may contain affiliate links that allow us to earn a commission at no expense to you. Learn more

This article aims to show you a simple way to create a hat symbol in LaTeX.

Writing in LaTeX gives beautiful documents, especially if you are in a science-oriented area like mathematics or physics, and most of the time you may be working with equations, integrals, and vectors.

And if you have vectors you will have unitarian vectors. That’s when the hat symbols come into play.

The hat symbols also receive the name of caret or circumflex symbols. And today you will get the knowledge to create a hat product symbol.

## The Vectors

We begin with mathematics and physics: vectors are used to define an object that has magnitude and direction, and has many kinds of properties. Most of the time it is used in physics, engineering, or math branches.

## The Unit Vector

Now, back to the definition, it mentioned direction, here is when the unit vector comes in. It denotes the direction of the vectors you are using.

And to define a unit vector, and recognize it from other nonunit vectors, you use the hat above the vectors.

## The LaTeX hat symbol

It is straightforward to insert the hat symbol in your document; you begin with the command that only requires one value (the character) between {}, denoted by the command \hat{}. The command is built-in, you don’t need external packages.

\begin{document}

$$\vec{A} = |a|\hat{a}$$

\end{document}


The hat symbol must be inside the math mode to call the command, you can open math mode with, $$, or , and close it with the same symbol at the end. ## In the Text mode: It is also possible to use it in a text. To call it, you use \^{}. You can also use the math mode inline the text, but you have to use the  symbol to open and close it, and the command \hat{}. Given the code below \begin{document} $\vec{B} = x\hat{i} + y\hat{j} + z\hat{k}$ Expression using the hat symbol with math mode in \hat{i}, \hat{j}, \hat{k} in text, looks like a Wikipedia article. \\ Here we are using the hat symbol with text only \^{i}, \^{j}, \^{k}. \end{document}  Notice the difference between the fonts in the letters, math is italic, the text is not. ## Hat symbol in LaTeX variations It is useful to know the existence of some variations of this symbol that you may use or not customize something. The command is different, it is \widehat{}. The command produces …$$\hat{abc}\widehat{abc}\widehat{keyboard}$$…  ## Caret/Circumflex/Hat in languages Some languages may have symbols known as caret or circumflex. The hat symbol in text mode is the recommended command to use. For example Standard output for languages ## LaTeX Hat symbol with packages There are other variants for the hat symbol in your document, especially in physics, with a package, but sometimes it is better to use already built-in commands. The package is called physics, and the command is denoted by \vu{} and \vu*{}. Physics package$$ \vu{i}, \vu*{abc} \vu{land}


Whatever method you choose to write the hat/caret/circumflex symbol in your document or article and the context, now you have the knowledge on how to write it and the output that you’ll get.

I hope this post was helpful. If you have any questions leave them in the comments.

And, as always, keep writing in LaTeX