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は、彼のAmiriフォントのコンパニオンとして、LibertinusMathを含むKhaledHosnyのLibertinusフォントをロードします。
\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}し、使用されている言語を自動検出して、フォントを自動的に切り替えることができます。
これを行う1つの方法は、一部のコードスニペットで行ったようにfontspecとpolyglossiaを使用することです。(すでに試したので、pdfLaTeXではなくLuaLaTeXでドキュメントを作成していると思います。)
ポリグロシアを使用して複数の言語をアクティブにし、それらを切り替える方法を詳しく知りたい場合は、ポリグロシアのマニュアルを参照することをお勧めします。これが1つの例です(すでにインストールされているので、アラビア語フォントとして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{...}、すべてのアラビア語のテキストを配置する必要はありません。