我想使用hypperref
创建蓝色链接仅有的目录部分和小节。
\documentclass[12pt,oneside]{book}
\usepackage{amsmath,amssymb,amsthm,amstext,amscd,amsfonts,amsbsy,amsxtra,latexsym,cite,hyperref}
\usepackage[retainorgcmds]{IEEEtrantools}
\usepackage{ytableau}
\usepackage{titlesec}
\usepackage{mathrsfs}
\usepackage{verbatim} % math stuff % more math stuff
\usepackage{graphicx} % including figures
\usepackage[lofdepth]{subfig} % subfigures
\usepackage[left=1.0in,right=1.0in,%
top=1.0in,bottom=1.0in]{geometry} % margin control
\usepackage[toc,page]{appendix} % appendix stuff
\usepackage{times} % Times New Roman font
\usepackage{color} % colored text
\usepackage{float}
\usepackage[square, numbers]{natbib} % nicer citing
\usepackage{indentfirst} % indents first paragraph of every section
\usepackage{setspace} % manual line spacing control
\usepackage{fancyhdr} % these 5 lines are for header/footer:
\fancypagestyle{plain}{
\fancyhead[R]{\thepage}\fancyhead[L]{}\fancyfoot[C]{}
\renewcommand{\headrulewidth}{0pt}}
\pagestyle{plain}
\setlength{\headheight}{15pt}
\usepackage{titlesec} % these 4 lines are for formatting chapter titles:
\titleformat{\chapter}[display]
{\normalfont\Huge\bfseries\centering}
{\vspace{8ex}\chaptertitlename\ \thechapter}{20pt}{\Huge}
\renewcommand{\headrulewidth}{0pt}}
\pagestyle{plain}
\setlength{\headheight}{15pt}
\usepackage{titlesec} % these 4 lines are for formatting chapter titles:
\titleformat{\chapter}[display]
{\normalfont\Huge\bfseries\centering}
{\vspace{8ex}\chaptertitlename\ \thechapter}{20pt}{\Huge}
\hypersetup{
colorlinks=true, % make the links colored
linkcolor=blue, % color TOC links in blue
linktoc=all % 'all' will create links for everything in the TOC
}
完成一些其他内容后,我开始撰写文档,其基本内容如下所示:
\begin{document}
\renewcommand{\contentsname}{Table of Contents}
\tableofcontents
\mainmatter
\include{mainmatter/chapter1/chapter1}
\include{mainmatter/chapter2/chapter2}
\backmatter
\include{backmatter/bibliography}
\end{document}
问题出现在主要内容部分;所有方程式标签都为蓝色,而参考文献(例如“[21]”)为绿色。我甚至没有在任何地方指定绿色,并且在hyppersetup
上面的片段中,我指定仅为目录创建链接,而不为文档内的标签/参考文献创建链接。
我没有在主要部分中包含具体内容,因为我认为这些内容不相关。如果我需要添加任何内容,请告诉我,这样会有帮助。
答案1
如果文档以目录开始,则可以\hypersetup{hidelinks}
在目录完成后使用。
\documentclass{book}
\usepackage{blindtext}
\usepackage{hyperref}
\hypersetup{
colorlinks=true, % make the links colored
linkcolor=blue, % color TOC links in blue
linktoc=all % 'all' will create links for everything in the TOC
}
\begin{document}
\tableofcontents
\hypersetup{hidelinks}
\chapter{First hapter}\label{ch1}
See chapter \ref{ch2}
\chapter{Second chapter}\label{ch2}
See chapter \ref{ch1}
\end{document}
或者您将全局所有颜色更改为黑色,并linkcolor=blue
在本地设置 TOC。
\documentclass{book}
\usepackage{blindtext}
\usepackage{amsmath}
\usepackage{hyperref}
\hypersetup{
colorlinks=true, % make the links colored
linkcolor=black, % color TOC links in blue
citecolor=black,
filecolor=black,
urlcolor=black,
linktoc=all % 'all' will create links for everything in the TOC
}
\begin{document}
{
\hypersetup{linkcolor=blue}
\tableofcontents
}
\chapter{First hapter}\label{ch1}
See chapter \ref{ch2}
\chapter{Second chapter}\label{ch2}
See chapter \ref{ch1}
\end{document}