# Repeating frame contents

Supposing that I'll use always two blocks on each frame.

Then, I'd like to have a simple way to do the following, without copy/paste procedure:

On each frame (except the first one),

• the first block should be the second block from the previous frame.

So I guess that something similar to the code below would be possible and helpful:

\begin{frame}
% code to call the second block from the previous frame
\begin{block} % the new block, to be used again on the next frame
\end{block}
\end{frame}


If it's possible to use some overlays it would be nice.

Any idea?

-
I'm working on a solution based on the environ package. –  Jubobs Apr 6 '13 at 19:02

Here's a solution without manual intervention; \dupbox makes all the job; initially you define the initial contents and then simply invoke it with the new text; \dupbox has also an optional argument allowing you to specify a title for the block:

\documentclass{beamer}
\usepackage{tikz}
\usetheme{Warsaw}
\usecolortheme{crane}

\newcommand\dupbox[2][]{%
\begin{block}{\duptitle}
\begin{minipage}{\linewidth}
\duptext
\end{minipage}
\end{block}
\begin{block}{#1}
\begin{minipage}{\linewidth}
#2
\end{minipage}
\end{block}
\gdef\duptext{#2}
\gdef\duptitle{#1}
}

\gdef\duptext{Initial text}
\gdef\duptitle{}

\begin{document}

\begin{frame}
\dupbox[Optional title]{Some text for frames one and two}
\end{frame}

\begin{frame}
\dupbox{Another test text for frames two and three with some math:
$a=b.$
}
\end{frame}

\begin{frame}
\dupbox[A simple TikZ drawing]{\tikz{\fill[blue] (0\linewidth,0) circle (13pt);
\fill[orange] (6,0) circle (13pt);}
}
\end{frame}

\begin{frame}
\dupbox{Even more text}
\end{frame}

\end{document}


-
Perfect!! If I could I would give you +10. It was a simple but genial solution. Thanks so much. –  Sigur Apr 6 '13 at 19:26
How about the block titles? –  Jubobs Apr 6 '13 at 19:28
@Jubobs, I'm trying to do this using a second argument #2. –  Sigur Apr 6 '13 at 19:31
@Sigur please see my updated answer for a version allowing to have titles. –  Gonzalo Medina Apr 6 '13 at 19:40
@Sigur the extra pair of square brackets is precisely telling TeX that the first argument is optional; leaving it empty (as in this case) simple indicates that no default value will be used. The syntax for defining a command with an optional argument is \newcommand[<number>][<default value for #1>]{<do someting with the parameters>}. –  Gonzalo Medina Apr 6 '13 at 20:17

Like that?

\documentclass{beamer}
\begin{document}
\begin{frame}
\only<1>{\begin{block}{First} block \end{block}}
\only<1,2>{\begin{block}{Second} block  \end{block}}
\only<2,3>{\begin{block}{Third} block \end{block}}
\only<3>{\begin{block}{4th}  block \end{block}}
\end{frame}
\end{document}

-
Yes, the result would be the same. But your code produces only one frame with many slides. I'd like to be able to use other frames. –  Sigur Apr 6 '13 at 18:44
Well, this has been solved already by Gonzalo Medina, just add that another solution could be use external files and include twice with \input{file}. –  Fran Apr 6 '13 at 20:16