blob: 5fa3ed4ec8fe8bf4644b4402164917f12603053d (
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
54
55
56
57
58
59
|
% https://tex.stackexchange.com/q/224408/
\documentclass{article}
\usepackage{xsim}
\usepackage{needspace}
\DeclareExerciseProperty{hint}
% we'll use a description list for the hints:
\newcommand\printhints{%
\begin{description}
\ForEachUsedExerciseByType{%
\def\ExerciseType{##1}%
\def\ExerciseID{##2}%
\GetExercisePropertyT{hint}
{%
\item[\XSIMmixedcase{\GetExerciseName}~##3]
####1%
}%
}%
\end{description}
}
\newcommand\hint[1]{\SetExerciseProperty{\ExerciseType}{\ExerciseID}{hint}{#1}}
\begin{document}
\section{Problems}
% set hint through option:
\begin{exercise}[subtitle=Pythagoras,hint=This is a hint to the first problem.]
This is the first problem.
\end{exercise}
\begin{solution}
This is the solution to the first problem.
\end{solution}
\begin{exercise}[subtitle=Another Problem]
This is the second problem.
\end{exercise}
\begin{solution}
This is the solution to the second problem.
\end{solution}
% set hint with custom command:
\begin{exercise}[subtitle=Yet Another Problem]
This is the third problem.
\hint{This is a hint to the third problem.}
\end{exercise}
\begin{solution}
This is the solution to the third problem.
\end{solution}
\section{Hints}
\printhints
\section{Solutions}
\printsolutions[headings=false]
\end{document}
|