Symbols denoting equivalence relations are typically used in two ways. They are either binary relation symbols denoting that two elements are equivalent or they appear as ordinary symbols in the standard notation for quotients of sets by equivalence relations. In the latter case LaTeX needs to be told explicitly that we want to treat the equivalence symbol as an ordinary symbol.
The code
\documentclass{minimal}
\begin{document}
Good spacing: $x \sim y$.
Bad spacing: $X / \sim$.
Good spacing: $X / \mathord\sim$.
\end{document}
produces
I wonder whether it is possible for \sim
to automatically convert to \mathord
class in such situations. I think it would be enough to make it so that \sim
is \mathrel
unless it immediately follows /
in which case it should be \mathord
.
\sim
to be\mathrel
, not\mathbin
(and\sim
is a\mathrel
). The simplest method is to type{\sim}
when you don't want it to be spaced as a relation.\mathbin
is for binary operations. And enclosing it in braces is indeed a very simple solution...