是否有可能用除蓝色、红色和绿色之外的任何其他两种颜色来为小节和小小节着色?!。
我用
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\usepackage[svgnames]{xcolor}
\geometry{footskip=15pt}
\usepackage{amsmath}
\hypersetup{
colorlinks=true,
linkcolor=blue,
filecolor=magenta,
urlcolor=red,
}
\usepackage{tocloft}
\begin{document}
\tableofcontents
\end{document}
答案1
在您的示例中,蓝色是主要链接颜色(hyperref
选项linkcolor
)。您可以更改不同级别的目录条目的链接颜色:
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\usepackage{hyperref}
\usepackage[svgnames]{xcolor}
\geometry{footskip=15pt}
\usepackage{amsmath}
\usepackage{tocloft}
\renewcommand{\cftsubsecfont}{\hypersetup{linkcolor=green}}% you can replace green by the defined colour you want (see `xcolor` manual)
\renewcommand{\cftsubsubsecfont}{\hypersetup{linkcolor=red}}% you can replace red by the defined colour you want (see `xcolor` manual)
\hypersetup{%
colorlinks=true,% switch on coloured instead of framed links
linkcolor=blue,% main link color (e.g. for the ToC)
filecolor=magenta,% color of links to external files
urlcolor=red,% color to external URLs
} %
\usepackage{mwe}% for the example only
\begin{document}
\tableofcontents
\blinddocument
\end{document}
说实话:这是个 hack。但它确实有效:
答案2
和tocloft
:
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\usepackage{hyperref}
\usepackage[svgnames]{xcolor}
\geometry{footskip=15pt}
\usepackage{amsmath}
\hypersetup{ %
pdfborder={0 0 0} % new code
} %
\usepackage{tocloft}
\renewcommand{\cftsubsecfont}{\color{green}} % newcode
\renewcommand{\cftsubsubsecfont}{\color{red}} % newcode
\begin{document}
\tableofcontents
\hypersetup{ %
colorlinks=true, %
linkcolor=blue, % moved after \tableofcontents
filecolor=magenta, %
urlcolor=red, %
} %
\section{section}
\subsection{subsection}
\subsubsection{subsubsection}
\end{document}
我曾经\cftXfont
改变颜色,不得不将超链接设置语句推迟到目录之后,这样它就不会干扰\cftXfont
要更改点的颜色和页码,请添加:
\renewcommand{\cftsubsecpagefont}{\color{green}}
\renewcommand{\cftsubsubsecpagefont}{\color{red}}
\renewcommand{\cftsubsecleader}{\color{green}\cftdotfill{\cftsubsecdotsep}}
\renewcommand{\cftsubsubsecleader}{\color{red}\cftdotfill{\cftsubsubsecdotsep}}