奇怪的“多语”阿拉伯语错误,带有“toc”

奇怪的“多语”阿拉伯语错误,带有“toc”

如果我arabic像下面这样注释掉 polyglossia 选项,则不会出现错误。否则,如果我想要目录,文档甚至不会编译。

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

%weird toc problem in twoside mode in mwbk
\makeatletter
\renewcommand*\chapter@toc{%
    \ifHeadingNumbered\typeout{\@chapapp\space\thechapter.}\fi
    \addcontentsline{toc}{chapter}{%
        \ifHeadingNumbered
        \mw@seccntformat{\@chapapp\ \thechapter}%
        \fi
        \HeadingTOCText}}%

\makeatother


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


\begin{document}

\tableofcontents

\chapter{Test}

\end{document}

答案1

ycbookmwbk不受bidi包支持。发生的情况是bidi重新定义一些tocloft宏,但当您加载时,该宏mwbk的重新定义会因该宏的重新定义而丢失。因此,显然,解决方案是在文件加载后重新定义。\l@chaptermwbk\l@chaptertocloftbidi\l@chaptertitletoc-xetex-bidi.def

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

%weird toc problem in twoside mode in mwbk
\makeatletter
\renewcommand*\chapter@toc{%
    \ifHeadingNumbered\typeout{\@chapapp\space\thechapter.}\fi
    \addcontentsline{toc}{chapter}{%
        \ifHeadingNumbered
        \mw@seccntformat{\@chapapp\ \thechapter}%
        \fi
        \HeadingTOCText}}%

\renewcommand*\l@chapter[2]{\addvspace{.3\baselineskip}%
        \mw@tocline{0}{\@tocindent}{\@tocindenti}{\textbf{#1}}{#2}%
        \addvspace{.2\baselineskip}}
\makeatother


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


\begin{document}

\tableofcontents

\chapter{Test}

\end{document}

相关内容