I want to create a macro
\d
where something like
$4+\d x$
is interpreted as
$4+d\! x$
but
$\int f(x) \d x$
is interpreted as
$\int f(x) \,d\! x$
In essence, I want the macro to behave differently if it is preceded by a binary operation.
d\!x
? – egreg Dec 15 '15 at 15:08\newcommand{\diff}{\mathop{}\!d}
does what you want. Don't redefine\d
. – egreg Dec 15 '15 at 15:09\mathop
you get the same behavior as with\sin
or\log
, that leave a thin space if preceded by an ordinary or closing symbol, but not with a binary operation or relation symbol. – egreg Dec 15 '15 at 15:25