1

I have a bidi-longtable in a mixed language document (mainlanguage Arabic). I am using minipages in each cell of the table because I will need to do some complicated things later like footnotes. The dimensions and visible borders and fonts are not important.

What is tricky for me is the right / left alignment within the cell. And further, the longtable affects the section heading. If I comment out the section with the longtable, the section heading is formatted nicely. But as soon as I put in the longtable the section heading is indented weirdly.

I want to achieve this: Imgur

But I get this:
Imgur

My MWE is not behaving. I have tried putting in % at the end of some lines because this seems to be a magic setting in TeX, but even this dark magic is not helping.

To make your answer even more helpful, could you please also explain why my code doesn't work?

\documentclass{article}
\usepackage{longtable}
\usepackage{bidi-longtable}

\usepackage{polyglossia}
\setmainlanguage{arabic}
\setotherlanguage{english}
\newfontfamily\arabicfont[Script=Arabic, Scale=1.50]{Times New Roman}
\newfontfamily\englishfont[Script=Latin]{Times New Roman}
\setlength{\parindent}{0pt}
\begin{document}


\section{بببببب \\%
\mbox{}\hfill\textenglish{bbbbbbb}}%

\begin{Arabic}
كلمة كلمة كلمة كلمة كلمة كلمة كلمة كلمة كلمة كلمة كلمة كلمة 
كلمة كلمة كلمة كلمة كلمة .\end{Arabic}

\begin{english}
word word word word word word word word word word word word word 
word word word word word word word word word word word word 
\end{english}

\begin{longtable}{p{2in}|p{2in}}
\begin{minipage}{2in}
\begin{Arabic}
كلمة 
\end{Arabic}%

\raggedleft 
\begin{english}
word \end{english}
\end{minipage}%
&
\begin{minipage}{2in}
\begin{english}
word 
\end{english}
\end{minipage}%
\end{longtable}


\end{document}
1

The package bidi-longtable is experimental; there is no way in TeX--XeT algorithm to make tabular material RTL except putting it inside

\hbox{\beginR\vbox{...}\endR}

construction. This has its own set of problems which adds up to TeX--XeT limitation.

A minimal example showing the problem is:

\documentclass{article}
\usepackage{lipsum}
\usepackage[RTLdocument]{bidi}
\setlength{\parindent}{0pt}
\begin{document}
\hbox{\beginR\vbox{%
\section{%
This is a test\\
\mbox{}\hfill\LRE{Another test}%
}%
}\endR}

\begin{LTR}
\lipsum[1]
\end{LTR}
\end{document}

The problem is that the file latex-xetex-bidi.def, redefines \@hangform as:

\def\@hangfrom#1{\setbox\@tempboxa\hbox{{#1}}%
      \hangindent \if@RTL-\else\fi\wd\@tempboxa\noindent\box\@tempboxa}

This redefinition is logical but if it ends up inside the following construction:

\hbox{\beginR\vbox{...}\endR}

Then margins will be opposite. With your minimal working example, I suggest the following redefinition:

\documentclass{article}
\usepackage{longtable}
\usepackage{bidi-longtable}

\usepackage{polyglossia}
\setmainlanguage{arabic}
\setotherlanguage{english}
\newfontfamily\arabicfont[Script=Arabic, Scale=1.50]{Times New Roman}
\newfontfamily\englishfont[Script=Latin]{Times New Roman}
\setlength{\parindent}{0pt}

\makeatletter
\def\@hangfrom#1{\setbox\@tempboxa\hbox{{#1}}%
      \hangindent \wd\@tempboxa\noindent\box\@tempboxa}
\makeatother
\begin{document}


\section{بببببب \\%
\mbox{}\hfill\textenglish{bbbbbbb}}%

\begin{Arabic}
كلمة كلمة كلمة كلمة كلمة كلمة كلمة كلمة كلمة كلمة كلمة كلمة 
كلمة كلمة كلمة كلمة كلمة .\end{Arabic}

\begin{english}
word word word word word word word word word word word word word 
word word word word word word word word word word word word 
\end{english}

\begin{longtable}{p{2in}|p{2in}}
\begin{minipage}{2in}
\begin{Arabic}
كلمة 
\end{Arabic}%

\raggedleft 
\begin{english}
word \end{english}
\end{minipage}%
&
\begin{minipage}{2in}
\begin{english}
word 
\end{english}
\end{minipage}%
\end{longtable}


\end{document}

Note that this is not a perfect solution; it only fixes your problem but breaks the bidi package.

  • at least i understand the problem better! – Tim Nov 28 '15 at 18:31

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.