<div dir="ltr">Actually, bidi does clobber imakeidx. In all of the document classes, bidi redefines the \theindex environment. Some of the imakeidx functionality also comes from redefining \theindex. I had problems with this in the past. The only issue that would be presented with the op's patch is that there won't be bidi support inside the index. That's easily solved by just using othercode = \raggedleft when setting up the index. <br></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Apr 25, 2018 at 6:20 PM Zdenek Wagner <<a href="mailto:zdenek.wagner@gmail.com">zdenek.wagner@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Sure, bidi has nothing to do with it. And I woult prefer to modify the prolog generated by the index. If you randomly redefine a few macros inside \AtBeginDocument, it might fail unpredictably if a package is used with its own modifications.<br><br></div>Stackexchange may contain useful solutions but the original documentation is often a better and more reliable source of information.<br><br></div><div class="gmail_extra"></div><div class="gmail_extra"><br clear="all"><div><div class="m_-7579132596042118293gmail_signature" data-smartmail="gmail_signature">Zdeněk Wagner<br><a href="http://ttsm.icpf.cas.cz/team/wagner.shtml" target="_blank">http://ttsm.icpf.cas.cz/team/wagner.shtml</a><br><a href="http://icebearsoft.euweb.cz" target="_blank">http://icebearsoft.euweb.cz</a></div></div>
<br></div><div class="gmail_extra"><div class="gmail_quote">2018-04-25 16:55 GMT+02:00 Vafa Khalighi <span dir="ltr"><<a href="mailto:vk489@uowmail.edu.au" target="_blank">vk489@uowmail.edu.au</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div dir="auto">
<div style="direction:ltr">The comment about bidi is wrong.</div>
<br>
<div id="m_-7579132596042118293m_-4560690212895468288AppleMailSignature">Sent from my iPhone</div><div><div class="m_-7579132596042118293h5">
<div><br>
On 26 Apr 2018, at 12:51 am, Kamal Abdali <<a href="mailto:k.abdali@acm.org" target="_blank">k.abdali@acm.org</a>> wrote:<br>
<br>
</div>
<blockquote type="cite">
<div>
<div dir="ltr">
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">
Thanks, Zdeněk. I found the problem and a solution for it discussed here: <br>
<a href="https://tex.stackexchange.com/questions/263696/polyglossias-setotherlanguage-blocks-imakeindexs-indexprologue" target="_blank">https://tex.stackexchange.com/questions/263696/polyglossias-setotherlanguage-blocks-imakeindexs-indexprologue</a>. The solution did work
 for me. <br>
