Hiding Content

From Wiki
Revision as of 12:48, 8 June 2020 by Garulfo (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Probably for your slides, probably for some animation or for whatever reason you may want it: you can hide some content from the document, while leaving exactly the same amount of space as that content would need if typeset in the usual way.

Beware, this doesn’t work in current (2018) MkIV. Have a look at Viewer Layers, attr-lay.mkiv.


On the mailing list Hans suggested many different ways (astonishing easy to use) to hide the content in a PDF document. Sadly, most of them are viewer-dependent.

method properties
My public secret.
  • makes (invisible) layer on top (JS-based)
  • completely hides everything
  • works with newer Adobe Acrobat/Viewer; in most other browsers the content is not hidden
  • I managed to freeze Acrobat 6.0 pro when trying to save the text
To \ConTeXt\ or not to \ConTeXt?
\button{Show   Decision}[VideLayer{my-hesitations}]
\button{Hide   Decision}[HideLayer{my-hesitations}]
\button{Toggle Decision}[ToggleLayer{my-hesitations}]
  • makes (invisible) layer, which can be switched on and off (JS-based)
  • you can switch the content on and off
  • when hidden, it is completely hidden
  • works with newer Adobe Acrobat/Viewer; in most other browsers the content is not hidden
  • even some new Acrobat versions can't handle the buttons
\starteffect[hidden] % In MkIV
My secret hidden for Adam's apple ;)
  • makes transparent fonts
  • no JavaScript
  • pretty safe for different viewers
  • only text is hidden, but not images, rules, ...
the plain TeX way
  • puts a blank box instead of its content (letter)
  • absolutely no content in the document, not even hidden (only blank space)
  • only works for letters and whitespace, no macros, no figures, ...

The plain TeX way

This example was adapted from the TeXBOOK. However, it can only handle usual text. Forget about macros, forget about graphics ...

I hope and still believe that it is possible to extend this macro to make it work in general case. This would also be a preferred solution as it doesn't depend on the viewer's JavaScript incapabilities.

% the portion of code adapted from the TeXBOOK, Excercise 11.5 %

\def\dolist{\afterassignment\dodolist\let\next= }
  \else \\\let\next\dolist \fi

\def\\{\if\space\next\ % assume that \next is unexpandable


Layer: state=top

You can try something like:


I don't tell this to everybody:
\quotation{\ConTeXt\ goes beyond the limits of imagination, that's why I love it!}
You'll understand that once you get to know it better.

which results in

This can be compared to the non-hidden version, which is:

Final Remarks

  • Just as a hint: don't ever think about hiding your secrets or solutions to the problems for your students this way. Readers with Adobe Acrobat Professional can select Layers on the left and switch the hidden layer on again. You have been warned.
  • Kerning could cause miniscule differences in the exact placement of the (hidden) content.