2

Why in this example clickable box appears in RTL context very larger from what I have declared (2cm), in left to right context width of box is fine

% lualatex
\documentclass[12pt]{article}
\usepackage{hyperref}


\begin{document}

%\pardir TRT \textdir TRT \linedir TRT

a
{\hypersetup{pdfhighlight={/P},pdfborder={0 0 4}}%
\vbox{\hyperlink{thesentence}{\vbox to 3cm{\hbox  to 2cm{ \hfil}\vfil}}}}

\newpage

Text \hypertarget{thesentence}{this sentence}

\end{document}

Result in LTR context

enter image description here

Result in RTL context

enter image description here

2
  • You are using texlive 2021? It seems to be a bug introduced in the new luatex, with texlive 2020 the output is okay. I sent a bug report to the luatex list, but it is a pity that this wasn't discovered during the pretest period. Apr 8 at 20:20
  • @UlrikeFischer Yes I have TL 2021, a file which produce previously fine result with TL 2020 currently produce in RTL context stretched clickable box.
    – Salim Bou
    Apr 8 at 20:45
2

While this is a LuaTeX bug there is a rather simple workaround until it's fixed in the engine: LuaTeX has two codepaths to calculate the dimensions of a link. A simpler (and faster) one (which has the bug) and a more complicated one (which works correctly). So you only have to force LuaTeX to use the more complicated code, e.g. by setting a PDF transformation matrix:

\documentclass[12pt]{article}
\usepackage{hyperref}

\AddToHook{shipout/background}{% Insert on every page
  \pdfextension setmatrix{1 0 0 1}% {1 0 0 1} describes an identity matrix and doesn't actually do anything, but it stops LuaTeX from using simpler link calculations.
}

\begin{document}

\pardir TRT \textdir TRT \linedir TRT

a
{\hypersetup{pdfhighlight={/P},pdfborder={0 0 4}}%
\vbox{\hyperlink{thesentence}{\vbox to 3cm{\hbox  to 2cm{ \hfil}\vfil}}}}

\newpage

Text \hypertarget{thesentence}{this sentence}

\end{document}

enter image description here

1
  • There is no fix for the bug until now!
    – Salim Bou
    Jul 7 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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