summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/exercisesheets/examples/exshexample.tex
blob: 815b7d54af21953e08e0b6855740ca73e44fc8b3 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
\long\def\ifbeamer#1#2{#2}
\ifbeamer{\documentclass{beamer}}{\documentclass[a5paper]{article}}

%navigation symbols and the title collide if
%beamerwithheadline is set
\ifbeamer{
  \setbeamertemplate{navigation symbols}{}
}{}

%patchenumerate is the deafault
\usepackage[patchenumerate=true,beamerwithheadline,
  %when directly messing with page breaks
  %and the sheet start page actio (as we do below)
  %using exercisesheets' page numer redefinitions per
  %sheet do not make much sense
  patchpagenumbers=false,
  beamerwithfootline,
  beamercompatibility,
  exercisespath=exercises]%
  {exercisesheets}
\usepackage{varioref}
\usepackage{hyperref}
\usepackage{xcolor}

\exshset{solutions=true,
task restate font={\color{black!60}},
only={1-3,5-},
}

%solutions may be printed out on paper -> a4
%exercises are read on (smartphone) screen -> a5
\ifsolutions{
  \usepackage[left=1cm,right=1cm,top=1cm,bottom=1.5cm,a4paper]{geometry}
  }{
  \usepackage[left=0.7cm,right=0.7cm,top=1cm,bottom=1.5cm]{geometry}
}

%Usually the person responsible for the entire course:
\author{Exampleauthor}
\date{Example term/semester}
\title{Introduction to Exercise Sheets Creation}
\subject{Introduction to Exercise Sheets Creation}
%Only used for beamer at the moment:
\exshset{exauthor={Author of exercises}}

\ifbeamer{\exshset{beameruseblocks=false}}{}





\begin{document}

%1
\begin{sheet}[note={Learn how to create nice exercise sheets.},
  date={Novanuar 42, -2022},title={First Sheet}]

  \includeexercise*{exshexample-ex1}
  \includeLexercise*{exshexample-ex2}

  \begin{exercise}[points={many, many},firstline={Read the manual.}]
  \end{exercise}

  \begin{exercise}[points={sum},firstline={After you read the manual:}]
    Play around with this example. You might want to read further manuals like:
    \begin{enumerate}
      %pointsfloatright should be usually set globally
      \item\points[pointsfloatright]{2}pgf (for pgfkeys)
      \item enumitem and similar \points[abbrev,bonus]{1}
      \begin{enumerate}
        \item paralist \thesubex
        \item
          \begin{enumerate}
            \item varioref
          \end{enumerate}
      \end{enumerate}
      \item all the others \points[inplace]{3} (why not?)
      \label{subex:man2}
    \end{enumerate}
  \end{exercise}
\end{sheet}

\begingroup
\ifbeamer{}{
  \exshset{
    %default is \clearpage
    sheet start page action={\pagebreak[3]\hrule},
    sheet end page action={\vspace{4mm}\hrule\vspace{2cm}},
  }
}

%2
\begin{sheet}[date={Novanuar 35, -2022}]
  \begin{exercise}[points={many, many},
    firstline={Read the manual.}]
  \end{exercise}
  \begin{solution}[framed,fragile]
    Oh no, it's quite long.
    \newframe
    Really long, but please \verb|\relax|.
    Ok, but my brain feels like:
    \begin{verbatim}
%
 x
	$	t
&


\
#
    \end{verbatim}
    And yours?
  \end{solution}
\end{sheet}

%3
\begin{sheet}[date={Novanuar 28, -2022},title={Third Sheet},
  number within sheet]
  \begin{exercise}[points={many, many},
    firstline={Read the manual.}]
    \begin{solution}
      OK, done.
      \newpage
      still done.
    \end{solution}
  \end{exercise}
\end{sheet}

\endgroup

