在考試類中自訂 \pointpoints 以獲得更多形式,而不僅僅是單數和複數

在考試類中自訂 \pointpoints 以獲得更多形式,而不僅僅是單數和複數

我重新發送一個問題,與其他人一起發布,在這裡 重新定義考試類別的 \pointname

我有一個問題,與考試類別中命令“\thepoints”的自訂有關。如果已為問題指定了分數,則 Exam.cls 中的命令「\thepoints」總是會替換為「@points @pointname」。 (@points 是點條目,@pointname 是點名稱。

該點名由命令 ''\pointpoints{point}{points}'' 定義,其中 '\pointname' 在 @points=1 或=1/2(單數)時替換為 ''point'',並替換為 '當@points > 1(複數)時為「點」。

我想為其他語言(特別是阿拉伯語)自訂命令'\thepoints',其中可以有兩種以上的情況,例如四種:情況'@points=1 or=1/2', '@points=2 ', ' 3<=@points<=10',且'@points>10')。

然後,'@pointname' 將有 4 個不同的值名稱,例如 {WORD_1, WORD_2, WORD_3, WORD_4}。

所以我想寫一個巨集來取代「\thepoints」:

  • "WORD_1" if '@points=1 or=1/2'' (注意這裡沒有寫@points...)
  • "WORD_2" if '@points=2' (注意這裡也沒有寫@points...)
  • "@points WORD_3" if '3<= @points <=10' (這裡我們寫@points的值...)
  • "@points WORD_4" if '@points >10' (這裡 @points 也必須寫在這裡......)

更準確地說,我想要的命令是:

\question[1] 給出: 問題 (WORD_1)

\question[2] 給出: 問題 (WORD_2)

\question[8] 給出: 問題 (8 WORD_3)

\question[14] 給出: 問題 (14 WORD_4)

答案1

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

我們獲得:

在此輸入影像描述

相關內容