topnush
```
\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}[fragile]
\frametitle{Title}
\vspace{-0.1cm} % Reduce space after title
We are interested in how similar two sets are.
\vspace{0.4cm} % Increase space before tikzpicture
\centering
\begin{tikzpicture}
% Add a box around everything with some padding
\draw[black, thin] (-2.5,-2.5) rectangle (4.5,2.8);
\end{tikzpicture}
\only<4->{
The standard measure is the so-called Jaccard similarity.
}
\only<4>{\[
0 \leq \frac{A \cap B}{A \cup B} \leq 1
\]
}
\only<5>{\[
0 \leq \frac{8}{A \cup B} \leq 1
\]
}
\end{frame}
\end{document}
```
I tried using \visible instead of \only but this then doesn't show the transitions. I also tried \vphantom but I couldn't get it to work. How can I keep the box and the text above it steady?
Top Answer
samcarter
I'd use a top-aligned frame:
```
\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}[t,fragile]
\frametitle{Title}
We are interested in how similar two sets are.
\medskip
\centering
\begin{tikzpicture}
% Add a box around everything with some padding
\draw[black, thin] (-2.5,-2.5) rectangle (4.5,2.8);
\end{tikzpicture}
\only<4->{
The standard measure is the so-called Jaccard similarity.
\[
0 \leq \frac{\strut\alt<5>{8}{A \cap B}}{A \cup B} \leq 1
\]
}
\end{frame}
\end{document}
```
![document.gif](/image?hash=7e10fd575aaa2a91c58ad7beafdc3d68ee3f1ee3412097b3aedeafe1c4980d47)
Answer #2
Skillmon
Instead of `\only` the following uses `\visible` for your maths:
```
\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}[fragile]
\frametitle{Title}
\vspace{-0.1cm} % Reduce space after title
We are interested in how similar two sets are.
\vspace{0.4cm} % Increase space before tikzpicture
\centering
\begin{tikzpicture}
% Add a box around everything with some padding
\draw[black, thin] (-2.5,-2.5) rectangle (4.5,2.8);
\end{tikzpicture}
\visible<4->{%
The standard measure is the so-called Jaccard similarity.
\[
0 \leq \frac{\vphantom{A \cap B}\only<4>{A \cap B}\only<5>{8}}{A \cup B} \leq 1
\]
}%
\end{frame}
\end{document}
```
![document.gif](/image?hash=ea7d4543169432d3a3cc623783f32ee6604d386eb911dbdaa0b1b3757a2f1648)
Answer #3
topnush
```
\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}[fragile]
\frametitle{Title}
\vspace{-0.1cm} % Reduce space after title
We are interested in how similar two sets are.
\vspace{0.4cm} % Increase space before tikzpicture
\centering
\begin{tikzpicture}
% Add a box around everything with some padding
\draw[black, thin] (-2.5,-2.5) rectangle (4.5,2.8);
\end{tikzpicture}
\only<4->{
The standard measure is the so-called Jaccard similarity.
}
\only<1-3>{\[\vphantom{0 \leq \frac{A \cap B}{A \cup B} \leq 1}\]} % Reserve space for the equation
\only<4>{\[
0 \leq \frac{A \cap B}{A \cup B} \leq 1
\]
}
\only<5>{\[
0 \leq \frac{8}{A \cup B} \leq 1
\]
}
\end{frame}
\end{document}
```
This helps a bit but not completely.