2

I have succeeded in building an itemize environment with circled number symbols that auto-increment thanks to the pifont package

\documentclass[a4paper,10pt]{article}
\usepackage{pifont}
\begin{document}

\begin{dingautolist}{202} % pifont symbol number for solid numbered circles
    \item First item
    \item Second item
    \item Last item
\end{dingautolist}

\end{document}

Now I would like to dynamically adjust the color of each itemize symbol. I tried changing the first item as suggested here

\usepackage{xcolor}
\item[\textcolor{blue}{\textbullet}] First item

However this reverts the item symbol to the standard bullet instead of the symbol used by dingautolist. In the post, there is no discussion of using a command other than \textbullet as the argument to \textcolor.

How can I adjust the color while retaining my custom symbols? Ideally I would create \newcommands like \blueitem[1]{def} and \reditem[1]{def} which accept a single argument for the text to display with the item

3

The following provides \colouritem{<colour>} that works just like \item, but sets the colour using \color{<colour>}.

enter image description here

\documentclass{article}

\usepackage{pifont,xcolor}

\newcommand{\colouritem}[1]{%
  {\color{#1}\item\leavevmode}\ignorespaces%
}

\begin{document}

\begin{dingautolist}{202} % pifont symbol number for solid numbered circles
  \item First item
  \colouritem{blue} Second item
  \colouritem{red} Last item
\end{dingautolist}

\end{document}
  • Adding \label{referb} to the first \colouritem statement and \label{referc} to the second \colouritem statement doesn't provide the right value when referring in a later \refer{referb} sentence, ils print the first item (1 in a black disk). Is there a way to correct this situation very confusing? – pzorba75 Jul 24 '19 at 3:14
  • @pzorba75: One would have to use a completely different approach to capture the colour of the label and transport that with the reference. Ask a follow-up question... – Werner Jul 24 '19 at 15:02

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.