Debian Codegraph @

texmf-dist/doc/latex/xsim/examples/xsim.difficulties.tex

raw
1 \documentclass{article}
2
3 \usepackage[clear-aux]{xsim}
4 \DeclareExerciseTagging{difficulty}
5 \xsimsetup{
6 difficulty={easy,hard}
7 }
8
9 \DeclareExerciseEnvironmentTemplate{custom}
10 {
11 \subsection*
12 {%
13 \XSIMmixedcase {\GetExerciseName}\nobreakspace
14 \GetExerciseProperty{counter}%
15 \IfExercisePropertySetT{difficulty}
16 { {\normalfont(\GetExerciseProperty{difficulty})}}%
17 \IfInsideSolutionF{%
18 \IfExercisePropertySetT{subtitle}
19 { {\normalfont\itshape\GetExerciseProperty{subtitle}}}%
20 }%
21 }%
22 \IfExercisePropertySetT{points}
23 {%
24 \marginpar
25 {%
26 \IfInsideSolutionF{\rule{1.2cm}{1pt}\slash}%
27 \GetExerciseProperty{points}%
28 \IfExercisePropertySetT{bonus-points}
29 {\nobreakspace(+\GetExerciseProperty{bonus-points})}
30 \nobreakspace\XSIMtranslate{point-abbr}%
31 }%
32 }%
33 }
34 {}
35
36 \xsimsetup{exercise/template = custom}
37
38 \begin{document}
39
40 \begin{exercise}[difficulty=easy]
41 An easy question.
42 \end{exercise}
43 \begin{exercise}[difficulty=medium]
44 This one's a bit harder.
45 \end{exercise}
46 \begin{exercise}[difficulty=hard]
47 Now let’s see if you can solve this one.
48 \end{exercise}
49 \begin{exercise}[difficulty=medium]
50 This is medium but printed anyway
51 \end{exercise}
52
53 \end{document}