5

Using the following bit of code in an otherwise black text:

\color[HTML]{636060}27.~Mai/1.~Juni: Gegenregierung in Kanton unter Sun Ke (☞~S.~\pageref{bio:SunKe}). Diese wird im Dez. von Nanking kooptiert.

produces the required grey paragraph, except that the referenced page number is still displayed in black.

The relevant line in the preamble is:

\usepackage[colorlinks,filecolor=black,linkcolor=black,citecolor=black,urlcolor=black,breaklinks,pdfa]{hyperref}

changing that to e.g.: \usepackage[colorlinks,filecolor=black, %linkcolor=black, citecolor=black,urlcolor=black,breaklinks,pdfa]{hyperref}

of course defaults ALL references to red. As far as the hyperref documentation is concerned “23 Localized nullifying of package” appears to be relevant. I can't make sense of that code.

Summing up the question: Is there a (simple) way of definig linkcolor (here [HTML]{636060}) for a single/few instances only?

1

1 Answer 1

5

You could change the link color locally to another color:

{\hypersetup{linkcolor=red}\pageref{...}}

With the special color . the current text color is used:

{\color{red} Text \hypersetup{linkcolor=.}\pageref{...}}

Maybe you can use linkcolor=. for the document:

\documentclass{article}
\usepackage{xcolor}
\usepackage[colorlinks,breaklinks,pdfa,
  linkcolor=.
]{hyperref}

\definecolor{specialtext}{HTML}{636060}

\begin{document}
\section{Color test}
\label{sec:test}

Text

Black link: \pageref{sec:test}

\textcolor{red}{Red text with red link: \pageref{sec:test}}

{\color{specialtext}Gray text with gray link: \pageref{sec:test}}

Black link again: \pageref{sec:test}
\end{document}

Result:

enter image description here

3
  • Works fine as suggested.
    – AdiMeymuc
    Jul 24, 2017 at 11:07
  • 1
    I think in your second example, where you use the dot operator you also have to use linkcolor instead of the present color. at least it didn't work for me with just color. Aug 31, 2020 at 11:03
  • @NathanaelSkrepek Thanks for the hint. I have changed it.
    – esdd
    Sep 1, 2020 at 8:51

Not the answer you're looking for? Browse other questions tagged .