A bare ~ in LaTeX is a non-breaking space, which is why it never prints. For the relation sign use \sim; for an accent use \tilde; for a literal tilde in text (file paths, Unix home directories) use \textasciitilde or the url package.
All ways to write it
| Command | Use | Package | Copy |
|---|---|---|---|
\sim | binary ∼ (similar, distributed as) | none | |
\tilde{a} | accent over one letter | none | |
\widetilde{abc} | wide accent over several | none | |
\textasciitilde | literal ~ in text mode | none | |
\texttt{\~{}} | ~ in a monospace path or URL | none | |
\url{~user} | tilde in a URL | hyperref, urlnot in KaTeX |
Commands marked with a package need that \usepackage line in a LaTeX document. “Not in KaTeX” means the command will not render in KaTeX- or MathJax-based tools such as Markdown previews, Jupyter and Confluence math apps; use one of the other forms there.
Example
\tilde{x} = \frac{x - \mu}{\sigma}, \qquad X \sim \text{Poisson}(\lambda)A tilde accent for a standardised variable, and ∼ for a distribution.
Questions
Why does ~ print as a space?
In LaTeX ~ is the non-breaking space. Use \textasciitilde (text) or \sim (math) when you want the glyph.
How do I write ~/Documents in LaTeX?
\texttt{\textasciitilde/Documents}, or \path{~/Documents} from the url package.
Related symbols
- Approximately ≈
\approx - Hat x̂
\hat{x} - Bar x̄
\bar{x}
Using tilde in Confluence
Confluence Cloud has no built-in LaTeX. With LaTeX Math for Confluence you add a math macro to any page, type \sim and it renders inline or as a block, with a live preview while you edit. The app uses KaTeX, so pick one of the commands above that is not marked “not in KaTeX”.