Greetings,
Suppose I have a following list:
\begin{enumerate}
\item ABC
\item DEF
\item GHI
\end{enumerate}
The output is
1. ABC
2. DEF
3. GHI
Now I would like to have these labels (1,2,3) colored in blue, for example, while keeping the color of the text (ABC, DEF, GHI) as it is. How can I do it? Please advise.
1. ABC
2. DEF
3. GHI
Best regards,
Text Formatting ⇒ Using color in the label in the listing environment
NEW: TikZ book now 40% off at Amazon.com for a short time.
Using color in the label in the listing environment
You should be able to do that with a combination of the xcolor and enumitem packages. E.g.:
Code: Select all
Code, edit and compile here:
\documentclass{article}\usepackage{xcolor}\usepackage{enumitem}\begin{document}\begin{enumerate}[label=\textcolor{blue}{\arabic*.}]\item ABC\item DEF\item GHI\end{enumerate}\end{document}
Re: Using color in the label in the listing environment
Is it possible to do this without using enumitem package?
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Using color in the label in the listing environment
Using this package is the most easiest solution. I wonder about the reason that makes you oppose.lances wrote:Is it possible to do this without using enumitem package?
Best regards and welcome to the board
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Using color in the label in the listing environment
The following code works without enumitem:
If the list is nested in one or more enumerate environments, you should replace the enumi suffix in \labelenumi and enumi by enumii, enumiii or enumiv, depending on the nesting level. This nuisance can be avoided by using enumitem, since this package takes care automatically of the nesting level.
Code: Select all
Code, edit and compile here:
\documentclass{article}\usepackage{color} % or xcolor, as you like\begin{document}\begin{enumerate}\renewcommand{\labelenumi}{\textcolor{blue}{\arabic{enumi}.}}\item ABC\item DEF\item GHI\end{enumerate}\end{document}
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
Using color in the label in the listing environment
Hey, many thanks for your answer. GOD bless you.