4

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...

2 Answers 2

3

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}
8
  • 1
    Thank you very much!!However, it does not work when I use themes like Frankfurt or Copenhagen.
    – tipus
    Feb 12, 2011 at 11:53
  • 1
    and it would be a good idea, if you'd mentiond this in your question ...
    – user2478
    Feb 12, 2011 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, 2011 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, 2011 at 12:35
  • 1
    @Liu: I do not like balls ...
    – user2478
    Feb 12, 2011 at 13:11
2

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}%
    {\usebeamertemplate{alerted text begin}
     \setbeamercolor{alerted text}{fg=myitem}
     \usebeamercolor{alerted text}}
    {\usebeamertemplate{alerted text end}}
    {\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}
6
  • Nice! But \citem sounds to much like \cite. Feb 12, 2011 at 11:19
  • Well, it doesn't matter. I tried \coloritem but that's too long.
    – Leo Liu
    Feb 12, 2011 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, 2011 at 11:23
  • 1
    that did not work when using \begin{itemize}[<+->] for overlays.
    – user2478
    Feb 12, 2011 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, 2011 at 11:36

You must log in to answer this question.

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