latex3 / babel

The babel system for LaTeX, LuaLaTeX and XeLaTeX
LaTeX Project Public License v1.3c
124 stars 34 forks source link

English & Arabic document breaks when using paracol #241

Closed amarakon closed 1 year ago

amarakon commented 1 year ago

Followup to #233. Previously, there was an issue where English and Arabic documents broke within a multicols environment from the multicol package. This has since been fixed. However, the issue still persists within a paracol environment from the paracol package. This only happens when inserting a paragraph end before \end{otherlanguage}, but I want to insert a paragraph end before \end{otherlanguage}, so that the linebreaker package can work. On the first page of the following document, the English text is shifted all the way to the left edge of the document, and the Arabic text is not visible.

\documentclass{book}

\usepackage{paracol, lipsum, linebreaker}
\usepackage[bidi = basic]{babel}

\babelprovide[main, import]{english}
\babelprovide[import]{arabic}

\babelfont[arabic]{rm}{Amiri}

\newcommand{\arabictext}{%
    \begin{otherlanguage}{arabic}
        لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار  النشوة وتمجيد
        الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة
        البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء
        الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية
        ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في
        الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن
        السعاده فيما نتحمله من كد وأسي.

    \end{otherlanguage}%
}

\begin{document}

\begin{paracol}{2}
    \lipsum[1]
    \switchcolumn
    \arabictext
    \switchcolumn*
    \lipsum[2]
    \switchcolumn
    \arabictext
    \switchcolumn*
    \lipsum[3]
    \switchcolumn
    \arabictext
\end{paracol}

\end{document}

babel-issue-1 babel-issue-2

jbezos commented 1 year ago

IIR, the order of columns is reversed, too (Arabic is first at the left, although hidden, and then at the right).

amarakon commented 1 year ago

That would explain why the Arabic is not visible on the first page.

jbezos commented 1 year ago

I’m not sure what paracol is doing, but the following piece of code seems to fix it (although the direction is hardcoded). I’ve done it a little blindly:

\makeatletter
\edef\pcol@output{\pagedir TRT \bodydir TRT \unexpanded\expandafter{\pcol@output}}
\makeatother
jbezos commented 1 year ago

The following seems better:

\edef\pcol@output{\bodydir\pagedir\unexpanded\expandafter{\pcol@output}}
amarakon commented 1 year ago

The following seems better:

\edef\pcol@output{\bodydir\pagedir\unexpanded\expandafter{\pcol@output}}

This works, thanks. If the problem is from paracol and not babel, you can close this issue.