Tilde (~) in LaTeX

A ~ typed in LaTeX is not printed: it is a non-breaking space. To show the character in text, write \textasciitilde (or \texttt{\~{}} in code-style text). In math, use \sim for the relation ∼ ("similar to", "distributed as") and \tilde{x} for a tilde accent over a letter, \widetilde{xyz} over several.

Tilde commands

  • Fig.~1
    Text mode, no math preview

    Non-breaking space in text: keeps "Fig." and "1" on the same line. No tilde is printed.

  • \textasciitilde
    Text mode, no math preview

    A visible ~ in running text.

  • \texttt{\~{}}
    Text mode, no math preview

    A tilde in typewriter text, e.g. paths like \texttt{\~{}/docs}.

  • \tilde{x}
    x ~

    Tilde accent over one letter.

  • \widetilde{xyz}
    x y z ~

    Wide tilde that stretches over several symbols.

  • a \sim b
    a ∼ b

    Relation ∼: similar to, equivalent to, distributed as.

  • A \nsim B
    A ≁ B

    Not similar (amssymb).

  • a \simeq b
    a ≃ b

    Asymptotically equal / isomorphic, ≃.

  • \mathord{\sim} 10
    ∼ 10

    ∼ used as "about" in front of a number, without relation spacing.

Try it live

Change the formula and the preview redraws as you type. Copy the LaTeX, download a PNG or SVG, copy it for Word, or use Edit here on any example below to load it.

Templates

Tilde (~) examples

Each result below is drawn from the LaTeX under it. Copy the code, edit it on this page, or open it in the full editor.

  • Tilde accent

    x ~ , θ ~ , A ~
    LaTeX
    \tilde{x}, \quad \tilde{\theta}, \quad \tilde{A}
  • Wide tilde

    f ( x ) ~ A B ~
    LaTeX
    \widetilde{f(x)} \quad \widetilde{AB}
  • Distributed as

    X ∼ N ( μ , σ 2 )
    LaTeX
    X \sim \mathcal{N}(\mu, \sigma^2)
  • Similar triangles

    △ A B C ∼ △ D E F
    LaTeX
    \triangle ABC \sim \triangle DEF
  • Asymptotic equivalence

    n ! ∼ 2 π n ( n e ) n
    LaTeX
    n! \sim \sqrt{2 \pi n} \left( \frac{n}{e} \right)^{n}
  • About a value

    latency:  ∼ 10  ms
    LaTeX
    \text{latency: } \mathord{\sim} 10 \text{ ms}

    Plain \sim would add relation spacing; \mathord{\sim} sits tight against the number.

  • Not similar

    A ≁ B
    LaTeX
    A \nsim B

Why ~ prints a space

In LaTeX source, ~ is a tie: a space the line breaker is not allowed to break. Use it between a label and its number (Figure~3, Section~2.1, Dr.~Smith) so the two never end up on different lines. That is why typing ~ never shows a tilde.

For the character itself in text, use \textasciitilde. \~{} also works but puts the tilde high, like an accent over an empty letter, which looks odd in normal text. In monospaced code, \texttt{\~{}} or \verb|~| gives a mid-height tilde.

LaTeX
See Figure~3.            % tie, no tilde printed
Home folder: \texttt{\~{}/docs}
About \textasciitilde 10 ms
\url{https://example.com/~user}  % url or hyperref package

Tilde in math: accent or relation

Over a letter, \tilde{x} is an accent (often a median, a transformed variable or an approximation). Between two expressions, \sim is a relation with space on both sides. They are different commands; \~ is a text accent and fails in math mode.

For "approximately" in a formula, ≈ (\approx) is the usual choice; ∼ is used for asymptotic equivalence and "of the same order". See the approximately-equal page for the full set.

Tildes in URLs

Inside \url{} or \href{}{} from the url / hyperref packages you can type ~ directly; the package prints it as a character and keeps the link working.

Common mistakes

  • ~ is a space, in math as well as in text. Use \sim for the symbol.

    Instead of
    x ~ y  (expecting x ∼ y)
    Write
    x \sim y
  • \~ is a text accent; in math mode LaTeX reports "Command \~ invalid in math mode".

    Instead of
    $\~{x}$
    Write
    $\tilde{x}$
  • \tilde stays narrow and centers over the group. \widetilde stretches across it.

    Instead of
    \tilde{abc}
    Write
    \widetilde{abc}
  • Both \ and ~ are special. Write paths in \verb or escape each character.

    Instead of
    C:\Users\~me
    Write
    \texttt{\~{}me}  or  \verb|~me|

In Overleaf, MathJax and Word

  • Overleaf and pdfLaTeX

    \tilde, \widetilde, \sim, \simeq and \textasciitilde work without packages; \nsim needs amssymb. A literal ~ in a URL needs \url from the url or hyperref package.

  • MathJax and KaTeX

    MathJax and KaTeX handle \sim, \tilde and \widetilde, and treat ~ as a space inside math just like LaTeX. In some Markdown editors, ~~ outside math delimiters becomes strikethrough before the math renderer sees it.

  • Microsoft Word

    In Word the ~ key simply types a tilde. For an accent over a variable or the ∼ relation inside an equation, write it here and use Copy for Word to paste an editable equation.

Tilde (~) in LaTeX: questions

How do I write a '~' symbol in LaTeX?
In text use \textasciitilde; in typewriter text \texttt{\~{}}; in math \sim. Typing ~ alone gives a non-breaking space.
Why does ~ create a space in LaTeX?
LaTeX reserves ~ for a non-breaking space (a tie), used as in Figure~2 so a number is never separated from its label at a line break.
How do I put a tilde over a letter?
Use \tilde{x} in math mode, or \widetilde{xy} for more than one symbol. In text, \~{n} gives ñ.
What is the difference between \sim and \approx?
\approx (≈) means numerically approximately equal. \sim (∼) usually means asymptotically equivalent, similar, or "distributed as" in probability.

Have the formula as a picture?

Paste a screenshot or photo of the equation and get its LaTeX, ready to copy or open in the editor.

Convert an image to LaTeX