4

I have two tabular side by side and I want their tops aligned.

When I use English language, it works fine.

When I use Arabic language, the tables suddenly become bottom-aligned, even though I used the [t] specification. For the Arabic I have used Times New Roman font, but this isn't essential. I am using the booktabs package.

I am guessing the problem lies in Bidi or polyglossia, but I don't know.

The MWE places both on the screen to show the problem.

\documentclass[10pt]{article}
\usepackage{booktabs}
\usepackage{polyglossia}
\setmainlanguage{arabic}
\setotherlanguage{english}
\newfontfamily\arabicfont[Script=Arabic]{Times New Roman}
\begin{document}


\begin{tabular}[t]{rl} \toprule
كلمة&كلمة\\ \midrule
كلمة&كلمة\\
\bottomrule
\end{tabular}
\hfill
\begin{tabular}[t]{rl} \toprule
كلمة&كلمة\\ \midrule
كلمة&كلمة\\
كلمة&كلمة\\
كلمة&كلمة\\
كلمة&كلمة\\
\bottomrule
\end{tabular}

\begin{english}
\begin{tabular}[t]{rl} \toprule
word&word\\ \midrule
word&word\\
\bottomrule
\end{tabular}
\hfill
\begin{tabular}[t]{rl} \toprule
word&word\\ \midrule
word&word\\
word&word\\
word&word\\
word&word\\
\bottomrule
\end{tabular}
\end{english}

\end{document}
5

There is a bug in array-xetex-bidi.def, line 90

\let\\\@arraycr \let\tabularnewline\\\let\par\@empty \if@RTLtab\hbox\bgroup\beginR\vbox\bgroup\fi\@preamble}

To be more precise, the bug is in

\if@RTLtab\hbox\bgroup\beginR\vbox\bgroup\fi

which unconditionally inserts the table in a \vbox, making irrelevant the \vtop started with the [t] option.

If I change it to

\if@RTLtab
  \hbox\bgroup\beginR
  \if#1t\vtop\else\vbox\fi\bgroup
\fi

the output is

enter image description here

(note: I used \quad instead of \hfill between the tables).

Temporary workaround:

\documentclass[10pt]{article}
\usepackage{booktabs}
\usepackage{polyglossia}
\setmainlanguage{arabic}
\setotherlanguage{english}
\newfontfamily\arabicfont[Script=Arabic]{Times New Roman}

\usepackage{etoolbox}

\makeatletter
\patchcmd{\@array}
  {\beginR\vbox}
  {\beginR\if#1t\vtop\else\vbox\fi}
  {}{}
\makeatother

\begin{document}

The patch will be unsuccessful when the bug is fixed, so it will make no harm.

  • did you submit bug, or should i? – Tim Nov 4 '15 at 19:48
  • @Tim Please, do. – egreg Nov 4 '15 at 20:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.