I would like my slide presentation to display one item at a time, where the codesnippet is considered another item. Here's what I have.
\documentclass{beamer}
\usetheme{Madrid}
\usepackage{listings}
\begin{document}
\begin{frame}[fragile]
\frametitle{Test Slide}
\defverbatim[colored]\codesnippet{
\begin{lstlisting}[language=Python,basicstyle=\ttfamily,keywordstyle=\color{blue}]
def main():
<statements>
\end{lstlisting}
}
\begin{itemize}
\item<1-> test
\item<2-> test
\codesnippet
\end{itemize}
\end{frame}
\end{document}
What happens with my current code is that item<1-> appears on the first slide, but then item 1 and item 2 appear on the second slide together with codesnippet. On slide 2, I just want item 1 and item 2 without the codesnippet, and then have item 1, item 2, and codesnippet appear on slide 3. If i try to nest codesnippet in another item like so, then I get an extra item after the code snippet.
\begin{itemize}
\item<1-> test
\item<2-> test
\item<3->{\codesnippet}
\end{itemize}
How can I treat a code snippet like an item that can be added to the next slide? Thanks.
<x-y>
means that something will be shown onframe
sx
toy
. So if you want everything to appear alone, just ommit the-
. Have a look at the\only
and\onslide
commands too.You could remplace youritemize
with\begin{itemize}item<1> test\item<2> test\end{itemize}\only<3>{\codesnippet}\end{frame}\end{document}
– BambOo Apr 16 '20 at 21:16