TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am looking a way to generate a toggle region in PDF compiled by pdflatex. Something like this implemented with javascript in html


I remember long time ago I saw a post online to implement this function but I can't find that post anymore.

share|improve this question
you can search for ocgx from Paul Gaborit. The manual has a few nifty examples. tex.stackexchange.com/questions/65096/… – percusse Feb 1 '13 at 1:20
But collapsing won't be possible. – AlexG Feb 1 '13 at 9:27

Your best bet would be to use PDF layers, i.e. . That's the only way you can emulate collapsing.

share|improve this answer
I doubt that collapsing works in addition to hide/display page content using ocgs. The reason is that the effect of changing the current transformation matrix within marked content (BDC ... EMC) is not local. – AlexG Feb 1 '13 at 12:03
@AlexG: You would have to put the rest of the page/block for both case (collapsed/uncollapsed) on different layers. Ugly, but it may work (I haven't tested this for pages, I know it works for blocks). – Martin Schröder Feb 1 '13 at 12:07
Ok, this may indeed be possible, but difficult in case of multiple vertically aligned collapsable blocks. Every possible combination of expanded and collapsed blocks would have to be prepared beforehand. – AlexG Feb 1 '13 at 13:09

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.