Carattere arabo per documentclass {exam}
Il mio codice
\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}
Tutti questi codici non funzionavano.
\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
Risposte
LuaLaTeX richiede che il renderizzatore HarfBuzz mostri script complessi con caratteri combinati, ma seleziona il vecchio renderer per impostazione predefinita. Sembrava funzionare per me (anche se non conosco l'arabo e mi scuso se il testo è sbagliato)
\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}
Sarebbe anche possibile usare babel. Questo MWE carica i font Libertinus di Khaled Hosny, incluso Libertinus Math, come compagni per il suo font 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}
Se utilizzi solo l'inglese per frasi brevi all'interno di un documento in arabo, puoi rimuovere l' englishopzione da babele aggiungere \babelprovide[onchar=ids fonts]{english}per rilevare automaticamente la lingua utilizzata e cambiare i caratteri automaticamente.
Un modo per farlo sarebbe usare fontspec e polyglossia come hai fatto in alcuni dei tuoi frammenti di codice. (Dato che li hai già provati, immagino che tu stia costruendo il documento con LuaLaTeX, non pdfLaTeX.)
Se vuoi sapere in dettaglio come utilizzare la poliglossia per attivare più lingue e passare da una lingua all'altra, ti consiglio di dare un'occhiata al manuale della poliglossia. Ecco un esempio (ho appena usato Amiri come carattere arabo perché l'avevo già installato):
\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}
Che dà questo output:
Se vuoi usare principalmente l'arabo nel tuo documento, probabilmente dovresti usare \setdefaultlanguage{arabic}. Quindi non è necessario inserire \textarabic{...}ogni testo arabo.