3

As seen in How do I change the color of itemize bullet? specific and default, it is easy to change the color of an itemize item bullet like this:

\documentclass{article}

\usepackage{enumitem,xcolor}

\begin{document}

\begin{itemize}
  \item First item
  \item[\textcolor{blue}{\textbullet}] Second item
  \item Last item
\end{itemize}

\end{document}

How can I do the equivalent for an enumerate environment? Is there something like \textbullet that gives me the complete label for the current item? (ideally the label itself, formatted as per the label environment option, if given, although the I could work with the raw item number otherwise). I have tried \labelenumi and \theenumi (without understanding very well what these are exactly) and it did not work.

EDIT:

The document I am working is a Beamer presentation. I did not mention it initially because I did not think it was relevant to the question, but indeed the nice answers provided by Bernard and user94293, while absolutely correct for article, do not work in my presentation.

  • You want tho change the colour of some labels of the environment, not all? – Bernard Apr 6 '18 at 11:56
  • @Bernard Yes, that's right. The use case, if you want context, is having a list of steps where some of them are "done", hence should be in green (both the label and the item text, but I already know how to change the color of the text). – jdehesa Apr 6 '18 at 11:59
  • For beamer, see also tex.stackexchange.com/questions/14319 – user94293 Apr 6 '18 at 13:54
3
\documentclass{beamer}

\begin{document}

\begin{frame}
\begin{enumerate}
  \item First item
  {
      \setbeamercolor{enumerate item}{fg=green}
        \color{green}
      \item Second item
  }
  \item Last item
\end{enumerate}
\end{frame}
\end{document}

Or much easier using the alert feature of beamer:

\documentclass{beamer}

\begin{document}

\begin{frame}
\begin{enumerate}
  \item First item
  \item<alert@+-> Second item
  \item Last item
\end{enumerate}
\end{frame}
\end{document}
  • Almost right! But to get it to work with enumerate I had to replace itemize item with local structure. Otherwise, it works fine. – jdehesa Apr 6 '18 at 13:33
  • 1
    Use \setbeamercolor{enumerate item}{fg=green} for enumerate lists. – user94293 Apr 6 '18 at 13:37
  • @samcarter This solution does not seem to work with \begin{enumerate}[<+->] – user94293 Apr 6 '18 at 14:54
  • @user94293 Thanks for pointing this out. I added a second much easier solution which also works in this case. – user36296 Apr 6 '18 at 20:54
4

enter image description here

You can use \normalcolor to switch back to the normal color.

\documentclass{article}

\usepackage{color} 

\begin{document}

\begin{enumerate}
  \item First item
  \item Second item
  \color{blue}
  \item \normalcolor Third item
  \item Last item
\end{enumerate}

\begin{enumerate}
  \item First item
  \item Second item
  \color{blue}
  \item Third item
  \normalcolor
  \item Last item
\end{enumerate}

\end{document}
  • Much simpler than my solution! – Bernard Apr 6 '18 at 13:14
  • Huh, never thought of trying this, thanks! However, this is not working in my case... I'm using Beamer, sorry for not specifying it in the question in the first place, I didn't think it would be relevant... I'll update the question.. – jdehesa Apr 6 '18 at 13:15
3

You can do it in a (comparatively) simple way withe the resume* and before keys:

\documentclass{article}

\usepackage{enumitem}
\usepackage[svgnames]{xcolor} 

\begin{document}

\begin{enumerate}
  \item First item
  \item Second item
\end{enumerate}
\begin{enumerate}[resume*, before=\vspace*{-\dimexpr\baselineskip}\color{DarkSeaGreen}]
  \item Third item
\end{enumerate}
\begin{enumerate}[resume*, before=\vspace*{-\dimexpr\baselineskip}]
  \item Last item
\end{enumerate}

\end{document} 

enter image description here

Edit:

Here is a solution for beamer, with the etoolbox package:

\documentclass[svgnames]{beamer}

\begin{document}

\begin{frame}
\begin{enumerate}
  \item First item
  \item Second item
 {\pretocmd{\insertenumlabel}{\color{DarkSeaGreen}}{}{}\color{DarkSeaGreen}
 \item Third item}
  \item Last item
\end{enumerate}
\end{frame}

\end{document} 

enter image description here

  • Thanks, this is indeed a working solution. I was hoping for something analogous to the itemize case, but if no better proposals are posted I'll accept this answer. – jdehesa Apr 6 '18 at 12:52
  • @Bernard : Could you explain what does "before=\vspace*{-\dimexpr\baselineskip}"? – pzorba75 Apr 6 '18 at 12:52
  • @pzorba75 presumably make the vspacing even – daleif Apr 6 '18 at 13:00
  • @pzorba75: Exactly as daleif said. With custom \itemsep, \topsep, \partopsep, it might have to be adapted – Bernard Apr 6 '18 at 13:13
  • 1
    @jdehesa: I've added a solution for beamer. – Bernard Apr 6 '18 at 13:39

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.