# Improving typesetting of sums with long limits

This piece of code

\documentclass{article}
\usepackage{mathtools}
\begin{document}
$\smashoperator[r]{\sum_{s=n-t+1}^{j-1}}s-(n-t)=\sum_{s=1}^{j-1-(n-t)}s=\frac{\bigl(j-1-(n-t)\bigr)\bigl(j-(n-t)\bigr)}{2}$
\end{document}


produces

I’d like to have

commands like \smashoperator or \mathclap are of no use as the width of the upper limit is correctly pushing the equal signs apart. How can I give TeX a hint that I want to move the summand s close to the sigma and under the upper limit?

• Not quite understood, \smashoperator smashes both upper and lower limit. Or is what you are asking for, that if the summand is short, then the with of the limits should still be taken into account? That case is IMO too special to make a makro for it, I would just pull back the s by hand. – daleif Dec 23 '11 at 11:33
• If the middle sum would stand on its own \smashoperator would do the job. But here the = should not move under the upper limit only the s. How do I move the s easily? What commands are there to achieve this? – uli Dec 23 '11 at 11:36
• Ugly Hack: You can always insert some negative horizontal space just before s i.e. \hspace{-2ex}s – percusse Dec 23 '11 at 11:50

\documentclass{article}
\usepackage{mathtools}
\begin{document}
$\smashoperator[r]{\sum_{s=n-t+1}^{j-1}}s-(n-t)= \mathop{\sum_{s=1} s}^{j-1-(n-t)}=\frac{\bigl(j-1-(n-t)\bigr)\bigl(j-(n-t)\bigr)}{2}$
\end{document}

• haha, yes, ofcourse! – morbusg Dec 23 '11 at 12:13

Maybe if you make the \sum s a single \mathop entity:

\let\hw\hidewidth
$$\sum_{\hw s=n-t+1\hw}^{j-1} s-(n-t) =\mathop{\sum s}_{s=1}^{j-1-(n-t)}={\bigl(j-1-(n-t)\bigr)\bigl(j-(n-t)\bigr)\over2}$$
\bye

• Then the lower limit is centered incorrectly. – uli Dec 23 '11 at 11:55
• @uli: Oh, bummer. You could stuff a \enspace (or something along that size) at the end of the lower limit, but it's ugly. – morbusg Dec 23 '11 at 12:00
• or you could use \mathop{\phantom{s} \sum s} and then the limits will be centered because the new operator is "symmetrical." – Phineas Q. Butterfats Aug 8 '13 at 19:40