Is there any package that lets me insert "smart comments" in a LaTeX document?

What I mean by "smart commenting":
I have a source (.tex) file of notes of the lecture that happened in the classroom. However, the notes do not have the detailed discussion of the proofs. I want to edit the source file and add the comments, such that the output PDF file will be same as the output of the original source; except that it will have small buttons (or similar constructs), which on pressing, will reveal the additional comments that I have made.

Essentially, one could achieve this by adding editor notes using any of the PDF reading programs. However, those notes are not portable from program-to-program, and more importantly, I cannot insert mathematical equations using those annotation tools, which I can using LaTeX.

I know this sounds kind of vague, but can someone help?

  • Have you tried fixme? It has many different ways to show the todos.
    – Juri Robl
    Commented Aug 17, 2014 at 11:03
  • I have not. But I cannot find a working example on the page you linked to decide whether that is what I want. Can you link to an actual document that uses fixme notes?
    – taninamdar
    Commented Aug 17, 2014 at 11:10
  • What I did not get from your request: You have slides in the lecture, right? And there is a notes file for each lecture. The slides have the detailed proofs, the notes not? For the beamer package one can create a combined file, which generates notes and slides in one document. I once created a German article in my blog: uweziegenhagen.de/?p=1053 Commented Aug 17, 2014 at 11:20
  • What you could do as well is to use the attachfilepackage to attach additional PDF files to the main file. I use this feature to add the TeX code of my documents to the PDF container file to have source and result in one file. Commented Aug 17, 2014 at 11:25
  • 1
    @taninamdar All solutions using additional content (ocg, pdf comments) or JavaScript will not be very portable. So you probably won't find a solution which works in many viewers, simply because most don't support the more advanced pdf features.
    – Juri Robl
    Commented Aug 17, 2014 at 12:01

2 Answers 2


You could use ocg and use different layers for the main document and the proofs, although this solution might not be particularly user-friendly.

One example using ocgx:

It is common knowledge that $1+1=1$. \switchocg{ocg1}{[PROOF]}

\begin{ocg}{OCG 1}{ocg1}{0}
Proof: I am one. The Pope is one. Therefore, the Pope and I are one.

Please note that most PDF viewers can’t handle OCG correctly.

  • 3
    Yes but can you expand your answer with an example? It is not particularly useful to point to a very generic concept. Also one important detail is that it would only work with Acrobat.
    – percusse
    Commented Aug 17, 2014 at 11:16
  • Yeah, I would like to see a working example before deciding whether I should implement it. :-)
    – taninamdar
    Commented Aug 17, 2014 at 11:29
  • I provided a somewhat minimal example. There are more sophisticated ways to use OCG in LaTeX though. Commented Aug 17, 2014 at 12:06

It sounds like pdfcomment may be what you're looking for. Like all the more advanced pdf features, it doesn't work with all pdf viewers; xpdf will display the comment icon but can't seem to get to the comment itself, while okular can handle them correctly. I didn't check on anything else. Run texdoc pdfcomment with your preferred viewer; the second page of the documentation has a test which will tell you whether it works.

Now is the time for all good men\pdfcomment{And women.} to
come to the aid of their party.

There are lots of options---you can put the comment in the margin, you can use different graphics to indicate a comment's presence, you can compile with the comment and with replies to the comments, and so forth---but at its root it's simple as can be, as you can see above.

If you really need fully typeset LaTeX math, though, you're probably going to have to use OCG or something similar, as I don't think you can get complex equations in pdf comments. You'd be stuck doing a plain-text substitute, as far as I can tell.

You must log in to answer this question.

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