如何使用 align* 环境对齐总和?

如何使用 align* 环境对齐总和?
\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{align*}
\sum_{k=1}^\infty \frac{1}{k} &\rightarrow \infty
&\sum_{k=1}^\infty \frac{1}{k^2} &= \frac{\pi^2}{6}
&&\sum_{k=1}^\infty \frac{1}{k^3} = \zeta(3)
\\
\\
\sum_{k=1}^\infty \frac{(-1)^{k+1}}{k} &= \ln(2)
&\sum_{k=1}^\infty \frac{(-1)^{k+1}}{k^2} &= \frac{\pi^2}{12}
&&\sum_{k=1}^\infty \frac{(-1)^{k+1}}{k^3} = \frac{3}{4}\zeta(3)
\\
\\
\sum_{k=1}^\infty \frac{1}{2k} &\rightarrow \infty
&\sum_{k=1}^\infty \frac{1}{{(2k)}^2} &= \frac{\pi^2}{24}
&&\sum_{k=1}^\infty \frac{1}{{(2k)}^3} = \frac{1}{8}\zeta(3)
\\
\\
\sum_{k=1}^\infty \frac{(-1)^{k+1}}{2k} &= \frac{\ln(2)}{2}
&\sum_{k=1}^\infty \frac{(-1)^{k+1}}{{(2k)}^2} &= \frac{\pi^2}{48}
&&\sum_{k=1}^\infty \frac{(-1)^{k+1}}{{(2k)}^3} = \frac{3}{32}\zeta(3)
\\
\\
\sum_{k=0}^\infty \frac{1}{2k+1} &\rightarrow \infty
&\sum_{k=0}^\infty \frac{1}{{(2k+1)}^2} &= \frac{\pi^2}{8}
&&\sum_{k=0}^\infty \frac{1}{{(2k+1)}^3} = \frac{7}{8}\zeta(3)
\\
\\
\sum_{k=0}^\infty \frac{(-1)^{k}}{2k+1} &= \frac{\pi}{4}
&\sum_{k=0}^\infty \frac{(-1)^{k}}{{(2k+1)}^2} &\neq \frac{\pi^2}{16}
&&\sum_{k=0}^\infty \frac{(-1)^{k}}{{(2k+1)}^3} = \frac{\pi^3}{32} \neq \frac{21}{32}\zeta(3)
\end{align*}

\end{document}

抱歉,我不知道如何显示此代码的输出,所以我上传了 pdf 图像。我试图让总数像最后一列一样对齐。不过,我认为如果总数和等号都对齐,效果会更好。 总和

答案1

其中一个选项是:

\documentclass[12pt]{article}

\usepackage{amsmath}

\begin{document}

\begin{align*}
&\sum_{k=1}^\infty \frac{1}{k} \rightarrow \infty 
&& \sum_{k=1}^\infty \frac{1}{k^2} = \frac{\pi^2}{6} 
&& \sum_{k=1}^\infty \frac{1}{k^3} = \zeta(3)
\\
&\sum_{k=1}^\infty \frac{(-1)^{k+1}}{k} = \ln(2) 
&& \sum_{k=1}^\infty \frac{(-1)^{k+1}}{k^2} = \frac{\pi^2}{12}  
&& \sum_{k=1}^\infty \frac{(-1)^{k+1}}{k^3} = \frac{3}{4}\zeta(3)
\\
&\sum_{k=1}^\infty \frac{1}{2k} \rightarrow \infty 
&& \sum_{k=1}^\infty \frac{1}{{(2k)}^2} = \frac{\pi^2}{24} 
&& \sum_{k=1}^\infty \frac{1}{{(2k)}^3} = \frac{1}{8}\zeta(3)
\\
& \sum_{k=1}^\infty \frac{(-1)^{k+1}}{2k} = \frac{\ln(2)}{2}
&& \sum_{k=1}^\infty \frac{(-1)^{k+1}}{{(2k)}^2} = \frac{\pi^2}{48}
&& \sum_{k=1}^\infty \frac{(-1)^{k+1}}{{(2k)}^3} = \frac{3}{32}\zeta(3)
\\
& \sum_{k=0}^\infty \frac{1}{2k+1} \rightarrow \infty
&& \sum_{k=0}^\infty \frac{1}{{(2k+1)}^2} = \frac{\pi^2}{8}
&& \sum_{k=0}^\infty \frac{1}{{(2k+1)}^3} = \frac{7}{8}\zeta(3)
\\
& \sum_{k=0}^\infty \frac{(-1)^{k}}{2k+1} = \frac{\pi}{4}
&& \sum_{k=0}^\infty \frac{(-1)^{k}}{{(2k+1)}^2} \neq \frac{\pi^2}{16}
&& \sum_{k=0}^\infty \frac{(-1)^{k}}{{(2k+1)}^3} = \frac{\pi^3}{32} \neq \frac{21}{32}\zeta(3)
\end{align*}

