阿拉伯語模板中的目錄錯誤

阿拉伯語模板中的目錄錯誤
\documentclass[12pt,a4paper]{mathbook_arabic}
 
 %\newfontfamily\arabicfont[Script=Arabic]{Arial}
   \addto\captionsarabic{\renewcommand{\contentsname}{الفهرس}}
  
  % \newfontfamily\arabicfonttt[Script=Arabic]{Arial}
 
\usepackage{listings}
 \usepackage{mathrsfs}
 
 
 
  
  
\definecolor{bleu}{cmyk}{0.59,0.11,0,0.59}
\definecolor{vert}{cmyk}{0.78,0,0.74,0.45}
       
 
\begin{document}

 
\tableofcontents

\chapter*{Intro}
some textes 
\chapter{ch1}


  
  
  
 
  
  
     
 
 
 \end{document}

我編譯時的錯誤是

掃描 @dottedtocline 的使用時檔案結束。 \par l.68 \目錄

答案1

感謝您連結到背面的模板。我無法在 TeX Live 2020 上重現您的錯誤,儘管我確實得到了一個不同的錯誤:在should be\newfontfamily\arabicfonttt的第 107 行上。然後它在下一行重新聲明。舊版本允許這樣做,但現代版本將其標記為錯誤。mathbook_arabic.sty\newfontfamily\arabicfontsf\newfontfamily\arabicfontttfontspec

該模板中有很多特定於其編寫的書籍的內容,並且已經有點過時了。如果您可以自由地使用您想要的任何模板,我建議您從類似的模板開始,並根據需要進行修改。

\documentclass[a4paper]{book} % Or article, scrbook, etc.
\tracinglostchars=2 % Warn if the current font does not have a character.

%% The previous sample you were using loaded the cmyk color space and manually
%% declared color names in French.  This loads the standard color names used in
%% CSS, SVGs and HTML, e.g. Blue and DarkCyan.  You can add HTML to allow hex
%% values.
\usepackage[svgnames]{xcolor}

%% Requires LuaHBTeX, or LuaLaTeX from 2020 or later.
\usepackage[bidi=basic, layout=sectioning]{babel}
\usepackage{unicode-math}
\usepackage{microtype}

%% You will certainly want to set more options than this, either here or with
%% \hypersetup.
\usepackage[unicode,
            colorlinks]{hyperref}

%% Can substitute import=ar-DZ, import=ar-MA or import=ar-SY for import.
%% To change the numbers from Western to localized, add the maparabic option.
%% Can also change other counters, e.g. alph=alphabetic, Alph=abjad.
\babelprovide[import, main, onchar=ids fonts]{arabic}
\babelprovide[onchar=ids fonts]{english}

\defaultfontfeatures{Scale=MatchLowercase, Ligatures=TeX, Renderer=HarfBuzz}

%% You can change these to your fonts of choice.

\babelfont{rm}
          [Scale=1.0, Ligatures=Common, Script=Default, Language=Default]{Libertinus Serif}
\babelfont[arabic]{rm}
          {Amiri}
\babelfont{sf}
          [Ligatures=Common, Script=Default, Language=Default]{Libertinus Sans}
\babelfont[arabic]{sf}
          [Language=Default]{Noto Sans Arabic}
\babelfont{tt}
          [Script=Default, Language=Default]{Libertinus Mono}
\babelfont[arabic]{tt}
          {ALM Fixed}

\setmathfont{Libertinus Math}

\babeltags{english=english}
%% \babeltags would fail to redefine \arabic, so provide `\textArabic`, etc.
%% You are unlikely to need them, because babel will switch to Arabic whenever
%% you use the Arabic script.
\babeltags{Arabic=arabic}

\begin{document}
\chapter{A Chapter}

للُّغَة العَرَبِيّة هي أكثر اللغات السامية تحدثاً، وإحدى أكثر اللغات انتشاراً في العالم، يتحدثها أكثر من 467 مليون نسمة،

\begin{english}
Arabic (اَلْعَرَبِيَّةُ, al-ʿarabiyyah, [al ʕaraˈbijːa] or عَرَبِيّ‎, ʿarabīy, [ˈʕarabiː]
or [ʕaraˈbij]) is a Semitic language that first emerged in the 1st to 4th
centuries CE.
\end{english}

\end{document}

當您輸入拉丁文字時,此版本的範本將自動切換為英語,而每當您輸入阿拉伯文字時,此範本將自動切換為阿拉伯語。在此範例中,它確實使用了一種語言標記,這是因為我複製貼上的來源中的 IPA 符號兩者都不是,但它們應該以英文字體從左到右顯示。可以告訴 Babel 將他們視為英國人。您可以為每個缺少的字元新增重新定義,例如

\babelcharproperty{`ʕ}{locale}{english}

我選擇的主要字體是 Khaled Hosny 的 Amiri 和 Libertinus Sans,這兩種字體都基於早期的設計,並且相得益彰。

您可以將這些變更為您選擇的字體。例如,如果您擁有隨 Windows 10 一起分發的新版本 Arial,而不是某些作業系統仍附帶的舊版本,則可以將\babelfont{sf}和 後面的三行替換為\babelfont{sf}{Arial}.字體將自動縮放並選擇正確的ScriptOpenTypeLanguage功能。 (實際上,該Language=功能會給您發出虛假警告,因此您可以使用它\babelfont{sf}[Language=Default]{Arial}來抑制它們。)

對於數學,我將他的 Libertinus Math 加載到unicode-math.這意味著您不需要(也不應該使用)任何舊版數學字體包,例如amssymb.它支援\boldmath\boldsymbol.如果這不是您想要的,您可以將 和\usepackage{unicode-math)行替換\setmathfont

\usepackage{fontspec}
\usepackage[libertine]{newtxmath}
\usepackage{bm}

我不會更改頁面、標題、章節、目錄等的預設格式,但您可以使用您選擇的套件(例如tocloft和 )來執行此操作fancyhdr

相關內容