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

This question is similar to this one, only that I'm using the siunitx package:

\documentclass{minimal}
\usepackage{siunitx}
\begin{document}
The temperature is \SI{\sim 200}{\kelvin}. \\
The temperature is \SI{{\sim} 200}{\kelvin}. \\
The temperature is \SI{{\sim}200}{\kelvin}. \\
The temperature is $\sim$\SI{200}{\kelvin}.
\end{document}


The last line leads to the result I want. It is however not very elegant in my oppinion. Is there a way to tell the si package that I don't want a space before my value?

-
Welcome to TeX.SX! –  Heiko Oberdiek Apr 9 '14 at 9:08
Should you not use \approx? –  Raphael Apr 9 '14 at 13:12

You could define

\newcommand{\appr}{{\mathord{\sim}}}


as per the answer you linked to; with double curly braces this is even usable in \SI like so

\SI{\appr 200}{\kelvin}


MWE: compare this solution (first line) to your desired output (second line)

\documentclass{minimal}
\usepackage{siunitx}
\newcommand{\appr}{{\mathord{\sim}}}
\begin{document}
The temperature is \SI{\appr 200}{\kelvin}.

The temperature is $\sim$\SI{200}{\kelvin}.
\end{document}


-
Use \approx, instead of define \appr. Also, the 2nd example looks like a big hack to me. –  jmc Apr 9 '14 at 13:27
@jmc I would have liked to use \approx, but that macro is already defined and yields ≈. (Whether one should use the ∼ or ≈ symbol here is an entirely different matter.) The second example is just to compare my solution the OP's preferred output. –  moewe Apr 9 '14 at 13:36

~ is a relational symbol and should be used such. Further you can use \SI macro inside the math mode. Hence, the correct way is

\documentclass{minimal}
\usepackage[detect-all]{siunitx}
\begin{document}
The temperature is $\sim\SI{200}{\kelvin}$.
\end{document}


-
You could add one sentence, why this is correct. The but stands so alone there. –  Johannes_B Apr 9 '14 at 9:12
@Johannes_B OK, I added the reason. Thanks :) –  Harish Kumar Apr 9 '14 at 9:43
It's the same here for ~ as for <: You always write $x$ is in modulus $<1$ and not ... in modulus $<$1. –  yo' Apr 9 '14 at 9:51
Just to clarify: do you mean this solely in a programming context? Because I was referring mainly to the typography of my text and especially with single digit numbers the rather huge distance to the ~ looks a bit strange to me. In the scientific literature connected to my work I've found both notations so I don't know if there is a "right" one. –  Lukas Brunner Apr 9 '14 at 10:12
@Hans-PeterE.Kristiansen In physics, it is ~ 200K and not ~200K. This appears to be physics related. In the question, the OP doesn't want ~ to be relational but unary (I know) but that, according to me, is not correct. Hope I am clear now. –  Harish Kumar Apr 9 '14 at 13:47

Like Raphael said in the comments:

\documentclass{minimal}
\usepackage{siunitx}
\begin{document}
The temperature is \$\approx \SI{200}{\kelvin}.
\end{document}

-