2
\begin{enumerate}
\item 1
\item[red] 2
\end{enumerate}

For itemize I could use \item[\textcolor{red}{--}] or something, but for enumerate that does not really work.

I already tried [\textcolor{red}{\arabic{enumi}}] - which oddly started with 1 again [\textcolor{red}{\value{enumi}}] - which resulted in a pdflatex error [\textcolor{red}{\theenumi}] - which printed the (custom) ref= for that entry - and also counted from 1 on

1
  • You can adapt the answers to this question: tex.stackexchange.com/q/167454/231952. For example, in the first answer by @egreg, replace the first * with \color{red} (and adjust the open paren)
    – Ivan
    Commented Jun 10, 2021 at 17:15

1 Answer 1

5

The following method works with or without the enumitem package being loaded, and it works for both enumerate and itemize environments.

Observe that the macro \myitem is set up to take one optional argument, and that the default value of the optional argument is red. Thus, \myitem will create an item number that's red, while \myitem[blue] will create an item number that's -- you guessed right -- blue.

enter image description here

\documentclass{article}
\usepackage{xcolor}
\newcommand\myitem[1][red]{\color{#1}\item\color{black}}

\begin{document}
\begin{enumerate}
\item   A
\myitem B
\myitem[blue] C
\item   D
\end{enumerate}
\end{document}
5
  • 1
    thanks, I also came up that idea. Is there a latexway to define a makro or so? like "\reditem" "\blueitem" or even better: \myitem[red]
    – weltio
    Commented Jun 11, 2021 at 17:22
  • @weltio - I'll edit my answer to show how to set up a macro called \myitem that takes an optional argument, with the default value of the optional argument being red.
    – Mico
    Commented Jun 11, 2021 at 17:40
  • 1
    @Mico Do you think that this question is it a duplicate of this? tex.stackexchange.com/questions/155968/…
    – Sebastiano
    Commented Jun 11, 2021 at 20:02
  • 1
    @Sebastiano - I don't think so. The earlier question required an automatic cycling thru a list of colors; this one does not.
    – Mico
    Commented Jun 11, 2021 at 20:10
  • @Mico Surely is my low level for English language. Very often I find that I don't understand what the user is asking for.
    – Sebastiano
    Commented Jun 11, 2021 at 21:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .