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.
I don't really understand exactly what you are trying to do, but the basic idea is to arrange your items as you'd like them if everything were shown. So if a
is a sub-item of b
, it needs to be an \item
in a list nested as part of the specification of b
e.g. a nested list, if b
is itself an \item
. Once you have that, add the overlay specifications you need. If you want alerted text separate from overlays, use \alert{}
as you have been. Otherwise, you can add it to the \item
overlay specification.
Since you want something pretty bespoke, just specify the slide numbers for each \item
. I wouldn't bother trying to define a default for the list in this kind of case, or try to use relative overlay specifications. It will just be too confusing, I think. If you stick to the numbers, it should be relatively straightforward, if a bit fiddly, to get the result you want.
This is an example. Since I don't completely understand your question and have no idea what to do with the fourth item and its sub-items, it will surely need modification. However, hopefully, it should be pretty straightforward to do that, even if you need a bit of trial-and-error.
\documentclass{beamer}
\begin{document}
\begin{frame}{Test}
Animation with beamer: learn
\begin{itemize}
\item<2,5-> \alert<5,8>{First item}% show on slide 2 and 5 onwards, alert only on 5 and 8
\begin{itemize}% these are sub-items - need a nested list
\item<6-| alert@6> sub-first item% show on slide 6 and later, alert on 6 only
\item<6-| alert@6> sub-second item
\end{itemize}
\item<4> Extra item% only on slide 4, never alert
\item<3,5-> \alert<5,8>{Second item}% show on slide 3 and 5 onwards, alert only on 5 and 8
\begin{itemize}% these are sub-items - need a nested list
\item<7-| alert@7> sub-first item% show on slide 7 and later, alert on 7 only
\item<7-| alert@7> sub-second item
\end{itemize}
\onslide<9->% no idea what to do here - let's just put it on the next slide with everything bar the extra item
\item \alert{Fourth item}
\begin{itemize}% sub-items follow parent by default, so this is all on slide 9 onwards (which is just slide 9 in this case)
\item sub-first item
\item sub-second item
\end{itemize}
\end{itemize}
\end{frame}
\end{document}
Best Answer
The
overlayarea
command (thanks to this post here) may be what you are searching for:You will just have to adjust the second argument of the
\begin{overlayarea}
command to fit the height of your itemize and replace the\rule
command with your\includegraphics
.