36

Influenced by Elsevier's Article of the future and this blog post where someone writes an article with Apple's iAuthor and gets many functionalities (clicking on references show a balloon with the given reference, or previous definitions and theorems, etc...).

I am conscient of the existence of acrotex and the many hyper-referencing capabilities it offers, quizzes, etc, but can something like these "floating balloons" can be implemented in pdf with latex? It would be interesting as having a free substitute for Apple software is always a good idea.

5
  • 9
    pgfplots uses javascript to allow dynamic interaction with plots. While I wrote that stuff, I stumbled over the problem that you cannot modify the document object model unless the complete document is signed. That, in turn is impossible with pdftex as it seems (?). Recently, I found that it might be possible with dvipdfmx - perhaps that would be an option. Nov 28, 2012 at 18:38
  • I don’t know, whether I’ve misunderstood you, but see package pdfcomment for its features and answer(s) to the question Mouseover events in beamer: hovering on \eqref and a comment containing the original equation popping up.
    – Speravir
    Dec 2, 2012 at 1:17
  • To the OP: I put the bounty because I find this issue interesting, but I would prefer to award it to the answer accepted by you. Maybe you could comment on the existing answers whether or not they meet your interest, or what should be enhanced. Dec 8, 2012 at 5:51
  • Huh, so article of the future domain was allowed to lapse (if I search for the Elseiver site even their link is broken). Someone should buy it and do something amusing with it. Feb 5, 2021 at 8:57

3 Answers 3

19
+100

Note: incoming version 0.5 of ocgx package uses ocg-p package (instead of ocg.sty from documentation of Asymptote).

Here is a very simple example using ocgx package and TikZ. You can click on equation to show its name if your PDF viewer is compatible with OCGs (like Adobe Reader, Foxit Reader, Evince...).

(Note: this example requires two compilations.)

enter image description here

enter image description here

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{shapes.callouts}
\usetikzlibrary{ocgx}

