แบบอักษรอาหรับสำหรับ documentclass {exam}
รหัสของฉัน
\documentclass{exam}
\pagestyle{headandfoot}
\firstpageheader{\bfseries\large رياضيات\\مأمون }{\includegraphics{example-image}}{\bfseries\large الإمتحان الأول }
\begin{document}
مرحبا كيف حالكم, جزاكم الله كل خير
\begin{table}
\begin{tabular}{lllll}
الوحدة & فصول الوحدة & عدد الحصص & الفترة الزمنية & الوسائل المقترحة\\
\end{tabular}
\end{table}
\end{document}
รหัสทั้งหมดนี้ใช้ไม่ได้
\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}
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{english}
\setotherlanguage{arabic}
\newfontfamily\arabicfont[Script = Arabic]{Simplified Arabic}
\usepackage{sexam} % wexam & sexam package
%\setdefaultlanguage[calendar=gregorian,,locale=algeria]{arabic} % on sexam.sty
%\newfontfamily\arabicfont[Script=Arabic,Scale=1.1]{Amiri}% on sexam.sty
%\newfontfamily\arabicfontsf[Script=Arabic,Scale=1.2]{Aljazeera}% on sexam.sty
%\newfontfamily\arabicfonttt[Script=Arabic,Scale=1.1]{Simplified Arabic} % on sexam.sty
คำตอบ
LuaLaTeX ต้องการตัวแสดงผล HarfBuzz เพื่อแสดงสคริปต์ที่ซับซ้อนพร้อมด้วยอักขระที่รวมเข้าด้วยกัน แต่จะเลือกตัวแสดงผลแบบเก่าตามค่าเริ่มต้น สิ่งนี้ดูเหมือนจะได้ผลสำหรับฉัน (แม้ว่าฉันจะไม่รู้ภาษาอาหรับและขออภัยหากข้อความไม่ถูกต้อง)
\documentclass{exam}
\usepackage{polyglossia}
\setmainlanguage[numerals=maghrib]{arabic}
\setotherlanguage{english}
\newfontfamily\arabicfont{Amiri}[
Script=Arabic,
Scale=MatchLowercase,
AutoFakeSlant=-0.03, % Are you sure?
Renderer=HarfBuzz ]
\pagestyle{headandfoot}
\firstpageheader{\bfseries\large رياضيات\\مأمون }{}{\bfseries\large الإمتحان الأول }
\begin{document}
مرحبا كيف حالكم, جزاكم الله كل خير
\end{document}
babelนอกจากนี้ยังจะเป็นไปได้ที่จะใช้ MWE นี้โหลดแบบอักษร Libertinus ของ Khaled Hosny รวมถึง Libertinus Math เป็นเพื่อนร่วมงานสำหรับแบบอักษร Amiri ของเขา
\documentclass{exam}
\usepackage[bidi=basic,layout=sectioning.tabular,english]{babel}
\usepackage{unicode-math}
\babelprovide[import,main]{arabic} % You might select a variant here.
\defaultfontfeatures{ Scale=MatchLowercase, Ligatures=TeX, Renderer=Harfbuzz }
\babelfont{rm}
[Scale=1.0, Ligatures={Common,Discretionary}]{Libertinus Serif}
\babelfont[arabic]{rm}
{Amiri} % Might want to load a stylistic set or activate font features.
\babelfont{sf}
[Ligatures={Common,Discretionary}]{Libertinus Sans}
% Load a sans-serif Arabic font here if needed, for example Noto Sans Arabic.
\babelfont{tt}
{Libertinus Mono}
\babelfont[arabic]{tt}
{ALM Fixed}
\setmathfont{Libertinus Math}
\babeltags{Arabic=arabic} % Enable \Arabic, \textArabic, etc.
\babeltags{english=english}
\pagestyle{headandfoot}
\firstpageheader{\bfseries\large رياضيات\\مأمون }{}{\bfseries\large الإمتحان الأول }
\begin{document}
\begin{tabular}{lllll}
الوحدة & فصول الوحدة & عدد الحصص & الفترة الزمنية & الوسائل المقترحة
\end{tabular}
\end{document}
หากคุณใช้เฉพาะภาษาอังกฤษสำหรับวลีสั้น ๆ ในเอกสารภาษาอาหรับคุณสามารถลบenglishตัวเลือกออกbabelและเพิ่ม\babelprovide[onchar=ids fonts]{english}เพื่อตรวจหาภาษาที่ใช้โดยอัตโนมัติและสลับแบบอักษรโดยอัตโนมัติ
วิธีหนึ่งที่จะทำได้คือการใช้ fontspec และ polyglossia เหมือนกับที่คุณทำในข้อมูลโค้ดของคุณ (เนื่องจากคุณลองใช้แล้วฉันเดาว่าคุณกำลังสร้างเอกสารด้วย LuaLaTeX ไม่ใช่ pdfLaTeX)
หากคุณต้องการทราบรายละเอียดว่าคุณสามารถใช้โพลิกลอเซียเพื่อเปิดใช้งานหลายภาษาและสลับไปมาระหว่างภาษาเหล่านี้ได้อย่างไรขอแนะนำให้คุณดูในคู่มือของ polyglossia นี่คือตัวอย่างหนึ่ง (ฉันเพิ่งใช้ Amiri เป็นแบบอักษรภาษาอาหรับเพราะฉันติดตั้งไว้แล้ว):
\documentclass{exam}
\usepackage{fontspec}
\usepackage{polyglossia}
\setdefaultlanguage{english}
\setotherlanguage{arabic}
\newfontfamily\arabicfont{Amiri}
\usepackage{graphicx}
\pagestyle{headandfoot}
\firstpageheader{\bfseries\large \textarabic{رياضيات\\مأمون}}{\includegraphics{example-image}}{\bfseries\large \textarabic{الإمتحان الأول}}
\begin{document}
\textarabic{مرحبا كيف حالكم, جزاكم الله كل خير }
\end{document}
ซึ่งให้ผลลัพธ์นี้:
\setdefaultlanguage{arabic}หากคุณต้องการส่วนใหญ่ใช้ภาษาอาหรับในเอกสารของคุณคุณอาจจะใช้ จากนั้นคุณไม่จำเป็นต้องใส่\textarabic{...}ข้อความภาษาอาหรับทุกข้อความ