4

Given a frame that has code rendered in a \begin{lstlisting}...\end{lstlisting} environment, is it possible to use beamer's incremental frame building feature to highlight code snippets?

Here is an example of what I would like to use:

\begin{frame}[fragile]{Test}
\begin{lstlisting}
x = y \alert<2->{// Assigns the value of y to x.}
\end{lstlisting}
\end{frame}
5

You can do this although you don't get the listings formatting inside the alert, but perhaps that's OK for comments..

enter image description here

\documentclass{beamer}
\usepackage{listings}
\begin{document}

\begin{frame}[fragile]{Test}
\begin{lstlisting}[escapeinside=`']
x = z // Assigns the value of y to x.
x = y `\alert<2->{// Assigns the value of y to x.}'
\end{lstlisting}
\end{frame}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.