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 wish to create a dynamic PDF file to write an article. This article will contain some theorems. The user will click a theorem and this will drill down to reveal the proof of that theorem. I think its different than hyperref since the proof is not visible initially in the PDF file only clicking the theorem makes the proof visible. If someone can also give a sample script that'll be much appreciated.

share|improve this question
Use Beamer –  Yiannis Lazarides Jun 2 '11 at 13:46

5 Answers 5

This would be so much easier as website. PDF isn't very dynamically (in general, not just using pdflatex). The only way I know of to do it would be to use PDF forms and javascript. This means that you have a text area in a form which is initially empty but then filled with a text using javascript code when a button is pressed. However, this wouldn't look very nice and you are limited to normal text. Also I don't think some drop down action is possible.

share|improve this answer
I second the website suggestion. This sort of "dynamic" activity is much more suited to websites than documents. Incidentally, the idea of this sort of click-through proof was once championed by none other than Leslie Lamport. It's a small world. –  Loop Space Jun 2 '11 at 10:37
@Andrew: do you know where Lamport said that? I'd like to read more about it. –  Matthew Leingang Jun 3 '11 at 17:08
@Matthew: I searched for "Lamport proof" and turned up this as the first hit: research.microsoft.com/en-us/um/people/lamport/pubs/… (since when did it become impossible to use "copy link location" from a Google search? Makes linking to PDFs very difficult.) –  Loop Space Jun 3 '11 at 18:07
@andrew blush thanks for doing my googling for me. –  Matthew Leingang Jun 4 '11 at 13:41
@Matthew: No worries! What I actually meant to convey was that I didn't remember exactly where he'd said it but vaguely remembered reading it, Google led me to that one, but it might not be the best one for conveying his ideas. –  Loop Space Jun 4 '11 at 19:59

The package ocgtools allows you to define some layers and make them active or not by cliking somewhere. Creating PDF layers using ocg.sty is an entry in TeXample.net's webblog explaining how to use it. And Figure 3 of this article is an example of its real use.

share|improve this answer
I just took a look at that article, and found more evidence for the argument that this isn't the way to do this! My PDF viewer did absolutely nothing when I clicked on those checkboxes. I agree that it would have been nice to have that functionality (particularly with that diagram), but I don't like features that rely too heavily on one particular viewer. –  Loop Space Jun 2 '11 at 16:01
@Andrew Stacey It does not rely on a particular viewer but on an open standard. That most of the so called PDF viewers ignore the standard is not the problem of Adobe Reader. It's chic to bash Adobe, but in this case others would deserve it much more. –  Josef Jun 2 '11 at 19:29
@Josef: I wasn't intending my comment to be taken as an Adobe-bash. I have no opinion on Adobe's software. I would like to be able to use HTML5 on my website so that I can embed MathML a little more easily, and snazzy CSS3 tricks like rounded corners for boxes. But they aren't supported yet by "most" browsers so I don't. They should be, but they aren't yet. "Best viewed with XX" generally means "Don't bother looking at my website" as far as I'm concerned. –  Loop Space Jun 2 '11 at 20:15
I have a similar problem to the OP and have just played around with this and found your approach meets my needs. The simple example I constructed worked with Acrobat Reader and with evince (3.10.3). On my system ocg.sty wasn't available. However, texlive-latex-extra had ocg-p and ocgx available; I used the latter (which provides support without using javascript). –  TooTone Apr 26 at 22:18

It isn't exactly what you wanted, but with some hyperref magic you could include a link that would take you to an appendix at the end of the document that would include the proof and have a link at the end of the proof to take you back to where you started. This is a bit like "anon"'s solution, but within one file...

share|improve this answer
Something along the lines of these notes? These notes have a 6 page "cheetsheet" followed by the full text, with links back and forth between cheetsheet and full text. I coded that package some months back. But I never finished it. Should I? –  Bruno Le Floch Jun 2 '11 at 16:25
@Bruno exactly like that. What exactly does the package do? Provide an easy interface to hyperreffing up backlinks like that? –  Seamus Jun 2 '11 at 16:32
yes. The syntax is basically repeated blocks \begin{head}...\end{head} \bein{body}...\end{body}. The content of all the head environments is typeset first, then all the bodies. Links are automatically created. My first question on {TeX} has an example with nesting. I also converted the same source with tex4ht (math rendered with jsmath) into something close to what the OP is asking. See this page. –  Bruno Le Floch Jun 3 '11 at 6:57
@Bruno Any plans to make the package public? –  Yuval Filmus Dec 15 '11 at 11:08
@YuvalFilmus No precise plan, but I really should. I never finished that package because I started reading the TeXbook, and then got into LaTeX3. Some time ago I tried to understand and update the package, but I broke it, and wasn't using version control, so I essentially need to rewrite it from scratch :-/. Since I'll be rewriting everything, I could change the input syntax (currently it's what I gave in my first question on {TeX}). Any idea? –  Bruno Le Floch Dec 15 '11 at 12:01

You can mimic this. From a single TeX file, you can produce to two pdf files, one with proofs and one without. Each theorem in each pdf file will have a link: clicking on it in the lean file will take you to the same place in the file with proofs; clicking on it in the verbose file will take you back to the lean file.

There are several packages that allow you to have an environment that prints or not according to some switch. The package xr allows you to reference a second file. You may have to do a search/replace to change \ref{leanfile-abc} to \ref{verbosefile-abc} to get the two sets of references (unless an expert comes up with a better idea).

share|improve this answer

Do you mean tooltips? In context that works like this:

This is \tooltip{test}{\TeX\ data}.

Hovering over 'test' will then show the (typeset) '\TeX\ data' as a popup. I am almost certain that there is a LaTeX package for that as well, but I do not know its name.

Edit: found two candidates, even: cooltooltips and fancytooltips.

share|improve this answer
In cooltooltips and fancytooltips the tooltips are a bonus to other functionalty. pdfcomment offers with \pdftooltip a possibility to just use a tooltip. –  Josef Jun 2 '11 at 13:56
@Josef is the content actually typeset? That what not quite clear from the example.pdf –  Taco Hoekwater Jun 2 '11 at 14:15
Yes, e.g. $\pdftooltip{H_{2}SO_{4}}{Sulfuric acid}$ typesets H_{2}SO_{4} with a Sulfuric acid tooltip. –  Josef Jun 2 '11 at 19:40

Your Answer


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.