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,
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
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}