5

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?

0

1 Answer 1

5

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}

enter image description here

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.

enter image description here

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}

enter image description here

5
  • 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? Commented Apr 2, 2021 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.
    – egreg
    Commented Apr 2, 2021 at 7:39
  • 1
    @MichaelHardy I added the “abstraction": the list of big operators comes from amsmath.
    – egreg
    Commented Apr 2, 2021 at 9:08
  • This works with \lim but not with \max. Would just adding that to the list do it? Commented Apr 2, 2021 at 18:38
  • 1
    @MichaelHardy Just add \renewcommand\max{\spaced@lim{max}} and similarly for \min\sup\inf
    – egreg
    Commented Apr 2, 2021 at 21:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .