Centering terms of equation with tag

alignmentarraysequationstag

This minimal example

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}

\begin{document}
\begin{frame}
    \begin{equation}
    \begin{array}{ccc}
        f(x) & =& \displaystyle\int_0^1 f'(x) d x\\[.2cm]
        e^{i\pi} +1 &=& 0\\
        g(x)&=& 2 f(x)\\
        2x+12&=&3
        \end{array}
    \end{equation}
\end{frame}
\end{document}

produces the following result

enter image description here

What if one wants to put the tag next to the second or the third equation, keeping the horizontal alignment at the centre for each column? Is there a way to do it automatically without specifying space for each cell? I need to have exactly this alignment, hence the align environment does not fit in this case.

EDIT: Since I only got comments on the fact I do not use align, I publish another example to explain the reason for the choice.

\begin{equation}
\begin{array}{cccc}
    (2x+1)^p & =&c(p)&(x+1)^{p+1}\\[.2cm]
    \downarrow&& \downarrow&\downarrow\\
   (2x+1)&=&2&(x+1)^2 \\[1ex]
    x^2-1&=&0&
    \end{array}
\end{equation}

enter image description here

Best Answer

You can, if you must, push everything into the array (or rather tabular* to force full width)

enter image description here

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{array}
\begin{document}
\begin{frame}
\[
    \begin{tabular*}{\textwidth}{
@{}
c
@{\extracolsep{\textwidth minus \textwidth}}
>{$\displaystyle}c<$
!{\extracolsep{0pt}}
>{$\displaystyle}c<$
>{$\displaystyle}c<$
@{\extracolsep{\textwidth minus \textwidth}}
r}
&        f(x) & =& \int_0^1 f'(x) d x\\[.2cm]
&        e^{i\pi} +1 &=& 0 &(\refstepcounter{equation}\theequation)\\
&        g(x)&=& 2 f(x)\\
&        2x+12&=&3
        \end{tabular*}
\]

zzz
\[
\begin{tabular*}{\textwidth}{
@{}
c
@{\extracolsep{\textwidth minus \textwidth}}
>{$\displaystyle}c<$
!{\extracolsep{0pt}}
>{$\displaystyle}c<$
>{$\displaystyle}c<$
>{$\displaystyle}c<$
@{\extracolsep{\textwidth minus \textwidth}}
r}
&    (2x+1)^p & =&c(p)&(x+1)^{p+1}&(\refstepcounter{equation}\theequation)\\[.2cm]
&    \downarrow&& \downarrow&\downarrow\\
&   (2x+1)&=&2&(x+1)^2 &(\refstepcounter{equation}\theequation)\\[1ex]
&    x^2-1&=&0&
    \end{tabular*}
\]
\end{frame}
\end{document}
Related Question