I want to show some program code line by line. I have the following code:
\documentclass[10pt,english]{beamer}
\usepackage{listings}
\lstset{
language=C,
basicstyle=\ttfamily
}
\begin{document}
\begin{frame}[fragile]
\frametitle{Slides with code}
\begin{itemize}
\item <1-> A piece of code
\item[] <2-> \begin{lstlisting}
int main(void)
\end{lstlisting}
\item[] <3-> \begin{lstlisting}
{
\end{lstlisting}
\item[] <4-> \begin{lstlisting}
int i;
\end{lstlisting}
\end{itemize}
\end{frame}
\end{document}
Now this is error-prone a painstaking. Is there another way to produce these slides?
Best Answer
You can use
mathescape
to insert appropriate\pause
s within the code, resulting in an easier way to negotiate the code reveal: