5

I have a big list of questions and solutions and I want to select a subset of them to use in exams. I am using documentclass exam. See the following example

\documentclass[12pt]{exam}
\begin{document}
    \begin{questions}
    \question[30] this is a question I will use in this exam
         \begin{solution} solution is here \end{solution}
    \question this is another question but I will not use in this exam
         \begin{solution} its solution is here \end{solution}
    \question[20] yet another question that will be used in this exam
       \begin{solution} yet another solution is here \end{solution}
    \question this is another question it will not be in the exam
         \begin{solution} its solution is here \end{solution}
\end{document}
vonbrand
  • 5,473
Utku
  • 51

1 Answers1

1

There will most likely be a more efficient way of doing this, but when I recently had to select subsets of questions, I used newcommand to create a hide command. Note that this will be time consuming if you have a large number of questions.

\documentclass[12pt]{exam}

\newcommand{\hide}[1]{}

\begin{document}
    \begin{questions}
    \question[30] this is a question I will use in this exam
         \begin{solution} solution is here \end{solution}
    % Hide the next question
    \hide{%
    \question this is another question but I will not use in this exam
         \begin{solution} its solution is here \end{solution}
    }
    \question[20] yet another question that will be used in this exam
       \begin{solution} yet another solution is here \end{solution}
    % Hide the next question
    \hide{
    \question this is another question it will not be in the exam
         \begin{solution} its solution is here \end{solution}
    }
    \end{questions}
\end{document}

You will have to go through manually to decide which questions you want to display.


Side note: When I was doing this, my questions were rather large (long question stem and multiple subparts). As such, I put each question in a separate tex file and gave them long descriptive names, e.g. q_car_accelerating_around_a_corner.tex

Then, in a master file I could specify which questions I wanted to include in my exam. For example I could specify \include{q_car_accelerating_around_a_corner.tex} and it would appear in my exam. Note that I wanted page breaks in my exam - if you didn't then you would probably want input. More detail can be found here: When should I use \input vs. \include?

Alwin
  • 679