I set \mathsurround
to 2pt
in order to have a bit more horizontal spacing between text and in-line equations. Is there a way to set it to 0pt
on the right whenever the in-line equation is followed by a punctuation mark?
For instance, the code
Let $x=0$ and $y=1$.
is typeset as in the first line below, while I would like it to be as in the second.
Is there a way to achieve this without having to provide every time \hspace{-2pt}
?
Edit:
I have already considered @barbarabeeton's advice, that is, to include the punctuation before the final $
, but some marks are typeset differently in text mode and math mode. Probably punctuation marks is a bit too restrictive, as I would like to include brackets () [] {} or even the apostrophe '. In addition I would like my code to be flexible, so whenever I decide to change something I don't have to edit the whole document.
$
sign.