LaTeX对齐堆叠求和

发布于 2024-09-24 13:11:01 字数 275 浏览 1 评论 0原文

我正在写一个基本的求和证明,并想写这个

  1 + 2 + 3 + ... + n-2 + n-1 + n
+ n + n-1 + n-2 + ... + 3 + 2 + 1
= n+1 + n+1 + n+1 + ...

等等。我希望符号对齐,以便很容易看到垂直相加。我如何在 LaTeX 中做到这一点? align 环境不能很好地处理多个要对齐的内容,并且创建 tabular 环境很烦人,因为它不处于数学模式。

I am writing an elementary summation proof and would like to write that

  1 + 2 + 3 + ... + n-2 + n-1 + n
+ n + n-1 + n-2 + ... + 3 + 2 + 1
= n+1 + n+1 + n+1 + ...

and so on. I want the symbols to line up so that it's easy to see the vertical addition. How do I do this in LaTeX? The align environment doesn't do so well with multiple things to align on, and creating a tabular environment is annoying because it's not in math mode.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

天赋异禀 2024-10-01 13:11:01

array 环境是这里的最佳选择。这个解决方案在某些方面比 Jack Kelly 的更好,但在其他方面更差:

\begin{array}{c *{6}{c@{\hspace{6pt} + \hspace{6pt}}} c}
    & 1   & 2   & 3   & \ldots & n-2 & n-1 & n   \\
  + & n   & n-1 & n-2 & \ldots & 3   & 2   & 1   \\
  = & n+1 & n+1 & n+1 & \ldots & n+1 & n+1 & n+1
\end{array}

在列规范中需要注意的两件事:我们使用 *{6}{spec} 来获取列的六个副本规范规范。我们还使用 @ 指定每个列分隔符应该看起来像一个六点间隙、一个加号和另一个间隙。

有关 @ 技巧的更多信息此处

The array environment is the way to go here. This solution is better in some ways than Jack Kelly's, and worse in other ways:

\begin{array}{c *{6}{c@{\hspace{6pt} + \hspace{6pt}}} c}
    & 1   & 2   & 3   & \ldots & n-2 & n-1 & n   \\
  + & n   & n-1 & n-2 & \ldots & 3   & 2   & 1   \\
  = & n+1 & n+1 & n+1 & \ldots & n+1 & n+1 & n+1
\end{array}

Two things to notice in the column specification: we use *{6}{spec} to get six copies of a column with specification spec. We also use @ to specify that each column separator should look like a six-point gap, a plus sign, and another gap.

More on the @ trick here.

欲拥i 2024-10-01 13:11:01

我的 LaTeX 有点生锈了,但这里是这样的:

\[
\begin{array}{l r c r c r c c c r c r c r}
    & 1 & + & 2 & + & 3 & + & \ldots & + & n-2 & + & n-1 & + & n \\
  + & n & + & n-1 & + & n-2 & + & \ldots & + & 3 & + & 2 & + & 1 \\
  = & n+1 & + & n+1 & + & n+1 & + & \ldots & + & n+1 & + & n+1 & + & n+1\\
\end{array}
\]

My LaTeX is a little rusty, but here goes:

\[
\begin{array}{l r c r c r c c c r c r c r}
    & 1 & + & 2 & + & 3 & + & \ldots & + & n-2 & + & n-1 & + & n \\
  + & n & + & n-1 & + & n-2 & + & \ldots & + & 3 & + & 2 & + & 1 \\
  = & n+1 & + & n+1 & + & n+1 & + & \ldots & + & n+1 & + & n+1 & + & n+1\\
\end{array}
\]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文