[Tex/LaTex] Using \only in beamer presentation

beamerpresentations

I have the following code for a slide from a presentation:

\begin{frame}
\frametitle{Heuristic Policies}
\begin{columns}

\column{0.5\textwidth}
\begin{itemize}
\item<1-> These are methods aiming to give a good but not necessarily optimal solution to a problem.
\item<2-> There exist a number of such policies for bandit problems.
\only<1-9>{
\item<3-9> Greedy policy:
\begin{itemize}
\normalsize
\item<4-9> choose arm with greatest expected reward
\item<5-9> ignores variability in prior distribution
\item<6-9> quite good for Bernoulli bandits, but less effective for normal bandits
}
\end{itemize}

\end{itemize}


\column{0.3\textwidth}

\vspace{-25pt}
\uncover<7->{\begin{figure}
\begin{center}
\includegraphics[height = 2.7cm, trim=-1cm 0cm 0cm 0cm,clip=true]{bandit.jpg}
\caption*{$(\alpha,\beta) = (1,1)$}
\end{center}
\end{figure}}
\vspace{-25pt}
\uncover<8->{
\begin{figure}
\begin{center}
\includegraphics[height = 2.7cm, trim=-1cm 0cm 0cm 0cm,clip=true]{bandit.jpg}
\caption*{$(\alpha,\beta) = (6,5)$}
\end{center}
\end{figure}}


\column{0.2\textwidth}

\uncover<7->{$\mu = \frac{1}{2}$}\\
\vspace{70pt}
\uncover<8->{$\mu = \frac{6}{11}$}\\
\only<9>{$\Rightarrow$ play this arm}


\end{columns}
\end{frame}

At the moment, it's doing what I want. However, the next step is to have it so that all of the bullets from "Greedy policy" are removed as well as "play this arm", and the bulleted text replaced by similar text formatted in the same way. However, I can't see to use \only to do what I want. I tried:

...

\item<4-9> choose arm with greatest expected reward
\item<5-9> ignores variability in prior distribution
\item<6-9> quite good for Bernoulli bandits, but less effective for normal bandits
}
\end{itemize}

\only<10-16>{
\item<10-16> Next policy:
\begin{itemize}
\normalsize
\item<11-16> comment 1
\item<12-16> comment 2
\item<13-16> comment 3
}
\end{itemize}

\end{itemize}

\column{0.3\textwidth}

...

but this didn't work. Could anyone show me what I'm doing wrong? Thanks.

Best Answer

Your aim seems to be to present several different policies, while leaving the general description of the first two items as a constant. You can use a combination of \alt and \only `:

\documentclass{beamer}

\begin{document}

\begin{frame}[t]
\frametitle{Heuristic Policies}

\begin{columns}

\column{0.5\textwidth}
\begin{itemize}
\item<1-> These are methods aiming to give a good but not necessarily optimal solution to a problem.
\item<2-> There exist a number of such policies for bandit problems.
\alt<1-9>{
\item<3-9> Greedy policy:
\begin{itemize}
\normalsize
\item<4-9> choose arm with greatest expected reward
\item<5-9> ignores variability in prior distribution
\item<6-9> quite good for Bernoulli bandits, but less effective for normal bandits
\end{itemize}
}{\only<10-14>{\item<10-> Next policy:
\begin{itemize}
\normalsize
\item<11-14> comment 1
\item<12-14> comment 2
\item<13-14> comment 3\par
\rule{0pt}{2.7cm}
\end{itemize}}
\only<15-18>{\item<15-> Another policy:
\begin{itemize}
\normalsize
\item<16-18> Another comment 1
\item<17-18> Another comment 2
\item<18-18> Another comment 3\par
\rule{0pt}{2.7cm}
\end{itemize}}
}
\end{itemize}

\column{0.3\textwidth}
\vspace{-25pt}
\uncover<7->{\begin{figure}
\begin{center}
\includegraphics[height = 2.7cm, trim=-1cm 0cm 0cm 0cm,clip=true,width=3cm]{example-image-a}
\caption*{$(\alpha,\beta) = (1,1)$}
\end{center}
\end{figure}}
\vspace{-25pt}
\uncover<8->{
\begin{figure}
\begin{center}
\includegraphics[height = 2.7cm, trim=-1cm 0cm 0cm 0cm,clip=true,width=3cm]{example-image-a}
\caption*{$(\alpha,\beta) = (6,5)$}
\end{center}
\end{figure}}

\column{0.2\textwidth} 
\only<9>{$\Rightarrow$ play this arm} 
\only<13-14>{$\Rightarrow$ play this arm with probability $\varepsilon$\vspace{80pt}} 
\only<14>{$\Rightarrow$ play this arm with probability $1-\varepsilon$} 
\end{columns} 
\onslide<10>{\null}
\end{frame}

\end{document}

To avoid the jumping of the first common two items I used some "invisible" rules.

An animated image of the resulting document:

enter image description here