3

I'm a newbie in LaTeX. When I was reading the Tutorial book about LaTeX, I got a command

\newcommand {\dd}{\mathop{}\,\mathrm{d}}

Actually, I understand the function of that command but I don;t get the practical function of a command \mathop{} in this situation and in general case.

Hoang Nam
  • 133

1 Answers1

11

Fine math typography prescribes a thin space in order to separate a function from a differential.

The \mathop{} bit does this, because when a \mathop follows an ordinary atom or a closing atom, TeX will add a thin space between them.

Such a thin space will not be added if \mathop is preceded by an operation symbol, like in \dd x+\dd y: only the automatic space surrounding + would be used.

The problem with the definition you found is that there is too much space: indeed, \mathop{} also inserts a thin space if followed by an ordinary atom (your \mathrm{d}), and you add another one.

You should instead remove the automatically added space.

\documentclass{article}

\newcommand{\ddbad}{\mathop{}\,\mathrm{d}}
\newcommand{\ddgood}{\mathop{}\!\mathrm{d}}

\begin{document}

\[
\int f(x)\ddbad x \qquad \int f(x)\ddgood x
\]

\end{document}

enter image description here

With \ddbad you get three thin spaces, one before \mathop{} and two after it. With \ddgood there is just one thin space, because \! cancels out the one automatically inserted after \mathop{}.

If you try and typeset

\[
\ddbad x+\ddbad y \qquad \ddgood x+\ddgood y
\]

you'll see more clearly what goes wrong.

enter image description here

egreg
  • 1,121,712