从印度语到阿拉伯语的编号“阿拉伯巴别塔”

从印度语到阿拉伯语的编号“阿拉伯巴别塔”
\documentclass[12pt]{arabbook}
%%%%%%%%%%% packages
\usepackage{fancyhdr}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english, arabic]{babel}
\usepackage{t1enc}
\usepackage{float}
 \usepackage{arabtex} 
 \usepackage{amssymb}
\usepackage{graphicx}% ajouter des photos
\pagestyle{fancy}
\addto\captionsarabic{\renewcommand{\chaptername}{الفصل}}
\makeatletter
\newcommand{\arabic@words}[1]{% substitute the relevant Arabic numbers here
\ifcase#1\or الأوّل
\or الثاني\or الثالث\or الرابع\else\@ctrerr\fi}
\newcommand*\arabicwords[1]{\expandafter\arabic@words\csname c@#1\endcsname}
\renewcommand\thechapter{\arabicwords{chapter}}
\makeatother
\setcounter{page}{1}
\begin{document}
\tableofcontents
\chapter{أهلا}
\section{مرحبا}
\begin{arabtext}
mr.hbn bkm
\end{arabtext}
\end{document}

我想得到

韋斯特

代替

閱讀

并在章节标题中使用 مرحبا 1.1 代替 ١.١ مرحبا

我编辑了文件,感谢@Alan Munn,但问题出在目录中: 在此处输入图片描述

答案1

编辑如果由于某种原因需要使用 arabtex,这里是使用 pdflatex(arabi 和 arabtex)的另一种解决方案:

笔记我认为需要添加这个

\renewcommand*\l@section{\@dottedtocline{1}{1em}{1.5em}}

正确设置目录

\documentclass[12pt]{arabbook}
%---------------------------------------------                
\usepackage[LAE,T1]{fontenc}
\usepackage[utf8]{inputenc} 
\usepackage[english, arabic]{babel}
\usepackage{arabtex} 
%---------------------------------------------
\usepackage{amsmath,amssymb}
\usepackage{graphicx}  
\usepackage{float}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{etoolbox}
%---------------------------------------------
\addto\captionsarabic{\renewcommand{\chaptername}{الفصل}}
\makeatletter
\newcommand{\arabic@words}[1]{% substitute the relevant Arabic numbers here
\ifcase#1\or الأوّل
\or الثاني\or الثالث\or الرابع\else\@ctrerr\fi}
\newcommand*\arabicwords[1]{\expandafter\arabic@words\csname c@#1\endcsname}
\patchcmd{\@makechapterhead}{\thechapter}{\arabicwords{chapter}}{}{}
\makeatother
\renewcommand \thechapter {\textLR{\arabic{chapter}}}
\renewcommand \thesection {\thechapter.\textLR{\arabic{section}}}
\renewcommand \thesubsection {\thesection.\textLR{\arabic{subsection}}}

%---------------------------------------------
\begin{document}
\tableofcontents
\chapter{أهلا}
\section{مرحبا}
\begin{arabtext}
mr.hbn bkm
\end{arabtext}
\end{document}

这是一个解决方案。这个想法是重新定义\@makechapterhead命令并替换\thechapter\arabicwords{chapter}。为此,我们可以\patchcmd使用电子工具箱包裹:

\patchcmd{\@makechapterhead}{\thechapter}{\arabicwords{chapter}}{}{}

这是带有 xelatex 的 MWE:

\documentclass[12pt]{book}  
%---------------------------------------------                
\usepackage{fontspec}
\setmainfont{Times New Roman}
\setsansfont{Arial}
\setmonofont{Courier New}
\newfontfamily{\arabicfont}[Script=Arabic,Scale=1.2]{Amiri}
%\newfontfamily{\arabicfont}[Script=Arabic]{Amiri}
%---------------------------------------------
\usepackage{etoolbox}
\usepackage{amsmath,amssymb}
\usepackage{graphicx}  
\usepackage{float}
\usepackage{fancyhdr}
\pagestyle{fancy}
%---------------------------------------------
\usepackage{polyglossia}
\setdefaultlanguage[locale=algeria]{arabic}
\setotherlanguage{english}
%---------------------------------------------
\addto\captionsarabic{\renewcommand{\chaptername}{الفصل}}
\makeatletter
\newcommand{\arabic@words}[1]{% substitute the relevant Arabic numbers here
\ifcase#1\or الأوّل
\or الثاني\or الثالث\or الرابع\else\@ctrerr\fi}
\newcommand*\arabicwords[1]{\expandafter\arabic@words\csname c@#1\endcsname}
\patchcmd{\@makechapterhead}{\thechapter}{\arabicwords{chapter}}{}{}
\makeatother
%---------------------------------------------
\begin{document}
\tableofcontents
\chapter{أهلا}
\section{مرحبا}
مرحباً بكم
\textenglish{hello}
اللغة العربية

\begin{english}
welcome to TeX.se 
\textarabic{مرحباً}
This is an entire paragraph in english.
\end{english}


\end{document}

相关内容