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:
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).
Therefore, my question is:
- How to change the color of a single itemized text (i.e., text1 here) using the command
\color<>[]{}
?- If the command is not feasible (why?), then what are the alternative approaches?
Best Answer
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:To confine the effect of the
\color
macro then you can enclose it into a groupYou 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
.