# Stop equation with overlays from moving

I am very new to Beamer (and a latex novis) so I guess I am just missing some basics. I couldn't find an answer to my question, so I hope this isn't a repost.

I am trying to show my equation changing in the same frame and keep alignment of all things that do not change. As you can see I managed to set a new width of the 0 on slide 2-3 to take up as much space as the F that was there before but I can't figure out how to get it to stay still when i move the last term to the left side.

I have tried moving the & around and now I have sprinkled with some \phantom's but it still moves.

Sorry about all the packages. I have forgotten which does what so I included them all.

Is there an easy fix to get it to be still?

\documentclass[12pt]{beamer}
\usefonttheme[onlymath]{serif}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{parskip}
\usepackage{physics}
\usepackage{mathtools}
\usetheme{Frankfurt}
\usecolortheme{seagull}
\setbeamertemplate{footline}[frame number]
\DeclareFontShape{OT1}{cmss}{b}{n}{<->ssub * cmss/bx/n}{}
\newcommand{\inserteqstrut}[1]{%
\rlap{$\displaystyle#1$}%
\phantom{\biggesteq}}

\newcommand{\biggesteq}{\sum_{n=0}^{\infty}\dfrac{(-1)^{n}}{2n+1}x^{2n+1}}

\newlength{\slength}
\settowidth{\slength}{$\mathbf{F}$}
\newcommand*{\Sz}{\makebox[\slength][c]{0}}

\begin{document}

\begin{frame}
\frametitle{$\int \frac{dp}{\rho} + \frac{\partial \phi}{\partial t} + \frac{1}{2} \norm{\nabla \phi}^2 = constant$}

\begin{align*}
&\only<1-2>{\phantom{-\frac{1}{\rho }\nabla p +}\frac{\partial \mathbf{v}}{\partial t} + (\mathbf{v} \cdot \nabla)\mathbf{v}} \only<3->{\frac{1}{\rho }\nabla p + \frac{\partial \mathbf{v}}{\partial t} + (\mathbf{v} \cdot \nabla)\mathbf{v}} =
\only<1>{\mathbf{F}-\frac{1}{\rho }\nabla p}
\only<2>{\Sz-\frac{1}{\rho }\nabla p}
\only<3>{\Sz \phantom{-\frac{1}{\rho }\nabla p}}
\end{align*}
\end{frame}

\end{document}


I've simplified your implementation using \alt<os>{<default>}{<other>} which sets <default> on the given overlay specification and <other> otherwise.

\documentclass{beamer}

\usefonttheme[onlymath]{serif}

\usepackage{mathtools}

\begin{document}

\begin{frame}
\frametitle{An equation}

$\alt<3>{\frac{1}{\rho }\nabla p +}{\phantom{\frac{1}{\rho }\nabla p + {}}} \frac{\partial \mathbf{v}}{\partial t} + (\mathbf{v} \cdot \nabla)\mathbf{v} = \alt<1>{\mathbf{F}}{\mathrlap{0}\phantom{\mathbf{F}}} \alt<1-2>{-\frac{1}{\rho }\nabla p}{\phantom{{} -\frac{1}{\rho }\nabla p}}$
\end{frame}

\end{document}


The important thing to note here is additional {} within \phantom as it provides the appropriate spacing around binary operators.

• Wow, that was fast! And also a much simpler way of writing it =) I implemented your code, but I'll go over mine tomorrow with your tip regarding '\phantom' to see where I got it wrong. Thank you, sir! Feb 24 at 21:09