bidi-tex / bidi

Bidirectional typesetting in plain TeX and LaTeX, using XeTeX
Other
3 stars 0 forks source link

Shifted frame with showframe package #6

Open jspitz opened 5 years ago

jspitz commented 5 years ago

(Moving from https://github.com/reutenauer/polyglossia/issues/33)

When compiling this example:

% !TeX TS-program = xelatex
\documentclass{book}
\usepackage{xcolor}

\usepackage{polyglossia}
\setdefaultlanguage{arabic}
\newfontfamily\arabicfont[Script=Arabic]{Amiri}

\usepackage{showframe}
\begin{document}
A\newpage B\newpage C
\end{document}

it becomes obvious that showframe does not recognize text area and margins correctly when \setdefaultlanguage{arabic} is used.

This problem is not restricted to the showframe package but to packages using the information about the page layout in general, of course, for example the thumbs package. Screen shot of two sided pdf

u-fischer commented 5 years ago

bidi is (depending on the loading order of the various packages) trying to patch eso-pic, which imho the wrong place. It would make more sense to switch back to LTR before the atbegshi picture.

\documentclass[a4paper]{book}%
\usepackage{atbegshi}
\usepackage{etoolbox}
\usepackage{xcolor,graphicx}
%
\makeatletter
\patchcmd\AtBegShi@BeginPicture{\begingroup}{\begingroup\@RTLfalse}{}{\fail}
\makeatother
\usepackage{polyglossia}
\setdefaultlanguage{arabic}
\newfontfamily\arabicfont[Script=Arabic]{Amiri}
%load later to avoid the eso-pic patch:
\usepackage{showframe}
\usepackage{wallpaper}

\begin{document}
\ThisCenterWallPaper{1}{example-image-duck}
A\newpage B\newpage C
\end{document}