reutenauer / polyglossia

An alternative to Babel for XeLaTeX and LuaLaTeX
http://www.ctan.org/pkg/polyglossia
MIT License
187 stars 52 forks source link

Horizontal positioning of a TikZ Picture with a fitted frame in a right-to-left polygossia document doesn't work as expected #570

Closed EvanAad closed 1 year ago

EvanAad commented 1 year ago

The following LaTeX code is saved in the file ~\test.tex:

\documentclass{article}
\usepackage{lipsum,tikz}
\usetikzlibrary{fit}

\iffalse
\usepackage{polyglossia}
\setmainlanguage{hebrew}
\setmainfont{Arial}
\fi
\begin{document}
\lipsum[1-1]

\noindent\hspace{0cm}\tikz \node [ draw, fit={(0,0) (12,1)} ] {};

\noindent\hspace{3cm}\tikz \node [ draw, fit={(0,0) (12,1)} ] {};
\end{document}

When the following commands are executed in the Terminal:

cd ~
pdflatex test

a PDF file is generated at the path ~\test.tex. When opened in a PDF viewer, the file displays as follows:

Without polyglossia

If now the two lines containing \iffalse and \fi are commented, and the command xelatex test (rather than pdflatex test) is run, a new PDF file is generated at the path ~/test.pdf. Here's what I expected to see when the file were opened in a PDF viewer, essentially a horizontal mirror image of the version shown above:

Expected outcome

However, here's what the file actually displayed as when opened in a PDF viewer:

With polyglossia

Why isn't the distance of the lower rectangle from the right margin as specified, namely 3cm? How can this be fixed?

jspitz commented 1 year ago

As shown by the following example, this is not a bug in polyglossia, but a bug in bidi. So please file a ticket at kvafa/bidi/issues

\documentclass{article}
\usepackage{lipsum,tikz}
\usetikzlibrary{fit}

\usepackage[RTLdocument]{bidi}

\begin{document}
    \lipsum[1-1]

    \noindent\hspace{0cm}\tikz \node [ draw, fit={(0,0) (12,1)} ] {};

    \noindent\hspace{3cm}\tikz \node [ draw, fit={(0,0) (12,1)} ] {};
\end{document}

grafik