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.

In my ocgx package, I would use the new ocg-p package instead of the ocg package. With pdflatex or lualatex, all is good. But with xelatex, I obviously can't use \pdfstartlink and \pdfendlink (these primitives are provided by pdftex or luatex).

How to emulate these two primitives with xetex?

Here is an example of current code in my ocgx package:

\long\def\switchocg#1#2{%
  \def\ocgx@list{}%
  \ocgx@listOCG#1 ENDOFOCGS %
  \leavevmode%
  \pdfstartlink user {%
    /Subtype /Link
    /A << /S/SetOCGState /State [/Toggle \ocgx@list] >>
    /Border [0 0 0]
  }%
  #2\pdfendlink%
}
share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

According to texdoc dvipdfmx the pair of specials

\special{pdf:bann <<dict>>}
\special{pdf:eann}

allow for producing breakable annotations with dvipdfmx/XeTeX in analogy to the pdfTeX commands \pdfstartlink/pdfendlink.

Thus,

\long\def\switchocg#1#2{%
  \def\ocgx@list{}%
  \ocgx@listOCG#1 ENDOFOCGS %
  \leavevmode%
  \special{pdf:bann <<
    /Subtype /Link
    /A << /S/SetOCGState /State [/Toggle \ocgx@list] >>
    /Border [0 0 0]
  >>}%
  #2%
  \special{pdf:eann}%
}
share|improve this answer
    
Unlike pdfTeX/LuateX, XeTeX/(x)dvipdfm(x) does not support nested annotations. –  Heiko Oberdiek Dec 10 '12 at 11:32
    
@Heiko: Do you think of something like \pdfstartlink user {...} ... \pdfstartlink user {...} ... \pdfendlink ... \pdfendlink? Doesn't seem to be relevant for @Paul's problem. What might this be good for? Do mouse events bubble through superimposed PDF annotations? –  AlexG Dec 10 '12 at 12:07
    
The question was about emulating \pdfstartlink and \pdfendlink with XeTeX. \pdfstartlink can be nested, \special{pdf:bann} cannot. –  Heiko Oberdiek Dec 10 '12 at 12:45
    
@Heiko: I am pretty sure that nesting links, that is, the possibility for \switchocg{foo}{footext\switchocg{bar}{bartext}footext cont'd}, isn't really wanted by the OP. Maybe @Paul could comment on this. –  AlexG Dec 11 '12 at 10:19
    
@AlexG Thanks for your excellent answer (I looked at the xetex documentation and not at the dvipdfmx documentation). –  Paul Gaborit Dec 13 '12 at 10:46
show 1 more comment

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.