[Tex/LaTex] Spacing around math operator in sub-/superscript

math-operatorsspacing

Consider the following:

\documentclass{article}

\begin{document}

What I have:
\[x^{1+1}\]

What I would like:
\[x^{1\,+\,1}\]

That is, I will like to have spacing around the operator as in `$1+1$'.\\[\baselineskip]
\textsf{Question:} How do I get the above throughout my document without having to add \verb|\,| on each side of the operator every time?

\end{document}

output

Best Answer

enter image description here

Luatex has primitives to control the space added between each class in each math style, so to control the space between a mathord and a mathbin in script style:

\documentclass{article}

\begin{document}
$a+b x^{a+b}$

\Umathordbinspacing\scriptstyle=10mu
\Umathbinordspacing\scriptstyle=10mu

$a+b x^{a+b}$

\end{document}

For classic TeX engines You can do

enter image description here

\documentclass{article}
\DeclareMathSymbol{\realplus}{\mathbin}{operators}{"2B}
\begin{document}
$a+b x^{a+b} +cx^{+c}$

%\Umathordbinspacing\scriptstyle=10mu
%\Umathbinordspacing\scriptstyle=10mu


\def\z{{\mskip\medmuskip{\realplus}\mskip\medmuskip}}

$a\z b x^{a \z b} \z  cx^{\z c}$

\catcode`\+\active\let+\z
\catcode`\+12
\mathcode`\+="8000

$a+b x^{a+b} +cx^{+c}$

\end{document}

But it's not so good, it always adds the space so only works if + is used as a binary operator between to mathord atoms. Note the final prefix +c in the last term gets the wide space, which isn't really what you want, you'd need a separate command to access a prefix +.

In an answer linked via comments I suggested a construct using \nonscript which looks more involved but actually I think it has the same flaw.

The version suggested by egreg using \text gets the correct spacing but it requires more markup than just adding the space (although of course you could define your own variant \sp command that made superscripts using this construct).