1

\For the shown, MWE I have an issue which that the index package (any of the indexes package: makeidx,imakeidx,xindy,xindex) does not generate the index upon compilation. However, Upon removing the option (layout=counters.lists.tabular) within the babel package. The file index is generated normally. Does anyone know a workaround this since I need such option in order to maintain numbering in the document to appear with the main document language.


\documentclass[a4paper,12pt,twoside]{book}
%General Settings
\usepackage[a4paper,top=2.5cm,bottom=2.5cm,margin=2.5cm,bindingoffset=0.5cm]{geometry} % Set paper layout

%==================================================================================================
%CROSS-Referencing
%==================================================================================================

\usepackage{makeidx}
    \makeindex

%======================================================================================================
%Babel Package Settings%
%======================================================================================================

\usepackage[nil,bidi=basic-r,layout=counters.lists.tabular]{babel}
\babelprovide[import=ar,mapdigits,main]{arabic}
\babelprovide[import=en,language=Default]{english}
\babelfont{rm}{Latin Modern Roman}
\babelfont[arabic]{rm}{amiri}
%==================================================
%Start actual document %
%===================================================


\title{jhhjjhhj}
\author{}
\date{}


\begin{document}
 يسبسيسيب
 سيبيسيبيسب
 سيبيسبسيبس
 سيبسيبسيب
\index{dfdfdf}
\end{document}
``````````````````````````````````````````````````````````````````````````````

  • Don't make so long examples. I at least have neither the time nor the will to install lots of fonts and read lots of unrelated code lines to answer a question. This here it is a question and answer site where people are helping in their free time. Take this into account. – Ulrike Fischer Sep 5 '19 at 7:34
  • @ Ulrike, Sorry for annoyment, I simplified the code. – Silva Sep 5 '19 at 7:53
  • Isn't this much the same as your question at tex.stackexchange.com/questions/506372/… ? – David Purton Sep 5 '19 at 8:32
  • @ David, The same however, I wasn't able to post the code above in the comments of the previous question, so I thought the discussion can be continued here. The previous one was resolved through the use of the bib2gls package, however, I believe that using xindex - xindy - imakeidx can be made possible if we figured out the conflict between such packages and the babel package option (layout=counters.lists.tabular), as the issue was thought to be a conflict due to the use of unicode characters, while it might not be – Silva Sep 5 '19 at 8:41
  • 1
    As I already mentioned in one comment of your many questions: The problem is that babel changes the definition of \arabic and so the page counter has a form in the idx file that makeindex doesn't like. – Ulrike Fischer Sep 5 '19 at 9:42
2

Update

Using bidi=basic allows us to dispense with layout=counters. This means we can run xindy without any of the below perl hacks.

This also shows how you might have two indexes for two languages.

Run

$ lualatex filename.tex
$ texindy -L persian-variant1 -C utf8 filename.idx
$ texindy -C utf8 filename-en.idx
$ lualatex filename.tex

The texindy commands are supposed to run automatically if you call lualatex with --shell-escape, but for some reason they don't for me :/.

MWE

\documentclass{article}

\usepackage[bidi=basic,layout=lists.tabular]{babel}
\babelprovide[import=ar,mapdigits,main]{arabic}
\babelprovide[import=en,language=Default]{english}
\babelfont[arabic]{rm}{Amiri}
\babelfont[english]{rm}{Latin Modern Roman}

\usepackage[xindy,nonewpage]{imakeidx}
\makeindex[options=-L persian-variant1 -C utf8]
\makeindex[name=\jobname-en, options=-C utf8]


\begin{document}
يسبسيسيب
\index{أَلِف}

يسبسيسيب
\index{بَاء}

يسبسيسيب
\index[\jobname-en]{Alpha@\foreignlanguage{english}{Alpha}}

يسبسيسيب
\index[\jobname-en]{Beta@\foreignlanguage{english}{Beta}}

\printindex
\selectlanguage{english}
\printindex[\jobname-en]
\end{document}

MWE output


Original answer

Difficult. And I don't really understand what is going on here.

This is what happens. With the babel option layout=counters.lists.tabular, an extra macro gets inserted into the idx file by babel with the page number. This causes the indexing programs to die. Perhaps babel should not do this.

So for \index{أَلِف} the idx file has a line in it like this:

\indexentry{أَلِف}{\babelsublr  {1}}

But we want it to look like this:

\indexentry{أَلِف}{1}

So, what to do? We could use a perl one-liner to edit the file:

perl -pi -e 's/\\babelsublr\s*?{(.*?)}/$1/'

For the actual index set up, I think you need to use xindy. Sadly I find xindy very difficult to understand and use. It's not very well documented and there are few examples. There are no Arabic rules, but some have suggested that it's possible to xindy-persian.

I do seem to be able to get semi-sensible results.

MWE

I build this manually using the following commands:

$ lualatex filename.tex
$ perl -pi -e 's/\\babelsublr\s*?{(.*?)}/$1/' filename.idx
$ xindy -L persian-variant1 -C utf8 -M numeric-sort -M latex -M latex-loc-fmts -M texindy filename.idx
$ lualatex filename.tex

I get the xindy command line from here.

\documentclass{article}

\usepackage[bidi=basic-r,layout=counters.lists.tabular]{babel}
\babelprovide[import=ar,mapdigits,main]{arabic}
\babelprovide[import=en,language=Default]{english}
\babelfont[arabic]{rm}{Amiri}
\babelfont[english]{rm}{Latin Modern Roman}

\usepackage[xindy,nonewpage]{imakeidx}
\makeindex[noautomatic]

\begin{document}
 يسبسيسيب
\index{أَلِف}

يسبسيسيب
\index{بَاء}

يسبسيسيب
\index{Alpha@\foreignlanguage{english}{Alpha}}

يسبسيسيب
\index{Beta@\foreignlanguage{english}{Beta}}

\printindex
\end{document}

MWE output

  • Regarding the [xindex] package, can it provide any further privileges?? – Silva Sep 5 '19 at 9:59
  • @Silva, I'm not sure what you mean. Are you referring to the xindy-persian package? – David Purton Sep 5 '19 at 10:00
  • ctan.org/pkg/xindex?lang=en – Silva Sep 5 '19 at 10:01
  • 1
    @silva, Looking at the babel manual I think nil is no longer needed. It used to be and I hadn't checked for a while. It seems to work OK (better?) without it. And yes, maybe using bidi=basic is better, especially since you are using many languages. Try and see? – David Purton Sep 5 '19 at 10:14
  • 1
    @Silva, from the manual I take it that you could get rid of counters then which might give the right idx output. – David Purton Sep 5 '19 at 10:16

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.