How to write a tilde symbol in LaTeX

How to write a tilde 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 tilde symbol in LaTeX.

Whether you are writing an article or document about mathematics, or an essay (depending on the language you are writing it), you will need the tilde symbol, it is pretty common in some languages and in some areas in mathematics.

Today you will learn how to insert the tilde in your documents, independently of the context.

Tilde Symbol

The tilde is used every single day in some languages, for example in Spanish some words have a tilde, and in Portuguese some words have tildes, sometimes above or below the letters.

Another purpose for the tilde is in mathematics, either in algebra, geometry or set theory. But, what is a tilde? And a tilde is just

Write Tilde in LaTeX

LaTeX has two main built-in options to generate the tilde. The first one is with the command \~{}, it takes one value as an argument (a letter), it is important to notice that this is principally used for spanish and portuguese, the command works in text mode.

The following commands can be used:

\documentclass{article}
\begin{document}
el peque\~{n}o ni\~{n}o es cari\~{n}oso \\
irm\~{a} (sister), avi\~{a}o (plane)
\end{document}


As you can see, Spanish is always used with the “n”, in Portuguese depending on the word the tilde can be in other vowels.

The other option is with the command \tilde{}, it takes one value as argument Compared to the first method, this one is only allow in math mode, for example

\documentclass{article}
\begin{document}
ara$\tilde{n}$a en su telara$\tilde{n}$a\\
opini$\tilde{o}$es (opinions), capit$\tilde{a}$es (captains)

\end{document}


The downside of this method is the fact that you will get the letter inside the command, in math mode font.

As a plu if maybe you need for some reason a wider tilde you can use the \widetilde{} command, it generates a wide tilde. For example

\documentclass{article}
\begin{document}
$$\widetilde{abc}$$
\end{document}


Both methods are limited to letters, but there is one method available to write the tilde when referring to mathematics.

Tilde in Math Mode

The tilde in math has many variations, either alone or together with another symbol, so depending on which one you will need you have to define it luckily all of them are built-in in LaTeX.

The principal command is \sim for the plain ~ symbol, it does require the math mode. The most populars symbols with tilde are presented in the example.

\documentclass{article}
\begin{document}
$$\pi \sim 3.14$$
$$\theta \simeq 90$$
$$\tau \approx \pi$$
$$x \backsim y$$
$$A \approxeq B$$
\end{document}


There could be LaTeX packages that can also have more options regarding the tilde symbol. But it’s is up to you to decide if you want to use the built-in commands or external resources for specific code, font, or character in latex math mode.

LaTex, like math, allows for multiple answers rather than just one right answer.

Now you know the basics of the tilde symbol in the LaTeX document.

I hope this post helps your research effort, and as always keep writing in LaTeX.

Not the answer you’re looking for? Check out our LaTex Tutorial for the other answers.

FAQ

Q1. How does one insert a “\” (backslash) into the text of a LaTeX document?

According to tex.stackexchange.com, the following solution is considered the best.

A backslash is produced in text-mode by /textbackslash. Math-mode $/sim$ and /texttildelow (from the textcomp package) are options for producing a lower tilde (while /*{} and /textasciitilde produce a raised tilde in text-mode).

It is important that you familiarize yourself with the Comprehensive LaTeX Symbol List. Although the link seems to keep changing, the command texdoc symbols-a4 will display the local copy if you have a complete TeX Live installation.

\textbackslash and \textasciitilde are found in several places in the document, but the LaTeX 2e ASCII Table (Table 529 as of this writing) and the following discussion are convenient resources for all ASCII characters.