user-is-inactive-forever / xepersian

Persian for LaTeX, using XeTeX
https://ctan.org/pkg/xepersian
5 stars 1 forks source link

Right-to-left columns in Latin environment #5

Open lrkrol opened 5 years ago

lrkrol commented 5 years ago

Brief outline of the issue

Using columns inside a XePersian Latin environment, the columns are in the wrong order (i.e., the first column is on the right-hand side of the page). In some cases, adding \LTRdblcol fixes this, but not always.

Specifically, when using makeidx's \printindex command, which prints a two-column index, in a Latin environment, the columns are in the wrong order. The same problem occurs when using a multicols environment. In the case of makeidx, this can be resolved by using bidi's \LTRdblcol --- but this should not be necessary. Furthermore, \LTRdblcol does not fix the same issue in the multicols environment.

Check/indicate

Minimal example showing the issue

% !TEX TS-program = XeLaTeX
% !TEX encoding = UTF-8 Unicode

\documentclass{article}

\usepackage{makeidx}
\usepackage{multicol}
\usepackage{xepersian}
\settextfont{IRXLotus}
\makeindex

\begin{document} 
\begin{latin}

\index{a}
\index{b}

% \LTRdblcol
\printindex

\begin{multicols}{2}
First column
\vfill\columnbreak
Second column
\end{multicols}

\end{latin}
\end{document}

Expected behavior

The first page should have an automatically generated two-column index, where the columns are populated left-to-right. The second page should have a two-column multicols environment, where the columns are populated left-to-right.

Instead, both are populated right-to-left. The \LTRdblcol command only solves the index, not the multicols environment.

Log and PDF files

xepersianlog.txt xepersiancolumns.pdf

user-is-inactive-forever commented 5 years ago

Dear Laurens,

Thanks for your bug report. My understanding from your bug report is that

  1. The control sequence \LTRdblcol has no effect when the package multicol is used; and

  2. Whenever we are inside the latin environment, the columns should automatically be typeset from left to right.

The control sequence \LTRdblcol is only for twocolumn option of the control word \documentclass. For the multicol package, you would need to use the control sequence \LTRmulticolcolumns.

Regarding issue 2, the columns order changes whenever the main direction changes. Since your document's main direction is right to left, therefore the columns order are right to left. If you change the main direction in your document to left to right, then columns are also typeset left to right.

\documentclass{article}

\usepackage{makeidx}
\usepackage{multicol}
\usepackage[%
  documentdirection=lefttoright%
]
{xepersian}
\settextfont{IRXLotus}
\makeindex

\begin{document} 
\begin{latin}

\index{a}
\index{b}

% \LTRdblcol
\printindex

\begin{multicols}{2}
First column
\vfill\columnbreak
Second column
\end{multicols}

\end{latin}
\end{document}

This has been the default behavior of the bidi package for more than 10 years. I think you are saying that whenever the direction changes, the order of columns also should be changed to agree with the direction. If I was going to make a change, this would introduce an incompatibility with older versions of the bidi package.

I keep this issue open while I am thinking about what it is best to do.

Best wishes, Vafa Khalighi

lrkrol commented 5 years ago

Dear Vafa,

Thank you very much for the swift reply. I wasn't aware of the separate \LTRmulticolcolumns command. Your suggestions have certainly solved the immediate issues I was having.

But it was indeed my expectation that any columns started in a latin environment would default to LTR. Using a single global option works fine for my document, where I only need one and the same column order throughout. I can see how switching between different column orders within the same document may actually be really confusing, but a RTL column order with LTR text (and vice versa) is, too. Perhaps it's best to leave the choice to the user, but emphasise that this choice exists --- e.g. \begin{...}[LTRcols] and \begin{...}[RTLcols] as additional, optional arguments for the latin and persian environments?

Either way, thanks again for the help, and for the great packages!

Laurens