# Spacing in subscripts

Obviously if you put n{=}1 into a LaTeX document you don't get the proper spacing that you get with n=1, except that in things like \sum_{n=1}^\infty the spacing seems no different from what it would be if you write \sum_{n{=}1}^\infty.

But if I recall correctly, in Walter Rudin's Principles of Mathematical Analysis it's not like that; it looks the way it would if you wrote \sum_{n\,=\,1}^\infty.

Is there some standard way of having it do that every time by putting something above the \begin{document} line? Or if not that, some reasonable non-standard way?

TeX suppresses spaces around binary operation symbols in subscripts and superscripts.

Can you reinstate it? Yes, if you wrap the subscript/superscript in \text{$...$}.

\documentclass{article}
\usepackage{amsmath}

\let\oldsum\sum % for comparison

\makeatletter
\renewcommand{\sum}{\DOTSB\spaced@sum}
\NewDocumentCommand{\spaced@sum}{e{_^}}{%
\sum@\slimits@
\IfValueT{#1}{_{\text{\m@th $#1$}}}%
\IfValueT{#2}{^{\text{\m@th $#2$}}}%
}
\makeatother

\begin{document}

\begin{gather}
\oldsum\dots\oldsum_{n=1}^\infty a_n
\\
\sum\dots\sum_{n=1}^\infty a_n
\end{gather}

\end{document}


If you're running an older version of LaTeX you may need \usepackage{xparse}.

If you replace the main definition with

\NewDocumentCommand{\spaced@sum}{e{_^}}{%
\sum@\slimits@
\IfValueT{#1}{_{\text{\thickmuskip=3mu \m@th $#1$}}}%
\IfValueT{#2}{^{\text{\thickmuskip=3mu \m@th $#2$}}}%
}


you get less space.

You can abstract the setting:

\documentclass{article}
\usepackage{amsmath}

\let\oldsum\sum % for comparison

\makeatletter
\NewDocumentCommand{\spaced@operator}{me{_^}}{%
\csname #1@\endcsname\slimits@
\IfValueT{#2}{_{\text{\thickmuskip=3mu \m@th $#2$}}}%
\IfValueT{#3}{^{\text{\thickmuskip=3mu \m@th $#3$}}}%
}
\def\operator@list{%
coprod,bigvee,bigwedge,biguplus,%
bigcap,bigcup,prod,sum,bigotimes,%
bigoplus,bigodot,bigsqcup%
}
\@for\next:=\operator@list\do{%
\expandafter\edef\csname\next\endcsname{%
\noexpand\DOTSB\spaced@operator{\next}%
}%
}
\renewcommand\lim{\spaced@lim{lim}}
\renewcommand\liminf{\spaced@lim{lim\,inf}}
\renewcommand\limsup{\spaced@lim{lim\,sup}}
\NewDocumentCommand{\spaced@lim}{me{_^}}{%
\qopname\relax m{#1}%
\IfValueT{#2}{_{\text{\thickmuskip=3mu \m@th $#2$}}}%
\IfValueT{#3}{^{\text{\thickmuskip=3mu \m@th $#3$}}}%
}
\makeatother

\begin{document}

\begin{gather}
\oldsum\dots\oldsum_{n=1}^\infty a_n
\\
\sum\dots\sum_{n=1}^\infty a_n
\\
\prod_{a=1}\lim_{n\to\infty}
\end{gather}

\end{document}


• So this works only with \sum and not with \lim, \max, etc. How would one cause TeX not to suppress spaces around binary operation symbols in subscripts and superscripts? Apr 2 at 1:37
• @MichaelHardy Sorry, you have to do it for every big operator; the procedure can be abstracted, though. I’ll add some ideas. Apr 2 at 7:39
• @MichaelHardy I added the “abstraction": the list of big operators comes from amsmath. Apr 2 at 9:08
• This works with \lim but not with \max. Would just adding that to the list do it? Apr 2 at 18:38
• @MichaelHardy Just add \renewcommand\max{\spaced@lim{max}} and similarly for \min\sup\inf Apr 2 at 21:11