12

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?

  • Welcome to TeX.SE. This is a very good question. I am curious about the explanation. – Jan Apr 3 '17 at 8:52
  • 3
    The difference is in the context where the symbol is used; in the context of the linked question, “id” is used as if it were a single letter, on par with, say, “f”. – egreg Apr 3 '17 at 8:56
  • Here(tex.stackexchange.com/a/16650/97026) you say that "If \id denotes the identity map, then it shouldn't be an operator, but an ordinary symbol". What is the context, when to define the identity map as an math operator? – varsop Apr 3 '17 at 9:02
10

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.

  • So this question is merely a typographical question at all, am I right? For instance, if one wants to define the automorphism group of an object $X$, most of the mathematicians would write $\mathrm{Aut}(X)$, where $\operatorname{Aut} X$ is "more" correct. But in many source files $\Aut$ is defined as an operator and it is used like $\Aut(X)$, i.e. with parentheses. Can one speak of an "over usage" of declaring MathOperators in source files with wrong application? – varsop Apr 3 '17 at 12:04
  • @varsop Using parentheses or not in such cases is personal preference. I'd say that for “Aut” it's correct \operatorname in any case. – egreg Apr 3 '17 at 12:06
6

\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

  • For binary operators, we use \mathbin in TeX, no \mathop. – wipet Apr 3 '17 at 9:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.