hyperref icon indicating copy to clipboard operation
hyperref copied to clipboard

Dimen `\XeTeXLinkMargin` defined for all engines but apparently only needed for XeTeX

Open jfbu opened this issue 3 years ago • 2 comments

Looking at some log file I noticed a dimen register was allocated with name \XeTeXLinkMargin.

I looked into hyperref.sty and found this:

\newdimen\XeTeXLinkMargin
\setlength{\XeTeXLinkMargin}{2pt}
\ifxetex
  \font\XeTeXLink@font=pzdr at 1sp\relax
...
\else
  \newcommand*{\XeTeXLinkBox}[1]{%
    \begingroup
      \leavevmode
      \sbox\z@{#1}%
      \copy\z@
    \endgroup
  }%
\fi

which seems to indicate it is is needed only for XeTeX engine. I did not find other references in the code and the documentation 7.7 \XeTeXLinkBox mentions it as XeTeX-specific thing.

Is there some reason to allocate it always?

jfbu avatar May 24 '22 15:05 jfbu

I don't know if it's the original reason but if you only conditionally allocate then all box logging shows different box numbers for any later allocated boxes in xetex which complicates testing engine neutral code

davidcarlisle avatar May 24 '22 15:05 davidcarlisle

Well it is only needed for xetex, but defining it for the other engines too makes it easier for the users: they don't have to test for the engine but can simply add the box and set the dimen.

u-fischer avatar May 24 '22 21:05 u-fischer