18

Often when I use beamer for slides I use an itemize environment with \pause to show off one bullet point at a time. Also, often all the points I want to show on a single slide does not fit and I need to start a new slide with a couple of more points.

What I would like is instead an itemize-like environment that would give me (when the points do not fit on a single slide) rolling bullet points, something similar to what the following code does:

\documentclass{beamer}
\begin{document}
    \begin{frame}
        \begin{itemize}
            \only<-5>{\item one}
            \only<2-6>{\item two}
            \only<3-7>{\item three}
            \only<4-8>{\item four}
            \only<5-9>{\item five}
            \only<6-10>{\item six}
            \only<7-11>{\item seven}
            \only<8-12>{\item eight}
            \only<9->{\item nine}
            \only<10->{\item ten}
            \only<11->{\item eleven}
            \only<12->{\item twelve}
        \end{itemize}
    \end{frame}
\end{document}

However I don't want to keep track of how many slides I'm using.

Is there such an environment out there somewhere?

Also, some sort of animated rolling would be excellent, but that might be to ask for to much.

2

3 Answers 3

17

This is built into beamer:

\documentclass{beamer}
\begin{document}
\begin{frame}
    \begin{itemize}[<only@+-+(4)>]
        \item one
        \item two
        \item three
        \item four
        \item five
        \item six
        \item seven
        \item eight
        \item nine
        \item ten
    \end{itemize}
\end{frame}
\end{document}

The overlay specification +-+(4) means the same thing as (n+1)-(n+5), where n is the current slide count. The only@ action wraps the item in an \only<...>. Putting the specification as an argument to the itemize environment makes it the default for each item.

If you want to specify item text in a \foreach loop you can explicitly call \only before each item:

\documentclass{beamer}
\usepackage{pgffor}
\begin{document}
\begin{frame}
    \begin{itemize}
        \foreach \x in {a,b,...,z} {%
            \only<+-+(4)>{\item \x}
        }
    \end{itemize}
\end{frame}
\end{document}

See sections 9.6.3 (Action Specifications) and 9.6.4 (Incremental Specifications) of the beamer (v3.22) manual. Also this answer of mine.

5
  • Thanks for this tip I didn' know, it does not work with a \foreach loop, but Tom's solution does : \begin{frame}[t] \begin{itemize} \foreach \x in {a,...,z} {% \myitem{\x \theiii} } \end{itemize} \end{frame} will work, but \begin{itemize}[<only@+-+(4)>] \foreach \x in {a,...,z} {% \item \x } \end{itemize} will not.
    – Tarass
    Jul 15, 2014 at 8:32
  • 1
    @Tarass: see edit. Jul 15, 2014 at 12:31
  • This should be marked as the "correct" answer!
    – Yossi Gil
    Aug 18, 2014 at 16:25
  • That's great and I'll sure use it. However, in the best of worlds I don't want to keep track of how many of my bullet points actually fit on a slide. Let's say that the first four bullet points fit fine on a single slide but the fifth takes more space so then I want only bullet points 3, 4, and 5 to show on the second slide. And so on. Is there an easy way of accomplishing this? Nov 27, 2015 at 14:29
  • @feffemannen: That's a good question. So you would like to have, for each step, the maximum number of bullet points through that step that will fit on the slide, to appear? That seems possible but I'm not skilled enough to do it. Nov 30, 2015 at 14:22
10

Here's a version, with a rather weird problem and therefore a limitation. It defines a new counter iii and a new \myitem command. If you use such itemize environments on more than one slide, then the counter has to be reset. Otherwise, if for example you had 10 points on the first slide, it would start at slide 11 on the next slide. So I used etoolbox's \AtBeginEnvironment to reset the iii counter. This however means that you can only use one such itemize list per frame as otherwise you'll scroll through both of them at the same time. I tried to improve this by reseting the iii counter at the begin of each frame. But if I don't have the line \AtBeginEnvironment{itemize}{\setcounter{iii}{0}} I get a large pile of errors ("perhaps a missing item"), so for the moment this is limited to one scrolling itemize per frame. Also, as there's no look ahead mechanism, it won't stop when the last 5 items are displayed, but only when the last one is present.

Code

\documentclass{beamer}
\usetheme{Darmstadt}
\usepackage{tikz}
\usepackage{etoolbox}

\newcounter{iii}

\AtBeginEnvironment{itemize}{\setcounter{iii}{0}}

\newcommand{\myitem}[2][$\bullet$]
{ \stepcounter{iii}
    \pgfmathtruncatemacro{\endslide}{\theiii+4}
    \only<\theiii-\endslide>{\item[#1] #2}
}

\begin{document}

\begin{frame}[t]
    \begin{itemize}
        \myitem{a \theiii}
        \myitem{b \theiii}
        \myitem{c \theiii}
        \myitem{d \theiii}
        \myitem{e \theiii}
        \myitem{f \theiii}
        \myitem{g \theiii}
        \myitem{h \theiii}
        \myitem{i \theiii}
        \myitem{j \theiii}
        \myitem{k \theiii}
        \myitem{l \theiii}
        \myitem{m \theiii}
        \myitem{n \theiii}
        \myitem{o \theiii}
        \myitem{p \theiii}
        \myitem{q \theiii}
        \myitem{r \theiii}
        \myitem{s \theiii}
        \myitem{t \theiii}
        \myitem{u \theiii}
        \myitem{v \theiii}
        \myitem{w \theiii}
        \myitem{x \theiii}
        \myitem{y \theiii}
        \myitem{z \theiii}
    \end{itemize}
\end{frame}

\end{document}

Result

enter image description here

1
  • Thanks. Great, that looks like it should work! I'll try that for the next slides I produce. Sep 21, 2012 at 7:26
1

For reference as an extension to @Matthew Leingang's excellent answer. here is how you hardcode the beginning and end to avoid even having the list display less than 4 items.

\documentclass{beamer}
\usepackage{pgffor}
\begin{document}
\begin{frame}
    \begin{itemize}
        \only<-1>{\item 1}
        \only<-2>{\item 2}
        \only<-3>{\item 3}
        \only<+-+(3)>{\item 5}
        \only<+-+(3)>{\item 6}
        \only<+-+(3)>{\item 7}
        \only<+-+(3)>{\item 8}
        \only<+-+(3)>{\item 9}
        \only<+-+(3)>{\item 10}
        \only<+-+(3)>{\item 11}
        \only<+-+(3)>{\item 12}
        \only<+-+(3)>{\item 13}
        \only<+->{\item 14}
        \only<+->{\item 15}
        \only<+->{\item 16}
        \only<+->{\item 17}
    \end{itemize}
\end{frame}
\end{document}

You must log in to answer this question.

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