3

I am trying to use the polyglossia package to write exams in Arabic with the Exam documentclass, as can be seem in the following MWE. I ended up however with an error :

! Missing number: Treated as Zero.

< to be read again>

1.32 \question[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} 

Edit:

Here is another trial using the babel package. The only problem now is that the grading table is not shown correctly; it is shown in the reverse order.

\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
    Welcome to TeX.se and thanks for posting a minimal example document. Don't load the xltxtra package; it's not needed and is the source of the error you report. But your document still doesn't compile with arabic as the main language. – Alan Munn Aug 13 '17 at 15:18
  • 1
    the fontspec package requires either Xelatex or Lualatex. You must change your typesetting engine to"xelatex" or "lualatex" – Deepesh Meena Aug 13 '17 at 16:22
  • Thank you @AlanMunn for your reply. I deleted xltxtra and got the error after compiling with Xelatex ! Missing number, traeted as zero. which refers to the points number at \question[5] – fai391 Aug 13 '17 at 16:55
  • Thank you @james for your reply. I deleted xltxtra and got the error after compiling with Xelatex ! Missing number, traeted as zero. which refers to the points number at \question[5] – fai391 Aug 13 '17 at 16:56
  • Yes. Please edit your question to show that error. It doesn't arise if the main language is English so there's something going on with Arabic here but I don't know what. – Alan Munn Aug 13 '17 at 16:58
4

The class is buggy. It uses in various places formatting commands as numbers, and this breaks as soon as \@arabic no longer gives a number. An incomplete sample of problematic places:

\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}%

The class is full of them.

A simple example to break it is

\documentclass[addpoints,12pt]{exam}
\makeatletter\let\@arabic\@alph \makeatother

\begin{document}

\begin{questions}
\question[5]
blbuj
\end{questions}
\end{document} 

\pagenumbering{alph} is also enough to get errors. As it is it is completly unusable with arabic.

0

To resolve the issue of Arabic not shown correctly you can use \textRL as shown in the code.

\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} 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.