Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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."

share|improve this question
    
related: tex.stackexchange.com/questions/48/… –  Marco Daniel May 13 '12 at 19:42
1  
\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
2  
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
show 1 more comment

1 Answer

up vote 11 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.