7

I want to change the item text color in Beamer. I checked the Beamer User Guide and found the \color<>[]{} command in page 80.

\color<2-3>[rgb]{1,0,0} This text is red on slides 2 and 3, otherwise black.

Then I found an example which uses this command in the enumerate environment in the tutorial (page 15).

\begin{enumerate}[A]   
    \item<2-5> James Madison    
    \item<3-5> Harry Truman    
    \item<4-> \color<6>[rgb]{0,0.6,0}Abraham Lincoln    
    \item<5-5> Calvin Coolidge    
\end{enumerate}   

I then try a minimal example as follows (the example is also publicly available at ShareLatex. It is read-write allowed. So you are free to modify it.):

\documentclass[a4paper]{beamer}   
\begin{document}    
    \begin{frame}    
        \begin{itemize}    
            \item \color<2>[rgb]{1,0,1}{text1}    
            \begin{itemize}    
                \item text11    
            \end{itemize}    
            \item text2    
            \begin{itemize}    
                \item text21    
            \end{itemize}    
            \item text3    
       \end{itemize}    
  \end{frame}  
\end{document}

On the first slide, it is OK:

item text color 1

On the second slide (\color<2>[rgb]{1,0,1}{text1}), all the three outer itemized texts (i.e., text1, text2, and text3) become red as shown in the following image. However, I only want to change the color of the first itemized text (i.e., text1 here). item text color 2

Therefore, my question is:

  1. How to change the color of a single itemized text (i.e., text1 here) using the command \color<>[]{}?
  2. If the command is not feasible (why?), then what are the alternative approaches?
  • Use \begin{itemize}[<+->] – Sigur Dec 2 '13 at 14:12
  • 2
    @Sigur: I believe it's just matter of grouping the text, i.e. putting braces: \item {\color<2>[rgb]{1,0,1}{text1}}. – Claudio Fiandrino Dec 2 '13 at 14:14
  • @ClaudioFiandrino, yes, it works. We don't know it the OP wants to display all items at the same time. Thanks. – Sigur Dec 2 '13 at 14:15
  • @Sigur It works partially. However, I don't want too many overlays introduced by [<+->]. – hengxin Dec 2 '13 at 14:18
  • In alternative to grouping you can also use \textcolor which colors the text in its argument to confine the effect to it – Bordaigorl Dec 2 '13 at 14:19
15

When you call a \color<overlay>[colorsys]{color} command that changes the color from then on (within the current group) as it takes as argument only the color specification and not the content that needs to be colored. What happens here is that the sub-itemizes are in their own color environment so they are not affected by your command; instead the other items are in the same color environment. A simple example to illustrate the issue:

a {\color{red} a {\color{blue} a} a} a

color

To confine the effect of the \color macro then you can enclose it into a group

\documentclass[a4paper]{beamer}   
\begin{document}    
    \begin{frame}    
        \begin{itemize}    
            \item {\color<2>[rgb]{1,0,1} text1}    
            \begin{itemize}    
                \item text11    
            \end{itemize}    
            \item text2    
            \begin{itemize}    
                \item text21    
            \end{itemize}    
            \item text3    
       \end{itemize}    
  \end{frame}  
\end{document}

You can also use the \textcolor<overlay>[colorsys]{color}{content} macro which applies the change in color only to the content argument.

\textcolor is to \color what \textbf is to \bf.

  • +1, but I disagree with "[...] command that changes the color from then on"; as you said later, the color is applied to the current group, "from then on" seem to me pretty much the same as "for the rest of the document". – Claudio Fiandrino Dec 2 '13 at 15:13
  • @ClaudioFiandrino maybe this is more accurate now? – Bordaigorl Dec 2 '13 at 15:17
  • Excellent, thank you!! It's definitely more accurate this way. – Claudio Fiandrino Dec 2 '13 at 15:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.