# How do I write $\sim$ approximately with the correct spacing?

I would like to use the symbol $\sim$ as "approximately". e.g:

\documentclass{minimal}
\begin{document}
There are $\sim 10^{80}$ atoms in the universe.
\end{document}


I think that I need to declare $\sim$ as some sort of unary math operator, to make the spacing correct! How?

Edit:

Here: http://en.wikipedia.org/wiki/Tilde it can be read, that $\sim$ can be used both as a binary relation operator, and an unary operator meaning "approximately".

Common use

This symbol (in English) sometimes means "approximately", such as: "~30 minutes ago" meaning "approximately 30 minutes ago".[2] It can mean "similar to",[3] including "of the same order of magnitude as",[4] such as: x ~ y" meaning that x and y are of the same order of magnitude. Another approximation symbol is ≈, meaning "approximately equal to."

-
– Marco Daniel May 13 '12 at 19:42
\sim is a relation symbol, and usually one wants some space between it and the following object. If you want no space (but I would avoid it), then ${\sim}10^{80}$ will do. – egreg May 13 '12 at 19:44
For a symbol that indicates approximate equality, you may want to consider using $\approx$ instead of $\sim$. – Mico May 13 '12 at 19:56
@Mico: Yes - I would use $\approx$ for "approximate equal". e.g $\pi \approx 3.14. -but it looks wrong(ugly) for "approximately" as in my example. – Hans-Peter E. Kristiansen May 13 '12 at 20:21 @egreg: Yes for a relation, I would definitely want the space, but not for the unary operator. Your solution looks good, but I am looking for the correct way to make $\sim$ behave nicely. (minus ,- can also be both unary and binary e.g. $2-5=-3$ – Hans-Peter E. Kristiansen May 13 '12 at 20:28 ## 2 Answers The \sim symbol is classified as a relation symbol. By the rules of TeX, the combination Rel Ord (relation followed by an ordinary symbol) results in a thick space between them. The case of binary operations (Bin) is different: they are treated as binary operations only if preceded and followed by math atoms compatible with binary operations, for instance Ord Bin Ord Ord Bin Op and others (Op stands for "operator"). [This is not the full truth, but a good approximation to it.] When a binary operation is "out of place", it's treated as an Ord atom. This is why no space is inserted in $-1$. Every math symbol can be turned into an ordinary atom by enclosing it in braces. TeX inserts no space between ordinary symbols, so $\sim 10^{80}$ will result in ~ 1080 while ${\sim}10^{80}\$


will give

~1080

I'm afraid that no automatic way exists that allows using only \sim. You can define

\newcommand{\unsim}{\mathord{\sim}}


(the \mathord is just for clarity, the additional braces would do the same) and use \unsim when the "unary" symbol is needed.

-

I had the same problem, wanting to use \sim for the (unary) logical negation operator. Building on egreg's answer from above, another option is to simply redefine the \sim command so that it produces the tilde without the space:

\let\oldsim\sim
\renewcommand{\sim}{{\oldsim}}
`
-
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – Martin Schröder Jun 8 '15 at 17:35