Adaptation of pgfpages for \pagedir TRT (lualatex)
Brief outline of the proposed feature
With lualatex and \pagedir TRT layouts are shifted out of page this is due to that the reference point of pages is at lower left corner but with \pagedir TRT the reference point of pages change to lower right
A solution is to reverse x coordinate in \pgfpoint command and this give correct result see
https://tex.stackexchange.com/a/559842/54817
Maybe this can be added to pgfpages like this
\newif\ifpgfpagedir@trt
\pgfpagedir@trtfalse
\newcommand{\pgfpagedirtrt}{\pgfpagedir@trttrue}
% Perhaps we should add \ifluatex
% \newcommand{\pgfpagedirtrt}{\ifluatex\pgfpagedir@trttrue\else\relax\fi}
\let\pgfpoint@TLT\pgfpoint
\def\pgfpoint@TRT#1#2{\pgfpoint@TLT{-1*#1}{#2}}
Then for every pgfpages commands containing \pgfpoint we need to add
\ifpgfpagedirtrt\let\pgfpoint\pgfpoint@TRT\fi
Usage example
% lualatex
\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{pgfpages}
\pgfpagedirtrt <-- % to reverse x coordinate in \pgfpoint inside pgfpages commands
\pgfpagesuselayout{4 on 1}[a4paper,landscape]
\begin{document}
\pagedir TRT \bodydir TRT \pardir TRT
\Huge
Page 1
\newpage
Page 2
\newpage
Page 3
\newpage
Page 4
\end{document}
While I appreciate the feature request, I absolutely hate the proposed solution. First of all, having an extra \ifpgfpagedirtrt is completely unnecessary, because we can just check \pagedir directly. Second, doing \let\pgfpoint\pgfpoint@TRT will have very unexpected side-effects, because then suddenly all points in every tikzpicture made thereafter have the x-component flipped. This will most likely also break things like intersections. Also, specializing this mechanism to TRT is not productive, since there are also LTL and RTT. I'll see if I can come up with a better solution, also in regards to #910.
Thanks, for #910 I thought the feature is useful for xelatex with bidi package if one need pages to be placed from right to left.
Hi @hmenke , perhaps it would be better to change \pgfpoint with another command \pgfpagespoint in pgfpages.sty with the same definition by default in case of TLT page, and with TRT page we can redefine \pgfpagespoint by \def\pgfpagespoint#1#2{\pgfpoint{-1*#1}{#2}}.