5

I would like to change the color of an \item in a list and I would like the item to look like a regular item.

\begin{itemize}
\item item one
\reditem item two
\item item three
\end{itemize}

and have "item two" be red and leave the font color of everything else alone?

I've looked and my google-fu is weak.

0
5

Using \specialitems you can switch between different styles:

enter image description here

\documentclass{article}
\usepackage{xcolor}% http://ctan.org/pkg/xcolor
\newcommand{\specialitems}{%
  \let\olditem\item% Store old \item in \olditem
  \newcommand{\reditem}{\olditem\leavevmode\color{red}}%
  \renewcommand{\item}{\color{black}\olditem\leavevmode}%
}
\begin{document}
\begin{itemize}
\specialitems
\item item one
\reditem item two
\item item three
\end{itemize}
\end{document}​

Of course, you could also make your own specialitemize environment that does the same:

\newenvironment{specialitemize}
  {\itemize\specialitems}% \begin{specialitemize}
  {\enditemize}% \end{specialitemize}

Now you can use

\begin{specialitemize}
\item item one
\reditem item two
\item item three
\end{specialitemize}
2
  • Why do you use leavevmode? I've never understood exactly what's it for.
    – NVaughan
    Oct 11 '12 at 16:52
  • 1
    @NVaughan: You have to enter horizontal mode for the alignment to be proper - TeX builds up a page by placing stuff in boxes... horizontal boxes, which are then stacked on top of one another into a vertical list. Without that, you sometimes run into vertical box issues. See what happens when you don't use \leavevmode in the itemize environment (part of \AddLinkToFile) of the answer to Adjust vertical spacing in tabular containing \href. Then there's also Function and usage of \leavevmode.
    – Werner
    Oct 11 '12 at 17:20

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.