summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/xsim/doc/examples/xsim.difficulties.tex
blob: 02712f15d66d68551f5d1cd217727a1dd8125c63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
\documentclass{article}

\usepackage[clear-aux]{xsim}
\DeclareExerciseTagging{difficulty}
\xsimsetup{
  difficulty={easy,hard}
}

\DeclareExerciseEnvironmentTemplate{custom}
  {
    \subsection*
      {%
        \XSIMmixedcase {\GetExerciseName}\nobreakspace
        \GetExerciseProperty{counter}%
        \IfExercisePropertySetT{difficulty}
          { {\normalfont(\GetExerciseProperty{difficulty})}}%
        \IfInsideSolutionF{%
          \IfExercisePropertySetT{subtitle}
            { {\normalfont\itshape\GetExerciseProperty{subtitle}}}%
        }%
      }%
    \IfExercisePropertySetT{points}
      {%
        \marginpar
          {%
            \IfInsideSolutionF{\rule{1.2cm}{1pt}\slash}%
            \GetExerciseProperty{points}%
            \IfExercisePropertySetT{bonus-points}
              {\nobreakspace(+\GetExerciseProperty{bonus-points})}
            \nobreakspace\XSIMtranslate{point-abbr}%
          }%
      }%
  }
  {}

\xsimsetup{exercise/template = custom}

\begin{document}

\begin{exercise}[difficulty=easy]
  An easy question.
\end{exercise}
\begin{exercise}[difficulty=medium]
  This one's a bit harder.
\end{exercise}
\begin{exercise}[difficulty=hard]
  Now let’s see if you can solve this one.
\end{exercise}
\begin{exercise}[difficulty=medium]
  This is medium but printed anyway
\end{exercise}

\end{document}