# Switch to \displaystyle in superscripts (automatic \limits)

I have to use a lot of sums in exponential functions like

I would like to have the summation indices of sums to be displayed below the sums for increased readability. I know that I can achieve this for a single sum by placing \limits. Is there also a global solution for all math environments (of course beside inline math)?

Examples why I prefer to use an exponent instead the exponential function.
This: uses less horizontal space than this: But is in my opinion just as readable. The second case however will force me to put additional line-breaks or define further abbreviations.

• For decreased readability, you mean… Jan 27 '18 at 15:51
• And we remember e^{...}  us mathematically the same as \exp(...), so use the other form. Jan 27 '18 at 15:58
• You could define \newcommand{\suml}{\sum\limits}, but the result is not at all pretty. It is not already without \limits. Jan 27 '18 at 16:13
• There are no conventions on math typography other than trying to mimic old books in the name of math snobbery which I was also guilty of for some time. Only readability matters. Some old books are just horrible how rigorous they are. Jan 28 '18 at 17:46
• +1 for that the question is well-stated. However, the idea is insane as the ligibility will be very low.
– yo'
Jan 28 '18 at 19:27

## Only changing the limits for \sum:

You could use the internal conditional \if@display from amsmath to test whether or not \limits should be inserted. Below, I'm redefining \sum by adding \if@display\limits\fi to its definition.

\documentclass{article}

\usepackage{amsmath}

\makeatletter %% <- make @ usable in command names
\renewcommand*\sum{\DOTSB\sum@\if@display\limits\fi}
\makeatother  %% <- revert @

\begin{document}

Lorem $e^{\sum_{n=1}^\infty \frac1n}$ ipsum

$e^{\sum_{n=1}^\infty \frac1n}$

\begin{align}
e^{\sum_{n=1}^\infty \frac1n}&
\\
&e^{\sum_{n=1}^\infty \frac1n}
\end{align}

Lorem $e^{\sum_{n=1}^\infty \frac1n}$ ipsum

\end{document}


This can be adapted to work for other operators like \prod, \coprod, \bigcup, \bigotimes, etc. by changing \sum@ in the obvious way. If you have an operator, say \myoperator, for which \myoperator@ does not exist, you can create it with

\makeatletter %% <- remove if you paste the next line between \makeatletter/-other
\let\myoperator@\myoperator
\makeatother  %% <- remove this one too, then


and proceed as above.

### Alternative:

I originally had another solution that I was quite happy with that uses \everydisplay. The contents of this register is inserted at the start of every display math environment and I used it to redefine \sum by including \limits. It works without amsmath (which everyone should use), but apart from that I think it's superceded by the solution above.

Anyway, here it is. The following would replace the \makeatletter-\makeatother block above.

\makeatletter %% <- make @ usable in command names
\let\sum@beforelimitmodification\sum
\everydisplay\expandafter{\the\everydisplay                %% <- old \everydisplay
}
\makeatother  %% <- revert @


## Changing the limits for all operators:

I just thought of another completely different method that affects all big operators (compatible with \amsmath) at once.

With amsmath loaded, all big operators (apart from integrals) include \slimits@ in their definition, which simply expands to \displaylimits (which acts as \limits in \displaystyle and does nothing in other math styles). By redefining it, you can give all operators used in display environments limits.

\documentclass{article}

\usepackage{amsmath}

\makeatletter %% <- make @ usable in command names
\renewcommand*\slimits@{\if@display\limits\else\displaylimits\fi}
\makeatother  %% <- revert @

\begin{document}

Lorem $e^{\sum_{n=1}^\infty \frac1n}$ ipsum

$e^{\sum_{n=1}^\infty \frac1n}$

\begin{align}
e^{\sum_{n=1}^\infty \frac1n}&
\\
&e^{\sum_{n=1}^\infty \frac1n}
\end{align}

Lorem $e^{\sum_{n=1}^\infty \frac1n}$ ipsum

\end{document}


↑↑ Output looks identical, so see the image above ↑↑

If this doesn't work for some custom defined operator, say \myoperator, you should add \slimits@ to its definition, like this:

\makeatletter %% <- make @ usable in command names
\let\myoperator@beforelimitchange
\renewcommand*\myoperator{\DOTSB\myoperator@beforelimitchange\slimits@}
\makeatother  %% <- revert @

• I think you could use (with amsmath) \def\sum{\DOTSB\sum@\limits} sparing you definition of \sum@beforelimitmodification (untested, just looking at amsmath.dtx) (now tested, seems ok)
– user4686
Dec 31 '18 at 15:07
• another +1 for correct handling of \everydisplay many answers simply overwrite it...
– user4686
Dec 31 '18 at 15:09
• @jfbu: I actually used \edef\sum{\sum\limits} before (also works with amsmath, not without), but decided to post a solution that can easily be adapted to work for other symbols. Dec 31 '18 at 15:10
• ok, the amsmath has not only \sum@ but \coprod@, ..., \prod@,....\bigsqcup@
– user4686
Dec 31 '18 at 15:11
• @jfbu: I actually decided to overhaul the answer somewhat. I think the solution that uses \if@display is superior to the one with \everydisplay (even though \if@display is also defined through \everydisplay). I am now using \sum@ and I also added another solution that affects all operators, and which I only thought of some moments ago. Dec 31 '18 at 16:42

I'm still pretty new to latex so forgive me then correct me if I'm wrong.

When the \sum_{min}^{max} command is used in \displaystyle the produced text shows the symbols as you want it with the indices above and below the large, capital Greek sigma. https://www.sharelatex.com/learn/Integrals,_sums_and_limits

However even when your entire equation is in \displaystyle some parts might still render in \textstyle. When \texstyle\sum_{min}^{max} is called the result is the sigma symbol with adjacent indices. To force the summation symbol to always have the indices above and below the sigma you'll have to force the \sum command to be \displaystyle\sum. If you only have one or two summations the easiest way to achieve this is simply to add the \displaystyle command. However when you have a large scientific document this becomes tedious.

In cases where you want all your summations to have the indices above and below (as you have it in your crazy equation examples) the simplest way is to instruct latex to always render \sum as \dispaystyle\sum. this can be done by redefining \sum to be \displaystyle\sum by adding this to your preamble:

\let\oldsum\sum
\renewcommand{\sum}{\displaystyle\oldsum}


(credit to this guy https://latex.org/forum/viewtopic.php?t=14345).

Take note that this solution will force the \sum to always be in \display even when you are adding inline math so this solution is not perfect. You can however still call the old version of \sum (i.e. \oldsum) for inline cases.

The same thing happens to integrals and products and the same solution should work (although I did not test it on anything other that the \sum command)

\let\oldsum\sum
\renewcommand{\sum}{\displaystyle\oldsum}
$$y = \frac{\sum{x}}{\sum_{i}^{\infty}{x_i}} \cdot \frac{\oldsum{x}}{\oldsum_{i}^{\infty}{x_i}}$$


shows up as

For completeness I should mention that the same can be achieved by using the \limits command as mentioned in the sharelatex article referenced above.

• This old question just got bumped to the home page. And this answer has so many things wrong with it, I hardly know where to begin. First, \displaystyle and \textstyle are declarations. Their effect lasts until the end of the current group, end of formula, or next explicit style change. So redefining \sum in the way of this answer is quite counterproductive. Look to this answer for a much better explanation. And read the comments on the question above for the typographical issues and why this is generally a bad idea. Jul 29 '18 at 19:45