Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}

enter image description here

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.

share|improve this question
3  
"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

2 Answers 2

up vote 8 down vote accepted

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}

Result

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}

Result

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}

Result

share|improve this answer
    
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

+1 for Heiko's answer, and in particular his advice about keeping it simple.

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

screenshot

\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}
share|improve this answer
    
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
1  
@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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.