試験クラスで単数形と複数形以外の形式に \pointpoints をカスタマイズする

試験クラスで単数形と複数形以外の形式に \pointpoints をカスタマイズする

他の人が投稿した問題を再送信します。 試験クラスの \pointname を再定義する

Exam クラスのコマンド ''\thepoints'' のカスタマイズに関連する問題があります。Exam.cls のコマンド ''\thepoints'' は、質問にポイント数が指定されている場合、常に ``@points @pointname'' に置き換えられます。 (@points はポイント エントリで、@pointname はポイント名です。

このポイント名はコマンド ''\pointpoints{point}{points}'' によって定義されます。ここで、'\pointname' は、@points=1 または =1/2 (単数) の場合は ''point'' に置き換えられ、@points > 1 (複数) の場合は ''points'' に置き換えられます。

他の言語 (具体的にはアラビア語) 用にコマンド '\thepoints' をカスタマイズします。この場合、2 つ以上のケース (例: 4 つ: '@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
}

条件文内でさらにケース(4つ)を作成することもできます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}

\@pointsword-1とword-2をマクロから削除するには、exam.clsで\thepoints元の定義を見つけることができません\thepoints。回避策として、次の助けを借りて定義を変更できます。\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}

私達は手に入れました:

ここに画像の説明を入力してください

関連情報