Difference between \mathop and \mathord

It's a tough call, for this case.

In the linked question, the symbol “id” was apparently used in the context of functors, so like

\id\otimes f

and, as shown there, declaring it as an operator would not work.

One is unlikely to use \id x for “the identity applied at x”, and \id(x) will print just right.

There is still a problem: if one has to type r\id\otimes f (r is supposed to be a scalar) then probably

\newcommand{\id}{\operatorname{id}\!{}}

would be a better choice, because a thin space would be added between r and \id, but the operator nature on the right is nullified by adding a negative thin space and an empty ordinary atom. Unfortunately, there's little hope to have a context aware \id that would work also on the right and, for “id r” (meaning right multiplication) you need to resort to \id\,r.

Other function symbols like \sin and so on don't usually suffer from the issue.


\mathop is overloaded with two types of mathematical objects, both unary operators that operate from the left on some terms. TeX uses a simple heuristic to decide which is meant

1.Unary operators consisting of only one character are vertically centered (examples are \sum and \int.

  1. Unary operators consisting of more than one character are treated as function names (typeset in roman).

When you have something that neither operates from the left as a unary operator nor conjoining two operands on the left and right as a binary operator, it is best to make it a \mathord. A \mathord object is kind of neutral to its left and right neighbours where an unary operator binds stronger to its right neighbour than to its left one (expressed be different spacing and potential break points).

There are also binary operators in a separate class \mathbin: The are put between two terms with additional spacing. This class contains the signs + and - and many more. Binary operators can be unary in certain circumstances (think of (-1)) and TeX is pretty good in singling out these circumstances.

EDIT: here is a short demo of the effects of \mathord vs. \mathop: The first two lines demonstrate the spacing of a left multiplacative factor, the second pair of lines demonstrate the action on a negated right term including the different interpretations of the minus sign as unary/binary operator.

The generating code is the following:

\documentclass{minimal}
\begin{document}
\begin{eqnarray*}
  x \mathop{\mathrm{op}} x\\
  x \mathord{\mathrm {ord}} x\\
  \mathop{\mathrm{op}} -x\\
  \mathord{\mathrm {ord}} -x
\end{eqnarray*}
\end{document}

enter image description here