Latex hyperref:获取颜色和小写字母

Latex hyperref:获取颜色和小写字母

在 中,可以借助选项打开/关闭和\hypersetup指定的颜色。还可以通过设置 获得小写字母样式参考;但是后者似乎只有在设置时才有效。linkcolorcitecolorcolorlinksfrenchlinks=truecolorlinks=false

是否可以获取链接中的颜色小写字母?具体来说,我只希望 citecolor 为灰色,但通过设置colorlinks为也可以消除灰色false

答案1

如果没有钩子(对于较旧的安装),您可以复制并组合源文件中的frenchlinks定义:colorlinkshyperref.sty

\documentclass{article}
\usepackage{xcolor}
\usepackage[citecolor=gray]{hyperref}
\begin{document}
\makeatletter
\def\@pdfborder{0 0 0}%
\let\@pdfborderstyle\@empty
\def\Hy@colorlink#1{\begingroup\HyColor@UseColor#1%
\fontshape{\scdefault}\selectfont}%
\def\Hy@endcolorlink{\endgroup}%
\makeatother
\href{https://tex.stackexchange.com}{A Link To A Website}

A citation: \cite{book-minimal}
\bibliographystyle{apalike}
\bibliography{xampl}
\end{document}

在此处输入图片描述

答案2

(更新于 2023-10) frenchlinks替换颜色,这在 hyperref 中是相当硬编码的。在我看来,这个选项相当奇怪。

使用新的 pdfmanagement 您可以做到这一点,因为有许多挂钩:

\DocumentMetadata{}
\documentclass{article}
\usepackage{xcolor}
\usepackage{hyperref}
\hypersetup{colorlinks=true}
\ActivateGenericHook{hyp/link/link}
\AddToHook{hyp/link/link}{\scshape} %for other internal links
\AddToHook{hyp/link/cite}{\hypersetup{linkcolor=blue}} %cite links
\begin{document}

\section{abc}\label{test}
\cite{citekey} 

\nameref{test}

\begin{thebibliography}{9}
\bibitem[Author]{citekey} some cite
\end{thebibliography}

\end{document}

在此处输入图片描述

相关内容