如何改变书中项目符号的颜色?
\documentclass{book}
\usepackage{pifont}
\usepackage{xcolor}
\definecolor{myblue}{RGB}{0,29,119}
\begin{document}
\begin{dinglist}{110}
\item{Sample text}
\begin{dinglist}{228}
\item{Sample text}
\begin{dinglist}{227}
\item{Sample text}
\end{dinglist}
\end{dinglist}
\end{dinglist}
\end{document}
答案1
您可以定义自定义项目命令:
\documentclass{book}
\usepackage{pifont}
\usepackage{xcolor}
\definecolor{myblue}{RGB}{0,29,119}
\newcommand{\bsquare}{\item[\color{myblue}\ding{110}]}
\newcommand{\barrow}{\item[\color{myblue}\ding{228}]}
\newcommand{\bwarrow}{\item[\color{myblue}\ding{227}]}
\begin{document}
\begin{dinglist}{110}
\bsquare{Sample text}
\begin{dinglist}{228}
\barrow{Sample text}
\begin{dinglist}{227}
\bwarrow{Sample text}
\end{dinglist}
\end{dinglist}
\end{dinglist}
\end{document}
或根据 Christoph B 的评论(相同的序言):
\begin{document}
\begin{itemize}
\bsquare Sample text
\begin{itemize}
\barrow Sample text
\begin{itemize}
\bwarrow Sample text
\end{itemize}
\end{itemize}
\end{itemize}
\end{document}
答案2
以下 MWE 提供\itemcolor{<colour>}
允许您根据需要设置列表项的颜色:
\documentclass{article}
\usepackage{pifont,xcolor}% http://ctan.org/pkg/{pifont,xcolor}
\definecolor{myblue}{RGB}{0,29,119}
\newcommand{\itemcolor}[1]{% Update list item colour
\renewcommand{\makelabel}[1]{\color{#1}\hfil ##1}}
\begin{document}
\begin{dinglist}{110}
\itemcolor{myblue}
\item Sample text
\begin{dinglist}{228}
\itemcolor{green!70}
\item Sample text
\itemcolor{red!50}
\item Sample text
\begin{dinglist}{227}
\item Sample text
\end{dinglist}
\end{dinglist}
\end{dinglist}
\end{document}
enumitem
label
通过键值对提供列表形式的项目挂钩:
\documentclass{article}
\usepackage{enumitem,pifont,xcolor}% http://ctan.org/pkg/{enumitem,pifont,xcolor}
\definecolor{myblue}{RGB}{0,29,119}
\begin{document}
\begin{itemize}[label={\color{myblue}\Pifont{pzd}{\char110}}]
\item Sample text
\begin{itemize}[label={\color{green}\Pifont{pzd}{\char228}}]
\item Sample text
\item Sample text
\begin{itemize}[label={\color{red!50}\Pifont{pzd}{\char227}}]
\item Sample text
\end{itemize}
\end{itemize}
\end{itemize}
\end{document}
和往常一样,您不必在文档级别定义这些列表。您可以在序言中完成此操作,将结构与内容分开。请参阅enumitem
文档(部分5 全局设置,第 9 页)以及的使用\setlist[<list type + level>]{<format>}
。
答案3
您可以侵入pifont
并重新声明其中一个命令,例如\Pisymbol
:
\documentclass{book}
\usepackage{pifont}
\usepackage{xcolor}
\definecolor{myblue}{RGB}{0,29,119}
\newcommand{\myPisymbolformatcommand}{}
\newcommand{\hackintoPisymbol}[1]{%
\renewcommand{\myPisymbolformatcommand}{#1}
}
\renewcommand{\Pisymbol}[2]{{\Pifont{#1}\myPisymbolformatcommand\char#2}}
\begin{document}
\begin{dinglist}{110}
\item{Sample text}
\begin{dinglist}{228}\hackintoPisymbol{\color{myblue}}
\item{Sample text}
\begin{dinglist}{227}
\item{Sample text}
\end{dinglist}
\end{dinglist}
\end{dinglist}
\end{document}