BehaviorCloud Logo
LaTeX

Inserting a Tilde (~) in LaTeX: A Handy Guide

We will look at how to insert a versatile tilde character (~) and how to incorporate it into your LaTeX document (without any breaks) in several ways:

The problem: Non-breaking Space

As you likely noticed, in LaTeX, using a single tilde (~) character serves as a non-breaking space. This means it will appear as a space in the output and prevent line breaks between words.

Hello~World

Output:

Hello World

Text Mode

To make the tilde appear in your text, you can use the following commands:

  1. \textasciitilde - This command will produce a tilde character (~) in text mode.
\textasciitilde
  1. \~{} - This is an alternate command to produce a tilde character (~) in text mode.
\~{}

Math Mode

In math mode, the tilde can be used as a symbol for similarity or as an operator. Use the following command to insert a tilde in math mode:

$\sim$

Over a Letter

You can also use the tilde as a diacritic mark over a letter, as demonstrated below:

\~{n}

This will produce a “ñ” character.

Utilizing Packages

You can use packages like textcomp for more options and versatility. Here’s how you can insert a tilde using this package:

\usepackage{textcomp} 
\texttildelow