I'd like to make a node whose text content changes between overlays. Of course, the different contents have different sizes, so the node itself changes size between overlays. I'd like to avoid that by allocating the maximum needed size.
Here's some code to demonstrate what I'd like. Because the Bar text caption's size changes, the whole picture jumps around. First, I try using \only for the overlays, but that means only the current one takes up space. Then, I try using \visible, but then all of them always take up space.
\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}{Try 1}
\begin{center}
\begin{tikzpicture}
\draw (0,0) node[draw]{Foo};
\draw (1,0) node[right]{Bar{\only<2>{short}}{\only<3>{much much longer}}};
\end{tikzpicture}
\end{center}
\end{frame}
\begin{frame}{Try 2}
\begin{center}
\begin{tikzpicture}
\draw (0,0) node[draw]{Foo};
\draw (1,0) node[right]{Bar{\visible<2-3>{\visible<2>{short}}{\visible<3>{much much longer}}}};
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}







text width=width("<longest text>")to that node. (Or just use a length that's wide enough.) Similar things can be done withminimum width. Or Q107227. – Qrrbrbirlbel Oct 08 '22 at 09:56\draw (1,0) node[right,text width=width("Barmuch much longer")]{Bar{\only<2>{short}}{\only<3>{much much longer}}};but it still jumps around (although only very slightly) – Cactus Oct 08 '22 at 10:42\strutto the always-displayed portion (i.e.Bar\strut). – Cactus Oct 08 '22 at 10:43