这是一个最小的例子,我不知道问题出在哪里?
\documentclass[12pt,a4paper,openany]{book}
%%%%%%%%%%%%%%%%%%%
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
linkcolor=blue,
filecolor=magenta,
urlcolor=cyan,
citecolor=blue
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{polyglossia}
\setmainlanguage[numerals=maghrib]{arabic}
\setotherlanguage{english}
\newfontfamily\arabicfont[Script=Arabic,Scale=1.1,AutoFakeSlant=-0.03]{Amiri}
\setsansfont[Script=Arabic,Scale=1.1]{Amiri}
\makeatletter
\pretocmd{\@chapter}{\begingroup \renewcommand{\thechapter}{{\words{chapter}}}}{}{}
\apptocmd{\@chapter}{\endgroup}{}{}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MACRO FOR LITERAL NUMBERING %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\words[1]{\expandafter\xwords\csname c@#1\endcsname}
\def\xwords#1{\ifcase#1\or
الأول\or
الثاني\or
الثالث\or
الرابع\or
\else
I need more words\fi}
\makeatletter
\patchcmd{\@makechapterhead}{\thechapter}{\words{chapter}}{}{}
\makeatother
%%%%%%%%%%%%%%%%%% REDEFINES \THECHAPTER IN CONTENTS
\makeatletter
\pretocmd{\@chapter}{\begingroup \renewcommand{\thechapter}{{\words{chapter}}}}{}{}
\apptocmd{\@chapter}{\endgroup}{}{}
\makeatother
\usepackage[Glenn]{fncychap}
\ChNumVar{\Large}% Dimension of the number of the chapter in the first page... instead of the default...\ChNumVar{\Huge}
\begin{document}
\chapter{واحد}
\end{document}
答案1
这可能是也可能不是一个合适的答案,但据我所知(作为一个不懂阿拉伯语的人),它给出的输出与您的 MWE 相同hyperref
(不包括目录和标题)。
我已改用babel
和 LuaLaTeX 来解决 的加载顺序问题bidi
。并进行了修补。这是嵌入到其自己的新 中的\Hy@org@chapter
原始\@chapter
宏。hyperref
\@chapter
\documentclass[12pt,a4paper,openany]{book}
\usepackage{etoolbox}
\usepackage[nil,bidi=basic-r]{babel}
\babelprovide[import,main]{arabic}
\babelprovide[import]{english}
\babelfont[arabic]{rm}[Scale=1.1, AutoFakeSlant=-0.03]{Amiri}
\babelfont[arabic]{sf}[Scale=1.1]{Amiri}
\usepackage[Glenn]{fncychap}
\ChNumVar{\Large}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
linkcolor=blue,
filecolor=magenta,
urlcolor=cyan,
citecolor=blue
}
\newcommand\words[1]{\expandafter\xwords\csname c@#1\endcsname}
\def\xwords#1{%
\ifcase#1\or
الأول\or
الثاني\or
الثالث\or
الرابع\or
\else
I need more words\fi}
\makeatletter
\pretocmd{\Hy@org@chapter}
{\begingroup \renewcommand{\thechapter}{{\words{chapter}}}}
{}
{}
\apptocmd{\Hy@org@chapter}
{\endgroup}
{}
{}
\patchcmd{\@makechapterhead}
{\thechapter}
{\words{chapter}}
{}
{}
\makeatother
\begin{document}
\chapter{واحد}
\end{document}