I am trying to define an alternative \item
command that would allow me to use a different color for some of the items. My code has the following form:
\documentclass{article}
\usepackage{color}
\definecolor{gray}{rgb}{0.7,0.7,0.7}
\newcommand{\grayitem}[1]{{\color{gray} \item #1}}
\begin{document}
\begin{enumerate}
\item First item.
\grayitem Second item.
\item Third item.
\end{enumerate}
\end{document}
I was hoping that
\grayitem Second item.
would produce the same result as
{\color{gray} \item Second item.}
but for some reason, these are not equivalent. They produce the following results, respectively:
Why are these two lines of code not equivalent? What am I doing wrong and how can I change the definition of \grayitem
to produce the second result?
I have also tried removing a pair of braces, like this
\newcommand{\grayitem}[1]{\color{gray} \item #1}
but then the third item becomes gray as well.
The solution should also work for multi-paragraph items.
Best Answer
A bit hacky, but without braces:
To make subliste adhere to the gray colour one could do something like the following, however if you want to use gray items inside a second level list, changing back to black won't work