# Spacing using operators

Why do I get two different outputs from the following lines (in plain TeX)?

$f=\mathop{\rm id}_Y\circ f$

$f={\mathop{\rm id}_Y}\circ f$

\bye


In both, an operator is used, but in the first one the f is too close to the binary symbol \circ; in the second one, by grouping the operator the glyph is well arranged.

How can I get the second output currently in my document without grouping the operators each time?

• In the first example, a math operator is to the left of \circ, wheras in the 2nd example, a math atom is to the left of the \circ. – Steven B. Segletes Oct 19 '15 at 13:09
• @StevenB.Segletes so that I should write the line in the second way or even \mathop {\rm id}_Y{}\circ f? – Martino Oct 19 '15 at 13:21
• It's not an operator: just use {\rm id}. – egreg Oct 19 '15 at 13:23
• @egreg indeed, it is a mapping name so I shall mean it as an operator, thus the line \mathop {\rm id}(x) is correctly spaced – Martino Oct 19 '15 at 13:32
• @Lorenzo No, \mathop has a very specific meaning, which is inappropriate in this case. You get exactly the same spacing with ${\rm id}(x)$ and with $\mathop{\rm id}(x)$, but the latter behaves badly in other situations. – egreg Oct 19 '15 at 13:34

You get different spacing because of the rules of TeX.

With $f=\mathop{\rm id}_Y\circ f$ we have

Ord Rel Op Bin Ord

Looking at the table at page 170 of the TeXbook, we can add the spacing between the atoms:

Ord 3 Rel 3 Op 1 Ord* Ord

Note that the Bin atom is turned into Ord, because the combination Op Bin is rejected. It's like $\log-1$, after all. So the Bin is turned into an Ord atom. The numbers represent spaces in the form 1=\thinmuskip, 2=\medmuskip and 3=\thickmuskip.

With $f={\mathop{\rm id}_Y}\circ f$ we get

Ord Rel Ord Bin Ord

because the braces around a subformula make it into an Ord atom, so the spacing is

Ord 3 Rel 3 Ord 2 Bin 2 Ord

The symbol for the identity map is not an operator, but an ordinary atom and

{\rm id}


is what you need. Using \mathord{\rm id} is more semantic, but completely equivalent.