| 1 |
% https://tex.stackexchange.com/q/391530 |
| 2 |
\documentclass{article} |
| 3 |
\usepackage{xsim} |
| 4 |
|
| 5 |
\DeclareExerciseType{subquestion}{ |
| 6 |
exercise-env = question , |
| 7 |
solution-env = answer , |
| 8 |
exercise-name = Question , |
| 9 |
solution-name = Answer , |
| 10 |
exercise-template = item , |
| 11 |
solution-template = item |
| 12 |
} |
| 13 |
|
| 14 |
\DeclareExerciseProperty{title} |
| 15 |
|
| 16 |
\makeatletter |
| 17 |
\DeclareExerciseEnvironmentTemplate{named}{% |
| 18 |
\subsection*{% |
| 19 |
\GetExercisePropertyTF{title} |
| 20 |
{#1} |
| 21 |
{??\@latex@warning{Please give an exercise title}}% |
| 22 |
}% |
| 23 |
}{} |
| 24 |
\makeatother |
| 25 |
|
| 26 |
\DeclareExerciseEnvironmentTemplate{item}{\item}{} |
| 27 |
\DeclareExerciseCollection{exercise-pool} |
| 28 |
|
| 29 |
\xsimsetup{ exercise/template = named } |
| 30 |
|
| 31 |
\begin{document} |
| 32 |
|
| 33 |
\collectexercises{exercise-pool} |
| 34 |
\begin{question} |
| 35 |
Who is the Defence Minister? |
| 36 |
\end{question} |
| 37 |
\begin{question} |
| 38 |
Who is the Home Minister? |
| 39 |
\end{question} |
| 40 |
\begin{question} |
| 41 |
Who is the Finance Minister? |
| 42 |
\end{question} |
| 43 |
\begin{question} |
| 44 |
Who is the External Affairs Minister? |
| 45 |
\end{question} |
| 46 |
\collectexercisesstop{exercise-pool} |
| 47 |
|
| 48 |
\begin{exercise}[title=Answer the following in one sentence:] |
| 49 |
\begin{enumerate} |
| 50 |
\item Who is the President? |
| 51 |
\item Who is the Prime Minister? |
| 52 |
\printrandomexercises[collection=exercise-pool]{2} |
| 53 |
\end{enumerate} |
| 54 |
\end{exercise} |
| 55 |
|
| 56 |
\end{document} |