1

It is indicated in the pdfx manual

To produce a validating PDF/X document,pdfx overrides internal macros while keeping colors associated with link anchors.

I can see the same claim in the answer here: pdfx - package leads to non-working hyperref links

But my minimal example (Luatex 2018) shows that any link is printed only in the surrounding colors.

\documentclass{article}
\usepackage[x-4]{pdfx} %option x-4 for print, a-1b for archive (also display)

%\usepackage{hyperref}, it is already included by pdfx
\hypersetup{ colorlinks, allcolors=blue}%

\begin{document}

\section{First}\label{first_section}

Check \ref{second_section} (it should be in {\color{blue}blue}).\\{\color{blue} Check \ref{second_section} (it just follows the surrounding color)}.

\section{Second}\label{second_section} 

\end{document}

enter image description here

If I change

\usepackage[x-4]{pdfx} 

to

\usepackage[a-1b]{pdfx} 

the blue link color (in the first line) appears again.

I have also used a CMYK color instead of blue, but no success:

\definecolor{amGrayCMYK}{cmyk}{0.45,0.34,0.34,0}

Any idea how to keep hyperref link colors (not the functionality) in PDF/X output?

3

pdfx with x-a loads hyperref with the option draft and this disables the link colors. There is no user level setting to get them back. You will either have to redefine \ref to add the colors, or redefine internal hyperref commands:

\documentclass{article}
\usepackage[x-4]{pdfx} %option x-4 for print, a-1b for archive (also display)
\hypersetup{colorlinks, allcolors=blue}%
\makeatletter
\AtBeginDocument{%
\def\hyper@link@[#1]#2#3#4{\textcolor{\@linkcolor}{#4}\Hy@xspace@end}%
}

\begin{document}


\section{First}\label{first_section}

Check \ref{second_section} (it should be in {\color{blue}blue}).\\{\color{blue} Check \ref{second_section} (it just follows the surrounding color)}.

\section{Second}\label{second_section}

\end{document}

enter image description here

  • Thanks a lot Ulrike! May I ask you to expand your answer to cover how to restore citecolor also? I have also problem with citecolor which I guessed should be the same as linkcolor (which seems is not). FYI: at the same time, considering your answer, I tried to use \hypersetup{draft=false} to trick pdfx. It worked for my minimal example but created problems with citations in the real-world document. – Shahryar Mar 28 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.