I have a PDF that is heavily internally linked. (I use terms and link them to the appendix definition with \term{termname}{displaytext}, which uses \hyperlink from the hyperref package.) I'm trying to create mouseover text to be part of that command.

(1) Is there a way inside hyperref to have a mouseover for \hyperlink?

I have tried cooltooltips, but it creates URL hyperlinks, not internal reference links, so it won't work with what I want to do.

(2) Is there a way to make cooltooltips create an internal link instead of a URL link?

I've also examined the tooltip code published on several answers (but not as a package) by a user, where he creates a \tooltip command. Unfortunately, his command nulls out my links. (I've tried \tooltop{\term{name}{display}} and \term{name}{\tooltip{display}}. The internal links don't work.)

(3) Is there a way to modify that code so that it accepts an internal reference argument?

TLDR version: I want to create a command \term{internal link}{display}{mouseover}, and none of the existing packages seem to allow this.

Added code example:


\usepackage[log-declarations=false]{xparse}%To enable better command creation
        pdfborder={0 0 0},
%        pdftitle=\booktitle,
%        pdfauthor=\theauthor,



\DeclareDocumentCommand \Link {o m O{}}{%

%%%%Specific Links:
%%(Many other link types cut)

Lots of text. \term{Test} this if you can. Trying it with cooltooltips \cond{foo}[bars] everything up.

\hypertarget{terms:test}{Here's my link: Test is a term.}

\hypertarget{conds:foo}{Here's another link: Foo is a condition.}

The reason for the complicated \Link command is two-fold: First, it handles the \lowercase problem correctly, allowing me to always reference the lowercased version for the link. Secondly, I have 5 types of keywords, each with their own formatting, all of which use \Link, and coding it once makes the document work consistently.

  • 1
    Somewhat related: tex.stackexchange.com/questions/119988/…
    – user31729
    Sep 8, 2014 at 11:55
  • @ChristianHupfer Knew you'd come up with that one. ;-) Didn't work on my TeX Distro which is fully up to date. That's not version-dependent of JS, right?
    – 1010011010
    Sep 8, 2014 at 12:01
  • @1010011010: I did not tested it for a while ;-) Just test it ... it works, apart from the dragging
    – user31729
    Sep 8, 2014 at 12:01
  • @JKreft Could you post some compilable code example using your \term macro? Maybe there is a way (some kind of workaround or solution) to achieve what you are after.
    – AlexG
    Sep 8, 2014 at 13:25
  • Alex: Here's the code I use right now (stripped down to essentials). I would be open to rewriting \Link which drives my links, if I can find a way to get it to work with both tooltips and internal links in the document.
    – JKreft
    Sep 8, 2014 at 13:44

1 Answer 1


Here is a generic solution, implementing the command


It is similar to hyperref's


command, except that the new command has an additional 3rd mandatory argument {<tiptext>} which provides the tip text to be shown when the mouse hovers over the link.

Optional arguments [<linkcolour>] and [<tipboxcolour>] do what they are supposed to do.

The example contains two hyperlinks with tip text. One of them makes use of \parbox to produce multiline tip text.



% usage:
% \hyperlinkWithTip{<destination>}[<linkcolour>]{<linktext>}[<tipboxcolour>]{<tiptext>}


      /E<</S/SetOCGState/State [/ON \ocgbase@last@ocg]>>%
      /X<</S/SetOCGState/State [/OFF \ocgbase@last@ocg]>>%
      /U<</S/SetOCGState/State [/OFF \ocgbase@last@ocg]/Next<</S/GoTo/D (#1)>>>>%
      /Subtype/Widget/FT/Btn/Ff 65537/T (tip:\thetcnt)%
      /AP<</N \tpPdfLastXform>>%
      /MK<</TP 1/I \tpPdfLastXform/IF<</S/A/FB true/A [0.0 0.0]>>>>%
      /OC \ocgbase@last@ocg
  \begin{tikzpicture}[overlay,remember picture]
    \path let \p0 = (0,0), \p1 = (current page.east) in


Lots of text. \hyperlinkWithTip{test}{Test}{To be explained on the next page} this if you can.

Lots of text. Another \hyperlinkWithTip{testB}{test}{\parbox[b]{0.5\linewidth}{This is a longer text. Don't miss the explanation given on the next page.}} if you wish.

\hypertarget{test}{Here's my link destination.}

\hypertarget{testB}{Yet another link destination.}

  • Thanks a bunch, AlexG. This is what I needed. In case I get too creative, what are the limitations of what I should put in a tooltip? Short text seems to work fine, long text appears in one long line. Can I force it to auto-wrap? If not, I can work with short text instead.
    – JKreft
    Sep 11, 2014 at 7:32
  • @JKreft: longer <tiptext> should go into a \parbox of predefined length. Of course, the parbox shouldn't be wider than linewidth of the main text. Apart from this, there is no limitation. You can even use \includegraphics as tip content.
    – AlexG
    Sep 11, 2014 at 7:38
  • @JKreft I improved the implementation, removing the need for JavaScript, and added a multiline tip text example (\parbox). However, still AR required for viewing.
    – AlexG
    Sep 11, 2014 at 8:16
  • Thank you! Letting people mouseover keywords in my rulebook for a definition is going to improve readability so much.
    – JKreft
    Sep 11, 2014 at 9:25
  • This answer is not working any more. It seems to me, that I am responsible for this, because I initiaded changes to ocgx2....:((( Mar 5, 2016 at 8:46

You must log in to answer this question.

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