我正在使用以下代码创建一个具有可点击目录和交叉引用的文档:
\documentclass[11pt,a4paper]{article}
\usepackage{lipsum}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{color,hyperref}
\definecolor{darkblue}{rgb}{0, 0, .7}
\hypersetup{colorlinks,
breaklinks,
linkcolor=darkblue, % color used for in-document links
urlcolor=darkblue,
anchorcolor=darkblue,
citecolor=darkblue}
\title{Title here}
\author{Author, First Name}
\date{\today}
\begin{document}
\maketitle
\tableofcontents
\newpage
\section{Introduction} \label{sec:intro}
\lipsum[2] The \textit{Section} \ref{sec:second} does things.
\section{Second section} \label{sec:second}
\lipsum[1]
\end{document}
我想为目录中的链接 ( black
) 和交叉引用 ( darkblue
) 使用不同的链接颜色。但是更改颜色linkcolor
会改变两者。有没有办法分别操作它们?
答案1
如果我理解正确的话,你想linkcolor
在目录之后进行更改,对吗?那么只需\hypersetup
在目录排版后再次调用即可:
\documentclass[11pt,a4paper]{article}
\usepackage{lipsum}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{color,hyperref}
\definecolor{darkblue}{rgb}{0, 0, .7}
\hypersetup{colorlinks,
breaklinks,
linkcolor=black, % color used for in-document links
urlcolor=darkblue,
anchorcolor=darkblue,
citecolor=darkblue}
\title{Title here}
\author{Author, First Name}
\date{\today}
\begin{document}
\maketitle
\tableofcontents
\hypersetup{colorlinks,
breaklinks,
linkcolor=darkblue, % color used for in-document links
urlcolor=darkblue,
anchorcolor=darkblue,
citecolor=darkblue}
\newpage
\section{Introduction} \label{sec:intro}
\lipsum[2] The \textit{Section} \ref{sec:second} does things.
\section{Second section} \label{sec:second}
\lipsum[1]
\end{document}