[Tex/LaTex] Switch twocolumn between right-to-left and left-to-right with the package multiind in polyglossia

arabicpolyglossiaright-to-left

Writing a book in arabic, I want to obtain a dictionnary of used words in my document between arabic and english, and want that the entries of the dictionnary will be in two different orders, in arabic alphabetic order and in english alphabetic order. My idea is to use the package multiind which produces several indexes, to produce two idx files dic_english.idx and dic_arabic.idx.

The commands

\index{dic_english}{Random@\idxsechead{Random\hfill arabic_word}|idxnopage} 

and

\index{dic_arabic}{arabic_word@\idxsechead{Random\hfill arabic_word}|idxnopage}

will produce these two files, the same files, in english order for the first and arabic order for the second. My problem is that the twocolumn command will produce columnation on the right for the two files (first column on the right and second on the left)… but I want to obtain the index in english order having the first column on the left and the second column on the right. Someone have some idea for this ?… Precisely, How can I obtain an index right-to-left and an index left-to-right in the same time?

Thanks, Faouzi

Best Answer

It's possible to change the page column layouts using the flowfram package, but it's quite complicated. The example below starts with a single column layout for the title page and first two chapters, then switches to a LR two column layout for the third chapter, followed by a RL two column layout for the fourth chapter and then switches back to a single column layout for the final two chapters.

\documentclass{book}

\usepackage{lipsum}
\usepackage{calc}
\usepackage{etoolbox}
\usepackage{flowfram}

\newlength\chapheadheight
\setlength\chapheadheight{0.25\textheight}

\newlength\chapflowheight
\setlength\chapflowheight{\textheight-\chapheadheight}

\newdynamicframe[none]{\textwidth}{\chapheadheight}{0pt}{\chapflowheight}[chaphead]

\dfchaphead*{chaphead}

\newflowframe[none]{\textwidth}{\chapflowheight}{0pt}{0pt}[chapmain]

\onecolumn
\setflowframe{2}{label=main}

\twocolumninarea[none]{\textwidth}{\chapflowheight}{0pt}{0pt}
\setflowframe{3}{label=chap-english-left}
\setflowframe{4}{label=chap-english-right}

\twocolumn[none]
\setflowframe{5}{label=english-left}
\setflowframe{6}{label=english-right}

\lefttorightcolumnsfalse

\twocolumninarea[none]{\textwidth}{\chapflowheight}{0pt}{0pt}
\setflowframe{7}{label=chap-arabic-right}
\setflowframe{8}{label=chap-arabic-left}

\twocolumn[none]
\setflowframe{9}{label={arabic-right}}
\setflowframe{10}{label={arabic-left}}

\newcommand*{\prechaphook}{%
  \dynamicswitchonnextoddonly*{chaphead}%
  \flowswitchonnextoddonly*{chapmain}%
  \flowswitchoffnextoddonly*{main}%
}

\preto\chapter{\prechaphook}

\newcommand*{\switchonLRtwocolumns}{%
  \flowswitchonnext*{english-left,english-right}%
  \flowswitchoffnext*{chapmain,main}%
  \dynamicswitchonnextoddonly*{chaphead}%
  \flowswitchonnextoddonly*{chap-english-left,chap-english-right}%
  \flowswitchoffnextoddonly*{english-left,english-right}%
  \cleardoublepage
  \renewcommand*{\prechaphook}{}%
}

\newcommand*{\switchonRLtwocolumns}{%
  \flowswitchonnext*{arabic-left,arabic-right}%
  \flowswitchoffnext*{english-left,english-right}%
  \dynamicswitchonnextoddonly*{chaphead}%
  \flowswitchonnextoddonly*{chap-arabic-left,chap-arabic-right}%
  \flowswitchoffnextoddonly*{arabic-left,arabic-right}%
  \cleardoublepage
}

\newcommand*{\switchononecolumn}{%
  \flowswitchoffnext*{arabic-left,arabic-right}%
  \flowswitchonnext*{main}%
  \dynamicswitchonnextoddonly*{chaphead}%
  \flowswitchonnextoddonly*{chapmain}%
  \flowswitchoffnextoddonly*{main}%
  \clearpage
  \renewcommand*{\prechaphook}{%
    \renewcommand*{\prechaphook}{%
       \dynamicswitchonnextoddonly*{chaphead}%
       \flowswitchonnextoddonly*{chapmain}%
       \flowswitchoffnextoddonly*{main}%
    }%
  }%
}

\title{Sample Title}
\author{Sample Author}

\begin{document}
\maketitle

\chapter{Sample}
\lipsum

\chapter{Another Sample}
\lipsum[1-5]

\switchonLRtwocolumns
\chapter{LR}
\lipsum

\switchonRLtwocolumns
\chapter{RL}
\lipsum

\switchononecolumn
\chapter{One Column Again}

\lipsum

\chapter{And Again}
\lipsum

\end{document}

This assumes a two-sided book. You may need to set a larger value for \chapheadheight if your chapter headings exceed the allocated space. You should be able to just replace \chapter{LR} with the \printindex{dico-english} command and replace \chapter{RL} with the \printindex{dico-arabic}{\LR{Arabic entries...}} command. (I don't have the required fonts installed to compile your example.)

Edit:

If you want to use polyglossia with flowfram you have to make sure you load polyglossia first, as they both modify the output routine.

Related Question