Math Operators – Difference Between \mathop and \mathord

best practicesmath-operators

Depending on this question I am totally confused now, when to define something as an operator or as an ordinary math symbol. egreg says in his comment that the identity function is to be used as an ordinary math symbol rather than as a operator. I would like to understand the reason for this.

Is there any thumb rule, when to declare something as an operator and when to define something a an ordinary math symbol?

For instance, I have seen in source files that one defines the adjoint action, as the following:

\DeclareMathOperator{\Ad}{Ad}

but egreg suggests to define the identity function like this

\newcommand{\id}{\mathrm{id}}.

What is the underlying principle which leads to this kind of usage?

Best Answer

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.

Related Question