1

I am using tikz-qtree to draw syntax trees that go inside of gb4e examples. I was very happy that I was able to get them to center by following this answer: Centering trees

However, I then decided that I wanted to use some Arabic text in my paper, so I loaded Arabic as the other language via polyglossia. Suddenly, none of my trees were centered. I'm guessing that the problem has something to do with loading bidi, which polyglossia does when you add a right-to-left language, but I'm not sure how to get around it.

Here is a MWE:

\documentclass{article}
\usepackage{tikz-qtree}
\usepackage{polyglossia}
\setmainlanguage{english}
% Uncomment the following line to see the problem behavior:
%\setotherlanguage{arabic}
\usepackage{gb4e}

\begin{document}
Here is an example tree that I want to be centered.
\begin{exe}
    \ex
    \hfil
    \begin{tikzpicture}[baseline]
        \Tree [.DP
                [.D the ]
                [.NP [.N center ] ] ]
    \end{tikzpicture}
    \hfil
\end{exe}
\end{document}

Here is a photo of the desired output: A centered tree in gb4e

And here is the output I get when bidi is loaded: enter image description here

  • Welcome! I get the same result whether I uncomment the line or not with XeTeX. With LuaTeX, it doesn't work at all and centring seems the least of the issues. – cfr Feb 20 '17 at 00:56
  • I can't reproduce this either. – Alan Munn Feb 20 '17 at 04:35
  • Weird... I had been using XeLaTeX, through TeXShop on a Mac, which has the problem I described. I had never tried LuaLaTeX, but I just tried it and it works with including Arabic or without it. – Aidan Kaplan Feb 20 '17 at 05:31
  • @AidanKaplan As far as I know, the bidi package (which is loaded by polyglossia if you select an RTL language like Arabic or Hebrew) is for use with XeLaTeX only, not LuaLaTeX, and so if your document requires Arabic, you should not use LuaLaTeX. And your sample document works fine with XeLaTeX for me. – Alan Munn Feb 20 '17 at 16:21
  • Hi Aidan! I also can't replicate the effect you're describing with XeLaTeX. – Jason Zentz Feb 20 '17 at 17:00
  • Have you tested to see whether the effect is still there for some other kind of box instead of the tikzpicture? – Jason Zentz Feb 20 '17 at 17:01
  • Also, your OS/editor configuration reminds me of this issue. If you add % !TEX encoding = UTF-8 Unicode to the top of the file, does that change the behavior? – Jason Zentz Feb 20 '17 at 17:03
  • Hi Jason! Unfortunately adding that line doesn't change anything about the output. And that's good to know that LuaLaTeX doesn't work with polyglossia – Aidan Kaplan Feb 21 '17 at 01:56
  • LuaLaTeX does work with polyglossia, but not bidi so not for RTL scripts. Can you put \listfiles before \documentclass and post the list of files you get on the console/in the log? I can only think you have an old version of something or a stale confg file. – cfr Feb 21 '17 at 02:09
  • Also, just to be sure, make a new directory and copy the code from the question to an empty document. Save into the new directory and compile there. This is a sanity check, basically, to rule out imponderables. – cfr Feb 21 '17 at 02:13
  • I just met with Aidan (my student), and we think the problem may be due to an out-of-date distribution. However, he wants to hold off on updating because he is finishing a thesis and doesn't want to break everything... – Jason Zentz Feb 23 '17 at 17:35
  • We did determine that the same effect happens inside any list item, whether from gb4e's exe environment or not. – Jason Zentz Feb 23 '17 at 17:37

1 Answers1

3

The original poster is my student, so I met with him in person to debug this problem since none of the commenters were able to replicate the issue he reported.

It turns out that the problem is not specific to tikz-qtree or gb4e. It is caused by a bug in older versions of bidi (previously reported here) that interferes with the tikzpicture environment of tikz. With these older versions of bidi, you can see the effect in any list environment, not just gb4e's exe environment.

There are two solutions:

  1. Update bidi to the current version, which no longer has the bug. In general this is what I would recommend, but Aidan has opted not to do this for now because he is nearly finished writing a thesis and doesn't want other things in his setup to break.
  2. Surround the tikzpicture environment in a \makebox{}, as suggested in this answer.
Jason Zentz
  • 4,158