[Tex/LaTex] Fix spacing when using \dot{}

math-modespacing

If I type $a \sim b$, I get enter image description here. However, if I type $a \dot{\sim} b$, I get this enter image description here and the spacing is gone. Is there a way to regain latex's good spacing mechanism, i.e. add spaces if needed and avoid unnecessary spacing?

Best Answer

You want to define a new command to make \dot{\sim} a binary relation:

\documentclass{article}
\usepackage{mathtools}

\newcommand{\dotrel}[1]{\mathrel{\dot{#1}}}

\begin{document}

\[a\sim b\]
\[a\dotrel{\sim} b\]
\[a\dot{\sim} b\]

\end{document}

enter image description here

Related Question