\ pagedir TRT con pgfpages causa un risultato errato (spostamento fuori pagina)
L'utilizzo di \pagedir TRT
with \pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm,landscape]
from pgfpages
package produce pagine logiche da spostare fuori pagina.
Stesso problema con i layout 4 on 1
, 8 on 1
, 16 on 1
.
% lualatex
\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{pgfpages}
\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm,landscape]
\begin{document}
\pagedir TRT \bodydir TRT \pardir TRT
\Huge
Page 1
\newpage
Page 2
\end{document}

Aggiornamento 22/08/2020
Trovo un metodo per spostare le pagine logiche utilizzando \pagerightoffset
, il problema è che per ogni layout ho bisogno di aggiungere manualmente la quantità di spostamento.
Esempio con pagina orizzontale di layout 2 su 1
% lualatex
\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{pgfpages}
\pgfpagesuselayout{2 on 1}[a4paper,landscape]
\begin{document}
\pagerightoffset = .55\pgfphysicalwidth % <--
\pagedir TRT \bodydir TRT \pardir TRT
\Huge
Page 1
\newpage
Page 2
\end{document}

Risposte
Penso che dovresti creare un nuovo layout che disponga le pagine RTL.
Cambio una riga nel 2 on 1
layout da:
center=\pgfpoint{.75\pgfphysicalwidth}{.5\pgfphysicalheight}%
per:
center=\pgfpoint{-.25\pgfphysicalwidth}{.5\pgfphysicalheight}%
È possibile farlo con xpatch
:
\usepackage{xpatch}
\expandafter\xpatchcmd\csname pgfpages@layout@2 on 1\endcsname
{center=\pgfpoint{.75\pgfphysicalwidth}{.5\pgfphysicalheight}}
{center=\pgfpoint{-.25\pgfphysicalwidth}{.5\pgfphysicalheight}}
{}
{}
Per i layout con più pagine per pagina, avresti bisogno di più chiamate a xpatchcmd
.
Esempio completo:
\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{pgfpages}
\pgfpagesdeclarelayout{rtl 2 on 1}
{
\edef\pgfpageoptionheight{\the\paperwidth} % landscaped by default
\edef\pgfpageoptionwidth{\the\paperheight}
\def\pgfpageoptionborder{0pt}
\def\pgfpageoptionfirstshipout{1}
}
{
\pgfpagesphysicalpageoptions
{%
logical pages=2,%
physical height=\pgfpageoptionheight,%
physical width=\pgfpageoptionwidth,%
current logical shipout=\pgfpageoptionfirstshipout%
}
\ifdim\paperheight>\paperwidth\relax
% put side-by-side
\pgfpageslogicalpageoptions{1}
{%
border shrink=\pgfpageoptionborder,%
resized width=.5\pgfphysicalwidth,%
resized height=\pgfphysicalheight,%
center=\pgfpoint{.25\pgfphysicalwidth}{.5\pgfphysicalheight}%
}%
\pgfpageslogicalpageoptions{2}
{%
border shrink=\pgfpageoptionborder,%
resized width=.5\pgfphysicalwidth,%
resized height=\pgfphysicalheight,%
center=\pgfpoint{-.25\pgfphysicalwidth}{.5\pgfphysicalheight}% <- Shift second page to left hand side
}%
\else
% stack on top of one another
\pgfpageslogicalpageoptions{1}
{%
border shrink=\pgfpageoptionborder,%
resized width=\pgfphysicalwidth,%
resized height=.5\pgfphysicalheight,%
center=\pgfpoint{.5\pgfphysicalwidth}{.75\pgfphysicalheight}%
}%
\pgfpageslogicalpageoptions{2}
{%
border shrink=\pgfpageoptionborder,%
resized width=\pgfphysicalwidth,%
resized height=.5\pgfphysicalheight,%
center=\pgfpoint{.5\pgfphysicalwidth}{.25\pgfphysicalheight}%
}%
\fi
}
\pgfpagesuselayout{rtl 2 on 1}[a4paper,border shrink=5mm,landscape]
\usepackage[bidi=basic-r,nil]{babel}
\babelprovide[import,main]{arabic}
\babelfont{rm}{Amiri}
\begin{document}
\Huge
نص من اليمين الى اليسار
الصفحة الأولى 1
\newpage
\Huge
نص من اليمين الى اليسار
الصفحة الثانية 2
\end{document}

Trovo una soluzione che inverte la coordinata x all'interno di ogni \pgfpoint
comando come questo
\let\Pgfpoint\pgfpoint
\def\pgfpoint#1#2{\Pgfpoint{-1*#1}{#2}}
Questa patch deve essere aggiunta ai comandi che pgfpages
contengono il comando \pgfpoint
per limitare l'azione della patch all'interno di altri comandi di altri pacchetti
% lualatex
\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{pgfpages}
\let\Pgfpoint\pgfpoint
\def\pgfpoint#1#2{\Pgfpoint{-1*#1}{#2}}
\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}
