Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

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}
share|improve this answer
    
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
    
Thanks! That was plain enough. –  NVaughan Oct 11 '12 at 17:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.