# Alignment problem with large subscript in sum

This MWE exhibits the problem I have:

\documentclass{article}
\usepackage{amsmath}
\usepackage{mathtools}

\begin{document}
This is a really long line of text to show where the margins of the page are.
This is a really long line of text to show where the margins of the page are.
This is a really long line of text to show where the margins of the page are.
$\sum_{\alpha \in \{a,b,c,d,e,f,g,h,i,j,k,\ell,m,n,o,p,q,r,s,t,u,v,w,x,y,z\}} 1 + \alpha + \alpha^2 + \alpha^3 + \alpha^4 + \alpha^5 + \alpha^6 + \alpha^7 + \alpha^8 + \alpha^9$
This is a really long line of text to show where the margins of the page are.
This is a really long line of text to show where the margins of the page are.
This is a really long line of text to show where the margins of the page are.

Using mathclap'':
$\sum_{\mathclap{\alpha \in \{a,b,c,d,e,f,g,h,i,j,k,\ell,m,n,o,p,q,r,s,t,u,v,w,x,y,z\}}} 1 + \alpha + \alpha^2 + \alpha^3 + \alpha^4 + \alpha^5 + \alpha^6 + \alpha^7 + \alpha^8 + \alpha^9$
\end{document}


## Question:

How can I implement the equivalent of moving the sum of alphas left (over top of the subscript of the sum) until they are right aligned to the right margin? The sum and its subscript should not move from its currently left aligned position.

-
"We denote by $\mathit{Alph}$ the set consisting of the letters in the Latin alphabet. We can write $\sum_{\alpha\in\mathit{Alph}} 1+\alpha+\dots+\alpha^{9}$ avoiding all issues with the excessive width." –  egreg Nov 2 '12 at 13:48
@egreg This is a Minimum Working Example (MWE), not my actual text. –  Tyson Williams Nov 2 '12 at 15:20

If I have understood you correctly, then the sum of alphas (1 + \alpha + ...) should be moved to the left to avoid the overful \hbox warning:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
This is a really long line of text to show where the margins of the page are.
This is a really long line of text to show where the margins of the page are.
This is a really long line of text to show where the margins of the page are.
$\sum_{\alpha \in \{a,b,c,d,e,f,g,h,i,j,k,\ell,m,n,o,p,q,r,s,t,u,v,w,x,y,z\}} \hspace{0pt minus 12.2pt}% value taken from the overful \hbox message 1 + \alpha + \alpha^2 + \alpha^3 + \alpha^4 + \alpha^5 + \alpha^6 + \alpha^7 + \alpha^8 + \alpha^9$
This is a really long line of text to show where the margins of the page are.
This is a really long line of text to show where the margins of the page are.
This is a really long line of text to show where the margins of the page are.
$\sum_{\alpha \in \{a,b,c,d,e,f,g,h,i,j,k,\ell,m,n,o,p,q,r,s,t,u,v,w,x,y,z\}} \hspace{0pt minus 1fil}% allows natural width for the spacing around plus operators 1 + \alpha + \alpha^2 + \alpha^3 + \alpha^4 + \alpha^5 + \alpha^6 + \alpha^7 + \alpha^8 + \alpha^9$
\end{document}


## With avoiding the magic number

\documentclass{article}
\usepackage{amsmath}

\newsavebox\testbox

\begin{document}
This is a really long line of text to show where the margins of the page are.
This is a really long line of text to show where the margins of the page are.
This is a really long line of text to show where the margins of the page are.
\newcommand*{\alphasum}[1]{%
\sum_{\alpha \in \{a,b,c,d,e,f,g,h,i,j,k,\ell,m,n,o,p,q,r,s,t,u,v,w,x,y,z\}}
\hspace{0pt minus #1}
1 + \alpha + \alpha^2 + \alpha^3 + \alpha^4 + \alpha^5 + \alpha^6 + \alpha^7
}
\sbox\testbox{$\displaystyle\alphasum{0pt}$}%
$\ifdim\wd\testbox>\linewidth \alphasum{\dimexpr\wd\testbox-\linewidth}% \else \alphasum{0pt}% \fi$
This is a really long line of text to show where the margins of the page are.
This is a really long line of text to show where the margins of the page are.
This is a really long line of text to show where the margins of the page are.
$\sum_{\alpha \in \{a,b,c,d,e,f,g,h,i,j,k,\ell,m,n,o,p,q,r,s,t,u,v,w,x,y,z\}} \hspace{0pt minus 1fil} 1 + \alpha + \alpha^2 + \alpha^3 + \alpha^4 + \alpha^5 + \alpha^6 + \alpha^7$
\end{document}


## Keep it simple

\documentclass{article}
\usepackage{amsmath}

\begin{document}
$\sum_{\alpha \in \{a,b,c,\dots, z\}} \hspace{0pt minus 1fil} 1 + \alpha + \alpha^2 + \alpha^3 + \dots + \alpha^9$
\end{document}


-
Can you explain this 1fil? –  Tyson Williams Nov 2 '12 at 13:27
Also \hspace{0pt minus 12.2pt}% value taken from the overful \hbox message is not good enough. I don't want my code to have magic numbers that have to be changed if the sounding math changes. –  Tyson Williams Nov 2 '12 at 13:31
@TysonWilliams See TeX by Topic, 8.3.1 Stretch and shrink. –  Heiko Oberdiek Nov 2 '12 at 13:35
Heiko, I gave a Minimum Working Example (MEW). I don't really have a sum over the Latin alphabet a nice sum of powers of alphas that I could replace with "...". –  Tyson Williams Nov 2 '12 at 15:23
The first use of 1fil in your reference is on page 87, but it seems to be used as though the reader is already familiar with it. Do you have another reference or can you explain it yourself? –  Tyson Williams Nov 2 '12 at 15:43

I would actually re-write your expression to use a local definition

\documentclass{article}
\usepackage{amsmath}

\begin{document}
$\sum_{\alpha \in S} 1 + \alpha + \alpha^2 + \alpha^3 + \dots + \alpha^9$
where
$S=\{a,b,c,\dots, z\}$
\end{document}

-
For the third time, this is just a MINIMUM WORKING EXAMPLE. I can't implement this solution with my actual problem. –  Tyson Williams Nov 2 '12 at 17:39
@TysonWilliams check your tone, and use down votes sparingly. If your MWE isn't representative of the problem, then it is not actually a MWE –  cmhughes Nov 2 '12 at 17:43
How would you make the example more "minimal"? –  Tyson Williams Nov 2 '12 at 18:15