# Aligning equations across slides (/only)

Goodday, I am currently working on a presentation on the Calculus of Variations. In it I present a proof for the Euler equation. Currently I use the following Latex code:

\begin{frame}
\frametitle{Euler}
\framesubtitle{Bewijs}
\begin{align*}
0 = \frac{\partial \mathcal{F}}{\partial \alpha} &= \frac{\partial}{\partial \alpha} \int_{x_0}^{x_1}f\{y(\alpha,x),y'(\alpha,x);x\}dx\\
\only<4-8>{&=...\\}
\only<2-3>{&= \int_{x_0}^{x_1} \frac{\partial}{\partial \alpha} f\{y(\alpha,x),y'(\alpha,x);x\}dx\\}
\only<3-4>{&= \int_{x_0}^{x_1} \left(\frac{\partial f}{\partial y}\frac{\partial y}{\partial \alpha} + \frac{\partial f}{\partial y'}\frac{\partial y'}{\partial \alpha}\right)dx\\}
\only<4-5>{&= \int_{x_0}^{x_1} \frac{\partial f}{\partial y}\eta(x)dx + \int_{x_0}^{x_1}\frac{\partial f}{\partial y'}\eta'(x) dx\\}
\only<5-6>{&= \int_{x_0}^{x_1} \frac{\partial f}{\partial y}\eta(x)dx - \int_{x_0}^{x_1}\frac{d}{dx}\left(\frac{\partial f}{\partial y'}\right)\eta(x)dx\\}
\only<6-8>{&= \int_{x_0}^{x_1} \left( \frac{\partial f}{\partial y} - \frac{d}{dx}\frac{\partial f}{\partial y'} \right)\eta(x)dx\\}
\only<8>{\implies &\frac{\partial f}{\partial y} - \frac{d}{dx}\frac{\partial f}{\partial y'} =0}
\end{align*}
\end{frame}


But unfortunately, as expected, it gets jumpy and looks really messy. I want to be able to align it properly. How would I go about doing this?

-
Use \uncover instead of \only. –  Sigur Feb 16 '14 at 23:49

One option using overlayarea and a couple of \phantoms:

\documentclass{beamer}

\begin{document}

\begin{frame}
\frametitle{Euler}
\framesubtitle{Bewijs}
\begin{overlayarea}{\textwidth}{.8\textheight}
\begin{align*}
0 = \frac{\partial \mathcal{F}}{\partial \alpha} &= \frac{\partial}{\partial \alpha} \int_{x_0}^{x_1}f\{y(\alpha,x),y'(\alpha,x);x\}dx\phantom{mmmm}\\
\only<4-8>{&=\cdots\phantom{\int_{x_0}^{x_1}}\\}
\only<2-3>{&= \int_{x_0}^{x_1} \frac{\partial}{\partial \alpha} f\{y(\alpha,x),y'(\alpha,x);x\}dx\\}
\only<3-4>{&= \int_{x_0}^{x_1} \left(\frac{\partial f}{\partial y}\frac{\partial y}{\partial \alpha} + \frac{\partial f}{\partial y'}\frac{\partial y'}{\partial \alpha}\right)dx\\}
\only<4-5>{&= \int_{x_0}^{x_1} \frac{\partial f}{\partial y}\eta(x)dx + \int_{x_0}^{x_1}\frac{\partial f}{\partial y'}\eta'(x)dx\vphantom{\left(\frac{\partial f}{\partial y'}\right)}\\}
\only<5-6>{&= \int_{x_0}^{x_1} \frac{\partial f}{\partial y}\eta(x)dx - \int_{x_0}^{x_1}\frac{d}{dx}\left(\frac{\partial f}{\partial y'}\right)\eta(x)dx\\}
\only<6-8>{&= \int_{x_0}^{x_1} \left( \frac{\partial f}{\partial y} - \frac{d}{dx}\frac{\partial f}{\partial y'} \right)\eta(x)dx\\}
\only<8>{\implies &\frac{\partial f}{\partial y} - \frac{d}{dx}\frac{\partial f}{\partial y'} =0}
\end{align*}
\end{overlayarea}
\end{frame}

\end{document}


-
Beautifully done! Thanks a lot! :) –  Knaapje Feb 17 '14 at 0:23