7

I'm trying to get a short description of a picture to appear when the cursor is hovering over this picture in the pdf file. I read that this might be possible using fancytooltips but I have to say that after reading through the documentation and some "basic" example, I am not convinced. Could someone explain to me how to modify the following code to get "this is the description" appearing next to the cursor, when this one is above the picture (Is it the same process for another kind of element, ie. pop-up above a word or a paragraph)?

\documentclass{article}
\usepackage[demo]{graphicx}

\begin{document}

\includegraphics[width=3cm,height=5cm]{example}

\end{document}

What are the options I have to customize this pop-up window (shape, background color, persistence, etc.) ?

  • I think without the tools provided by fancytooltips you simply can not. – Claudio Fiandrino Jul 4 '13 at 14:54
  • @ClaudioFiandrino OK. Do you have an idea then how to do it with fancytooltips? – Ludovic C. Jul 4 '13 at 14:59
  • @ClaudioFiandrino: fancytooltips is not required. See tex.stackexchange.com/a/120005 – AlexG Jul 4 '13 at 15:00
  • @AlexG: just upvoted: very nice suggestion, I wasn't aware of that answer. – Claudio Fiandrino Jul 4 '13 at 15:03
10

You can use the \tooltip macro defined in https://tex.stackexchange.com/a/120005.

\tooltip{\includegraphics{example}}[green!20]{this is the description}

It works with all common drivers (pdflatex, latex->dvips->ps2pdf, xelatex, ...). Moreover, the pop-up is draggable.

The box background colour of the pop-up box as well as the text colour of the link can be set by optional args. Of course, since the link is an included graphic here, changing the link text colour has no effect.

NOTE: This solution requires to have an updated system (TeXLive-2013 or other) and to use AdobeReader. For sure it won't work with Evince reader.

  • That seems to be really promising for my purpose, but when using your macro (the part between the %% lines in the link you have provided) and just inserting your line (tooltip{...}) in my MWE, I got an error concerning an undefined control sequence \tooltip. #1#2#3#4 etc. The output pdf is a white page with some writings on it. Apparently it is the \tpPdfLink command which is not working. Any ideas how to fix that? – Ludovic C. Jul 4 '13 at 15:18
  • @LudovicC. Which TeX system do you use? Package media9 may need to be installed first. I recommend TeXLive-2013. But MiKTeX-2.9 with sync'ed database and updated packages should do as well. – AlexG Jul 4 '13 at 20:02
  • Okay I am currently running TeXLive-2012 and I am trying to upgrade to TeXLive-2013... Will I need to install the media9 package with TeXLive-2013? – Ludovic C. Jul 4 '13 at 20:06
  • @LudovicC. You could try to install media9 in TeXLive-2012 via tlmgr, l3kernel and l3packages may need to be updated too. But an upgrade to TeXLive-2013 is definitely better, as TL-2012 is frozen. – AlexG Jul 4 '13 at 20:33
  • I have now TeXLive-2013 and the media9 package and the file compiles properly. However on the output there is no box appearing when the cursor hovers over the picture. Is it possible that the problem comes from my pdf reader (Evince under Ubuntu)? Or is Evince supported by your macro? – Ludovic C. Jul 4 '13 at 20:36
8

While not as fancy as the tooltip in the answer from @AlexG, you can have contents appear on mouse over/click events using ocg-p:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{ocg-p}

\begin{document}

\toggleocgs[triggerocg=allactions]{1}{%
    \includegraphics[width=3cm,height=5cm]{example}%
}%
\begin{ocg}[listintoolbar=never,printocg=never,exportocg=never]{tooltip}{1}{0}
This is a tooltip
\end{ocg}

\end{document}
  • Using PDF layers for this purpose is a nice option. Do you know of a PDF reader other than Adobe Reader, preferably open-source, which would correctly display this example? I tried evince-2.32.0 but it didn't work out. Maybe it is too old version? – AlexG Jul 5 '13 at 6:50
  • @AlexG: I don't know of any readers apart from Adobe Reader XI that displays you example or mine correctly. I have tried PDF XChangeViewer 2.0 and SumatraPDF 2.3.2 as well as the pdf-viewer build into Chrome. – Martin Heller Jul 5 '13 at 8:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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