Would it be possible through the \setlist
of the enumitem
package to globally color all labels with a unique color for itemize, enumerate and descriptions environments without going through the redefinition of each of them and keeping their default format otherwise?
2 Answers
This is possible and will trickle down to nested lists if you set the font
key, since the default font attribute is empty except for description
which has a default of \bfseries
:
\documentclass{article}
\usepackage{enumitem,xcolor}
\setlist[itemize]{font=\color{itemizecolor}}
\colorlet{itemizecolor}{.}% Default colour for \item in itemize
\setlist[enumerate]{font=\color{enumeratecolor}}
\colorlet{enumeratecolor}{.}% Default colour for \item in enumerate
\setlist[description]{font=\bfseries\color{descriptioncolor}}
\colorlet{descriptioncolor}{.}% Default colour for \item[.] in description
\begin{document}
\colorlet{itemizecolor}{red}
\colorlet{enumeratecolor}{blue}
\colorlet{descriptioncolor}{green}
\begin{itemize}
\item First item
\item Second item
\item Last item
\end{itemize}
\begin{enumerate}
\item First item
\item Second item
\item Last item
\end{enumerate}
\begin{description}
\item[First] item
\item[Second] item
\item[Last] item
\end{description}
\end{document}
\documentclass{article}
\usepackage{enumitem, xcolor}
\setlist[enumerate]{label=\color{red}\arabic*.}
\setlist[itemize]{label=\color{blue}\textbullet}
\begin{document}
\section*{enumerate}
\begin{enumerate}
\item test
\item test
\end{enumerate}
\section*{itemize}
\begin{itemize}
\item test
\item test
\end{itemize}
\end{document}
-
yes but you set all nested lists to
textbullet
labels, which I want to avoid. I want to keep the default format of all lists.– plutonMay 26, 2020 at 12:11 -
If you just want to change it for the outer environment in a nested situation, just add a 1, like
\setlist[enumerate, 1]{label=\color{red}\arabic*.}
in the definitions. See my updated answer.– NicoMay 26, 2020 at 12:15 -
Yes but I want to change the color for all list levels without affecting other list features...– plutonMay 26, 2020 at 12:16
-
1Ok, then you would need to redefine each level of each list seperately.– NicoMay 26, 2020 at 12:25