%4
\begin{sheet}
  \begin{Lexercise}
    task  = [[
      This exercise will be skipped.
    ]],
  \end{Lexercise}
  \begin{Lexercise}
    task  = [[
      \label{ex:skiplex}%
      This exercise will be skipped, but it has a reference.
    ]],
    subexercises = {[[\label{subex:skiplexOne} first]]},
  \end{Lexercise}
  \begin{exercise}[points={many, many},%savetasks,
    main task font={\tiny},subtask font={\itshape}
  ]
    \begin{maintask}
      \label{ex:skipex} This exercise will be skipped.
      Furt
    \end{maintask}
    \begin{subtasks}
      \item {first \label{subex:skipexOneOne}} This is an \string\item\space inside a subtasks environment. If
      \verb|subtask environment| is set to enumerate/itemize etc.,
      this works with some caveats (font settings for substaks are not used).
      \subtask{second}
    \end{subtasks}
    \begin{enumerate}
      \setcounter{enumi}{2}
      \subtask {first \label{subex:skipexOne}}
      This is a \string\subtask{} without the susbtasks
      environment, which is unsupported and a bad example!
      \item {\label{subex:skipexTwo}} {12345}
    \end{enumerate}
  \end{exercise}
\end{sheet}

%5
\begin{sheet}[date={Novanuar 21, -2022}]
  \begin{exercise}[points={many, many},
    firstline={Read the manual.}]
    \begin{solution}[framed]
      OK, done (again).
      \newframe
      Otherwise, I wouldn't know  \textbackslash newframe now which
      does not exist in beamer.
    \end{solution}
  \end{exercise}

  Loading varioref enables you to refer to sub-exercises, like
  this: Did you do \ref{subex:man2}? It is the subexercise
  \subexnref{subex:man2} and has label \subexlref{subex:man2}.


  \begin{exercise}[points={many, many},
  firstline={Play around with the options.}]
    Some exercise, there are far too few.
    \begin{solution}[defersolutiontitle]
      \begin{frame}
        This is a dual-use solution with explicit
        beamer frames (and no framed).
        \solutiontitle
        Note, that we can freely place the title, because of
        defersolutiontitle.
      \end{frame}
    \end{solution}
  \end{exercise}

  \begin{exercise}[points={many, many},beamersolution,
  firstline={Play around with the options.}]
    \begin{solution}
      This solution is only shown if using the non-beamer version, because the option beamersolution was used. Otherwise both
      solutions would be shown. You can set
      the option beamersolution for individual (normal) solutions
      to ignore some but not all solutions of an exercise.
    \end{solution}
    \begin{beamersolution}[defersolutiontitle]
      \begin{frame}[t]
      \solutiontitle
      This beamersolution is only shown if using the beamer
      version.
      \end{frame}
    \end{beamersolution}
  \end{exercise}



  \begin{exercise}[points={many, many},savetasks,
    main task font={\tiny},subtask font={\itshape}
  ]
    \begin{maintask}
      The exercise task can be saved and restated.
    \end{maintask}
    \begin{subtasks}
      \subtask{first}
      \begin{solution}[framed]
        None (yet).
      \end{solution}
      \subtask{second}
    \end{subtasks}
    I forgot all the tasks!
    \restatetask
    Yeah, but what about the subtasks? I forgot the \restatetask[1] and the \restatetask[2] one. Or did I?
  \end{exercise}

  \begin{Lexercise}
    --use [[]] if you need \ or escape it: "\\"
    firstline = [[Assume $\pi=4$.]],
    points=10,
    name="Pragmatic",
    options=[[main task font={\itshape}]],
    task  = [[
      This is the main task specified via the Lua
      interface, like subexercise \ref{subex:skiplexOne} in \ref{ex:skiplex}, whereas \ref{subex:skipexOne}
      and \ref{subex:skipexTwo} in
      \ref{ex:skipex} use the \LaTeX~interface.
    ]],
    solution=[[
      This is a solution for the main task.
    ]],
    altsolutions={
      {
        name="Alternative Solution",
        text="This is also a solution."
      },{
        idea=true,
        text="This is also a solution."
      }
    },
  \end{Lexercise}

  \begin{Lexercise}
    firstline = "Assume $e=3$.",
    points="sum",
    task  = [[
      This exercise has some subexercises. The Lua interface
      computes point sums in a single pass.
    ]],
    subexercises = {
      {
        task = "First things first.",
        bonuspoints = 4,
        pointoptions = "abbrev",--passed to LaTeX interface
        solution = [[None.]],
      },{
        task = "Second things afterwards.",
        points = 16,
        altsolutions = { [[None.]],[[Yet.]] },
      }
    }
  \end{Lexercise}

\end{sheet}

\end{document}