summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/xsim/examples/xsim.hints.tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-09-20 22:36:23 +0000
committerKarl Berry <karl@freefriends.org>2017-09-20 22:36:23 +0000
commitbaaddc3c242540fcc6eef178a4576c34df84c339 (patch)
tree3dd7e8072b95be228ebfff3acb9f40f0e7823b88 /Master/texmf-dist/doc/latex/xsim/examples/xsim.hints.tex
parent6fdb207f55c75b496f116c760eab2e1640de2b88 (diff)
xsim (20sep17)
git-svn-id: svn://tug.org/texlive/trunk@45355 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/latex/xsim/examples/xsim.hints.tex')
-rw-r--r--Master/texmf-dist/doc/latex/xsim/examples/xsim.hints.tex59
1 files changed, 59 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/xsim/examples/xsim.hints.tex b/Master/texmf-dist/doc/latex/xsim/examples/xsim.hints.tex
new file mode 100644
index 00000000000..5fa3ed4ec8f
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/xsim/examples/xsim.hints.tex
@@ -0,0 +1,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}