\end{document}

生成结果:

在此处输入图片描述

\quad注意:在每行的第一个和第二个方程后使用 可以在列之间添加更多空间。在行之间使用 可以\\在两行上添加空间,如提议者的原始代码所示。

答案2

alignat最适合这种情况。请记住,alignat交替对齐,left然后right等等,因此您应该添加两个&&以获得左对齐。

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{alignat*}{3}
&\sum_{k=1}^\infty \frac{1}{k} \rightarrow \infty
&&\sum_{k=1}^\infty \frac{1}{k^2} = \frac{\pi^2}{6}
&&\sum_{k=1}^\infty \frac{1}{k^3} = \zeta(3)
\\
\\
&\sum_{k=1}^\infty \frac{(-1)^{k+1}}{k} = \ln(2)
&&\sum_{k=1}^\infty \frac{(-1)^{k+1}}{k^2} = \frac{\pi^2}{12}
&&\sum_{k=1}^\infty \frac{(-1)^{k+1}}{k^3} = \frac{3}{4}\zeta(3)
\\
\\
&\sum_{k=1}^\infty \frac{1}{2k} \rightarrow \infty
&&\sum_{k=1}^\infty \frac{1}{{(2k)}^2} = \frac{\pi^2}{24}
&&\sum_{k=1}^\infty \frac{1}{{(2k)}^3} = \frac{1}{8}\zeta(3)
\\
\\
&\sum_{k=1}^\infty \frac{(-1)^{k+1}}{2k} = \frac{\ln(2)}{2}
&&\sum_{k=1}^\infty \frac{(-1)^{k+1}}{{(2k)}^2} = \frac{\pi^2}{48}
&&\sum_{k=1}^\infty \frac{(-1)^{k+1}}{{(2k)}^3} = \frac{3}{32}\zeta(3)
\\
\\
&\sum_{k=0}^\infty \frac{1}{2k+1} \rightarrow \infty
&&\sum_{k=0}^\infty \frac{1}{{(2k+1)}^2} = \frac{\pi^2}{8}
&&\sum_{k=0}^\infty \frac{1}{{(2k+1)}^3} = \frac{7}{8}\zeta(3)
\\
\\
&\sum_{k=0}^\infty \frac{(-1)^{k}}{2k+1} = \frac{\pi}{4}
&&\sum_{k=0}^\infty \frac{(-1)^{k}}{{(2k+1)}^2} \neq \frac{\pi^2}{16}
&&\sum_{k=0}^\infty \frac{(-1)^{k}}{{(2k+1)}^3} = \frac{\pi^3}{32} \neq \frac{21}{32}\zeta(3)
\end{alignat*}

\end{document}

在此处输入图片描述

答案3

我建议使用一种经典的对齐方式(使用align*),另一种(使用alignat*),也许读起来更愉快,它包括在每一行上不重复求和运算符,最后对整个对齐方式使用一个大的求和运算符:

\documentclass{article}

\usepackage{amsmath}
\usepackage{graphics} 
\usepackage{relsize}
\newcommand\Sum{\mathlarger{\sum}}
\usepackage{lettrine} 
\usepackage{showframe} 
\begin{document}

