我正在尝试为目录添加一种我已预定义的颜色,但是当我尝试为其添加颜色时,章节页码保持为黑色。
我尝试了多种解决方案,例如这但它就是不工作。这是一个 MWE(我决定包含我正在使用的所有包,以防问题出在那里):
\documentclass[12pt]{report}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{geometry}
\geometry{
a4paper,
top=42mm,
bottom=42mm,
inner=35.6mm,
outer=35.6mm
}
\usepackage{graphicx}
\graphicspath{{images/}}
\usepackage[export]{adjustbox}
\usepackage{ragged2e}
\usepackage{csquotes}
\usepackage{hyperref}
\usepackage{blindtext}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{float}
\usepackage{wrapfig}
\usepackage{titlesec}
\titleformat{\chapter}[hang]
{\normalfont\huge\bfseries}
{\thechapter}{20pt}{\huge}
\usepackage{amsmath}
\usepackage{array}
\usepackage{threeparttable}
\usepackage{caption}
\usepackage[
backend=biber,
style=authoryear,
citestyle=authoryear,
sorting=nty,
maxcitenames=2
]{biblatex}
\addbibresource{Sources.bib}
\usepackage{xcolor}
\definecolor{MUNIblue}{RGB}{0, 0, 220}
\usepackage{titlesec}
\titleformat
{\chapter} % command
[hang] % shape
{\bfseries\LARGE\color{MUNIblue}} % format
{\thechapter} % label
{1ex} % sep
{} % before-code
[] % after-code
\titleformat
{\section} % command
[hang] % shape
{\bfseries\Large\color{MUNIblue}} % format
{\thesection} % label
{1ex} % sep
{} % before-code
[] % after-code
\titleformat
{\subsection} % command
[hang] % shape
{\bfseries\large\color{MUNIblue}} % format
{\thesubsection} % label
{1ex} % sep
{} % before-code
[] % after-code
\PassOptionsToPackage{hyphens}{url}
\expandafter\def\expandafter\UrlBreaks\expandafter{\UrlBreaks
\do\a\do\b\do\c\do\d\do\e\do\f\do\g\do\h\do\i\do\j%
\do\k\do\l\do\m\do\n\do\o\do\p\do\q\do\r\do\s\do\t%
\do\u\do\v\do\w\do\x\do\y\do\z\do\A\do\B\do\C\do\D%
\do\E\do\F\do\G\do\H\do\I\do\J\do\K\do\L\do\M\do\N%
\do\O\do\P\do\Q\do\R\do\S\do\T\do\U\do\V\do\W\do\X%
\do\Y\do\Z\do\*\do\-\do\~\do\'\do\"\do\-}%
\renewcommand*{\nameyeardelim}{\addcomma\space}
\renewcommand*{\postnotedelim}{\addcomma\space s.\space}
\DeclareFieldFormat{postnote}{#1}
\DeclareFieldFormat{multipostnote}{#1}
\usepackage{xpatch}
\xpretobibmacro{date+extrayear}{\addperiod\space}{}{}
\xapptobibmacro{date+extrayear}{\nopunct}{}{}
\linespread{1}
\begin{document}
\pagenumbering{gobble}
{\color{MUNIblue}\tableofcontents}
{\color{MUNIblue}\listoftables} \addcontentsline{toc}{chapter}{List of tables} \pagenumbering{arabic}
\setcounter{page}{11}
\chapter*{Introduction}
\addcontentsline{toc}{chapter}{Introduction}
\justify
\blindtext
\chapter{First chapter!}
\section{And a section now!}
\blindtext
\section{Another section with a table}
\begin{table} [H]
\centering
\begin{threeparttable}
\caption{a table!}
\begin{tabular}{r|l}
aa & xxx \\
aa & xxx \\
aa & xxx \\
aa & xxx \\
\end{tabular}
\begin{tablenotes}
\item \flushright{\textit{\small{Source}}}
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}
其结果如下: 仅章节页码有颜色
提前感谢您并祝您有美好的一天!