[Tex/LaTex] Using \gather and \align together

alignamsmathequations

I'm very picky regarding alignment inside my proofs. What's frustrating me right now is that I have some lines that I want to be center-aligned (using \begin{gather}) and others that I wish to align at the "=" sign (using \begin{align}). My idea for how to do this was to just switch between the two within one proof, but this creates extra spacing (because closing one and opening another comes with implicit spacing).

I've messed around with adding in \vspace[-20pt] or something to that effect, but it's a rather clumsy solution and I've had problems with it. Also, ideally I would be able to go from align to gather back to align and have the second align keep aligned with the first, and obviously closing and reopening everything doesn't allow this.

Can anybody think of a better way to switch between the two alignment structures? Perhaps using a box to nest my gathers within align or something. Essentially, I usually like most of my proof in align but then want a couple of tangential points in gather. I've spent a while pondering the amsmath readme (and this website), but I can't find an answer.

Many thanks in advance!

Here's a little example coding to demonstrate the issue with my current scheme:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\begin{document}
\begin{proof}
\begin{align*}
10 &= 2+2+2+2+2 \\
&= 3+3+3+1
\end{align*}\begin{gather*}
\intertext{But now it puts this annoying large space above this line...}
5=5
\end{gather*}
\end{proof}
\end{document}

Best Answer

[Note: the improvement below, actually does not work.]

[Note: there is an important improvement to this code below.]

The closest I can get to a solution is

\documentclass[10pt,a4paper]{article}

\usepackage{amsmath,amsthm,mathtools}

\begin{document}
\begin{proof}
  \begin{align*}
    15 &= 5+4+3+2+1 = \sum_{i=1}^5 i \\
    120&=5\cdot4\cdot3\cdot2\cdot1 = 5! \\
    \shortintertext{
      \[ e^{\pi i} + 1 = 0 \]
      \[ x^n + y^n = z^n \]
    } 
    27 &= 3^3 \qedhere
  \end{align*}
\end{proof}
\end{document}

which gives as result Centered equation in align

and actually the spacing is quite nice, I think.


Failing important edit

I think the below code is nicer, and even gives better results.

\documentclass[10pt,a4paper]{article}

\usepackage{amsmath,amsthm,mathtools}

\begin{document}
\begin{proof}
  \begin{align*}
    15 &= 5+4+3+2+1 = \sum_{i=1}^5 i \\
    120&=5\cdot4\cdot3\cdot2\cdot1 = 5! \\
    \begin{gathered}
      e^{\pi i} + 1 = 0 \\
      x^n + y^n = z^n
    \end{gathered} 
    27 &= 3^3 \qedhere
  \end{align*}
\end{proof}
\end{document}

Credits go to barbara beeton (please vote up her comment on her own answer).