\newcommand{\tikzmark}[1]%
{\tikz[overlay,baseline,remember picture]\coordinate(#1);}

\begin{document}
\begin{frame}
  \switchocg{mee}{$E = mc^2$}\tikzmark{mee}

  \begin{tikzpicture}[overlay,remember picture]
    \begin{scope}[ocg={ref=mee,status=invisible,name=Mass Energy Equivalence}]
      \node[rectangle callout,callout absolute pointer=(mee),fill=orange]
      at ([shift={(+3,+1)}]mee) {Mass Energy Equivalence};
    \end{scope}
  \end{tikzpicture}

\end{frame}
\end{document}
12
  • See my answer to Mouseover events in beamer: hovering on \eqref and a comment containing the original equation popping up: “The package fancytooltips requires the package ocg …”.
    – Speravir
    Dec 2, 2012 at 1:18
  • @HarishKumar The ocg.sty files comes from asymptote documentation... Dec 2, 2012 at 1:23
  • @Speravir: * jumping to the link:
    – user11232
    Dec 2, 2012 at 1:24
  • @PaulGaborit: very nice solution and, BTW, thanks for the ocgx package (I used it for my thesis presentation in a plot to explain better some curves with a great success). I've adapted your solution into Explanatory bubbles in beamer to have basically two commands for doing the job. Oh.. forgot: +1 of course :) Dec 5, 2012 at 9:46
  • Cool package, indeed. I especially like the non-JavaScript take that would free us from Acrobat/Reader. Are you aware of any non-Adobe PDF reader for OSX that can deal with OCGs?
    – Daniel
    Dec 7, 2012 at 17:57
13

I don't know if you are looking for a purely LaTeX approach. If that is what you want, then it seems Paul Gaborit's ocgx package is the way to go. But you tagged your question as acrotex which uses javascript to enable its mouseover features. The manuals of acrotex also have mouseover features. In Mouseover events in beamer: hovering on \eqref and a comment containing the original equation popping up I used fancytooltips which also uses acrotex.

Looking at the pdf's you linked to, it seems that some javascript magic was also implemented. My answer and Speravir's additional answer to Mouseover will greatly help in this case. There are also a lot of examples provided in the devloper's site: http://user.mendelu.cz/marik/fancy-preview/.

Here is a sample article. (I'm sorry for the inconsistency of topics in content and bibliography:). I used different sources for it--the math is from http://en.wikipedia.org/wiki/Argument_principle while the bibliography is from biblatex's biblatex-examples.bib. (I am lazy and almost proud of it).

Read through Mouseover for the explanation about compiling the code in different platforms.

% myfile1.tex
\documentclass[10pt]{article}
\usepackage{amsmath}
\usepackage[backend=bibtex]{biblatex}
\usepackage{hyperref}
\newtheorem{theorem}{Theorem}
\addbibresource{biblatex-examples.bib}
\begin{document}
This is an example of a citation \parencite{markey,westfahl:space,aksin}. 

Here is a theorem.

\begin{theorem}[Argument Principle]
If $f(z)$ is a meromorphic function inside and on some closed contour $C$, and $f$ has no zeros or poles on $C$, then
\begin{equation}
\label{eq:1}
\oint \frac{f'(z)}{f(z)} dz = 2\pi i(N-P)
\end{equation}
\end{theorem}

$N$ and $P$ of Equation \eqref{eq:1} denote respectively the number of zeros and poles of $f(z)$ inside the contour $C$, with each zero and pole counted as many times as its multiplicity, respectively order, indicates.

\printbibliography.
\end{document}

I compiled this in terminal using

perl fancy-preview myfile1 --fancy_options="previewall,nosoap"

The previewall option enables mouseover pop-ups even if the link being referenced to is on the same page. I used it here just for the sake of the example but I personally think that enabling mouseover for equations when one can already see the equations on the same page is nonsensical. nosoap, the default, removes the soap-shaped figures (tooltipmarks) on the top of the links.

Here is the output.

enter image description here enter image description here enter image description here

To enable tooltipmarks, compile with

perl fancy-preview myfile1 --fancy_options="previewall"

To use any of the four pre-defined tooltipmarks of fancytooltips, you may use --fancy_options="previewall,tooltipmark=1 where you can replace 1 with 2,3, or 4.

Disadvantages

  1. You can only use Acrobat or Adobe Reader since other pdf readers like evince have no javascript capabilities.
  2. The files are bloated.
  3. The tooltipmarks, according to the fancytooltips manual can disturb the text and I agree.
  4. The mouseover effects are sometimes annoying especially when you unintentionally mouse over the tooltipmark.
  5. As reminded by Paul Gaborit in comment, the developer of AcroTex withdrew the bundle from TeXLive and the newer versions are now commercial. Although an older version available from CTAN is included in MikTeX.
4
  • 2
    Another disadvantage: AcroTeX bundle is not provided by TeXLive by explicit request of its authors (now, AcroTeX bundle is a commercial product even if an earlier version exists in CTAN with LPPL licence). Dec 7, 2012 at 11:01
  • @PaulGaborit Thanks for the reminder. I have updated my answer accordingly.
    – hpesoj626
    Dec 7, 2012 at 11:12
  • AcroTeX Presentation bundle is commercial, but the price is low and moreover, about the same functionality (libraries for inserting javascripts etc.) is in the free AcroTeX eDucation bundle. IMHO, this free AcroTeX eDucation bundle is better, since it allows to use pdftex and no postprocessing with Adobe Acrobat is necessary. Dec 17, 2012 at 14:08
  • This is great, thank you! I wonder if this can somehow be used with opentype fonts and full unicode. I asked this as a new question here tex.stackexchange.com/questions/111859/…
    – Mårten
    May 2, 2013 at 2:56
10

It is possible with LaTeX to program anything you want in a pdf. You might even make your document talk (see Hello World in pdfLaTeX). Effectively though you are writing JavaScript to a file via LaTeX.

However, my personal opinion is that once you start talking about presenting information in many different formats and media, you need to turn your thinking around. For example, I find it easier to start writing a document in a browser window (see LaTeX mark-up as a generic mark-up language) and sending the same mark-up to a LaTeX engine to produce the pdf. It costed me a few evenings work, but is substantially easier than trying to coerce LaTeX to produce the html patterns I want.

What I am suggesting is:

   info - > transformer       - > type of presentation
        - > htmtransformer    - > html
        - > voice transformer - > accesible document
        - > LaTeX             - > beautiful document

Remember that you want your document to be able to survive as long as possible, so it is better to keep the basic LaTeX or other mark-up to a minimum.

2
  • 1
    There is a professional discipline very similar to your approach called cross media publishing. A general property of this approach is that however you originally planned to use it, finally you end up having a content semantics in you information source which is the lowest common denominator of all the formats you are able to convert to. Hence, this is very different from pure print publishing which LaTeX is aimed at. Dec 1, 2012 at 23:02
  • @StephanLehmke Thanks for the link. In my early days of computing we had a similar problem with all the different file formats for data or otherwise (and no theory:). Agreed that one has to look at the lowest common denominator of all the formats. So far idea is working without the theory:) Dec 2, 2012 at 10:53

You must log in to answer this question.

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