I work as a Physics teacher and I am writing a "Problem-Solution-Book" with
hyperlinks from problems to solutions and backreferencing — all of it works pretty good.
Now I wanted to introduce something like a "Hint" – text at the problem header which is used as a tooltip, indicating some hints for possible ways to the solution (apart from directly clicking the "solution" link ;-))
I wonder whether it is possible to use LaTeX
code in the second argument of
the \pdftooltip
command from pdfcomment
package by Josef Kleber. I am using pdflatex
and pdfcomment
version 2.3a.
What I want to do is:
Using the \pdftooltip
command and as the mouse moves over the relevant portion a tooltip box with, say, blue background colour, appears.
Here is a minimal working example:
\documentclass{book}
\usepackage{xcolor}
\usepackage{pdfcomment}
\begin{document}
\pdftooltip{foo}{%
\colorbox{blue}{%
Hint: What is the definition of foo?}% End of Colorbox
}% End of pdftooltip command
\end{document}
(Well it compiles without complaining, but it does not give the expected result 🙁 )
However, there is no blue background colour but an almost verbatim
text of colorbox
… blue etc., bracketed by (presumably) pdf code.
I know, that there is the possibility of mathematical markup in pdftooltips
, but what about "eye candy"? 😉
Edited: I know of the packages fancytooltips
or cooltooltips
but they do not match my intents
Best Answer
If the mouse is moved over 'foo' the tip is shown and it disappears immediately when the mouse is moved out.
In order to drag the tip around, 'foo' must be clicked. The tip remains visible. Move the mouse over the tip, click it and move it around. Click the tip once more to pin it down at the current position.
To hide the tip, wipe over 'foo' with the mouse.
Link text and tip text colours are optional. Besides
pdftex
, all common drivers (xetex
,dvips
, ...) are supported.It is recommended that
<tip text>
is not wider than\linewidth
,<tiptext>
should be put into a\parbox
if necessary.(Code by M. Scharrer from https://tex.stackexchange.com/a/17808 is used to compute initial left-shift for wider tip text boxes.)