Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
1  
I'm working on a solution based on the environ package. –  Jubobs Apr 6 '13 at 19:02

2 Answers 2

up vote 8 down vote accepted

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}

enter image description here

share|improve this answer
    
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
1  
@Sigur please see my updated answer for a version allowing to have titles. –  Gonzalo Medina Apr 6 '13 at 19:40
1  
@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}
share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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