I am preparing a beamer presentation and using the lstlisting environment in order to put in code. However, I would like to use the \pause command within lstlisting. By definition that is not possible. I am numbering the lines so it is bad if I just end and begin the environment again in order to insert \pause. Any tips?
Asked
Active
Viewed 3,272 times
13
Gonzalo Medina
- 505,128
MCB
- 509
1 Answers
22
You can escape to LaTeX (Section 4.14 Escaping to LaTeX of the listings documentation) and use \pause:
\documentclass{beamer}
\usepackage{listings}
\usepackage{bera}
\lstset{basicstyle=\small\ttfamily,
numbers=left,
escapeinside=||
}
\begin{document}
\begin{frame}[fragile]
\begin{lstlisting}
line1 |\pause|
line2 |\pause|
line3
\end{lstlisting}
\end{frame}
\end{document}
Gonzalo Medina
- 505,128
\uncoveras what had been discussed in How to make overlay still work inside lstlisting environment?? – kiss my armpit Jun 07 '12 at 16:03\uncoveror\onslideare involved. – Gonzalo Medina Jun 07 '12 at 16:49