summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/xsim/examples/xsim.different-point-types.tex
blob: 0ac3536776042484d89b6f73613949dfe57f4b0c (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
\documentclass{article}
\usepackage{xsim}

\DeclareExerciseGoal{A}
\DeclareExerciseGoal{C}
\DeclareExerciseGoal{E}

\newcommand*\printA{\TotalExerciseGoal{A}{~A~point}{~A~points}}
\newcommand*\printC{\TotalExerciseGoal{C}{~C~point}{~C~points}}
\newcommand*\printE{\TotalExerciseGoal{E}{~E~point}{~E~points}}

\usepackage{needspace}
\DeclareExerciseEnvironmentTemplate{custom}
  {%
    \par\vspace{\baselineskip}
    \Needspace*{2\baselineskip}
    \noindent
    \textbf{\GetExerciseProperty{counter}}%
    \IfExercisePropertySetT{subtitle}
      { \textit{\GetExerciseProperty{subtitle}}} %
    \IfInsideSolutionF{%
      \marginpar{%
        (\IfExercisePropertySetTF{E}{\GetExerciseProperty{E}}{0}/%
         \IfExercisePropertySetTF{C}{\GetExerciseProperty{C}}{0}/%
         \IfExercisePropertySetTF{A}{\GetExerciseProperty{A}}{0})%
      }%
    }%
  }
  {}
\xsimsetup{
  exercise/template = custom ,
  solution/template = custom
}
\renewcommand*\theexercise{\arabic{exercise}.}

\begin{document}

Reachable: \printA, \printC, and \printE.

\begin{exercise}[E=1]
  Differentiate $y=3x^2+5x+3$.
\end{exercise}

\begin{exercise}[E=2,C=1]
  Find the equation of the tangent line to the function $y=x/2$ at $x=2$.
\end{exercise}

\begin{exercise}[C=1,A=2]
  Prove that the derivative of a constant is zero.
\end{exercise}

\end{document}