Debian Codegraph @

texmf-dist/doc/latex/exercisesheets/examples/exshexample.tex

raw
1 \long\def\ifbeamer#1#2{#2}
2 \ifbeamer{\documentclass{beamer}}{\documentclass[a5paper]{article}}
3
4 %navigation symbols and the title collide if
5 %beamerwithheadline is set
6 \ifbeamer{
7 \setbeamertemplate{navigation symbols}{}
8 }{}
9
10 %patchenumerate is the deafault
11 \usepackage[patchenumerate=true,beamerwithheadline,
12 %when directly messing with page breaks
13 %and the sheet start page actio (as we do below)
14 %using exercisesheets' page numer redefinitions per
15 %sheet do not make much sense
16 patchpagenumbers=false,
17 beamerwithfootline,
18 beamercompatibility,
19 exercisespath=exercises]%
20 {exercisesheets}
21 \usepackage{varioref}
22 \usepackage{hyperref}
23 \usepackage{xcolor}
24
25 \exshset{solutions=true,
26 task restate font={\color{black!60}},
27 only={1-3,5-},
28 }
29
30 %solutions may be printed out on paper -> a4
31 %exercises are read on (smartphone) screen -> a5
32 \ifsolutions{
33 \usepackage[left=1cm,right=1cm,top=1cm,bottom=1.5cm,a4paper]{geometry}
34 }{
35 \usepackage[left=0.7cm,right=0.7cm,top=1cm,bottom=1.5cm]{geometry}
36 }
37
38 %Usually the person responsible for the entire course:
39 \author{Exampleauthor}
40 \date{Example term/semester}
41 \title{Introduction to Exercise Sheets Creation}
42 \subject{Introduction to Exercise Sheets Creation}
43 %Only used for beamer at the moment:
44 \exshset{exauthor={Author of exercises}}
45
46 \ifbeamer{\exshset{beameruseblocks=false}}{}
47
48
49
50
51
52 \begin{document}
53
54 %1
55 \begin{sheet}[note={Learn how to create nice exercise sheets.},
56 date={Novanuar 42, -2022},title={First Sheet}]
57
58 \includeexercise*{exshexample-ex1}
59 \includeLexercise*{exshexample-ex2}
60
61 \begin{exercise}[points={many, many},firstline={Read the manual.}]
62 \end{exercise}
63
64 \begin{exercise}[points={sum},firstline={After you read the manual:}]
65 Play around with this example. You might want to read further manuals like:
66 \begin{enumerate}
67 %pointsfloatright should be usually set globally
68 \item\points[pointsfloatright]{2}pgf (for pgfkeys)
69 \item enumitem and similar \points[abbrev,bonus]{1}
70 \begin{enumerate}
71 \item paralist \thesubex
72 \item
73 \begin{enumerate}
74 \item varioref
75 \end{enumerate}
76 \end{enumerate}
77 \item all the others \points[inplace]{3} (why not?)
78 \label{subex:man2}
79 \end{enumerate}
80 \end{exercise}
81 \end{sheet}
82
83 \begingroup
84 \ifbeamer{}{
85 \exshset{
86 %default is \clearpage
87 sheet start page action={\pagebreak[3]\hrule},
88 sheet end page action={\vspace{4mm}\hrule\vspace{2cm}},
89 }
90 }
91
92 %2
93 \begin{sheet}[date={Novanuar 35, -2022}]
94 \begin{exercise}[points={many, many},
95 firstline={Read the manual.}]
96 \end{exercise}
97 \begin{solution}[framed,fragile]
98 Oh no, it's quite long.
99 \newframe
100 Really long, but please \verb|\relax|.
101 Ok, but my brain feels like:
102 \begin{verbatim}
103 %
104 x
105 $ t
106 &
107
108
109 \
110 #
111 \end{verbatim}
112 And yours?
113 \end{solution}
114 \end{sheet}
115
116 %3
117 \begin{sheet}[date={Novanuar 28, -2022},title={Third Sheet},
118 number within sheet]
119 \begin{exercise}[points={many, many},
120 firstline={Read the manual.}]
121 \begin{solution}
122 OK, done.
123 \newpage
124 still done.
125 \end{solution}
126 \end{exercise}
127 \end{sheet}
128
129 \endgroup
130
131 %4
132 \begin{sheet}
133 \begin{Lexercise}
134 task = [[
135 This exercise will be skipped.
136 ]],
137 \end{Lexercise}
138 \begin{Lexercise}
139 task = [[
140 \label{ex:skiplex}%
141 This exercise will be skipped, but it has a reference.
142 ]],
143 subexercises = {[[\label{subex:skiplexOne} first]]},
144 \end{Lexercise}
145 \begin{exercise}[points={many, many},%savetasks,
146 main task font={\tiny},subtask font={\itshape}
147 ]
148 \begin{maintask}
149 \label{ex:skipex} This exercise will be skipped.
150 Furt
151 \end{maintask}
152 \begin{subtasks}
153 \item {first \label{subex:skipexOneOne}} This is an \string\item\space inside a subtasks environment. If
154 \verb|subtask environment| is set to enumerate/itemize etc.,
155 this works with some caveats (font settings for substaks are not used).
156 \subtask{second}
157 \end{subtasks}
158 \begin{enumerate}
159 \setcounter{enumi}{2}
160 \subtask {first \label{subex:skipexOne}}
161 This is a \string\subtask{} without the susbtasks
162 environment, which is unsupported and a bad example!
163 \item {\label{subex:skipexTwo}} {12345}
164 \end{enumerate}
165 \end{exercise}
166 \end{sheet}
167
168 %5
169 \begin{sheet}[date={Novanuar 21, -2022}]
170 \begin{exercise}[points={many, many},
171 firstline={Read the manual.}]
172 \begin{solution}[framed]
173 OK, done (again).
174 \newframe
175 Otherwise, I wouldn't know \textbackslash newframe now which
176 does not exist in beamer.
177 \end{solution}
178 \end{exercise}
179
180 Loading varioref enables you to refer to sub-exercises, like
181 this: Did you do \ref{subex:man2}? It is the subexercise
182 \subexnref{subex:man2} and has label \subexlref{subex:man2}.
183
184
185 \begin{exercise}[points={many, many},
186 firstline={Play around with the options.}]
187 Some exercise, there are far too few.
188 \begin{solution}[defersolutiontitle]
189 \begin{frame}
190 This is a dual-use solution with explicit
191 beamer frames (and no framed).
192 \solutiontitle
193 Note, that we can freely place the title, because of
194 defersolutiontitle.
195 \end{frame}
196 \end{solution}
197 \end{exercise}
198
199 \begin{exercise}[points={many, many},beamersolution,
200 firstline={Play around with the options.}]
201 \begin{solution}
202 This solution is only shown if using the non-beamer version, because the option beamersolution was used. Otherwise both
203 solutions would be shown. You can set
204 the option beamersolution for individual (normal) solutions
205 to ignore some but not all solutions of an exercise.
206 \end{solution}
207 \begin{beamersolution}[defersolutiontitle]
208 \begin{frame}[t]
209 \solutiontitle
210 This beamersolution is only shown if using the beamer
211 version.
212 \end{frame}
213 \end{beamersolution}
214 \end{exercise}
215
216
217
218 \begin{exercise}[points={many, many},savetasks,
219 main task font={\tiny},subtask font={\itshape}
220 ]
221 \begin{maintask}
222 The exercise task can be saved and restated.
223 \end{maintask}
224 \begin{subtasks}
225 \subtask{first}
226 \begin{solution}[framed]
227 None (yet).
228 \end{solution}
229 \subtask{second}
230 \end{subtasks}
231 I forgot all the tasks!
232 \restatetask
233 Yeah, but what about the subtasks? I forgot the \restatetask[1] and the \restatetask[2] one. Or did I?
234 \end{exercise}
235
236 \begin{Lexercise}
237 --use [[]] if you need \ or escape it: "\\"
238 firstline = [[Assume $\pi=4$.]],
239 points=10,
240 name="Pragmatic",
241 options=[[main task font={\itshape}]],
242 task = [[
243 This is the main task specified via the Lua
244 interface, like subexercise \ref{subex:skiplexOne} in \ref{ex:skiplex}, whereas \ref{subex:skipexOne}
245 and \ref{subex:skipexTwo} in
246 \ref{ex:skipex} use the \LaTeX~interface.
247 ]],
248 solution=[[
249 This is a solution for the main task.
250 ]],
251 altsolutions={
252 {
253 name="Alternative Solution",
254 text="This is also a solution."
255 },{
256 idea=true,
257 text="This is also a solution."
258 }
259 },
260 \end{Lexercise}
261
262 \begin{Lexercise}
263 firstline = "Assume $e=3$.",
264 points="sum",
265 task = [[
266 This exercise has some subexercises. The Lua interface
267 computes point sums in a single pass.
268 ]],
269 subexercises = {
270 {
271 task = "First things first.",
272 bonuspoints = 4,
273 pointoptions = "abbrev",--passed to LaTeX interface
274 solution = [[None.]],
275 },{
276 task = "Second things afterwards.",
277 points = 16,
278 altsolutions = { [[None.]],[[Yet.]] },
279 }
280 }
281 \end{Lexercise}
282
283 \end{sheet}
284
285 \end{document}
286