Text Formatting ⇒ Using color in the label in the listing environment
Using color in the label in the listing environment
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,
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
Using color in the label in the listing environment
Code: Select all
\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
- 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
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Using color in the label in the listing environment
Code: Select all
\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}