Updated:
How can I uncover a certain lstlisting
environment on a particular slide using \onslide
or \uncover
?
For example:
\documentclass{beamer}
\usepackage{listings}
\begin{document}
\begin{frame}
\onslide<1-> HI
\onslide<2-> \begin{lstlisting} int i = 0; \end{lstlisting}
\end{frame}
\end{document}
Best Answer
Verbatim material cannot appear in an argument to another command (up to a certain point you could try using an external file and inputting it with
\lstinputlisting
) and use\uncover
on\onslide
, but the best approach here is to use theonlyenv
environment for your listing (since the frame contains verbatim material it requires thefragile
option):I also added an optional
overlayarea
environment to prevent possible "jumps". An animation of the result: