In LuaTeX, when \pagedirection is right to left then \pagerightoffset is
used instead of \hoffset to position the page. I attached a patch and an example
that demonstrates the problem.

Udi
From dc2ed7ce0e0ac5f1c901d6874378d676f83f5c97 Mon Sep 17 00:00:00 2001
From: Udi-Fogiel <udifog...@gmail.com>
Date: Sat, 8 Jun 2024 13:09:18 +0300
Subject: [PATCH] consider pagerightoffset in luatex with rtl languages

This patch will calculate \pagerightoffset when LuaTeX is used
and the page direction is right to left. It is important as in
this case LuaTeX will use this register, and not \hoffset to
position the page.
---
 latex/preview.dtx | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/latex/preview.dtx b/latex/preview.dtx
index 23f5b2da..9503e41f 100644
--- a/latex/preview.dtx
+++ b/latex/preview.dtx
@@ -752,6 +752,7 @@
    \ifx\pr@offset@override\@undefined
      \voffset=-\ht\pr@box
      \hoffset=\z@
+     \pr@set@pagerightoffset
    \fi
    \c@page=\pr@snippet
    \pr@shipout
@@ -769,6 +770,22 @@
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
+% \begn{macro}{\pr@set@pagerightoffset}
+%   In |luatex| when page direction is right to left, |\pagerightoffset|
+%   is used instead of |\hoffset|, so we need to calculate that as well.
+%    \begin{macrocode}
+\let\pr@set@pagerightoffset\@enpty
+\ifx\pagerightoffset\@undefined\else
+  \def\pr@set@pagerightoffset{%
+    \ifnum\pagedirection=1
+      \pagerightoffset=-1in
+      \advance\pagerightoffset-\pr@bb@i
+      \advance\pagerightoffset\pr@bb@iii
+    \fi
+  }
+\fi
+%    \end{macrocode}
+% \end{macro}
 % Oh, and we kill off the usual meaning of \cmd{\shipout} in case
 % somebody makes a special output routine.  The following test is
 % pretty much the same as in |everyshi.sty|.  One of its implications
-- 
2.44.0

\documentclass{article}
\usepackage[hebrew,bidi=basic,provide*=*]{babel}
\usepackage[tightpage,active]{preview}
\begin{document}
\begin{preview}
Test 
\end{preview}
\end{document}
_______________________________________________
bug-auctex mailing list
bug-auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-auctex

Reply via email to