If you define
\newcommand\abs[1]{#1^\sharp}
the spacing will be inherited by the nature of #1
; so
\abs{\sqcup}
will be spaced as a binary operator and
\abs{=}
will be spaced as a binary relation.
With you definition you get {\sqcup}^{\sharp}
that's treated as an ordinary symbol.
Some detail
When one tries the input $a+^{\sharp}b^2\showlists$
, the .log
file will report
### math mode entered at line <line number>
\mathord
.\fam1 a
\mathbin
.\fam0 +
^\fam1 ]
\mathord
.\fam1 b
^\fam0 2
The \mathord
and \mathbin
lines tell what type of math atom TeX is analyzing. Every atom has three fields: the nucleus (represented by .
), the superscript (represented by ^
) and the subscript (represented by _
).
Since +
is defined to be a \mathbin
atom, such type is reported. This atom has as nucleus the character +
taken from family 0, and a superscript taken from family 1 (cmsy10
font in the default setting, where the slot usually occupied by ]
has the "sharp" symbol).
If instead we say $a{+}^{\sharp}b\showlists$
, the response is
### math mode entered at line <line number>
\mathord
.\fam1 a
\mathord
.\mathbin
..\fam0 +
^\fam1 ]
\mathord
.\fam1 b
The braces around a subformula tell TeX to treat the whole subformula as a \mathord
atom; this atom has a nucleus formed by a \mathbin
atom (at an inner level, represented by the two periods ..
), but this would have consequences only for the typesetting of the subformula, not with respect to the "outer" level. The braced \mathord
atom has a superscript atom as before.
This is only the first step in typesetting a formula. When TeX has determined all the atoms it has to typeset, it applies its rules about spacing; for example
it inserts a medium space between \mathord
and \mathbin
atoms (I'll skip over some subtlety), but it never inserts spaces between two \mathord
atoms (unless, of course, such a space has been explicitly specified by the user).
Note that it's the same as with \sqcup
instead of +
, since also this symbol is declared as a \mathbin
atom.