1

This seems like it would be easy, but I don't see an environment that accounts for this. I'd like to horizontally align corresponding elements in a multi-line equation.

Σk^2 = 1 + 2 + 3 + ... + n
         + 2 + 3 + ... + n
             + 3 + ... + n
                   ... 
                       + n
  • 2
    Welcome to TeX SX! What should be aligned, exactly? – Bernard Mar 22 '18 at 0:27
  • Hi, I'd like it to result graphically like the code snippet above. I've used the align* environment frequently, but that would only allow the first alignment point. I want all of the 2's, 3's, ...'s, n's aligned correspondingly. – Alexander Vornsand Mar 22 '18 at 0:29
1

Your typesetting objective is much easier to achieve with an array environment than it is with an align* environment.

enter image description here

\documentclass{article}
\usepackage{array} % for "\newcolumtype" macro
\newcolumntype{C}{>{{}}c<{{}}} % for binary and relational operators
\newcolumntype{R}{>{\displaystyle}r} & automatic display-style math mode

\begin{document}
\[
\setlength\arraycolsep{0pt}
\renewcommand\arraystretch{1.33}
\begin{array}{R*{5}{CR}}
\sum k^2 & = & 1 & + & 2 & + & 3 & + & \cdots & + & n \\
         &   &   & + & 2 & + & 3 & + & \cdots & + & n \\
         &   &   &   &   & + & 3 & + & \cdots & + & n \\
         &   &   &   &   &   &   & + & \cdots & + & n \\
         &   &   &   &   &   &   &   & \cdots &   &   \\
         &   &   &   &   &   &   &   &        & + & n 
\end{array}
\]
\end{document}
2

A solution with alignat. I replaced the last \cdots with a vdots aligned with the last + signs:

\documentclass{article}
\usepackage{mathtools} %

\begin{document}
\begin{alignat*}{5}
\sum k^2 = 1 +{} & 2 &{}+{}& 3 & + & \cdots & + & n \\
       {}+{}& 2 &{}+{} & 3 &{}+{}& \cdots &{}+{} & n \\
          & & {}+{}& 3 & {}+{} & \cdots & {}+{} & n \\
            & & & & {}+{}& \cdots & {}+{} & n \\[-1.5ex]
        & & & & & & \vdotswithin{ + }& \\[-1ex]
         & & & & & & {}+{}& n
\end{alignat*}

\end{document} 

enter image description here

  • This is also an easy, and elegant solution. Thanks! – Alexander Vornsand Mar 23 '18 at 1:34
2

We can exploit the symmetry and the fact that the first column in aligned is right aligned.

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

\begin{document}
\[
\begin{aligned}
\sum k^2 = 1 + 2 + 3 + \cdots + n \\
          {} + 2 + 3 + \cdots + n \\
              {} + 3 + \cdots + n \\
                  {} + \cdots + n \\
\vdotswithin{+}\hphantom{n} \\
                           {} + n
\end{aligned}
\]
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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