No spacing after binary operator after math operator

There is some issue that I've come across while using \mathop where the space after a binary operator is not present when the first parameter is a operator.

Minimal Example

As you can see there is not the proper space after the binary operator +.

\begin{equation*}
\mathop{x} + y
\end{equation*}


Particular Example

I've been using a macro for the differential operator after integrals. The error occurred during (approximately) the following usage:

\newcommand{\intop}[1]{\mathop{d#1}}

\begin{equation*}
\int f(x) \intop{x} + y
\end{equation*}


• \mathop{dx} looks rather odd, usually people adjust the space before d not after x. you could use {}+y to compensate, Mar 20 at 20:52
• It may not necessarily be the case that your differential operator requires the use of \mathop. Just set it as dx, or \mathrm{d}x (as in, \newcommand{\intop}[1]{\mathrm{d}#1}.
– Werner
Mar 20 at 20:54
• or \newcommand{\intop}[1]{\mathop{}\!d#1} Mar 20 at 20:57

TeX follows its own rules. With

\int f(x) \diff{x} + y


(note that you cannot define \intop that's already taken) you have

Op Ord Open Ord Close Op Bin Ord

but the combination Op Bin is invalid and therefore the Bin atom is transformed into Ord, with the consequence that TeX will insert a thin space between x and +, but no space between + and y.

Your idea of using \mathop in order to get a thin space between the function and the differential is good, but you shouldn't overdo.

After the d there will always be either an Ord or an Open atom and you just want a thin space before the d, not after it.

It would be wrong to define

\newcommand{\diff}[1]{\mathop{d}\!#1}


because the letter d would be moved down. It's much easier to use an empty \mathop and to adjust the spacing, because there would be a thin space between the (empty) \mathop and d:

\newcommand{\diff}{\mathop{}\!d}


without arguments. Then

\int f(x)\diff x+y


will have the correct spacing. You might do

\newcommand{\diff}[1]{\mathop{}\!d#1}


but I see no reason for preferring \diff{x} over \diff x.

Caveat. Doing \renewcommand{\intop}{...} would be disastrous.

• Looks like there is a missing "close" in your atom sequence example. Mar 21 at 5:04
• @mickep Thanks, fixed. Mar 21 at 8:03

For the particular case only

If you want to write differentials, then one option is the package derivative. With the package you can simply write \odif{x} for an ordinary differential. For example:

\documentclass{article}
\usepackage{amsmath}
\usepackage{derivative}
\begin{document}
$\int f(x)\odif{x}+y$
\end{document}