tags:

views:

638

answers:

2

Hi,

I'm creating a presentation using the beamer LaTex package. Beamer comes with an environment called "semiverbatim" which is like "verbatim", but allows you to place commands inside the environment. This is useful in beamer to control how the overlays of a frame unfold. For example:

\begin{frame}[fragile, shrink]
  \frametitle{Some Code Sample}
\begin{semiverbatim}
private String foobar() \{
    String s = "val"
    \alert<2->{s = null};}
    return s;
\}
\end{semiverbatim}
\end{frame}

This will cause the third line to appear red in the second stage of the frame transition.

This is all good and fine, however, the "semiverbatim" environment, much like the "verbatim" environment, is pretty limited. I would like to use the "Verbatim" environment from the fancyvrb package.

Is there anyway to use "Verbatim" in the same way "semiverbatim" is used?

A: 

Not sure if it helps you directly, but when I've loaded source into a beamer slide, I used the listings package, lstset, and the lstlisting environment. I never use any reveals in the code, though, so I haven't tested that interaction.

Suppressingfire
(and by the way, I mark the containing frame as [fragile]
Suppressingfire
+1  A: 

I'm not having much luck, I'm afraid. I can get the \alert to work okay, but only without an overlay specification:

\documentclass{beamer}
\usepackage{fancyvrb}
\begin{document}
\begin{frame}[fragile]
\frametitle{Some Code Sample}
\begin{Verbatim}[commandchars={\\[]}]
private String foobar() {
    String s = "val"
    \alert[s = null];}
    return s;
}
\end{Verbatim}
\end{frame}
\end{document}

When you try \alert<2-> it breaks, and changing catcodes of < and > doesn't seem to help.

Will Robertson