What is the technical reason for the difference of $\sum{}^{...}$ and $\sum^{...}$?
TeX creates math list which is (roughly speaking) a sequence of atoms, each atom has nucleus+subscript+superscript. Each part of the atom can be empty. The sequence of atoms are converted to the definite \hboxes
(raised or lowered) in the second pas of scanning math mode material.
First example \sum{}^a
creates first atom with nucleus: sum character, subscript and superscript are empty. It is followed by second atom with empty nucleus, empty subscript and superscript is a
.
Second example \sum^a
creates only one atom with sum character in nucleus and a
in superscript. The subscript is empty.
The differences in visible output is given by differences in interpreting the two atoms versus one atom in second pass over math material. The positioning of superscript depends on the size of the nucleus and on the type of the atom.
The technical reason is that, in math mode, {}
is a math atom and is not something that gets discarded.
It's generally not a good idea to define macros to stand for text, because this reduces readability of the code, but in some occasions some macro that's not to be followed by arguments has to be used. The typical example is the command \LaTeX
.
Anyway, if you have text commands that are not to be followed by a argument in braces, terminating it with {}
is a good strategy for keeping a following space.
In math this is disastrous, as you witnessed. Just leave a space: if you want to type the sine of x, do \sin x
. Never use {}
to terminate a command name in math mode: compare
\sin(x+y)
\sin{}(x+y)
to see the reason:
In standard math typesetting there should be no space between “sin” and the parenthesis. The empty atom {}
is of type “ordinary” and will trigger the space like in \sin x
.
What happens with \sum{}_x^y
? That the subscript and superscripts are to the (empty) atom represented by {}
: the \sum
atom has already gone its way.
In the first version, \sum
and {}^{...}
are independent of each other. The second is typeset the same way, independently of \sum
. The result of \[ \sum{}^{a}\qquad {}^{a} \]
:
In the second version, the exponent is attributed to sum
and is interpreted as upper limit. The result of \[ \sum^{a}\qquad {}^{a} \]
: