Anpassen der Fragenumgebung im Prüfungsunterricht

Anpassen der Fragenumgebung im Prüfungsunterricht

Wie kann ich mithilfe von Klassen benutzerdefinierte Fragen erstellen exam? Ich muss beispielsweise drei verschiedene Fragen erstellen, jedoch mit den Beschriftungen A1, B1 und C1 und möglicherweise in unterschiedlichen Farben.

Etwas wie das

\begin{questions}

\Aquestion
This question starts with item label A1, and the text of this question is in blue color.

\Aquestion

This question starts with item label A2, and the text of this question is in blue color.

\Bquestion

This question starts with item label B1, and the text of this question is in red color.

\Cquestion

This question starts with item label C1, and the text of this question is in green color.

\Bquestion

This question starts with item label B2, and the text of this question is in red color.

\end{questions}

Antwort1

Die folgende Methode ist möglicherweise nicht narrensicher, funktioniert jedoch wie erwartet, ohne dass viele Prüfungsklassenoptionen verloren gehen.

Schritte, die wir versucht haben:

  • Definieren Sie Zähler für jeden Typ aqn, z. B. bqn, , usw.
  • Erhöhen Sie sie innerhalb der \deffür Aquestion, Bquestion, usw.,
  • Definieren Sie es \questionlabelbasierend auf Ihrem Zähler und dem erforderlichen Text, der ihm vorangestellt werden soll, neu.
  • Natürlich können Sie vorher jede beliebige Formatierung hinzufügen. Beachten Sie jedoch, dass diese Formatierung auch für alle Fragen unterhalb dieser Fragen gilt.

Wenn die obige Methode für Sie in Ordnung ist, können Sie sie implementieren. Ich habe meinen Code hier angegeben. Natürlich möchten Sie vielleicht noch etwas hinzufügen.

\documentclass{exam}
\usepackage{color}

\newcounter{aqn}
\newcounter{bqn}
\newcounter{cqn}


\def\Aquestion{
    \stepcounter{aqn}
        \renewcommand*{\questionlabel}{A\theaqn.}
        \color{blue}
    \question }

\def\Bquestion{
    \stepcounter{bqn}
    \renewcommand*{\questionlabel}{B\thebqn.}
    \color{red}
    \question
}

\def\Cquestion{ 
    \stepcounter{cqn}
    \renewcommand*{\questionlabel}{C\thecqn.}
    \color{green}
    \question
}



\begin{document}
    \begin{questions}
        
        \Aquestion
        This question starts with item label A1, and the text of this question is in blue color.
        
        \Aquestion
        
        This question starts with item label A2, and the text of this question is in blue color.
        
        \Bquestion
        
        This question starts with item label B1, and the text of this question is in red color.
        
        \Cquestion
        
        This question starts with item label C1, and the text of this question is in green color.
        
        \Bquestion
        
        This question starts with item label B2, and the text of this question is in red color.
        
         
        
    \end{questions}
\end{document}

Ausgabe:

Ausgabe

verwandte Informationen