是否可以通过\setlist
包enumitem
为 itemize、enumerate 和 descriptions 环境全局地为所有标签涂上独特的颜色,而无需对每个标签进行重新定义并保留其默认格式?
答案1
这是可能的,如果你设置了键,它将会渗透到嵌套列表中font
,因为默认字体属性为空除了其description
默认值为\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}
答案2
\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}