# Weird polyglossia Arabic error with toc

If I comment the arabic polyglossia option as below, there is no error. Otherwise, the document won't even compile if I want a Table of Contents.

\documentclass[twocolumn,twoside,titleauthor]{ycbook}
\usepackage{fontspec,polyglossia}

%weird toc problem in twoside mode in mwbk
\makeatletter
\renewcommand*\chapter@toc{%
\mw@seccntformat{\@chapapp\ \thechapter}%
\fi

\makeatother

\setmainlanguage{english}
%\setotherlanguage{arabic}
\newfontfamily\arabicfont[Script=Arabic,Mapping=arabicdigits]{Amiri}

\begin{document}

\tableofcontents

\chapter{Test}

\end{document}


The class ycbook or mwbk is not supported by the bidi package. What happens is that bidi redefines some tocloft macros but when you load mwbk, the redefinition of \l@chapter that mwbk does gets lost by the redefinition of \l@chapter of tocloft that bidi does. So clearly, the solution is to redefine \l@chapter after the file titletoc-xetex-bidi.def is loaded.

\documentclass[twocolumn,twoside,titleauthor]{ycbook}
\usepackage{fontspec,polyglossia}

%weird toc problem in twoside mode in mwbk
\makeatletter
\renewcommand*\chapter@toc{%
\mw@seccntformat{\@chapapp\ \thechapter}%
\fi

\mw@tocline{0}{\@tocindent}{\@tocindenti}{\textbf{#1}}{#2}%
\makeatother

\setmainlanguage{english}
\setotherlanguage{arabic}
\newfontfamily\arabicfont[Script=Arabic,Mapping=arabicdigits]{Amiri}

\begin{document}

\tableofcontents

\chapter{Test}

\end{document}