\begin{align*}
    & \sum_{k=1}^\infty \frac{1}{k}\rightarrow \infty &
  &\sum_{k=1}^\infty \frac{1}{k^2}= \frac{\pi^2}{6}
    & & \sum_{k=1}^\infty \frac{1}{k^3} = \zeta(3)
  \\[1ex]
  & \sum_{k=1}^\infty \frac{(-1)^{k+1}}{k}= \ln(2)
    & & \sum_{k=1}^\infty \frac{(-1)^{k+1}}{k^2}= \frac{\pi^2}{12}
    & & \sum_{k=1}^\infty \frac{(-1)^{k+1}}{k^3} = \frac{3}{4}\zeta(3)
  \\[1ex]
  & \sum_{k=1}^\infty \frac{1}{2k} \rightarrow \infty
    & & \sum_{k=1}^\infty \frac{1}{{(2k)}^2} = \frac{\pi^2}{24}
    & & \sum_{k=1}^\infty \frac{1}{{(2k)}^3} = \frac{1}{8}\zeta(3)
  \\[1ex]
  & \sum_{k=1}^\infty \frac{(-1)^{k+1}}{2k}= \frac{\ln(2)}{2}
    & & \sum_{k=1}^\infty \frac{(-1)^{k+1}}{{(2k)}^2} = \frac{\pi^2}{48}
    & & \sum_{k=1}^\infty \frac{(-1)^{k+1}}{{(2k)}^3} = \frac{3}{32}\zeta(3)
  \\[1ex]
  & \sum_{k=0}^\infty \frac{1}{2k+1}\rightarrow \infty
    & & \sum_{k=0}^\infty \frac{1}{{(2k+1)}^2}= \frac{\pi^2}{8}
    & & \sum_{k=0}^\infty \frac{1}{{(2k+1)}^3} = \frac{7}{8}\zeta(3)
  \\[1ex]
  &\sum_{k=0}^\infty \frac{(-1)^{k}}{2k+1}= \frac{\pi}{4}
    & & \sum_{k=0}^\infty \frac{(-1)^{k}}{{(2k+1)}^2}\neq \frac{\pi^2}{16}
    & & \sum_{k=0}^\infty \frac{(-1)^{k}}{{(2k+1)}^3} = \frac{\pi^3}{32} \neq \frac{21}{32}\zeta(3)
\end{align*}

\begin{alignat*}{3}
  \mathlarger{\sum}_{k=1}^\infty \enspace & \frac{1}{k}\rightarrow \infty
    & \quad \Sum_{k=1}^\infty\enspace &
  \frac{1}{k^2}= \frac{\pi^2}{6}
    & \quad \Sum_{k=1}^\infty\enspace & \frac{1}{k^3} = \zeta(3)
  \\[1ex]
  &\frac{(-1)^{k+1}}{k}= \ln(2)
    & & \frac{(-1)^{k+1}}{k^2}= \frac{\pi^2}{12}
    & & \frac{(-1)^{k+1}}{k^3} = \frac{3}{4}\zeta(3)
  \\[1ex]
  & \frac{1}{2k} \rightarrow \infty
    & & \frac{1}{{(2k)}^2} = \frac{\pi^2}{24}
    & & \frac{1}{{(2k)}^3} = \frac{1}{8}\zeta(3)
  \\[1ex]
  & \frac{(-1)^{k+1}}{2k}= \frac{\ln(2)}{2}
    & & \frac{(-1)^{k+1}}{{(2k)}^2} = \frac{\pi^2}{48}
    & & \frac{(-1)^{k+1}}{{(2k)}^3} = \frac{3}{32}\zeta(3)
  \\[1ex]
  & \frac{1}{2k+1}\rightarrow \infty
    & & \frac{1}{{(2k+1)}^2}= \frac{\pi^2}{8}
    & & \frac{1}{{(2k+1)}^3} = \frac{7}{8}\zeta(3)
  \\[1ex]
  & \frac{(-1)^{k}}{2k+1}= \frac{\pi}{4}
    & & \frac{(-1)^{k}}{{(2k+1)}^2}\neq \frac{\pi^2}{16}
    & & \frac{(-1)^{k}}{{(2k+1)}^3} = \frac{\pi^3}{32} \neq \frac{21}{32}\zeta(3)
\end{alignat*}


