Consider the following simple code:
\documentclass[11pt]{article}
\begin{document}
\begin{itemize}
\item plain text
\item I want this to be blue
\item another text
\end{itemize}
\end{document}
The result of the code is
Now, suppose that I want to make the text color of the second item blue. One can manually use the textcolor
command, but the thing is that in my real example there are many places to change the text, and such places are frequently modified. Hence, it is desirable to write a macro to change the color simply.
Question: How can I define custom command like \blueitem
, such that replacing \item
to \blueitem
in the above code gives the desired result? Or, as an alternative, one can also think of a macro that using \item[color=blue]
instead of \item
gives the result.
Edit: The answer by Sandy G does not work when used with the proof
environment. For example:
\documentclass[11pt]{article}
\usepackage{amsthm}
\usepackage{xcolor}
\let\olditem\item\renewcommand{\item}[1][black]{\color{#1}\olditem}
\begin{document}
\begin{itemize}
\item[blue] abc
\begin{proof}
abc.
\end{proof}
\end{itemize}
\end{document}
This code gives an error message
Package xcolor Error: Undefined color `\hskip \labelsep \itshape Proof\relax '. a
and the result is:
Note that there is no "Proof." symbol.