pgf icon indicating copy to clipboard operation
pgf copied to clipboard

Adaptation of pgfpages for \pagedir TRT (lualatex)

Open seloumi opened this issue 5 years ago • 3 comments

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}

seloumi avatar Aug 25 '20 11:08 seloumi

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.

hmenke avatar Aug 25 '20 22:08 hmenke

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.

seloumi avatar Aug 26 '20 12:08 seloumi

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

seloumi avatar Jun 06 '21 20:06 seloumi