1

How can I make custom questions using exam class? For e.g., I need to create 3 different questions, but with labels A1, B1 and C1 and possibly with different color.

Something like this

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

1 Answer 1

1

The following method may not be a foolproof method but works as expected without losing much of the exam class options.

Steps we have try:

  • Define counters for each of the type say aqn, bqn, etc.,
  • Increment them insider the \def for Aquestion, Bquestion, etc.,
  • Redefine the \questionlabel based on your counter and the required text to prefix it.
  • Of course you can add any formatting before that. But, be mindful for the fact that this formatting applies to anything below that questions too.

If the above method is okay for you, you can implement it. I have given my code here. Obviously, you might want to add some more.

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

Output:

output

1
  • Sure hints towards something useful. Thanks!
    – Scholar
    Jun 24, 2021 at 12:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .