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.

While exploring the depths of the microtype package with regard to LuaTeX I came across this innocent looking page 18 from the microtype.pdf 2.5 beta-08.

enter image description here

As the blue note in the margins hints a mouse click reveals the kerns and spacings

enter image description here

The final surprise comes be clicking on the words in the text.

enter image description here

Which is really neat! Of course, I want to know how it is done. As it is the official package documentation I immediately went for the dtx. However it does not give away its magic so easily. The relevant part in the dtx is:

\begin{verbatim}
\SetTracking
  [ no ligatures  = {"\anchorarrow{nolig}"f},
    spacing       = {60"\anchorarrow{ispace}"0*,-1"\anchorarrow{istretch}"00*,"\anchorarrow{ishrink}"},
    outer spacing = {4"\anchorarrow{ospace}"50,2"\anchorarrow{ostretch}"50,1"anchorarrow{oshrink}"50},
    outer kerning = {"\anchorarrow{okernbegin}"*,"\anchorarrow{okernend}"*} ]
  { encoding = * }
  { 1"\anchorarrow{lsamount}"60 }
\end{verbatim}
 and then write:
\begin{verbatim}
Stop \textls{stealing sheep}!
\end{verbatim}

this is the (typographically dubious) outcome:

\lssample

\noindent
While the word `Stop' is not letterspaced, the space between the letters in
the other two words is expanded by the \showarrow[tracking]{tracking~amount}{red}
of 160/1000\,em\,=\allowbreak\,0.16\,em.

The definitions of the macros are of course not to be found. Instead a “bonus material” section in the preamble shows that

\InputIfFileExists{microtype-lssample.dtx}

it is in another file, unfortunately not included in the .zip. So the questions is still open. How is this achieved. The macros in the dtx hint that a general solution is at work here. I would suspected some Tikz overlay magic at work here. But as the positions are not determined until after the page is typeset the arrows must somehow come afterwards. And then how is the information passed on to the pdf viewer that they can be toggled by clicking on the words?


EDIT: Following Martin Schröder’s pointer I have learned, that the PDF Format since version 1.5 supports “layers” here called Optional Content Groups (OCG). In an older thread (2007) on comp.text.tex Michael Ritzert offered his ocg.sty for creating them in LaTeX directly. There is even a nice demonstration on TeXample that shows that the toggling is achieved by bits of JavaScript executed by Acrobat Reader. There is also a fairly recent package ocgtools. The question that remains is how to get the anchors in the page and let the arrows cris-cross over the typesetted material?

share|improve this question

2 Answers 2

I suppose you are asking for the implementation of the layers/OCGs in the microtype documentation. AFAIK this is not done via pgf. Check microtype.dtx v1.66 for the code after line 517 with the comment

% the samples in the introduction, utilising nested optional content groups (aka. layers):

There he implements optional content.

share|improve this answer
up vote 2 down vote accepted

Well, as usual it is all there, right before ones eyes... my pgfmanual was old, the current one has section 16.13 Referencing Nodes Outside the Current Pictures starting with 16.13.1 Referencing a Node in a Different Picture and section 75.3.2 explains the behind the scenes details.

share|improve this answer

Your Answer

 
discard

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.