# Too many Sums: “TeX capacity exceeded ”

I am a lazy student who writes a lecture in LaTeX.

As I need many \sum\limits and \int\limits I tried to overwrite the command \sum\limits so I just have to write \sum. So I wrote

\renewcommand{\sum}{\sum\limits}


Now I get a lot of problems like

! TeX capacity exceeded, sorry [input stack size=5000].
\sum ->\sum
\limits
l.579 $$\sum _{i=1}^m K_i B(t,t_i) + N B(t,T)$$"


Is there a possibility to short the \sum\limits command and get no problems in a way I tried?

Or should I define a completely new command like

\newcommand{\summe}{\sum\limits}


Will this way work?

• See if \def{\sum}{\sum\limits} works. But a new command should certainly work. – Mike Renfro Nov 19 '14 at 14:55
• Circular definition. But please explain why you need \sum\limits all the time. There are good reasons not to use it. – daleif Nov 19 '14 at 15:00
• When you \def\sum{\sum\limits}, you tell TeX that \sum expands to the two tokens \sum and \limits. This \sum then expands to \sum\limits, expanding to \sum\sum\limits, expanding to \sum\sum\sum\limits, ad nauseam. – Sean Allred Nov 19 '14 at 15:06
• @MikeRenfro \def{ is a syntax error – David Carlisle Nov 19 '14 at 15:06
• @DavidCarlisle Would \edef work here? Not saying this general concept is good practice, but would it work? – Sean Allred Nov 19 '14 at 15:07

This is as easy as

\documentclass{article}

\usepackage{amsmath}
\makeatletter
\renewcommand{\slimits@}{\limits}
\renewcommand{\ilimits@}{\limits}
\makeatother

\begin{document}

A summation $\sum_{i=1}^{n} a_{n}$ and an integral
$\int_{0}^{1} x^2\,dx$
also inline: $\int_{0}^{1} x^2\,dx$

\end{document}


However the result is typographically terrible. There is a very good reason why limits in inline formulas are typeset on the side of the symbol and integrals have the limits beside them.

If all of your integrals need limits underneath (in display mode), then use

\usepackage[intlimits]{amsmath}


Here's a screenshot showing the horrible appearance.

Of course a definition such as

\renewcommand{\sum}{\sum\limits}


will horribly fail, as you discovered, because TeX will continue to substitute \sum with \sum\limits until exhausting its memory capacity.

You find a related trick in Is there any global settings to add \limits to evey \sum, \bigcup etc?

where an example of why using limits in inline formulas is bad, which I include here as well.

• \slimits@ -- neat, didn't know about this one :) Also, I wouldn't call the screenshot 'horrible' -- even I'm not attuned enough to math texts to find this so repugnant. There are good reasons, but your screenshot doesn't show them. Adding a lines above and below your sum will demonstrate this better :) – Sean Allred Nov 19 '14 at 15:10
• Would \newcounter\sumcounter\def\sum{\ifnum\sumcounter>0\sum\limits\stepcounter{\sumcounter}\else\relax\fi} or something work? – 1010011010 Nov 19 '14 at 15:14
• @1010011010 What should that be supposed to do? – egreg Nov 19 '14 at 15:16
• Is the question a dupe of the one you link to? – Joseph Wright Nov 19 '14 at 15:20
• @1010011010 Absurd. – egreg Nov 19 '14 at 15:23

You can use \edef\sum in this way:

\edef\sum{\mathchar\the\sum\limits}
...
A summation $\sum_{i=1}^{n} a_{n}$ ...

• Not at all recommended if amsmath is loaded. – egreg Nov 19 '14 at 18:13

When you \def\sum{\sum\limits}, you tell TeX that \sum expands to the two tokens \sum and \limits. This \sum then expands to \sum\limits, expanding to \sum\sum\limits, expanding to \sum\sum\sum\limits, ad nauseam.

Using the different name will resolve the issue, but I encourage you to not do this. There are many instances where such a shortcut will break in wholly unexpected ways (since you are using \limits without any real knowledge of what it does).

As \int is defined \intop\nolimits, you have at least two natural ways of obtaining limits placed where you want:

\documentclass{article}

\begin{document}

$\int_{0}^{1}1\,dx$

\def\Int{\int\limits}

$\Int_{0}^{1}1\,dx$

\let\uglyamericanint\int
\def\int{\intop\limits}

$\int_{0}^{1}1\,dx$

\end{document}


(I have no tools to crop the picture now).

• even if you do have tools to crop, it becomes easier if you have \thispagestyle{empty}. – barbara beeton Nov 19 '14 at 19:56