TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I like having my hyperref hyperlinks a different colour, so it's obvious that they are links. But when I print a copy of the PDF, I don't want the links to be coloured, because you can't click them, so it doesn't matter and it's distracting.

Other than just having a separate "for printing" version of the PDF where I turn off the hyperlinks, is there a way to have the printed version come out without the coloured links?

share|improve this question
up vote 62 down vote accepted

Yes. Use


This option must be given when loading hyperref. You cannot give it in \hypersetup.

With this option hypreref will make the colorlinks as Optional Contents Groups (OCG) with /PrintState/OFF and /ViewState/ON. Your pdf reader needs to support OCG.

Also, the default behaviour of hyperref is to draw a coloured box around links. This box does not print.

share|improve this answer
The ocgcolorlinks does indeed colour the links for the screen version and leave them black for the printed version, but it has some downsides: the links cannot break across lines; any spaces within the links are set at their natural width and not stretched or shrunk to match with the surrounding text. Therefore ocgcolorlinks is really only a good option when the links are short, unbreakable, single words. I've been pondering if there is a way to use the power of the soul package to get around these restrictions, but I haven't spent a lot of time on it. – Lev Bishop Oct 22 '10 at 23:42
(Yeah I should have mentioned that I changed the link behaviour from "ugly as hell primary colour boxes" to "sexy subtle dark coloured text") – Seamus Oct 23 '10 at 12:32
Perhaps you could incorporate Lev Bishop's comment into your answer, I think it's worth making clear the option has its downsides... – Seamus Oct 23 '10 at 12:39
Apropos my older comment, I've actually implemented a hack/patch to hyperref that addresses the two downsides Lev mentioned in his comment. I've emailed the maintainers of hyperref the code; I haven't heard from them yet. I could post the code here if people were interested in testing it themselves, but I make no guarantees to its robustness! :) It should work for any text that appears in a URL, but wouldn't work for, say, rules or graphics content...but those can't go in a URL anyway. – Ben Lerner Feb 11 '12 at 6:09
@LevBishop Wow, this is amazing. This is totally OT but could this OCG feature in principle be used to have a color plot on screen but print a dotted line b/w plot? Would also be useful to print photos in a dedicated high-contrast black and white version. Of course color printers are a problem but I don't think there's a PDF feature to solve that problem. Would still be good for journals that require b/w images but put the same PDF online. – Christian May 17 '12 at 13:53

Try the (experimental) option ocgcolorlinks to the hyperref package. I don't think it's documented in the manual, but see http://www.tug.org/applications/hyperref/ftp/README for a description.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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