更改未编号部分的内容表中的颜色

更改未编号部分的内容表中的颜色

我认为这是 unnumberedtotoc 和 tocloft 包之间的冲突...我想要一个带有黑色背景、白色字体和未编号部分的目录...但我不知道如何使未编号部分与白色字体配合使用...这是我尝试的方法:

\documentclass[a4paper,twoside]{book}
\usepackage{color}
\usepackage{afterpage}
\usepackage{xcolor}
\usepackage{tocloft}
\setcounter{secnumdepth}{0}
\let\oldcontentsline\contentsline  
\newcommand{\nopagecontentsline}[3]{\oldcontentsline{#1}{#2}{}}
\renewcommand{\cfttoctitlefont}{\fontsize{42pt}{0pt}\bfseries\color{white}}
\renewcommand\cftchapfont{\huge\bfseries\color{white}}
\renewcommand\cftsecfont{\huge\bfseries\color{white}}
\renewcommand\cftsecpagefont{\huge\bfseries\color{white}}
\renewcommand\cftchapafterpnum{\vskip10pt}
\renewcommand\cftsecafterpnum{\vskip20pt}
\renewcommand\cftsecindent{3,5cm} 
\begin{document}
\pagecolor{black}
\tableofcontents
\afterpage{\nopagecolor}
\clearpage  
\addtocontents{toc}{\let\protect\contentsline\protect\nopagecontentsline}
\addcontentsline{toc}{chapter}{Chapter}
\addtocontents{toc}{\let\protect\contentsline\protect\oldcontentsline}
\section{Name of unnumbered section}
Text
\clearpage
\end{document}

这不管用……如果我用标准的“\section”删除未编号的部分,它就可以工作,但部分是有编号的。我的另一个尝试是:

\begingroup
\color{white}
\tableofcontents
\endgroup

但它对除了保持黑色的部分名称之外的所有内容都有效......

编辑:

现在尝试使用“\setcounter{secnumdepth}{0}”而不是“unnumberedtotoc”来删除章节编号...第一个代码仍然不起作用,第二个代码仍然使标题以外的所有内容都变成白色。新版本已编辑。

相关内容