# Change the color of a single itemize item — command to do that?

My question concerns itemize items in Beamer slides. I want to obtain the following slide:

This has been produced by the code:

\documentclass{beamer}
\begin{document}
\begin{frame}{Title}
\begin{itemize}
\setbeamercolor{local structure}{fg=red}
\item \textcolor{red}{Red}, other text
\setbeamercolor{local structure}{fg=green}
\item \textcolor{green}{Green}, other text
\setbeamercolor{local structure}{fg=blue}
\item \textcolor{blue}{Blue}, other text
\end{itemize}
\end{frame}
\end{document}


Question. Is there a way to define a command \coloreditem{<color>} so that the above slide can be defined by the simplified code that follows?

\begin{frame}{Title}
\begin{itemize}
\coloreditem{red} \textcolor{red}{Red}, other text
\coloreditem{green} \textcolor{green}{Green}, other text
\item \textcolor{blue}{Blue}, other text
\end{itemize}
\end{frame}


My first guess was to define

\newcommand\coloreditem[1]{\setbeamercolor{local structure}{fg=#1}\item}


but of course the local structure get changed for too long. And adding a new pair of {} does not work.

• I didn't understand what is wrong. What do you mean by changed for too long? Both frames has the same format here. – Sigur May 6 '15 at 15:09
• I changed my second frame: The goal is that is does not change the following \items. – Bruno May 6 '15 at 16:47

You could do it like this:

\documentclass{beamer}
\newcommand\coloreditem[1]{\item[\textcolor{#1}{\usebeamertemplate{itemize \beameritemnestingprefix item}}]}
\begin{document}
\begin{frame}{Title}
\begin{itemize}
\coloreditem{red} blabl \textcolor{red}{Red}, other text
\coloreditem{green} blalba \textcolor{green}{Green}, other text
\item bnlabla
\end{itemize}
\end{frame}
\end{document}


• That's nice, thanks! I didn't know the command \beameritemnestingprefix which is very useful here. – Bruno May 6 '15 at 18:03

If it is okay to define a command with two arguments you could use

\newcommand\coloreditem[2]{{\setbeamercolor{itemize item}{fg=#1}\item #2}}


Then the changed color is restricted to the single item.

\documentclass{beamer}
\newcommand\coloreditem[2]{{\setbeamercolor{itemize item}{fg=#1}\item #2}}
\begin{document}
\begin{frame}{Title}
\begin{itemize}
\item Normal color, other text
\coloreditem{green}{\textcolor{green}{Green}, other text}
\item Normal color, other text
\end{itemize}
\end{frame}
\end{document}


• Right, that is a solution. Though I would prefer a command that works the same as \item. I could then have commands like \alertitem, \exampleitem and so on. Also (or otherwise) I could have a supplementary argument to \item (maybe hard since there is already an optional argument) to make it alerted or exampled. – Bruno May 6 '15 at 16:45
• What about restore the default color after \item in the command definition? – Sigur May 6 '15 at 17:02