# Custom itemize environment which takes color as argument

Using beamer, I would like to change the color of the itemize bullet according to a passed argument, something like

 \begin{myitemize}
\item[red] no
\item[green] yes
\end{myitemize}


Is there any way to achieve it? I have been googling but with no success...

-

that needs a redefinition of \makelabel

\documentclass{beamer}
\usetheme{Frankfurt}
\setbeamertemplate{itemize item}[triangle]
\newcommand\Item[1][blue]{%
\gdef\makelabel##1{{%
\hss\llap{{%
\usebeamerfont*{itemize \beameritemnestingprefix item}%
\color{#1}##1}}}}
\item }
\begin{document}

\begin{frame}{foo}{bar}
\begin{itemize}[<+->]
\Item[red] red
\Item[blue] blue
\end{itemize}
\end{frame}

\end{document}

-
Thank you very much!!However, it does not work when I use themes like Frankfurt or Copenhagen. –  tipus Feb 12 '11 at 11:53
and it would be a good idea, if you'd mentiond this in your question ... –  Herbert Feb 12 '11 at 12:15
For ball items, beamer uses color fg and parent.fg of item projected to shade it. It's quite different. See beamerbaseauxtemplates.sty. –  Leo Liu Feb 12 '11 at 12:32
Thus, \setbeamercolor{item projected}{bg=red} works for Frankfurt theme, if you use my solution. (but does not works for overlays) –  Leo Liu Feb 12 '11 at 12:35
@Liu: I do not like balls ... –  Herbert Feb 12 '11 at 13:11

Similar to Herbert's solution. This does not use internal macros, but it does not works for overlays.

\documentclass{beamer}
\usetheme{Frankfurt}
\begingroup
\usebeamercolor{itemize item}
\xglobal\colorlet{itemizefg}{fg}
\endgroup
\newcommand*\citem[1][itemizefg]{%
\setbeamercolor{item projected}{bg=#1}\item}

\begin{document}
\begin{frame}{Foo}{bar}
\begin{itemize}
\citem blue
\citem[red] red
\citem blue
\end{itemize}
\end{frame}
\end{document}


Here is a revised solution using overlay. I changed the requested syntax:

\documentclass{beamer}
\usetheme{Frankfurt}

\colorlet{myitem}{red}
\newenvironment{icolorenv}{%
\begin{altenv}%
{\color{.}}{}}
{\end{altenv}}

\newcommand{\icolor}[2]{\seticolor{#1}%
\begin{icolorenv}#2\end{icolorenv}}
\newcommand{\seticolor}[1]{\xglobal\colorlet{myitem}{#1}}

\begin{document}
\begin{frame}{Foo}{bar}

\begin{itemize}
\item blue\pause
\icolor{green}{\item green}\pause
\item blue\pause
\end{itemize}

\begin{itemize}[<+->]
\item blue
\seticolor{orange}\item<+-|icolor@+-> orange
\item green
\end{itemize}
\end{frame}
\end{document}

-
Nice! But \citem sounds to much like \cite. –  Martin Scharrer Feb 12 '11 at 11:19
Well, it doesn't matter. I tried \coloritem but that's too long. –  Leo Liu Feb 12 '11 at 11:22
Is there any way to get the current item color defined by beamer color theme? I don't like default blue here. –  Leo Liu Feb 12 '11 at 11:23
that did not work when using \begin{itemize}[<+->] for overlays. –  Herbert Feb 12 '11 at 11:27
@Herbert, you're right. It's a pity that we must once again check the source code of beamer. –  Leo Liu Feb 12 '11 at 11:36