2

I want to include a summation in the exponent. The following code I use now produce a somewhat uncanny-looking result:

\begin{align*}
    $x^{\displaystyle\sum_{i=0}^{k}}$ \\
    $x_{\displaystyle\sum_{i=0}^{k}}$ \\
\end{align*}

enter image description here

Even without the \displaystyle, the embedded contents still look a bit too large.

I have experimented this with several other "large" symbols such as integrals and products, and similarly tested them for both cases (with and without \displaystyle). The results all seem to have this problem.

Is there a way to make the result look more reasonable, for both with and without the \displaystyle? (I am currently thinking about the solution to make the "large" symbols only slightly larger than normal content inside the superscript or subscript, but there might be better ways.)

3
  • 4
    The best approach here "to make the result look more reasonable" is to define some symbol that denotes your sum, rather than placing the \displaystyle sum inside the super-/subscript.
    – Werner
    Dec 28, 2022 at 6:22
  • Welcome to TeX.SE.
    – Mico
    Dec 28, 2022 at 6:41
  • basically you just need to remove \displaystyle which is explicitly forcing the wrong layout Dec 28, 2022 at 7:08

3 Answers 3

5

First off: avoid complicated subscripts/superscripts as much as you can.

If you want to annoy your readers 😉, then you have some choices.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{gather}
x^{\sum_{i=0}^k a_i}_{\mathstrut} \\
x^{\sum\limits_{i=0}^k a_i}_{\mathstrut} \\
x^{\text{$\bigl(\,\sum_{i=0}^k a_i\bigr)$}}_{\mathstrut} \\
x^{\text{$\Bigl(\sum_{i=0}^k a_i\Bigr)$}}_{\mathstrut} \\
x^{\text{$\biggl(\,\sum\limits_{i=0}^k a_i\biggr)$}}_{\mathstrut} \\
x^{\scriptscriptstyle\text{$\Bigl(\sum_{i=0}^k a_i\Bigr)$}}_{\mathstrut} \\
x^{\scriptscriptstyle\text{$\biggl(\,\sum\limits_{i=0}^k a_i\biggr)$}}_{\mathstrut}
\end{gather}

\end{document}

In all of these I used a \mathstrut subscript that pushes the superscript a bit higher.

enter image description here

I'd exclude all that sport limits above and below the summation symbol (2, 5 and 7). I added 6 and 7 just for completeness, but the size of the characters is really too small.

Note the use of \text where parentheses are employed, in order to overcome the limitations of \big and friends that use fixed sizes everywhere.

If I had to choose among them, under physical threat, I'd go for 1 or 3. Maybe 4.

Caveat If you're using \usepackage{lmodern}, remember to also load \usepackage{fixcmex}. Try it and you'll see why.

2
  • Couldn’t agree more. Never put yourself in a position where you need to write something like this in a math equation. If no other options are available, you can always write $x^{s}$, where $s=\sum_{i=0}^{k} a_i$ or something like that. Alternatively, I think something like x^{\sum_i a_i} or x^{\sum a_i} could be acceptable if there is no alternative around.
    – Gaussler
    Dec 28, 2022 at 9:47
  • Or even just x^{a_{0} + \dotsb + a_{k}} ...
    – L. F.
    Dec 28, 2022 at 16:46
4

Some suggestions:

  • Don't use \displaystyle in the exponent term.

  • Use parentheses to denote the scope of the exponent. If you use both \big sizing directives, be sure to apply the correction suggested by David Carlisle (see below).

  • If x happens to be the base of the natural exponential, 2.71828...., consider writing \exp(...) rather than e^{...}. If this expression happens to occur in display-style math mode, be sure to enlarge the parentheses as needed.

enter image description here

\documentclass{article} % or some other suitable document class
\usepackage{amsmath} % for 'align*' env.
% 'DC' in '\DCbig' stands for "David Carlisle" 
% See https://chat.stackexchange.com/transcript/message/62653337
\def\DCbig#1{\left#1\vbox to7pt{}\right.\mkern-4mu} 

\begin{document}
\begin{align*}
& x^{\bigl(\sum_{i=0}^{k}2^i\bigr)} % parens and \sum not aligned correctly
  \quad
  x^{\DCbig(\sum_{i=0}^{k}2^i\DCbig)} \\ % <-- much better
&\displaystyle\exp\Bigl(\sum_{i=0}^{k}2^i \Bigr)
\end{align*}
\end{document}
4
  • 1
    In your first example, it looks like either the sum or your parentheses are not vertically aligned on the math axis. I have not seen that before.
    – mickep
    Dec 28, 2022 at 7:48
  • @mickep - I was puzzling over this issue -- the sum symbol and the parentheses not all being placed properly on the math axis -- as well. \smashing the term \sum_{i=0}^{k} doesn't make a difference. The issue goes away, though, if I omit the \bigl and \bigr sizing directives. Not sure what the reason for this oddity could be.
    – Mico
    Dec 28, 2022 at 8:02
  • David just explained in chat.
    – mickep
    Dec 28, 2022 at 8:14
  • 1
    @mickep - Many thanks for initiating this inquiry (and for David Carlisle's solution!). I've updated my answer accordingly.
    – Mico
    Dec 28, 2022 at 8:42
2

You could use \scriptscriptstyle to make superscripts/subscripts look smaller. Another approach is to rely on \scalebox.

\documentclass{article}

\usepackage{amsmath}
\usepackage{graphics}


\begin{document}

A first approach using \verb|\scriptscriptstyle|:
\begin{align*}
  x^{\scriptscriptstyle\sum_{i=0}^{k} 2^i} \\
  x_{\scriptscriptstyle\sum_{i=0}^{k} 2^i} \\
\end{align*}

You could also rely on \verb|\scalebox|.

\begin{align*}
  x^{\scalebox{.5}{$\sum_{i=0}^{k} 2^i$}} \\
  x_{\scalebox{.5}{$\sum_{i=0}^{k} 2^i$}} \\  
\end{align*}

\end{document}    

enter image description here

2
  • A drawback of using the \scriptscriptstyle approach is that while the size of the \sum symbol may be about right, the i=0 and k terms -- which are also rendered in \scriptscriptstyle as there is no \scriptscriptscriptstyle in TeX -- look a bit too large next to \sum.
    – Mico
    Dec 28, 2022 at 6:55
  • 1
    Added another approach
    – user94293
    Dec 28, 2022 at 7:03

You must log in to answer this question.

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