Я повторно отправляю проблему, опубликованную вместе с другой, здесь Переопределение \pointname для экзаменационного класса
У меня проблема, связанная с настройкой команды ''\thepoints'' в классе Exam. Команда ''\thepoints'' в Exam.cls всегда заменяется на ``@points @pointname'', если для вопроса указано количество баллов. (@points — это запись балла, а @pointname — это имя балла.
Это имя точки определяется командой ''\pointpoints{point}{points}'', где '\pointname' заменяется на ''point'', когда @points=1 или=1/2 (единственное число), и заменяется на ''points'', когда @points > 1 (множественное число).
Я хочу настроить команду '\thepoints' для других языков (в частности, арабского), где может быть больше двух случаев, например, четыре: случаи '@points=1 или=1/2', '@points=2', '3<=@points<=10' и '@points>10').
Тогда «@pointname» будет иметь 4 разных значения-имени, например {WORD_1, WORD_2, WORD_3, WORD_4}.
Поэтому я хочу написать макрос, который заменит "\thepoints" на:
- "WORD_1" если '@points=1 или=1/2'' (Обратите внимание, что @points здесь не написано...)
- "WORD_2" если '@points=2' (Обратите внимание, что @points здесь тоже не написано...)
- "@points WORD_3" если '3<= @points <=10' (Здесь мы записываем значение @points...)
- "@points WORD_4" если '@points >10' (Здесь также должно быть написано @points...)
Точнее, я хочу, например, чтобы команды:
\question[1] дает: Вопрос (WORD_1)
\question[2] дает: Вопрос (WORD_2)
\question[8] дает: Вопрос (8 СЛОВ_3)
\question[14] дает: Вопрос (14 СЛОВ_4)
решение1
Определение \points
макроса в exam.cls следующее:
\newcommand\points{%
\begingroup
\let\half=\relax
\edef\pt@string{\@points}%
\ifthenelse{\equal{\pt@string}{1} \or \equal{\pt@string}{\half}}
{\point@sing}{\point@plur}%
\endgroup
}
вы можете сделать больше случаев (четыре) внутри условного предложения, ifthenelse
как здесь
\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
}
здесь вы получаете то, что вам нужно. возможно, есть более короткий путь сделать это.
И вы можете проверить это с помощью этого MWE:
\documentclass[11pt]{exam}
\def\sample{What is the Pythagorean theorem}
\makeatletter
\newcommand\point@labelone{word-1}
\newcommand\point@labeltwo{word-2}
\newcommand\point@labelthree{word-3}
\newcommand\point@labelfour{word-4}
\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
}
\makeatother
\pointformat{(\thepoints)}
\begin{document}
\begin{questions}
\question[\half] \sample
\question[1] \sample
\question[2] \sample
\question[4] \sample
\question[12] \sample
\end{questions}
\end{document}
Чтобы удалить \@points
из \thepoints
макроса в случае word-1 и word-2, я не могу найти исходное определение \thepoints
в exam.cls, с обходным путем вы можете изменить его определение с помощью\pointformat
\documentclass[11pt]{exam}
\def\sample{What is the Pythagorean theorem}
\makeatletter
\newcommand\point@labelone{word-1}
\newcommand\point@labeltwo{word-2}
\newcommand\point@labelthree{word-3}
\newcommand\point@labelfour{word-4}
\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}
\begin{questions}
\question[\half] \sample
\question[1] \sample
\question[2] \sample
\question[4] \sample
\question[12] \sample
\end{questions}
\end{document}
Мы получаем: