和中大下标的对齐问题

和中大下标的对齐问题

这个 MWE 展示了我遇到的问题:

\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}

在此处输入图片描述

问题:

我如何才能实现将字母总和向左移动(总和下标的顶部)直到它们与右边距右对齐的等效效果?总和及其下标不应从其当前左对齐位置移动。

答案1

如果我理解正确的话,那么 alphas ( 1 + \alpha + ...) 的总和应该向左移动以避免出现过多的\hbox警告:

\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}

结果

避免使用魔法数字

\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}

结果

把事情简单化

\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}

结果

答案2

+1,Heiko 的回答,特别是他关于保持简单

我实际上会重写你的表达以使用本地定义

截屏

\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}

答案3

您可以将 smashoperator 与 \include{mathtools} 一起使用

\smashoperator[r]{\sum\limits_{parangaricutirimicuaro}} f(x)。

我最近在一篇文章中使用了它,效果非常好。希望它能有所帮助。

相关内容