我正在尝试使用 polyglossia 包通过 Exam 文档类用阿拉伯语编写考试,如以下 MWE 所示。但我最终遇到了一个错误:
! 缺失数字:视为零。
< 待再读 >
1.32 \问题[5]
\documentclass[addpoints,12pt]{exam}
\usepackage[no-math]{fontspec}
\usepackage[quiet]{polyglossia}
\usepackage{amsmath,amsthm,amsfonts}
\usepackage{amssymb}
\usepackage{fontspec}% هذه لنستطيع تغيير الخطوط
\setdefaultlanguage{arabic}
\setotherlanguage[variant=british]{english}
\setmainfont{Simplified Arabic}
\setromanfont{Arial}
\defaultfontfeatures{Scale=MatchLowercase}
\setmonofont{Simplified Arabic}
\setsansfont{Junicode}
\newfontfamily\arabicfont[Script=Arabic,Scale=1]{Amiri}
\newfontfamily\arabicfonttt[Script=Arabic,Scale=1.3]{Times New Roman}
\newcommand{\eng}{\textenglish}
\begin{document}
\pagestyle{headandfoot}
\firstpageheadrule
\firstpageheader{Name:} { } {مادة}
\firstpagefooter{}{الإختبار النهائي}
{}
\runningheader{Name:} { } {مادة}
\runningfooter{}{الإختبار النهائي}
{}
\runningheadrule
\runningfootrule
\begin{questions}
\question[5]
عرف الدالة؟
\\
\hrulefill
\question
أثبت أن
\end{questions}
\end{document}
编辑:
这是使用 babel 包的另一个尝试。现在唯一的问题是评分表显示不正确;它以相反的顺序显示。
\documentclass[11pt]{exam}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[arabic]{babel}
\makeatletter
\newcommand\point@labelone{درجة}
\newcommand\point@labeltwo{درجتان}
\newcommand\point@labelthree{درجات}
\newcommand\point@labelfour{درجات}
\renewcommand\points{%
\begingroup
\let\half=\relax
\edef\pt@string{\@points}%
\ifthenelse{\equal{\pt@string}{1} \OR \equal{\pt@string}{\half}}
{\point@labelone}{%
\ifthenelse{\equal{\pt@string}{2}}{\point@labeltwo}{%
\ifthenelse{\equal{\pt@string}{3} \OR \equal{\pt@string}{3\half}%
\OR \equal{\pt@string}{4} \OR \equal{\pt@string}{4\half}%
\OR \equal{\pt@string}{5} \OR \equal{\pt@string}{5\half}%
\OR \equal{\pt@string}{6} \OR \equal{\pt@string}{6\half}%
\OR \equal{\pt@string}{7} \OR \equal{\pt@string}{7\half}%
\OR \equal{\pt@string}{8} \OR \equal{\pt@string}{8\half}%
\OR \equal{\pt@string}{9} \OR \equal{\pt@string}{9\half}%
\OR \equal{\pt@string}{10}\OR \equal{\pt@string}{10\half}}
{\point@labelthree}{\point@labelfour}}}
%
\endgroup
}
\renewcommand\thepoints{%
\if@placepoints
\if@bonus
\@points \@bonuspointname
\else
\let\half=\relax
\edef\pt@string{\@points}%
\ifthenelse{\equal{\pt@string}{1} \OR \equal{\pt@string}{\half}%
\OR \equal{\pt@string}{2}}
{\@pointname}{\@points \@pointname}
\fi
\fi
}% thepoints
\makeatother
\pointformat{(\thepoints)}
\begin{document}
{
\centering
\vspace{0pt}
\gradetablestretch{2}
\vpword{نقاط}
\vtword{المجموع:}
\vsword{الدرجة}
\addpoints % required here by exam.cls, even though questions haven't started yet.
{\small
\gradetable[v]%[pages] % Use [pages] to have grading table by page instead of question
}
\begin{questions}
\addpoints
\question[1]
عرف الدالة الأسية.
\addpoints
\question[12] أوجد مشتقة الدالة $X^2 + \sin(x)$.
\addpoints
\question[12] ماهو نطاق الدالة السابقة؟
\end{questions}
\end{document}
答案1
这个类有缺陷。它在很多地方使用格式化命令作为数字,一旦\@arabic
不再给出数字,就会中断。以下是存在问题的地方的不完整示例:
\ifnum \thepageof@pagepoints > 0\relax
\ifnum \thepageof@pagebonuspoints > 0\relax
\ifnum \thepage > \PgInfo@get{@endquestions
\ifnum \thepage < \PgInfo@get{question@\thelatest@ques}\relax
\ifnum \the@iterator < \tbl@lastp\relax
\ifnum \theques@end > \thepage\relax
\setcounter{next@ques}{\thelatest@ques}%
班里挤满了人。
打破它的一个简单例子是
\documentclass[addpoints,12pt]{exam}
\makeatletter\let\@arabic\@alph \makeatother
\begin{document}
\begin{questions}
\question[5]
blbuj
\end{questions}
\end{document}
\pagenumbering{alph}
也足以产生错误。因为它完全不能用于阿拉伯语。
答案2
为了解决阿拉伯语无法正确显示的问题,您可以使用 \textRL,如代码所示。
\documentclass[11pt]{exam}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[arabic]{babel}
\makeatletter
\newcommand\point@labelone{\textRL{درجة}}
\newcommand\point@labeltwo{درجتان}
\newcommand\point@labelthree{درجات}
\newcommand\point@labelfour{درجات}
\renewcommand\points{%
\begingroup
\let\half=\relax
\edef\pt@string{\@points}%
\ifthenelse{\equal{\pt@string}{1} \OR \equal{\pt@string}{\half}}
{\point@labelone}{%
\ifthenelse{\equal{\pt@string}{2}}{\point@labeltwo}{%
\ifthenelse{\equal{\pt@string}{3} \OR \equal{\pt@string}{3\half}%
\OR \equal{\pt@string}{4} \OR \equal{\pt@string}{4\half}%
\OR \equal{\pt@string}{5} \OR \equal{\pt@string}{5\half}%
\OR \equal{\pt@string}{6} \OR \equal{\pt@string}{6\half}%
\OR \equal{\pt@string}{7} \OR \equal{\pt@string}{7\half}%
\OR \equal{\pt@string}{8} \OR \equal{\pt@string}{8\half}%
\OR \equal{\pt@string}{9} \OR \equal{\pt@string}{9\half}%
\OR \equal{\pt@string}{10}\OR \equal{\pt@string}{10\half}}
{\point@labelthree}{\point@labelfour}}}
%
\endgroup
}
\renewcommand\thepoints{%
\if@placepoints
\if@bonus
\@points \@bonuspointname
\else
\let\half=\relax
\edef\pt@string{\@points}%
\ifthenelse{\equal{\pt@string}{1} \OR \equal{\pt@string}{\half}%
\OR \equal{\pt@string}{2}}
{\@pointname}{\@points \@pointname}
\fi
\fi
}% thepoints
\makeatother
\pointformat{(\thepoints)}
\begin{document}
{
\centering
\vspace{0pt}
\gradetablestretch{2}
\vpword{\textRL{نقاط}}
\vtword{\textRL{المجموع:}}
\vsword{\textRL{الدرجة}}
\addpoints % required here by exam.cls, even though questions haven't started yet.
{\small
\gradetable[v]%[pages] % Use [pages] to have grading table by page instead of question
}
\begin{questions}
\addpoints
\question[1]
عرف الدالة الأسية.
\addpoints
\question[12] أوجد مشتقة الدالة $X^2 + \sin(x)$.
\addpoints
\question[12] ماهو نطاق الدالة السابقة؟
\end{questions}
\end{document}