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:
\documentclass[12pt,oneside]{book}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage[log-declarations=false]{xparse}%To enable better command creation
\usepackage[%ALWAYS LOAD THIS LAST
colorlinks=false,
pdfborder={0 0 0},
% pdftitle=\booktitle,
% pdfauthor=\theauthor,
pdfpagemode=UseNone,
bookmarksopen=true,
bookmarks=true
]{hyperref}
\colorlet{Conds}{Black}
\colorlet{Terms}{Green}
\newenvironment{terms}{\small\bfseries\color{Terms}}{}
\newenvironment{conds}{\ttfamily\color{Conds}}{}
\newcommand\envtype{}
\DeclareDocumentCommand \Link {o m O{}}{%
\begin{\envtype}%
\IfNoValueTF{#1}{\lowercase{\hyperlink{\envtype:#2}}{#2#3}}{\lowercase{\hyperlink{\envtype:#1}}{#2#3}}%
\end{\envtype}%
}
%%%%Specific Links:
\newcommand{\term}{\renewcommand{\envtype}{terms}\Link}
\newcommand{\cond}{\renewcommand{\envtype}{conds}\Link}
%%(Many other link types cut)
\begin{document}
Lots of text. \term{Test} this if you can. Trying it with cooltooltips \cond{foo}[bars] everything up.
\newpage
\hypertarget{terms:test}{Here's my link: Test is a term.}
\hypertarget{conds:foo}{Here's another link: Foo is a condition.}
\end{document}
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.
Best Answer
Here is a generic solution, implementing the command
It is similar to
hyperref
'scommand, 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.