Here's my requirements:

  1. I need to use XeTeX.
  2. I need to have links, so I'm using hyperref
  3. I need links to be black when printing, so I'm using option ocgcolorlinks with hyperref
  4. I need the links in the toc to be breakable, so I'm using ocgx2 instead of the hyperref option, as suggested here.

So far, so complicated. I then compile this MWE:

\section{this is a very very very very very very very very very very very very very very very very very very long section}

If I compile with XeTex, within Acrobat reader, when clicked, the link "inverts" to a square wich looks about the size of the page (pdf).

If instead I compile with LaTeX, within Acrobat reader, when clicked, the link "inverts" to the regular link size as it should (pdf).

I can't attach any meaningful screenshots, as the inverted link doesn't show in them.

Is there any way to fix this? At first I didn't even notice this, because it doesn't happen in the TeXWorks preview. I tried using \hypersetup{pdfhighlight=/N}, but it either has no effect when compiling with XeTex, or is overridden/not respected by ocgx2.

Output of \listfiles:

 *File List*
 article.cls    2014/09/29 v1.4h Standard LaTeX document class
  size10.clo    2014/09/29 v1.4h Standard LaTeX file (size option)
hyperref.sty    2017/03/14 v6.85a Hypertext links for LaTeX
hobsub-hyperref.sty    2016/05/16 v1.14 Bundle oberdiek, subset hyperref (HO)
hobsub-generic.sty    2016/05/16 v1.14 Bundle oberdiek, subset generic (HO)
  hobsub.sty    2016/05/16 v1.14 Construct package bundles (HO)
infwarerr.sty    2016/05/16 v1.4 Providing info/warning/error messages (HO)
 ltxcmds.sty    2016/05/16 v1.23 LaTeX kernel commands for general use (HO)
ifluatex.sty    2016/05/16 v1.4 Provides the ifluatex switch (HO)
  ifvtex.sty    2016/05/16 v1.6 Detect VTeX and its facilities (HO)
 intcalc.sty    2016/05/16 v1.2 Expandable calculations with integers (HO)
   ifpdf.sty    2017/03/15 v3.2 Provides the ifpdf switch
etexcmds.sty    2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO)
kvsetkeys.sty    2016/05/16 v1.17 Key value parser (HO)
kvdefinekeys.sty    2016/05/16 v1.4 Define keys (HO)
pdftexcmds.sty    2017/03/19 v0.25 Utility functions of pdfTeX for LuaTeX (HO)
pdfescape.sty    2016/05/16 v1.14 Implements pdfTeX's escape features (HO)
bigintcalc.sty    2016/05/16 v1.4 Expandable calculations on big integers (HO)
  bitset.sty    2016/05/16 v1.2 Handle bit-vector datatype (HO)
uniquecounter.sty    2016/05/16 v1.3 Provide unlimited unique counter (HO)
letltxmacro.sty    2016/05/16 v1.5 Let assignment for LaTeX macros (HO)
 hopatch.sty    2016/05/16 v1.3 Wrapper for package hooks (HO)
xcolor-patch.sty    2016/05/16 xcolor patch
atveryend.sty    2016/05/16 v1.9 Hooks at the very end of document (HO)
atbegshi.sty    2016/06/09 v1.18 At begin shipout hook (HO)
refcount.sty    2016/05/16 v3.5 Data extraction from label references (HO)
 hycolor.sty    2016/05/16 v1.8 Color options for hyperref/bookmark (HO)
  keyval.sty    2014/10/28 v1.15 key=value parser (DPC)
 ifxetex.sty    2010/09/12 v0.6 Provides ifxetex conditional
 auxhook.sty    2016/05/16 v1.4 Hooks for auxiliary files (HO)
kvoptions.sty    2016/05/16 v3.12 Key value format for package options (HO)
  pd1enc.def    2017/03/14 v6.85a Hyperref: PDFDocEncoding definition (HO)
hyperref.cfg    2002/06/06 v1.2 hyperref configuration of TeXLive
     url.sty    2013/09/16  ver 3.4  Verb mode for urls, etc.
  hxetex.def    2017/03/14 v6.85a Hyperref driver for XeTeX
   puenc.def    2017/03/14 v6.85a Hyperref: PDF Unicode definition (HO)
stringenc.sty    2016/05/16 v1.11 Convert strings between diff. encodings (HO)
rerunfilecheck.sty    2016/05/16 v1.8 Rerun checks for auxiliary files (HO)
   ocgx2.sty    2017/06/08 v0.29 ports `ocgx' functionality to dvips+ps2pdf, xe
latex and dvipdfmx
  xparse.sty    2017/07/19 L3 Experimental document command parser
   expl3.sty    2017/07/19 L3 programming layer (loader) 
expl3-code.tex    2017/07/19 L3 programming layer 
l3keys2e.sty    2017/07/19 LaTeX2e option processing using LaTeX3 keys
 ocgbase.sty    2017/03/30 v0.10 support package for ocgx2.sty
 pdfbase.sty    2017/08/25 v0.17 driver independent access to low-level PDF fea
   color.sty    2016/07/10 v1.1e Standard LaTeX Color (DPC)
   color.cfg    2016/01/02 v1.6 sample color configuration
   xetex.def    2016/07/11 v4.10 LaTeX color/graphics driver for XeTeX (L3/RRM/
 nameref.sty    2016/05/21 v2.44 Cross-referencing by name of section
gettitlestring.sty    2016/05/16 v1.5 Cleanup title references (HO)
se-ascii-print.def    2016/05/16 v1.11 stringenc: Printable ASCII characters
  • There is no need for a long url. Already with \url{short} xdvipdfms warns about "Annotation out of page boundary.". Write to the author of ocgx2. – Ulrike Fischer Sep 11 '17 at 14:50
  • Thanks @UlrikeFischer. I have only recently switched to TeXWorks and have yet to get accustomed to it's log display, otherwise I might have noticed that ... – takrl Sep 11 '17 at 15:43
  • Added an issue to github ... – takrl Sep 11 '17 at 20:10
  • 2
    A quick fiddling about with ocgx2.sty seems to suggest to me that ll. 763-767 cause the problem: they create a box of size 2\paperwidthx2\paperheight, which is roughly the wrong link size XeTeX produces. If these lines are removed, the links have the expected size instead. I do not currently understand the purpose of this box, so removing it might have some unexpected consequences that I am not aware of, but it at least seems like a good starting point for a more thorough investigation. – diabonas Sep 13 '17 at 14:59
  • 4
    I'm voting to close this question because the problem it addresses has been solved by a package update. – AlexG Sep 18 '17 at 13:18

Package version 0.30 containing the fix by diabonas is already available at github, and according to agrahn's comments there it's already on the way to CTAN, so it'll also be available there soon.

  • I think we should close this topic. This is the usual procedure here for questions that become obsolete by a package update. – AlexG Sep 18 '17 at 12:56
  • 1
    @AlexG Fine by me ... – takrl Sep 18 '17 at 13:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.