I really don't like the red box which indicates a link. I would like to have some filled rectangle rendered which shows up when someone hovers. Obviously before the text gets rendered as you cannot see whats written there then. To get a better sight into my idea I want something like this per link if you hover it:

But a clean white if you do not hover it. How can I make this happen?

  • Hi and welcome, I like the red borders in my files. I don't want the reader to hunt for links like the toc is some sort of minigame. As it is likely, that every entry in the toc is linked, you can locally switch off those borders and reset them later.
    – Johannes_B
    Dec 23, 2014 at 16:29
  • 1
    I'm leaning towards this only being possible via JavaScript outside of LaTeX...
    – Werner
    Dec 23, 2014 at 16:58
  • 6
    I don't want the links to look like links if they are not hovered. Whats the problem?
    – NaCl
    Dec 23, 2014 at 19:42
  • 3
    The problem is that it is not easy, and, I believe, heavily dependent on which viewer you use. See package fancytooltips, which (I believe) only works for Adobe Reader/Acrobat (no good for me). There's also cooltooltips, which is an explicitly "dead" package. Maybe those work for your needs. If not, as with all free software, there's no "problem" if (1) someone else has done what you want already, and/or (2) you do it yourself.
    – jon
    Dec 23, 2014 at 20:24
  • 1
    Have you considered specifying the linktocpage option when loading hyperref? Doing so makes the page number rather than the ToC/LoF/LoT entry into a hyperlink to the corresponding item in the body of the text. Choosing this route would not directly achieve your stated objective, but it is a very effective way of providing hyperlinks in a way that's not too obtrusive.
    – Mico
    Dec 26, 2014 at 23:32

1 Answer 1


This is only a partial answer, but it is kind of a roadmap how this could be achieved.

First, note that the hyperref package does not offer a "standard way" to do such a thing. It only offers border styles for links (including underlining a link as explained here: How can I have colored and underlined links with hyperref?). One of the reasons for this might be that the PDF standard offers such border styles directly for link annotations, but to obtain a non-border style, you need to use appearance streams and form XObjects instead. The documentation of such streams and objects can be found here: http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_reference_1-7.pdf (start at page 612 for appearance streams and page 355 for form XObjects)

What needs to be done is the following: Find out how the PDF output must look like for a link to have a background color (fortunately, appearance streams already offer three different modes, including one for being inactive and one for hovering over the object; thus, the "action logic" you need is already implemented within the PDF standard and you only need to provide the attributes implementing your desired look).

Then change the corresponding part of the hyperref package by redefining some of its commands as in the "automatic" part of this answer: How can I have colored and underlined links with hyperref?

You can find the source code of the hyperref package here: http://www.ctan.org/pkg/hyperref

Since both the PDF standard and the hyperref package are quite huge, it might involve a significant amount of time just to find the right attributes and commands where to plug these things together, though.

In any case, such a solution might not work with every PDF viewer as most of them do not implement everything that is written in the PDF standard. As long as you only use background color, however, it might work for many viewers (but no guarantees given).

  • 1
    You should probably point out that the results are unlikely to work in anything but Adobe's products. (I think this is going to be true of any answer so this isn't a criticism of your approach in particular - just a qualification I think any answer should include.)
    – cfr
    Dec 28, 2014 at 4:11
  • I'm not so sure that only Adobe's products will support this - I tried a little bit with PDF-XChange Viewer (en.wikipedia.org/wiki/PDF-XChange_Viewer), which can also add annotations with background color (text marking). This is also displayed with, e.g., SumatraPDF. So as long it is only about background color, it might actually work with more readers. However, it is of course true that most PDF viewers do not implement everything that is written in the PDF standard. I will add a corresponding remark. Dec 28, 2014 at 9:14
  • Sorry. Yes. You are probably right. I really just meant that you can't count on it working in other viewers (without testing them).
    – cfr
    Dec 28, 2014 at 14:21

You must log in to answer this question.

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