4

I'm trying without success to use an enumeration with circled numbers but with different colors for each item: enter image description here

Could you help me please?

2 Answers2

4

This is something that creates such colored lists. Ultimately you probably want to combine this with enumitem, but as you do not provide any code, here is a very basic version.

\documentclass{article}
\usepackage{circledsteps}
\usepackage{pgf}
\pgfkeys{/csteps/enumerate colors/.initial={"red","green!70!black","blue","orange","cyan",
    "magenta","teal","purple"}}
\renewcommand{\labelenumi}{%
\pgfmathtruncatemacro{\mydim}{dim({\pgfkeysvalueof{/csteps/enumerate colors}})}%
\ifnum\value{enumi}>\mydim
\textsf{\arabic{enumi}}%
\else
\pgfmathsetmacro{\mycolor}{{\pgfkeysvalueof{/csteps/enumerate colors}}[\value{enumi}-1]}%
\Circled[inner color=white,fill color=\mycolor,outer color=\mycolor]{\textsf{\arabic{enumi}}}%
\fi}
\begin{document}
\begin{enumerate}
 \item text
 \item text
 \item text
 \item text
\end{enumerate}
\end{document}

enter image description here

The colors are stored in the key /csteps/enumerate colors.

  • Thanks. Sorry, my document is a huge document so I did not put my code. I will try your solution, I have an error with other enumerate blocks now – Sébastien Mailfert Mar 31 '21 at 16:22
  • Your code works but (1) it changes all my other enumerate blocks and (2) there is a conflict with my style – Sébastien Mailfert Mar 31 '21 at 16:31
  • 2
    @SébastienMailfert My crystal ball broke, so I didn't know what your code loads. As you say, my code works. If you want to have a more specific answer, you probably want to make your question more specific by adding a minimal example others can build on. –  Mar 31 '21 at 16:33
2

You have to define the colors, as shown in the MWE. If you exceed 9 enumeration items, you will exceed the circle (bullet) diameter.

\documentclass{article}
\usepackage{stackengine,xcolor,enumitem}
\newcommand\circnum[1]{\stackinset{c}{}{c}{.1ex}{\small\textcolor{white}{#1}}%
  {\abovebaseline[-.7ex]{\Huge\textcolor{\csname colenum#1\endcsname}{$\bullet$}}}}
\csdef{colenum1}{red}
\csdef{colenum2}{blue}
\csdef{colenum3}{cyan}
\csdef{colenum4}{orange}
\csdef{colenum5}{green!70!black}
\begin{document}

\begin{enumerate}[label=\protect\circnum{\theenumi}] \item first \item next \item third \item fourth \item last \end{enumerate} \end{document}

enter image description here