我曾尝试找到一种方法来自定义内部链接的颜色,但我还不具备查找和重新定义命令的专业知识。在下面的 LaTeX 示例中,我描述了如何更改各种链接的颜色。任何想法或示例都非常感谢。
\documentclass{article}
\usepackage[backref=true]{biblatex}
\begin{filecontents}{refs.bib}
@book{cit1,
title = {The backreferences should be yellow},
author = {Last, First}
}
\end{filecontents}
\bibliography{refs.bib}
\usepackage{color}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage[colorlinks=true,
linkcolor=red,
urlcolor=blue,
citecolor=gray]{hyperref}
\begin{document}
\title{Title}
\maketitle
\tableofcontents
\listoffigures
\section{Table of content's links should be green}
\label{s1}
All text, captions, and section headers after the list of figures
should be black. The citation links should be gray.\autocite{cit1}
\subsection{Table of content's subsections links should be orange}
Internal links like this section link \ref{s1}
or this figure link \ref{f1} should be blue.
\begin{figure}[h]
\caption{List of figures links red}
\label{f1}
\end{figure}
\printbibliography
\end{document}
答案1
对于更改目录中子部分的链接颜色的问题,可以使用该tocloft
包:
\documentclass{article}
\usepackage{color}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage{hyperref}
\hypersetup{
colorlinks = true,
citecolor = gray
}
\usepackage{tocloft}
\renewcommand{\cftsubsecfont}{\normalfont\hypersetup{linkcolor=orange}}
\renewcommand{\cftsubsecafterpnum}{\hypersetup{linkcolor=green}}
\begin{document}
\title{Title}
\maketitle
\hypersetup{linkcolor=green}
\tableofcontents
\hypersetup{linkcolor=red}
\listoffigures
\hypersetup{linkcolor=blue}
\section{Table of content's links should be green}
\label{s1}
All text, captions, and section headers after the list of figures
should be black. The citation links should be gray.
\subsection{Table of content's subsections links should be orange}
Internal links like this section link \ref{s1}
or this figure link \ref{f1} should be blue.
\section{Making sure section titles turn back to green}
This should be green again in the ToC.
\begin{figure}[h]
\caption{List of figures links red}
\label{f1}
\end{figure}
\end{document}
需要稍微调整一下才能找到需要更改哪些命令才能获得所需的颜色。更多信息请参阅文档第 10 页。为了保持字体不变,我必须找到标准定义,即文档第 30 页。
该tocloft
软件包还处理各种用于更改图表列表(和表格列表)的选项,这意味着您可以使用该软件包在序言中设置您的所有愿望。
答案2
这hyperref
选项可以使用\hypersetup
命令进行配置,并通过 启用颜色colorlinks=true
。
下面是一个 MWE。citecolor
设置为灰色。对于目录链接颜色,在命令linkcolor
之前设置为绿色\tableofcontents
。同样,对于图表列表,在命令linkcolor
之前设置为红色\listoffigures
。稍后linkcolor
将内部链接设置为蓝色。
我无法使目录的子部分链接以橙色显示。
\documentclass{article}
\usepackage{color}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage[backref=true,backend=biber,natbib=true,hyperref=true]{biblatex}
\bibliography{refs}
\usepackage{hyperref}
\hypersetup{
colorlinks = true,
citecolor = gray
}
\begin{document}
\title{Title}
\maketitle
\hypersetup{linkcolor=green}
\tableofcontents
\hypersetup{linkcolor=red}
\listoffigures
\hypersetup{linkcolor=blue}
\section{Table of content's links should be green} \label{s1}
All text, captions, and section headers after the list of figures
should be black. The citation links should be gray~\cite{cit2}.
\subsection{Table of content's subsections links should be orange}
Internal links like this section link \ref{s1} or this figure link
\ref{f1} should be blue.
\begin{figure}[h]
\caption{List of figures links red}
\label{f1}
\end{figure}
\nocite{*}
\printbibliography
\end{document}
以下是输出的屏幕截图: