Debian Codegraph @

texmf-dist/doc/latex/xsim/examples/xsim.listofexercises.tex

raw
1 % https://tex.stackexchange.com/q/94766/
2 \documentclass[a4paper,10pt]{book}
3 \usepackage[utf8]{inputenc}
4
5 \usepackage{xsim}
6 \xsimsetup{
7 exercise/within=chapter,
8 exercise/template=theorem ,
9 exercise/the-counter=\thechapter.\arabic{exercise}
10 }
11
12 \DeclareExerciseEnvironmentTemplate{theorem}
13 {%
14 \par\addvspace{\baselineskip}
15 \noindent
16 \XSIMexpandcode{\noexpand\label{\ExerciseType:\ExerciseID}}
17 \Large\textbf{%
18 \space\GetExerciseProperty{counter}%
19 \GetExercisePropertyT{subtitle}{ (\PropertyValue)}%
20 } \normalsize\itshape
21 }
22 {\par\addvspace{\baselineskip}}
23
24 \usepackage{multicol}
25
26 \newcommand\listofexercises{
27 \chapter*{List of Exercises}
28 \def\CurrentExerciseChapter{}%
29 \ForEachPrintedExerciseByType{
30 \global\let\LastExerciseChapter\CurrentExerciseChapter
31 \xdef\CurrentExerciseChapter{\ExercisePropertyGet{##1}{##2}{chapter}}%
32 \XSIMifeqF{\LastExerciseChapter}{\CurrentExerciseChapter}
33 {
34 \XSIMifblankF{\LastExerciseChapter}{\end{multicols}}
35 \begin{multicols}{2}%
36 [\contentsline{chapter}{Chapter \CurrentExerciseChapter}{}{}]
37 }
38 \contentsline
39 {section}
40 {%
41 Exercise \ExercisePropertyGet{##1}{##2}{counter}%
42 \XSIMifblankF{##4}{ (##4)}%
43 }
44 {\pageref{##1:##2}}{}%
45 }
46 \end{multicols}
47 }
48
49 % \usepackage{hyperref}
50 % \newcommand\theHexercise{\thechapter.\arabic{exercise}}
51
52 \begin{document}
53
54 \chapter{kinetic}
55 \begin{exercise}
56 435-1
57 \end{exercise}
58 \begin{exercise}[subtitle=Foo Bar]
59 435-2
60 \end{exercise}
61 \begin{exercise}
62 435-3
63 \end{exercise}
64
65 \chapter{momentum}
66 \begin{exercise}
67 436-1
68 \end{exercise}
69 \begin{exercise}
70 436-2
71 \end{exercise}
72 \begin{exercise}
73 436-3
74 \end{exercise}
75 \begin{exercise}
76 436-4
77 \end{exercise}
78
79 \listofexercises
80
81 \end{document}