我正在使用这个elsearticle
类。目前,链接(引文、公式引用等)放在彩色框中,我宁愿让链接有颜色,而不是框。所以我尝试把
\usepackage{hyperref}
\usepackage[hyperref]{xcolor}
\hypersetup{
colorlinks = true, %Colours links instead of ugly boxes
urlcolor = red, %Colour for external hyperlinks
linkcolor = red, %Colour of internal links
citecolor = red %Colour of citations
}
但这个不起作用,它关闭了方框,但将所有链接的颜色变为蓝色。我该如何让它起作用?
答案1
该课程确实
\AtBeginDocument{\@ifpackageloaded{hyperref}
{\def\@linkcolor{blue}
\def\@anchorcolor{blue}
\def\@citecolor{blue}
\def\@filecolor{blue}
\def\@urlcolor{blue}
\def\@menucolor{blue}
\def\@pagecolor{blue}
\begingroup
\@makeother\`%
\@makeother\=%
\edef\x{%
\edef\noexpand\x{%
\endgroup
\noexpand\toks@{%
\catcode 96=\noexpand\the\catcode`\noexpand\`\relax
\catcode 61=\noexpand\the\catcode`\noexpand\=\relax
}%
}%
\noexpand\x
}%
\x
\@makeother\`
\@makeother\=
}{}}
所以你需要覆盖这个:
\documentclass{elsarticle}
\usepackage{hyperref}
\usepackage[hyperref]{xcolor}
\makeatletter
\hypersetup{colorlinks=true}
\AtBeginDocument{\@ifpackageloaded{hyperref}
{\def\@linkcolor{red}
\def\@anchorcolor{red}
\def\@citecolor{red}
\def\@filecolor{red}
\def\@urlcolor{red}
\def\@menucolor{red}
\def\@pagecolor{red}
\begingroup
\@makeother\`%
\@makeother\=%
\edef\x{%
\edef\noexpand\x{%
\endgroup
\noexpand\toks@{%
\catcode 96=\noexpand\the\catcode`\noexpand\`\relax
\catcode 61=\noexpand\the\catcode`\noexpand\=\relax
}%
}%
\noexpand\x
}%
\x
\@makeother\`
\@makeother\=
}{}}
\makeatother
\begin{document}
\tableofcontents
\section{Test section}
\href{www.tex.stackexchange.com}{TeX.sx} \cite{test}
\begin{thebibliography}{9}
\bibitem{test} Author, Title, 2015
\end{thebibliography}
\end{document}
或者更短,colorlinks=true
在序言中做并改变颜色
\hypersetup{
linkcolor=red,
urlcolor=red,
citecolor=red
}
在文档正文中:
\documentclass{elsarticle}
\usepackage{hyperref}
\usepackage[hyperref]{xcolor}
\hypersetup{
colorlinks=true,
}
\begin{document}
\hypersetup{
linkcolor=red,
urlcolor=red,
citecolor=red
}
\tableofcontents
\section{Test section}
\href{www.tex.stackexchange.com}{TeX.sx} \cite{test}
\begin{thebibliography}{9}
\bibitem{test} Author, Title, 2015
\end{thebibliography}
\end{document}
结果显示红色链接: