Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to generate tooltips in a PDF that will be accessible somehow on a tablet PDF reader, specifically on any iPad reader. So far, I have tried the packages pdfcomment, cooltooltips, and fancytooltips, but none of these were accessible on the iPad with Adobe Reader as a reference.

I am aware that tooltips on a tablet don't make much sense since there is no such thing as a mouse over, but maybe there is something similar that works with a box that opens and closes on click or something. For example, I found something similar for the Safari browser which uses JavaScript's jQuery:

http://code.drewwilson.com/entry/tiptip-jquery-plugin

Is there any way I could get something like that working or can you think of a reasonable work-around? Or does that actually work already and am I just using the wrong PDF viewer/settings/anything? My current solution would be to use notes at the end of the PDF and hyperref to jump between pages, but I'd like to have something more elegant.

Thank you for any hints or comments.

share|improve this question
    
Did you try GoodReader app? It is the most capable pdf reader to my knowledge. In fact, it allows to add notes and highlights to any pdf in a format compatible with (desktop) Adobe Reader, so I guess it should show the ones generated with the packages you mention. –  JLDiaz Nov 28 '12 at 17:27
    
Mmm.. I tried opening the documentation of cooltooltip package in GoodReader. I was unable to read the tooltip, although the text is displayed somewhat different (perhaps because of it is a link). So no, GoodReader is of no help either. –  JLDiaz Nov 28 '12 at 17:33
    
Did you try to view a PDF file with some OCG (Optional Content Group) layers? –  Paul Gaborit Nov 28 '12 at 23:13
    
I have tried that but I can't get any context menu on the iPad A-Reader which would allow me activate or deactivate layers. I have opened a PDF with OCG and it naturally shows all layers. So some activation/deactivation magic might do the trick, but I don't know how I would do that. –  Michael Nov 29 '12 at 10:57

1 Answer 1

The minimal tooltip macro definition below uses mouse-down and up events in addition to roll-over and out for showing/hiding the tooltip. This works in Adobe Reader on my PC. Take it as a proof of concept if it works on a tablet or phone too. In case of multiline tooltips, the tip text should be put into a \parbox[b]{}{}.

\documentclass{article}
\usepackage{color}
\usepackage{calc}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% usage: \tooltip{<link text>}{<tip text>}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\tooltip[2]{%
  \leavevmode%
  \immediate\pdfobj{<</S/Hide/T (tip\thetcnt)/H false>>}%
  \edef\showaction{\the\pdflastobj\space 0 R}%
  \immediate\pdfobj{<</S/Hide/T (tip\thetcnt)/H true>>}%
  \edef\hideaction{\the\pdflastobj\space 0 R}%
  \pdfstartlink
    user{
      /FT/Btn/Ff 65536/T(lnk\thetcnt)/H/N
      /Subtype/Widget/AA <<
        /D \showaction /U \hideaction
        /E \showaction /X \hideaction
        /PO \hideaction
      >>
    }{\color{red}#1}%
  \pdfendlink%
  \sbox\tiptext{\colorbox[gray]{0.8}{#2}}%
  \edef\twd{\the\wd\tiptext}%
  \edef\tht{\the\ht\tiptext}%
  \edef\tdp{\the\dp\tiptext}%
  \immediate\pdfxform\tiptext%
  \raisebox{\heightof{#1}}{%
    \pdfannot width \twd height \tht depth \tdp {
      /Subtype/Widget/FT/Btn/Ff 65537/T (tip\thetcnt)
      /AP <</N \the\pdflastxform\space 0 R>>
    }%
  }%    
  \stepcounter{tcnt}%
}
\newsavebox\tiptext\newcounter{tcnt}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}\Huge
  Einstein's \tooltip{formula}{$E=m c^2$} is well known.
  Another famous formula is due to \tooltip{Pythagoras}{$a^2+b^2=c^2$}.
\end{document}
share|improve this answer
    
Thanks for your help. I have tried your implementation in the A-Reader on my PC and it works like a charm. However, when I tried it on the Adobe Reader on the iPad, the tooltips were initially all activated and when I tried to click on one, the Reader crashed with no error report whatsoever :-( –  Michael Nov 29 '12 at 10:44
    
The PDF specific stuff in the code is quite conforming to the official spec. So the mobile version of AR must be bugged. The tips should be hidden during the page-open event as specified by the /PO entry. Did you try other pdf readers? –  AlexG Nov 29 '12 at 11:16
    
@Michael: What happens if you delete /E \showaction /X \hideaction from the code and recompile? Maybe registering the actions for roll-over and out causes problems. –  AlexG Nov 29 '12 at 12:06
    
I have recompiled without /E \showaction /X \hideaction but Adobe Reader still crashes on click. I have tried several other readers (DjVu Reader, GoodReader, iAnnotate PDF). They don't crash, but I cannot 'click' on the highlighted words. Touching the screen at those locations seems to do nothing. –  Michael Nov 29 '12 at 12:33
    
@Michael: What about initial visibility? Are the tips hidden as desired when the document/page is being opened? What about Foxit Reader? –  AlexG Nov 29 '12 at 14:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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