[I'm sorry if this is a duplicate. I searched and found related issues but haven't been able to solve my problem.]
I have a displayed equation and I want to replace it with another in an overlay without affecting the surrounding text. As shown below, I've tried six different ways, but none of them works. The surrounding text is fixed, which is what I want, in the "uncover", "uncover&overprint", and "overprint&onslide" solutions below but the equation shifts. In the other solutions, the surrounding text shifts.
I know absolute text positioning via the textpos package is a solution but it's tedious. I also think that giving a fake height to the less tall equation via phantom would work, too.
But, I thought that a simple solution would be already there, seeing that uncover and overprint are able to fix the position of the surrounding text.
\documentclass[14pt,aspectratio=1609]{beamer}
\begin{document}
%----
\begin{frame}{only}
Fixed text
\only<1>{\[\int f(x)\]}%
\only<2>{\[g(x)\]}%
fixed text.
\end{frame}
%---
\begin{frame}{uncover}
Fixed text
\uncover<1>{\[\int f(x)\]}%
\uncover<2>{\[g(x)\]}%
fixed text.
\end{frame}
%---
\begin{frame}{uncover \& overprint}
Fixed text
\begin{overprint}
\uncover<1>{\[\int f(x)\]}%
\uncover<2>{\[g(x)\]}%
fixed text.
\end{overprint}
\end{frame}
%----
\begin{frame}{Overprint \& onslide}
Fixed text
\begin{overprint}
\onslide<1>{\[\int f(x)\]}%
\onslide<2>{\[g(x)\]}%
\end{overprint}
fixed text.
\end{frame}
%----
\begin{frame}{Overprint, only, \& onslide}
Fixed text
\begin{overprint}
\only<1>{\[\int f(x)\]}%
\onslide<2>{\[g(x)\]}%
\end{overprint}
fixed text.
\end{frame}
%----
\begin{frame}{alt}
Fixed text
\alt<2->%
{\[g(x)\]}%
{\[\int f(x)\]}%
fixed text.
\end{frame}
\end{document}


\onslidecommands are used like\itemcommands (i.e. without argument)" There must be use cases where the item-like use is necessary. – Ryo May 15 '23 at 05:33