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
- Text mode, no math preview
Fig.~1Non-breaking space in text: keeps "Fig." and "1" on the same line. No tilde is printed.
- Text mode, no math preview
\textasciitildeA visible ~ in running text.
- Text mode, no math preview
\texttt{\~{}}A tilde in typewriter text, e.g. paths like
\texttt{\~{}/docs}. \tilde{x}Tilde accent over one letter.
\widetilde{xyz}Wide tilde that stretches over several symbols.
a \sim bRelation ∼: similar to, equivalent to, distributed as.
A \nsim BNot similar (amssymb).
a \simeq bAsymptotically equal / isomorphic, ≃.
\mathord{\sim} 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.
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
LaTeX\tilde{x}, \quad \tilde{\theta}, \quad \tilde{A}Wide tilde
LaTeX\widetilde{f(x)} \quad \widetilde{AB}Distributed as
LaTeXX \sim \mathcal{N}(\mu, \sigma^2)Similar triangles
LaTeX\triangle ABC \sim \triangle DEFAsymptotic equivalence
LaTeXn! \sim \sqrt{2 \pi n} \left( \frac{n}{e} \right)^{n}About a value
LaTeX\text{latency: } \mathord{\sim} 10 \text{ ms}Plain
\simwould add relation spacing;\mathord{\sim}sits tight against the number.Not similar
LaTeXA \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.
See Figure~3. % tie, no tilde printed
Home folder: \texttt{\~{}/docs}
About \textasciitilde 10 ms
\url{https://example.com/~user} % url or hyperref packageTilde 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
\simfor the symbol.Instead ofx ~ y (expecting x ∼ y)Writex \sim y\~is a text accent; in math mode LaTeX reports "Command \~ invalid in math mode".Instead of$\~{x}$Write$\tilde{x}$\tildestays narrow and centers over the group.\widetildestretches across it.Instead of\tilde{abc}Write\widetilde{abc}Both
\and~are special. Write paths in\verbor escape each character.Instead ofC:\Users\~meWrite\texttt{\~{}me} or \verb|~me|
In Overleaf, MathJax and Word
Overleaf and pdfLaTeX
\tilde,\widetilde,\sim,\simeqand\textasciitildework without packages;\nsimneeds amssymb. A literal ~ in a URL needs\urlfrom the url or hyperref package.MathJax and KaTeX
MathJax and KaTeX handle
\sim,\tildeand\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~2so 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.
Related LaTeX reference
- Approximately Equal in LaTeX\approx for ≈, plus \sim, \simeq, \cong and \equiv, with what each symbol means.
- Hat in LaTeX\hat and \widehat accents, hats with subscripts, dotless i and j, and how to print the ^ character itself.
- Dot in LaTeX\cdot, \ldots, \cdots, \vdots, \ddots, \dot{x} and \bullet, and which dot fits which context.
- LaTeX equation editorSymbol panel, live preview, and PNG, SVG, MathML or Word export.
- All LaTeX reference pagesSymbols, math structures and text formatting in one list.
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