4

I'm wondering if there is a possibility to create in beamer two Verbatim environments side by side, each with the frame of the width of \textwidth and with gradually uncovering lines.

More specifically:

  1. I use minipage to create two Verbatim environments. However, I'm not able to create frame with fixed width. I tried \fbox{} for minipage but once Verbatim is in minipage it does not work. With an option frame=single for Verbatim, the frame is displayed but it is only around the code.

  2. I would like to uncover some lines gradually in both minipages. \only and \uncover seem to not work with Verbatim. I used \begin{onlyenv} \end{onlyenv} instead, it works fine, but not sure how will it deal with possible frame.

Here is my code:

\documentclass[10pt, t]{beamer}

\usepackage{fancyvrb}

\begin{document}
\begin{frame}[fragile, plain]
%\fbox{ % this does not work
\begin{minipage}[t][\textheight]{0.45\textwidth}
\begin{onlyenv}<1->
    \begin{Verbatim}
Some code here 1a
    \end{Verbatim}
\end{onlyenv}
\begin{onlyenv}<3->
    \begin{Verbatim}
Some code here 1b
    \end{Verbatim}
\end{onlyenv}   
\end{minipage}
%}
%\fbox{ % this does not work
\begin{minipage}[t][\textheight]{0.54\textwidth}
\begin{onlyenv}<2->
    \begin{Verbatim}
Some code here 2a
    \end{Verbatim}
\end{onlyenv}   
\begin{onlyenv}<4->
    \begin{Verbatim}
Some code here 2b
    \end{Verbatim}
\end{onlyenv}   
\end{minipage}
\end{frame}
%}
\end{document}
3

1 Answer 1

3

You can use SaveVerbatim and the insert the code with \BUseVerbatim as follows:

Sample output

\documentclass[10pt, t]{beamer}

\usepackage{fancyvrb}

\begin{document}

\begin{SaveVerbatim}{1a}
Some code here 1a
\end{SaveVerbatim}
\begin{SaveVerbatim}{1b}
Some code here 1b
\end{SaveVerbatim}
\begin{SaveVerbatim}{2a}
Some code here 2a
\end{SaveVerbatim}
\begin{SaveVerbatim}{2b}
Some code here 2b
\end{SaveVerbatim}

\begin{frame}[fragile, plain]
\fbox{\begin{minipage}[t][.8\textheight]{0.45\textwidth}\strut
  \begin{onlyenv}<1->%
    \BUseVerbatim{1a}
  \end{onlyenv}
  \begin{onlyenv}<3->%
    \BUseVerbatim{1b}
  \end{onlyenv}
\end{minipage}}
\fbox{\begin{minipage}[t][.8\textheight]{0.45\textwidth}\strut
  \begin{onlyenv}<2->%
    \BUseVerbatim{2a}
  \end{onlyenv}
  \begin{onlyenv}<4->%
    \BUseVerbatim{2b}
  \end{onlyenv}
\end{minipage}}
\end{frame}
\end{document}

Note the \struts and %'s added to avoid unwanted spacing.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .