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

Since version 2.1 siunitx supports so called comparators such as <, =, > and also \approx and \sim. In version 2.6 the spacing for these was fixed such that

\SI{\sim 200}{\kelvin}

now gives exactly what you want. See also input-comparators on p. 21 of the siunitx documentation.

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

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

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

enter image description here


~ 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}

enter image description here