超链接的默认颜色更好

超链接的默认颜色更好

2021 年更新在新的驱动程序中hyperref我正在开发“LaTeX 标记 PDF“项目中我使用 Phelype Oleinik 建议的颜色作为默认颜色。所有其他建议都已添加为配色方案,可以通过选项进行选择。


有人抱怨说 的默认颜色hyperref不太好。所以现在您可以尝试更好的默认颜色。建议一组新颜色。最好的颜色要么是默认颜色(如果我们敢于更改它),要么是通过选项添加的,例如nicecolors

(还有一个anchorcolor选项,但是该颜色没有在任何地方使用所以我将其省略)。

您可以输入任何您想要的颜色,并使用您喜欢的语法。添加选项到xcolor或者加载其他包也是可以的。

\documentclass{article}
\usepackage{xcolor}
\usepackage[colorlinks]{hyperref}

%setup new colors
\hypersetup{
% linkcolor=
%,citecolor=
%,filecolor=
%,urlcolor=
%,menucolor=
%,runcolor=
%,linkbordercolor=
%,citebordercolor=
%,filebordercolor=
%,urlbordercolor=
%,menubordercolor=
%,runbordercolor=
}
\begin{document}
\section{hyperref colors / colorlinks}\label{sec}

\begin{tabular}{lll}
 default color               & example   \\\hline\\
 \textcolor{red}{red, linkcolor}  & \ref{sec} \\\\
 \textcolor{green}{green, citecolor}& \cite{cite} \\\\
 \textcolor{cyan}{cyan, filecolor} & \href{example-image.pdf}{file}\\\\
 \textcolor{magenta}{magenta, urlcolor}& \url{https://www.latex-project.org/}\\\\
 \textcolor{red}{red, menucolor}  & \Acrobatmenu{View}{View Something}\\\\
 \textcolor{cyan}{cyan, runcolor}  &  \href{run:sumatra}{run something}
\end{tabular}

\section{hyperref colors / border }
\makeatletter\def\@pdfborder{1 1 1} \def\HyColor@UseColor#1{}\makeatother

\begin{tabular}{lll}
 default color                    & example   \\\hline\\
 \textcolor{red}{red, linkbordercolor}  & \ref{sec} \\\\
 \textcolor{green}{green, citebordercolor}& \cite{cite} \\\\
 \textcolor{teal}{teal, filebordercolor} & \href{example-image.pdf}{file}\\\\
 \textcolor[rgb]{0,1,1}{rgb 0,1,1, urlbordercolor}& \url{https://www.latex-project.org/}\\\\
 \textcolor{red}{red, menubordercolor}  & \Acrobatmenu{View}{View Something}\\\\
 \textcolor[rgb]{0,0.7,0.7}{rgb 0,0.7,0.7, runbordercolor}  &  \href{run:sumatra}{run something}
\end{tabular}

\begin{thebibliography}{99}
\bibitem{cite} some text
\end{thebibliography}
\end{document}

在此处输入图片描述

答案1

这是一个建议(该default color列(不出所料)是默认颜色,并且该example列是我建议的颜色):

在此处输入图片描述

我尽量坚持使用较深的颜色,因为太亮的颜色,尤其是纯色黄色的#FFFF00), 但是也绿色的#00FF00) 和青色#00FFFF),阅读起来非常糟糕,无论是 PDF 打印版。请注意,上图中的菜单颜色仍然有点亮;黄色不适合放在白色背景上。...

我根据自己文档中使用的一些颜色选择了前三种颜色(一种红色、一种绿色和一种蓝色),并尝试选择其他三种颜色,以便它们与前三种颜色有足够的不同。边框颜色与文本颜色相同,只是它们与白色混合,这样当您看到边框时,边框不会刺眼。我还将边框的宽度从 改为10.3如果这是有效的选项。

我还对原来的颜色进行了调整,使它们看起来足够不同,适合患有三种严重色盲的人(使用彩色神谕):

绿色盲(绿盲):

在此处输入图片描述

红色盲(红盲):

在此处输入图片描述

蓝色盲(蓝盲):

在此处输入图片描述

我还选择了不太亮的颜色,这样文档的灰度打印也将清晰可读(尽管hidelinks在这种情况下是更好的选择)。最亮的颜色(View Something左栏中的文本)仍然比大约一半的默认颜色暗(结果可能因您计算亮度的方式而异)。

在此处输入图片描述

代码如下:

\documentclass{article}
\usepackage{xcolor}
\usepackage[margin=1.5cm]{geometry}
\usepackage{multicol}
\usepackage[colorlinks]{hyperref}

\def\tmp#1#2#3{%
  \definecolor{Hy#1color}{#2}{#3}%
  \hypersetup{#1color=Hy#1color}}
\tmp{link}{HTML}{800006}
\tmp{cite}{HTML}{2E7E2A}
\tmp{file}{HTML}{131877}
\tmp{url} {HTML}{8A0087}
\tmp{menu}{HTML}{727500}
\tmp{run} {HTML}{137776}
\def\tmp#1#2{%
  \colorlet{Hy#1bordercolor}{Hy#1color#2}%
  \hypersetup{#1bordercolor=Hy#1bordercolor}}
\tmp{link}{!60!white}
\tmp{cite}{!60!white}
\tmp{file}{!60!white}
\tmp{url} {!60!white}
\tmp{menu}{!60!white}
\tmp{run} {!60!white}

\begin{document}

\begin{multicols}{2}
\section{hyperref colors / colorlinks}\label{sec}

\begin{tabular}{lll}
 default color               & example   \\\hline\\
 \textcolor{red}{red, linkcolor}  & \ref{sec} \\\\
 \textcolor{green}{green, citecolor}& \cite{cite} \\\\
 \textcolor{cyan}{cyan, filecolor} & \href{example-image.pdf}{file}\\\\
 \textcolor{magenta}{magenta, urlcolor}& \url{www.latex-project.org}\\\\
 \textcolor{red}{red, menucolor}  & \Acrobatmenu{View}{View Something}\\\\
 \textcolor{cyan}{cyan, runcolor}  &  \href{run:sumatra}{run something}\\\\
\end{tabular}

You can read more in section~\ref{sec} and in~\cite{cite}. Both of which
contain a~\href{example-image.pdf}{file} that can also be found at
\url{www.latex-project.org}. Such file helps you \Acrobatmenu{View}{View
Something} or, alternatively \href{run:sumatra}{run something}, which is
rather nice.

\section{hyperref colors / border }
\makeatletter\def\@pdfborder{1 1 0.3} \def\HyColor@UseColor#1{}\makeatother

\begin{tabular}{lll}
 default color                    & example   \\\hline\\
 \textcolor{red}{red, linkbordercolor}  & \ref{sec} \\\\
 \textcolor{green}{green, citebordercolor}& \cite{cite} \\\\
 \textcolor{teal}{teal, filebordercolor} & \href{example-image.pdf}{file}\\\\
 \textcolor[rgb]{0,1,1}{rgb 0,1,1, urlbordercolor}& \url{www.latex-project.org}\\\\
 \textcolor{red}{red, menubordercolor}  & \Acrobatmenu{View}{View Something}\\\\
 \textcolor[rgb]{0,0.7,0.7}{rgb 0,0.7,0.7, runbordercolor}  &  \href{run:sumatra}{run something}\\\\
\end{tabular}

You can read more in section~\ref{sec} and in~\cite{cite}. Both of which
contain a~\href{example-image.pdf}{file} that can also be found at
\url{www.latex-project.org}. Such file helps you \Acrobatmenu{View}{View
Something} or, alternatively \href{run:sumatra}{run something}, which is
rather nice.

\end{multicols}

\begin{thebibliography}{99}
\bibitem{cite} some text
\end{thebibliography}
\end{document}

答案2

我个人的偏好是大多数链接应该是统一的深蓝色(在此为该选项投票)。

此外,默认应该是colorlinks而不是 border。边框不容易看到,而且在 macOS 上的 Preview.app 中会错误渲染(请参阅本文末尾的屏幕截图)。但是,默认情况下不会打印 border,因此有些人可能更喜欢它们而不是colorlinks


尽管如此,这里有一个建议,其中大多数类型的链接仍然可以区分。最常见的链接类型,即内部链接和引用,是当前使用的相同颜色的不同色调,以便熟悉这些颜色含义的人不会混淆。网络链接是蓝色的,因为这是网络上的事实标准。

屏幕截图来自 macOS 上的 Acrobat。

在此处输入图片描述

\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage[colorlinks]{hyperref}

%setup new colors
\hypersetup{
linkcolor=BrickRed
,citecolor=Green
,filecolor=Mulberry
,urlcolor=NavyBlue
,menucolor=BrickRed
,runcolor=Mulberry
,linkbordercolor=BrickRed
,citebordercolor=Green
,filebordercolor=Mulberry
,urlbordercolor=NavyBlue
,menubordercolor=BrickRed
,runbordercolor=Mulberry
}
\begin{document}
\section{hyperref colors / colorlinks}\label{sec}

\begin{tabular}{lll}
 default color               & example   \\\hline\\
 \textcolor{BrickRed}{BrickRed, linkcolor}  & \ref{sec} \\\\
 \textcolor{Green}{Green, citecolor}& \cite{cite} \\\\
 \textcolor{Mulberry}{Mulberry, filecolor} & \href{example-image.pdf}{file}\\\\
 \textcolor{NavyBlue}{NavyBlue, urlcolor}& \url{https://www.latex-project.org/}\\\\
 \textcolor{BrickRed}{BrickRed, menucolor}  & \Acrobatmenu{View}{View Something}\\\\
 \textcolor{Mulberry}{Mulberry, runcolor}  &  \href{run:sumatra}{run something}
\end{tabular}

\subsection*{Example text}

You can read more in section~\ref{sec} and in~\cite{cite}. Both of which
contain a~\href{example-image.pdf}{file} that can also be found at
\url{www.latex-project.org}. Such file helps you \Acrobatmenu{View}{View
Something} or, alternatively \href{run:sumatra}{run something}, which is
rather nice.


\section{hyperref colors / border }
\makeatletter\def\@pdfborder{1 1 1} \def\HyColor@UseColor#1{}\makeatother

\begin{tabular}{lll}
 default color                    & example   \\\hline\\
 \textcolor{BrickRed}{BrickRed, linkbordercolor}  & \ref{sec} \\\\
 \textcolor{Green}{Green, citebordercolor}& \cite{cite} \\\\
 \textcolor{Mulberry}{Mulberry, filebordercolor} & \href{example-image.pdf}{file}\\\\
 \textcolor{NavyBlue}{NavyBlue, urlbordercolor}& \url{https://www.latex-project.org/}\\\\
 \textcolor{BrickRed}{BrickRed, menubordercolor}  & \Acrobatmenu{View}{View Something}\\\\
 \textcolor{Mulberry}{Mulberry, runbordercolor}  &  \href{run:sumatra}{run something}
\end{tabular}

\subsection*{Example text}

You can read more in section~\ref{sec} and in~\cite{cite}. Both of which
contain a~\href{example-image.pdf}{file} that can also be found at
\url{www.latex-project.org}. Such file helps you \Acrobatmenu{View}{View
Something} or, alternatively \href{run:sumatra}{run something}, which is
rather nice.

\begin{thebibliography}{99}
\bibitem{cite} some text
\end{thebibliography}
\end{document}

以下是使用非视网膜屏幕时 macOS 上的 Preview.app 中经常发生的情况。Preview.app 是最常见的 PDF 查看器之一。因此,无论这是否是 Preview 中的错误,边框都不应是默认设置。colorlinks总是更好。

在此处输入图片描述

答案3

为了投票,我发布了第二个答案,其中大多数链接类型具有相同的颜色。我NavyBlue之所以选择这样做,是因为蓝色是网络上的典型链接颜色。那些可能被视为安全问题的链接类型可能有另一种更警示的颜色,例如Red。我将让其他人决定应该以这种方式突出显示哪些链接类型。对于此演示,我选择了文件、菜单和运行。有些人可能认为文件链接更类似于 url 链接而不是运行链接,因此可能更喜欢它们是蓝色的。

在此处输入图片描述

\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage[colorlinks]{hyperref}

%setup new colors
\hypersetup{
linkcolor=NavyBlue
,citecolor=NavyBlue
,filecolor=Red
,urlcolor=NavyBlue
,menucolor=Red
,runcolor=Red
,linkbordercolor=NavyBlue
,citebordercolor=NavyBlue
,filebordercolor=Red
,urlbordercolor=NavyBlue
,menubordercolor=Red
,runbordercolor=Red
}
\begin{document}
\section{hyperref colors / colorlinks}\label{sec}

\begin{tabular}{lll}
 default color               & example   \\\hline\\
 \textcolor{NavyBlue}{NavyBlue, linkcolor}  & \ref{sec} \\\\
 \textcolor{NavyBlue}{NavyBlue, citecolor}& \cite{cite} \\\\
 \textcolor{Red}{Red, filecolor} & \href{example-image.pdf}{file}\\\\
 \textcolor{NavyBlue}{NavyBlue, urlcolor}& \url{https://www.latex-project.org/}\\\\
 \textcolor{Red}{Red, menucolor}  & \Acrobatmenu{View}{View Something}\\\\
 \textcolor{Red}{Red, runcolor}  &  \href{run:sumatra}{run something}
\end{tabular}

\section{hyperref colors / border }
\makeatletter\def\@pdfborder{1 1 1} \def\HyColor@UseColor#1{}\makeatother

\begin{tabular}{lll}
 default color                    & example   \\\hline\\
 \textcolor{NavyBlue}{NavyBlue, linkbordercolor}  & \ref{sec} \\\\
 \textcolor{NavyBlue}{NavyBlue, citebordercolor}& \cite{cite} \\\\
 \textcolor{Red}{Red, filebordercolor} & \href{example-image.pdf}{file}\\\\
 \textcolor{NavyBlue}{NavyBlue, urlbordercolor}& \url{https://www.latex-project.org/}\\\\
 \textcolor{Red}{Red, menubordercolor}  & \Acrobatmenu{Red}{View Something}\\\\
 \textcolor{Red}{Red, runbordercolor}  &  \href{run:sumatra}{run something}
\end{tabular}

\begin{thebibliography}{99}
\bibitem{cite} some text
\end{thebibliography}
\end{document}

答案4

我喜欢 Phelypes 的建议。只是想添加一些我们用于几本书的建议(这些建议也可以作为 PDF 文件使用)。我们总是使用 colorlinks 选项,并且不区分文件和 url。

它们要么是不同的颜色,要么是默认颜色的较暗版本,主要是为了不影响阅读体验而选择。

\documentclass{article}
\usepackage{xcolor}
\usepackage[colorlinks]{hyperref}

%setup new colors
\hypersetup{
linkcolor={[rgb]{0,0.2,0.6}},
citecolor={[rgb]{0,0.6,0.2}},
filecolor={[rgb]{0.8,0,0.8}},
urlcolor={[rgb]{0.8,0,0.8}},
runcolor={[rgb]{0.8,0,0.8}},  % defaults to filecolor but it missing an
                              % expansion for this syntax
menucolor={[rgb]{0,0.2,0.6}}, % I never set or use this, so we'll see
                              % it to link color
linkbordercolor={[rgb]{0,0.2,0.6}},
citebordercolor={[rgb]{0,0.6,0.2}},
filebordercolor={[rgb]{0.8,0,0.8}},
urlbordercolor={[rgb]{0.8,0,0.8}},
runbordercolor={[rgb]{0.8,0,0.8}},
menubordercolor={[rgb]{0,0.2,0.6}}, 
}
\begin{document}
\section{hyperref colors / colorlinks}\label{sec}

\begin{tabular}{lll}
 default color               & example   \\\hline\\
 \textcolor{red}{red, linkcolor}  & \ref{sec} \\\\
 \textcolor{green}{green, citecolor}& \cite{cite} \\\\
 \textcolor{cyan}{cyan, filecolor} & \href{example-image.pdf}{file}\\\\
 \textcolor{magenta}{magenta, urlcolor}& \url{https://www.latex-project.org/}\\\\
 \textcolor{red}{red, menucolor}  & \Acrobatmenu{View}{View Something}\\\\
 \textcolor{cyan}{cyan, runcolor}  &  \href{run:sumatra}{run something}
\end{tabular}

\section{hyperref colors / border }
\makeatletter\def\@pdfborder{1 1 1} \def\HyColor@UseColor#1{}\makeatother

\begin{tabular}{lll}
 default color                    & example   \\\hline\\
 \textcolor{red}{red, linkbordercolor}  & \ref{sec} \\\\
 \textcolor{green}{green, citebordercolor}& \cite{cite} \\\\
 \textcolor{teal}{teal, filebordercolor} & \href{example-image.pdf}{file}\\\\
 \textcolor[rgb]{0,1,1}{rgb 0,1,1, urlbordercolor}& \url{https://www.latex-project.org/}\\\\
 \textcolor{red}{red, menubordercolor}  & \Acrobatmenu{View}{View Something}\\\\
 \textcolor[rgb]{0,0.7,0.7}{rgb 0,0.7,0.7, runbordercolor}  &  \href{run:sumatra}{run something}
\end{tabular}

\begin{thebibliography}{99}
\bibitem{cite} some text
\end{thebibliography}
\end{document}

在此处输入图片描述

相关内容