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?

  • 1
    )not tested, hence a comment, not an answer.) \sim is a relation, so typing `$a \mathrel{\dot{\sim}} b$ should restore the proper class. – barbara beeton Nov 10 '15 at 19:55

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




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


enter image description here

  • Can this solution be parametrized by the symbol, like = or \approx? – user3389669 Nov 10 '15 at 19:59
  • @user3389669: You mean for \dot{=} and \dot{\approx}? Simply wrap a \mathrel{} around them. – Francis Nov 10 '15 at 20:01
  • I meant something like \dotrel{<your symbol goes here>}, where you could insert arbitrary symbols, resulting in that symbol being printed dotted and being treated like a relation. – user3389669 Nov 10 '15 at 20:04
  • 1
    @user3389669: Yes, I slightly modified my answer – Francis Nov 10 '15 at 20:07
  • 2
    The TeXnical reason is that an Acc atom (resulting from <math accent>{<symbol>} (for instance \dot{\sim}) is then treated as an Ord atom (ordinary symbol) when the math list is transformed into a horizontal list. Enveloping the construction in \mathrel reestablishes the nature of the atom. – egreg Nov 10 '15 at 20:38

When you do something like \dot{\sim}, you're creating an Acc atom (for accent) which, by rule, is treated the same as an Ord atom (ordinary, like a normal letter) when the math list is converted into typesetting commands. See Rules 12 and 16 in Appendix G of the TeXbook (pages 443 and 445).

The amsmath package already defines an infrastructure it uses for trying and guess the right type of the second argument to \overset and \underset, so that, say, \overset{x}{=} results in a Rel atom.

The trick is to evaluate \binrel@ on the second argument, which will redefine \binrel@@ to be \mathrel, \mathbin or \mathord.

So the definition of a “smart dot” could be as follows:




Relation: $a \sdot{\sim} b$

Relation: $a \sim b$

Operation: $a \sdot{\times} b$

Operation: $a \times b$


Note that the spacing is the same for dotted and undotted symbols.

enter image description here


Try a \mathrel{\dot{\sim}} b.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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