3

I have a problem with Beamer. I'm trying do use lists with items of different colors, appearing once at a time.

Here's my MWE :

\documentclass{beamer}
\usetheme{Warsaw}

\newcommand\coloreditem[1]{\setbeamercolor{item projected}{bg=#1}\item}

\begin{document}
\begin{frame}
\begin{itemize}[<+->]
  \coloreditem{red} First
  \coloreditem{blue} Then
  \coloreditem{green} Now
  \coloreditem{orange} Last
  \end{itemize}
\end{frame}
\end{document}

It gives 4 pages, with incrementing number of bullet. However, items are all from the first color :

4th page of MWE

By replacing

\begin{itemize}[<+->]

with

\begin{itemize}

I get only one page, but correct colors

Desired result

Do you know why this doesn't work ? And what is the best way to do it ?

1 Answer 1

1

To get a clear explanation of why it does not work you probably need to dig deep into beamer. My guess is that \item is broken from the text after it, which should be displayed on the same slide. One way to solve the issue is to keep it together in a command. Below is a version where \citem{color}{text} print a bullet in color followed by text. The starred version appears one after each other.

\documentclass{beamer}
\usetheme{Warsaw}

\makeatletter
\def\citem{\@ifstar\c@itemstar\c@item}
\def\c@item#1#2{\c@@item[#1]{#2}}
\def\c@itemstar#1#2{\uncover<+->{\c@@item[#1]{#2}}}
\def \c@@item[#1]#2{\setbeamercolor{item}{fg=#1} \item #2}
\makeatother

\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\begin{itemize}
  \citem{red}{First}
  \citem{blue}{Then}
  \citem{green}{Now}
  \citem{orange}{Last}
\end{itemize}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\begin{itemize}
  \citem*{red}{First}
  \citem*{blue}{Then}
  \citem*{green}{Now}
  \citem*{orange}{Last}
\end{itemize}
\end{frame}

\end{document}

It would be nice to also have a default color. As it is now the color command changes the default value and the next bullet printed by \item has the same. It could be done by letting the color argument be optional.

You must log in to answer this question.

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