# How can I align symbol plus by using \shortintertext?

I am trying to align the symbol plus with \shortintertext I tried

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{align*}
\shortintertext{We have}
1 + 2 + 3 + \cdots + n &= \dfrac{n(n+1)}{2} \\
\shortintertext{and}
1^2 + 2^2 + 3^2 + \cdots + n^2 &= \dfrac{n (n+1) (2 n+1)}{6}
\end{align*}
\end{document}


How can I got the result like this picture (still contain "we have", "and")

You have to insert multiple alignment points. You can do it with alignat:

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{alignat*}{5}
\shortintertext{We have}
&1   && + 2   &&+ 3   &&+ \cdots + n   &&= \dfrac{n(n+1)}{2} \\
\shortintertext{and}
&1^2 && + 2^2 &&+ 3^2 &&+ \cdots + n^2 &&= \dfrac{n (n+1) (2 n+1)}{6}
\end{alignat*}
\end{document}


Another approach, with a little extra work maybe, would be to add ^\phantom{2} in the first equations wherever there is a ^2 in the second equation. To make things easier I defined a macro \ph to do this:

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\def\ph{^{\phantom{2}}}%
\begin{align*}
\shortintertext{We have}
1\ph + 2\ph + 3\ph + \cdots + n\ph &= \dfrac{n(n+1)}{2} \\
\shortintertext{and}
1^2  + 2^2  + 3^2  + \cdots + n^2  &= \dfrac{n (n+1) (2 n+1)}{6}
\end{align*}
\end{document}


The result is the same. Note that we need an extra pair of braces around the \phantom.