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.

I tried to compile

\documentclass{beamer}
\usepackage[english]{babel}

\newcounter{xxslide}

\begin{document}
\begin{frame}
  \addtocounter{xxslide}{2} 
  \visible<\value{xxslide}>{blabla}
\end{frame}
\end{document}

But the compiler generated an infinite amount of slides. How can I control number of overlays while programming a slide?

The point is that I'm making a complicated drawing. During the presentation things need to appear and disappear. I want to make macro's that say: show blabla during 5 overlays of a slide. Now, we go to the next overlay. Show blabla for the next 3 overlays and so on ... When I switch to the next overlay, I want to increment a counter that expresses the number of the current overlay and then use \visible < xxslide, xxslide+5 > { blabla } commands.

share|improve this question
2  
The frame contents are compiled at each slide for overlay effects. So \addtocounter continuously adds 2 at each slide. Take the \addtocounter command out of the frame and it works. –  percusse Jul 1 '12 at 11:42
1  
How do you "go to the next overlay"? Do you use a \pause, or how do you determine what the next overlay is? –  diabonas Jul 1 '12 at 14:00
add comment

3 Answers 3

up vote 5 down vote accepted

I'm not quite sure how your drawing is structured at the moment, but from what I understand, you could use the \pause command in combination with the . (dot) overlay specification to achieve what you want:

\documentclass{beamer}
\begin{document}
\begin{frame}

Overlay number: \insertpagenumber

\visible<-.(3)>{This text is shown 3 overlays long, starting from overlay 1}\pause

\visible<-.(5)>{This text is shown 5 overlays long, starting from overlay 2}\pause

\visible<-.(2)>{This text is shown 2 overlays long, starting from overlay 3}

\end{frame}
\end{document}

resulting output, showing six overlays

(Click on the image to see it full-size.)

It works like this: Each time a \pause command is encountered, the counter beamerpauses is increased by one, starting from 1. The dot in an overlay specification returns the value of this counter minus one, without changing the counter itself. If followed by an optional offset in round brackets, it returns (beamerpauses - 1) + offset instead, again without affecting the counter itself.

Take for example the second \visible command in the above example: As it is preceded by one \pause, it is shown from the second overlay on. The dot in the overlay specification returns (2 - 1) + 5 = 6, so the text is shown until overlay number 6.

Like this, you can specify how long a certain element of your drawing should be visible in the overlay specification, while managing the order of their appearance using \pause commands.

share|improve this answer
    
Thanks that was very helpful! –  Bruno Bauwens Jul 1 '12 at 15:07
add comment

Here is a solution based on the pgffor package (not sure of having get the point).

Code:

\documentclass{beamer}
\usepackage{pgffor}

\begin{document}
\begin{frame}
\foreach \xxslide in {1,3}{
\visible<\xxslide->{Text}
}
\newline
\visible<2>{Hello}
\end{frame}
\end{document}

Now you can control the overlays by inserting them as list.

share|improve this answer
    
The point is that I'm making a complicated drawing. During the presentation things need to appear and disappear. I want to make macro's that say: show blabla during 5 overlays of a slide. Now, we go to the next overlay. Show blabla for the next 3 overlays and so on ... When I switch to the next overlay, I want to increment a counter that expresses the current overlay. When I switch to the next overlay, I want to increment a counter that expresses the current overlay and then use \visible < xxslide, xxslide+5 > { blabla } commands. –  Bruno Bauwens Jul 1 '12 at 12:33
add comment

Thanks Diabonas, a simple representation of my problem is to make a moving snake. The code is below:

\documentclass{beamer}
\usepackage[english]{babel}
\usepackage{tikz}

\newcommand{\headsnake}[1]{
  \visible<.-.(3)>{\draw (#1) ellipse (0.5 and 0.5); \pause}
}

\begin{document}

\begin{frame}{A moving snake}
  \begin{figure}
  \begin{tikzpicture}
     \headsnake{0,0}
     \headsnake{0,1}
     \headsnake{1,1}
     \headsnake{2,1}
     \headsnake{2,2}
     \headsnake{2,3}
     \headsnake{2,4}
     \headsnake{2,5}
     \headsnake{3,5}
   \end{tikzpicture}
   \end{figure}
 \end{frame}

 \end{document}

result moving snake

share|improve this answer
add comment

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.