# Issue in width of hyperlink box in vbox (RTL context)

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

Result in RTL context

• 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. Apr 8 at 20:45

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}

\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}


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