<br>
Briefly, the problem is attributed to bidi's restoring the <code>book</code> definition of the
<span style="font-family:monospace,monospace"><code>theindex</code></span> environment for no apparent reason. The solution is to insert the following lines between the
<span style="font-family:monospace,monospace">\usepackage{imakeindex}</span> and <span style="font-family:monospace,monospace">
\makeindex[intoc]</span> lines:<br>
<br>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap"><span style="font-family:monospace,monospace">% nullify bidi redefinition</span></p>
<span style="font-family:monospace,monospace"></span>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap"><span style="font-family:monospace,monospace">% this should go after polyglossia and imakeidx have been loaded</span></p>
<span style="font-family:monospace,monospace"></span>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap"><span style="font-family:monospace,monospace">\let\imakeidxtheindex\theindex</span></p>
<span style="font-family:monospace,monospace"></span>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap"><span style="font-family:monospace,monospace">\let\imakeidxendtheindex\endtheindex</span></p>
<span style="font-family:monospace,monospace"></span>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap"><span style="font-family:monospace,monospace">\AtBeginDocument{%</span></p>
<span style="font-family:monospace,monospace"></span>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap"><span style="font-family:monospace,monospace">\let\theindex\imakeidxtheindex</span></p>
<span style="font-family:monospace,monospace"></span>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap"><span style="font-family:monospace,monospace">\let\endtheindex\imakeidxendtheindex</span></p>
<span style="font-family:monospace,monospace"></span>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap"><span style="font-family:monospace,monospace">}</span></p>
<span style="font-family:monospace,monospace"></span>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap"><br>
</p>
Kamal Abdali<br>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Wed, Apr 25, 2018 at 4:25 AM, Zdenek Wagner <span dir="ltr">
<<a href="mailto:zdenek.wagner@gmail.com" target="_blank">zdenek.wagner@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">You have to redefine the header, it automatically inserts \chapter*{Index}. You have to remove the asterisk. I do not remember the details, I would have to search in the documentatin but it is written there.<br>
<br>
</div>
<div class="gmail_extra"><br clear="all">
<div>
<div class="m_-7579132596042118293m_-4560690212895468288m_3704635144416860446gmail_signature" data-smartmail="gmail_signature">
Zdeněk Wagner<br>
<a href="http://ttsm.icpf.cas.cz/team/wagner.shtml" target="_blank">http://ttsm.icpf.cas.cz/team/wagner.shtml</a><br>
<a href="http://icebearsoft.euweb.cz" target="_blank">http://icebearsoft.euweb.cz</a></div>
</div>
<br>
<div class="gmail_quote">
<div>
<div class="m_-7579132596042118293m_-4560690212895468288h5">2018-04-24 23:09 GMT+02:00 Kamal Abdali <span dir="ltr"><<a href="mailto:k.abdali@acm.org" target="_blank">k.abdali@acm.org</a>></span>:<br>
</div>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div class="m_-7579132596042118293m_-4560690212895468288h5">
<div dir="ltr">
<div style="font-family:arial,helvetica,sans-serif;font-size:small">To get the index listed in the table of contents, I include these two lines in the preamble of a xelatex+polyglossia+bidi program:<br>
<br>
\usepackage[imakeidx]<br>
\makeindex[intoc]<br>
<br>
My problem is that while the index does get produced it doesn’t get listed in the TOC. The trouble can be reproduced in this small program:<br>
<br>
%%%%%%%%%%%%%%%%%%%<br>
\documentclass{book}<br>
<br>
\usepackage{imakeidx}<br>
\makeindex[intoc]<br>
<br>
\usepackage{polyglossia}<br>
\usepackage{bidi}       %%%%%<br>
\setmainlanguage{english}   <br>
<br>
\title{Facts}<br>
\author{Aleck}<br>
\date{}<br>
<br>
\begin{document}<br>
\maketitle<br>
\tableofcontents<br>
\chapter{Stars}<br>
Sirius, the brightest star in the night sky, is actually a double star.<br>
\index{Sirius}<br>
\printindex <br>
\end{document}<br>
%%%%%%%%%%%%%%%%%%%%<br>
<br>
The above program produces the index without listing it in the TOC. However, if you comment out the  \usepackage{bidi} line, the index IS produced and listed in TOC as expected.<br>
<br>
Note that the above program doesn’t really need bidi as all of its output text is in the Latin script. But I do need the bidi feature  in the actual document that I need to process.<br>
<br>
Any help will be appreciated.<span class="m_-7579132596042118293m_-4560690212895468288m_3704635144416860446HOEnZb"><font color="#888888"><br>
<br>
</font></span></div>
<span class="m_-7579132596042118293m_-4560690212895468288m_3704635144416860446HOEnZb"><font color="#888888">
<div style="font-family:arial,helvetica,sans-serif;font-size:small">Kamal Abdali<br>
</div>
<div style="font-family:arial,helvetica,sans-serif;font-size:small"><br>
</div>
</font></span></div>
<br>
<br>
<br>
</div>
</div>
--------------------------------------------------<br>
Subscriptions, Archive, and List information, etc.:<br>
  <a href="http://tug.org/mailman/listinfo/xetex" rel="noreferrer" target="_blank">
http://tug.org/mailman/listinfo/xetex</a><br>
<br>
</blockquote>
</div>
<br>
</div>
<br>
<br>
<br>
--------------------------------------------------<br>
Subscriptions, Archive, and List information, etc.:<br>
  <a href="http://tug.org/mailman/listinfo/xetex" rel="noreferrer" target="_blank">
http://tug.org/mailman/listinfo/xetex</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</blockquote>
</div></div></div>

</blockquote></div><br></div>
<br>
<br>
--------------------------------------------------<br>
Subscriptions, Archive, and List information, etc.:<br>
  <a href="http://tug.org/mailman/listinfo/xetex" rel="noreferrer" target="_blank">http://tug.org/mailman/listinfo/xetex</a><br>
</blockquote></div>