\begin{alignat*}{4}
\smash{\mathop{\raisebox{-0.7\height}{\scalebox{2.8}[4]{$ \sum $}}}_{\boldsymbol{k=}1}^{\boldsymbol\infty}}\! \enspace
 & \frac{1}{k}\rightarrow \infty
    & \hspace{2.5em} &
  \frac{1}{k^2}= \frac{\pi^2}{6}
    & \hspace{2.5em} & \frac{1}{k^3} = \zeta(3)
  \\
  &\frac{(-1)^{k+1}}{k}= \ln(2)
    & & \frac{(-1)^{k+1}}{k^2}= \frac{\pi^2}{12}
    & & \frac{(-1)^{k+1}}{k^3} = \frac{3}{4}\zeta(3)
  \\[1ex]
  & \frac{1}{2k} \rightarrow \infty
    & & \frac{1}{{(2k)}^2} = \frac{\pi^2}{24}
    & & \frac{1}{{(2k)}^3} = \frac{1}{8}\zeta(3)
  \\[1ex]
  & \frac{(-1)^{k+1}}{2k}= \frac{\ln(2)}{2}
    & & \frac{(-1)^{k+1}}{{(2k)}^2} = \frac{\pi^2}{48}
    & & \frac{(-1)^{k+1}}{{(2k)}^3} = \frac{3}{32}\zeta(3)
  \\[1ex]
  & \frac{1}{2k+1}\rightarrow \infty
    & & \frac{1}{{(2k+1)}^2}= \frac{\pi^2}{8}
    & & \frac{1}{{(2k+1)}^3} = \frac{7}{8}\zeta(3)
  \\[1ex]
  & \frac{(-1)^{k}}{2k+1}= \frac{\pi}{4}
    & & \frac{(-1)^{k}}{{(2k+1)}^2}\neq \frac{\pi^2}{16}
    & & \frac{(-1)^{k}}{{(2k+1)}^3} = \frac{\pi^3}{32} \neq \frac{21}{32}\zeta(3)
\end{alignat*}

\end{document} 

在此处输入图片描述

在此处输入图片描述

答案4

您也可以将整个构造设置在array

在此处输入图片描述

\documentclass{article}
\usepackage{amsmath,array}

\begin{document}

\[
  \renewcommand{\arraystretch}{3}% http://tex.stackexchange.com/a/31704/5764
  \begin{array}{ >{\displaystyle}l @{\quad} >{\displaystyle}l @{\quad} >{\displaystyle}l }
    \sum_{k=1}^\infty \frac{1}{k} \rightarrow \infty
    & \sum_{k=1}^\infty \frac{1}{k^2} = \frac{\pi^2}{6}
    & \sum_{k=1}^\infty \frac{1}{k^3} = \zeta(3)
    \\
    \sum_{k=1}^\infty \frac{(-1)^{k+1}}{k} = \ln(2)
    & \sum_{k=1}^\infty \frac{(-1)^{k+1}}{k^2} = \frac{\pi^2}{12}
    & \sum_{k=1}^\infty \frac{(-1)^{k+1}}{k^3} = \frac{3}{4}\zeta(3)
    \\
    \sum_{k=1}^\infty \frac{1}{2k} \rightarrow \infty
    & \sum_{k=1}^\infty \frac{1}{{(2k)}^2} = \frac{\pi^2}{24}
    & \sum_{k=1}^\infty \frac{1}{{(2k)}^3} = \frac{1}{8}\zeta(3)
    \\
    \sum_{k=1}^\infty \frac{(-1)^{k+1}}{2k} = \frac{\ln(2)}{2}
    & \sum_{k=1}^\infty \frac{(-1)^{k+1}}{{(2k)}^2} = \frac{\pi^2}{48}
    & \sum_{k=1}^\infty \frac{(-1)^{k+1}}{{(2k)}^3} = \frac{3}{32}\zeta(3)
    \\
    \sum_{k=0}^\infty \frac{1}{2k+1} \rightarrow \infty
    & \sum_{k=0}^\infty \frac{1}{{(2k+1)}^2} = \frac{\pi^2}{8}
    & \sum_{k=0}^\infty \frac{1}{{(2k+1)}^3} = \frac{7}{8}\zeta(3)
    \\
    \sum_{k=0}^\infty \frac{(-1)^{k}}{2k+1} = \frac{\pi}{4}
    & \sum_{k=0}^\infty \frac{(-1)^{k}}{{(2k+1)}^2} \neq \frac{\pi^2}{16}
    & \sum_{k=0}^\infty \frac{(-1)^{k}}{{(2k+1)}^3} = \frac{\pi^3}{32} \neq \frac{21}{32}\zeta(3)
  \end{array}
\]

\end{document}

列之间的填充设置为\quad

相关内容