| 1 |
% https://tex.stackexchange.com/q/224408/ |
| 2 |
\documentclass{article} |
| 3 |
\usepackage{xsim} |
| 4 |
|
| 5 |
\usepackage{needspace} |
| 6 |
|
| 7 |
\DeclareExerciseProperty{hint} |
| 8 |
|
| 9 |
% we'll use a description list for the hints: |
| 10 |
\newcommand\printhints{% |
| 11 |
\begin{description} |
| 12 |
\ForEachUsedExerciseByType{% |
| 13 |
\GetExercisePropertyT{hint} |
| 14 |
{\item[\XSIMmixedcase{\GetExerciseName}~##3]####1}% |
| 15 |
}% |
| 16 |
\end{description} |
| 17 |
} |
| 18 |
|
| 19 |
\newcommand\hint[1]{\SetExerciseProperty{hint}{#1}} |
| 20 |
|
| 21 |
\begin{document} |
| 22 |
|
| 23 |
\section{Problems} |
| 24 |
% set hint through option: |
| 25 |
\begin{exercise}[subtitle=Pythagoras,hint=This is a hint to the first problem.] |
| 26 |
This is the first problem. |
| 27 |
\end{exercise} |
| 28 |
\begin{solution} |
| 29 |
This is the solution to the first problem. |
| 30 |
\end{solution} |
| 31 |
|
| 32 |
\begin{exercise}[subtitle=Another Problem] |
| 33 |
This is the second problem. |
| 34 |
\end{exercise} |
| 35 |
\begin{solution} |
| 36 |
This is the solution to the second problem. |
| 37 |
\end{solution} |
| 38 |
|
| 39 |
% set hint with custom command: |
| 40 |
\begin{exercise}[subtitle=Yet Another Problem] |
| 41 |
This is the third problem. |
| 42 |
\hint{This is a hint to the third problem.} |
| 43 |
\end{exercise} |
| 44 |
\begin{solution} |
| 45 |
This is the solution to the third problem. |
| 46 |
\end{solution} |
| 47 |
|
| 48 |
\section{Hints} |
| 49 |
\printhints |
| 50 |
|
| 51 |
\section{Solutions} |
| 52 |
\printsolutions[headings=false] |
| 53 |
|
| 54 |
\end{document} |