# Punctuation spacing in math that ends with a differential \dd{}, and the physics package

It seems the physics package adds an extra (thin) space after \dd{x}, before my punctuation (usually "," or ".") and I don't want this. This is a common scenario for me, especially if I'm displaying a calculation that ends in an integral. It seems that I can get around this by sticking the punctuation into the \dd command, like so: \dd{x.}. I've used a regex to replace this in my document, but is there a way to get physics get this right automatically? This is probably the only feature of the physics package that I use, and while googling, I saw that a Henri Menke said in a comment

Do not use the physics package. The implementation is really horrible and it destroys the spacing all over the place.

...so if there is a good way to automatically have thin spaces at the correct places without the physics package, I'm all game.

A simple MWE so you can see what I mean (I don't usually punctuate inside inline math mode)

\documentclass{article}
\usepackage{physics}
\begin{document}
$A \dd{s}.$
$B \dd{s}.$
$C \dd{s.}$
$D \dd{s.}$
\end{document}

• \newcommand{\dd}{\mathop{}\!\mathrm{d}} (I'd prefer without the \mathrm, but the document is yours). Whether you type \dd s or \dd{s} it doesn't matter. The physics package is full of dubious constructions. – egreg Sep 14 at 9:19
• @egreg that works very nicely, thank you! While trying to understand how it works, I came across an answer of yours that in the process of explaining \mathop, gave this exact solution - tex.stackexchange.com/questions/84302/… If this counts as a duplicate then close away, otherwise in the near future I will summarise the relevant information into an answer... – Calvin Khor Sep 14 at 12:08