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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
|
% arara: pdflatex
% arara: biber
% arara: pdflatex
% arara: pdflatex
% --------------------------------------------------------------------------
% the TASKS package
%
% horizontal columned lists
%
% --------------------------------------------------------------------------
% Clemens Niederberger
% Web: https://bitbucket.org/cgnieder/exsheets/
% E-Mail: contact@mychemistry.eu
% --------------------------------------------------------------------------
% Copyright 2011-2014 Clemens Niederberger
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Clemens Niederberger.
% --------------------------------------------------------------------------
% The tasks package is part of the exsheets bundle
% --------------------------------------------------------------------------
% If you have any ideas, questions, suggestions or bugs to report, please
% feel free to contact me.
% --------------------------------------------------------------------------
\documentclass[load-preamble+]{cnltx-doc}
\usepackage[more]{tasks}
\setcnltx{
package = {tasks} ,
authors = Clemens Niederberger ,
email = {contact@mychemistry.eu} ,
url = {https://bitbucket.org/cgnieder/exsheets/} ,
info = {%
{\small part of the \href{exsheets_en.pdf}{\ExSheets}
bundle}\\[\baselineskip]
create horizontal columned lists%
} ,
add-cmds = {
checkedchoicebox ,
choicebox,
NewTasks,
settasks,
startnewitemline ,
task
} ,
add-silent-cmds = {
choice, correct,
DeclareInstance, DeclareTemplateInterface,
leftthumbsup,
s, sample
}
}
\newpackagename\ExSheets{ExSheets}
\newpackagename\ExSheetslistings{ExSheets-listings}
\newpackagename\cntformats{cntformats}
\newpackagename\Tasks{tasks}
% ----------------------------------------------------------------------------
% other packages, bibliography, index
\usepackage{xcoffins,wasysym,enumitem,booktabs,siunitx}
\usepackage[accsupp]{acro}
\DeclareAcronym{id}{
short = id ,
long = Identifier ,
format = \scshape ,
pdfstring = ID ,
accsupp = ID
}
\usepackage{filecontents}
\usepackage{csquotes}
% ----------------------------------------------------------------------------
% example definitions that have to be done in the preamble:
\usepackage{exsheets}
\usepackage{dingbat}
\NewTasks[style=multiplechoice]{multiplechoice}[\choice](3)
\newcommand*\correct{\PrintSolutionsTF{\checkedchoicebox}{\choicebox}}
\def\s{This is some sample text we will use to create a somewhat
longer text spanning a few lines.}
\def\sample{\s\ \s\par\s}
\begin{document}
\section{Motivation}
Originally \Tasks\ has been an integral part of \ExSheets\changedversion{0.7}.
However, users told me that it indeed could be useful to have it as a
stand-alone package not having to load the whole \ExSheets\ beast just for
having the \env{tasks} environment available. Since I agree with this the
environment has been extracted into a package if its own, \Tasks.
The reason for the \env{tasks} environment is an unwritten agreement in German
maths textbooks (in (junior) high school, especially) to organize exercises in
columns counting horizontally rather than vertically. That is what
\code{tasks} primarily is for. If you don't need this feature you're better
off using traditional \LaTeX{} lists and the \pkg{enumitem} package for
customization.
\section{License and Requirements}\label{sec:license}
\license
\Tasks\ requires the \bnd{l3kernel}~\cite{bnd:l3kernel} bundle
,\needpackage{xparse}, \pkg{xtemplate} and \needpackage{l3keys2e} which are
part of the \bnd{l3packages}~\cite{bnd:l3packages} bundle,
\pkg{epic}~\cite{pkg:epic}, \pkg{cntformats}\footnote{Part of the \ExSheets\
bundle}, and \pkg{environ}~\cite{pkg:environ}.
\section{How it works}
\subsection{The Basics}
The \env{tasks} environment is similar to a list like \env{enumerate} but not
the same. Here are some of the differences:
\begin{itemize}
\item A first difference: there is no pagebreak possible inside an item but
only between items.
\item A second difference: the enumeration default is a), b), c) \ldots
\item A third difference: there is a split at \emph{every} occurrence of the
item separator. For this reason the default separator is not \cs*{item}
but \cs{task} so it is unique to this environment only.
\item A fourth difference: the \env{tasks} environment cannot be nested.
You can, however, use an \env*{itemize} environment or something in it.
\item A fifth difference: verbatim material cannot be used in it. You'll
have to use \cs*{string}, \cs*{texttt} or \cs*{detokenize}. If this
won't suffice then don't use \env{tasks}.
% \item A sixth difference: %footnotes
\end{itemize}
\begin{environments}
\environment{tasks}[\oarg{options}\darg{num of columns}]
List like environment where the single items are iintroduced with
\cs{task}.
\end{environments}
Let's see an example:
\begin{example}
% \sample is defined to contain some sample text:
% \def\s{This is some sample text we will use to create a somewhat
% longer text spanning a few lines.}
% \def\sample{\s\ \s\par\s}
Some text before the list.
\begin{tasks}
\task \sample
\task \sample
\task \sample
\end{tasks}
And also some text after it.
\end{example}
The environment takes the optional argument \darg{num of columns} with which
the number of columns used by the environment is specified.
\begin{example}
\begin{tasks}(2)
\task \sample
\task \s\ \s
\task \s
\task \sample
\task \s\par\s
\end{tasks}
\end{example}
\subsection{Introducing a New Row}
Sometimes it may come in handy if the current\sinceversion{0.9} row of items
could be terminated and a new one is started. This is possible with the
following command:
\begin{commands}
\command{startnewitemline}
Introduce a new line in a \env{tasks} environment.
\end{commands}
\begin{example}
\begin{tasks}(4)
\task the first
\task the second
\task the third
\task the fourth
\task \rlap{the fifth item is way too long for this so we start a new row}
\startnewitemline
\task the sixth
\task the seventh
\task \rlap{the eighth item also is too long} \startnewitemline
\task the nineth
\task the tenth
\end{tasks}
\end{example}
\section{Available Options}\label{sec:tasks:options}
The \Tasks\ package has one package option which also is called when you load
\ExSheets\ with the \option{load-tasks} option.
\begin{options}
\opt{more}
Load additional instances for the \env{tasks} object, details are
explained later in section~\ref{sec:tasks:instances}.
\end{options}
The environment itself has some more options, namely the following ones that
can be set using a setup command:
\begin{commands}
\command{settasks}[\marg{options}]
Setup command for \Tasks.
\end{commands}
\begin{options}
\keyval{style}{instance}\Default
Choose the instance to be used. Read more on this in
section~\ref{sec:tasks}.
\keyval{counter-format}{counter specs}\Default
\sinceversion{0.9}Sets a custom label. The letters \code{tsk} are
replaced with the task-counter. An optional argument directly following
these letters specifies the counter format: \code{1}: \cs*{arabic},
\code{a}: \cs*{alph}, \code{A}: \cs*{Alph}, \code{r}: \cs*{roman} and
\code{R}: \cs*{Roman}.
\keyval{label-format}{code}\Default
\changedversion{0.9}Can be used to apply a formatting like, \eg,
\cs*{bfseries} to the labels.
\keyval{label}{code}\Default
\changedversion{0.9}Overwrite the automatic label to a custom one.
\keyval{label-width}{dim}\Default{1em}
Sets the width of the item labels.
\keyval{label-offset}{dim}\Default{.3333em}
\sinceversion{0.7}Sets the offset, \ie, the distance between label and
item.
\keyval{item-indent}{dim}\Default{2.5em}
\sinceversion{0.9a}The indent of an item, \ie, the horizontal space
available for both label and label-offset. If
\[
\text{\code{indent}} =
\text{\code{label-width}} + \text{\code{label=offset}}
\]
the label will align with the textblock above (if
\keyis{label-align}{left} is set).
\keychoice{label-align}{left,right,center}\Default{left}
\sinceversion{0.7}Determines how the labels are aligned within the
label-box whose width is set with \option{label-width}.
\keyval{before-skip}{skip}\Default{0pt}
Sets the skip before the list.
\keyval{after-skip}{skip}\Default{0pt}
Sets the skip after the list.
\keyval{after-item-skip}{skip}\Default{1ex plus 1ex minus 1ex}
\sinceversion{0.9}This vertical skip is inserted between rows of items.
\keybool{resume}\Default{false}
The enumeration will resume from a previous \env{tasks} environment. In
order to use this option properly you shouldn't mix different \env{tasks}
environments that both count their items.
\end{options}
Now the same list as above but with three columns and a different label:
\begin{example}
\begin{tasks}[counter-format=(tsk[r]),label-width=4ex](2)
\task \sample
\task \s\ \s
\task \s
\task \sample
\task \s\par\s
\end{tasks}
\end{example}
% \begin{tasks}[counter-format=(tsk[r]),label-width=4ex](3)
% \task \sample
% \task \s\ \s
% \task \s
% \task \sample
% \task \s\par\s
% \end{tasks}
Let's use it inside a question, \ie, inside \ExSheets' \env{question}
environment:
\begin{example}
% since settings are local the following ones will be lost
% outside this example;
\settasks{
counter-format = qu.tsk ,
item-indent = 2em ,
label-width = 2em ,
label-offset = 0pt
}
\begin{question}[type=exam]{4}
I have these two tasks for you. Shall we begin?
\begin{tasks}(2)
\task The first task: easy!
\task The second task: even more so!
\end{tasks}
\end{question}
\begin{solution}[print]
Now, let's see\ldots\ ah, yes:
\begin{tasks}
\task This is the first solution. Told you it was easy.
\task This is the second solution. And of course you knew that!
\end{tasks}
\end{solution}
\end{example}
\section{Available Instances}\label{sec:tasks:instances}
When you use the package option \option{more} of the \Tasks\ package or load
\ExSheets\ with the \option{load-tasks} option there are currently three
additional instances for the \code{tasks} object available:
\begin{description}
\item[itemize] uses \cs*{labelitemi} as labels.
\item[enumerate] enumerates the items with 1., 2., \ldots
\item[multiplechoice] a --~well~-- `multiple choice' list.
\end{description}
\begin{example}
\begin{tasks}[style=itemize](2)
\task that's just how\ldots
\task \ldots we expected
\end{tasks}
\begin{tasks}[style=enumerate](2)
\task that's just how\ldots
\task \ldots we expected
\end{tasks}
\begin{tasks}[style=multiplechoice](2)
\task that's just how\ldots
\task \ldots we expected
\end{tasks}
\end{example}
\section{Custom Labels}
If you want to change a single label inside a list, you can use the optional
argument of \cs{task}. This will temporarily overwrite the default label.
\begin{example}[side-by-side]
\begin{tasks}[style=itemize]
\task a standard item
\task another one
\task[+] a different one
\task and another one
\end{tasks}
\end{example}
\section{New Tasks}
It is possible to add custom environments that work like the \code{tasks}
environment.
\begin{commands}
\command{NewTasks}[\oarg{options}\marg{name}\oarg{separator}\darg{cols}]
Define environment \meta{name} that uses \meta{separator} to introduce a
new item. Default for \meta{separator} is \cs{task}, default for
\meta{cols} is \code{1}. The \meta{options} are the ones described in
section~\ref{sec:tasks:options}.
\command{RenewTasks}[\oarg{options}\marg{name}\oarg{separator}\darg{cols}]
Renew environment previously defined with \cs{NewTasks}.
\end{commands}
The \env{tasks} environment is defined as follows:
\begin{sourcecode}
\NewTasks{tasks}
\end{sourcecode}
The separator does not have to be a control sequence:
\begin{example}
% preamble:
% \usepackage{dingbat}
\NewTasks[label=\footnotesize\leftthumbsup,label-width=1.3em]{done}[*]
\begin{done}
* First task
* Second Task
\end{done}
\end{example}
Although this might seem handy or even nice I strongly advice against using
something different than a command sequence. Remember that the items will be
split at \emph{every} occurrence of the separator. So in order to use the
separator (here for example for a starred variant of a command) within an item
it has to be hidden in braces. This is avoided of you use a command sequence
which even doesn't have to be defined.
Let's say you want a \env*{multiplechoice} environment that has three columns
in its default state. You could do something like this:
\begin{example}
% preamble:
% \NewTasks[style=multiplechoice]{multiplechoice}[\choice](3)
% \newcommand*\correct{\PrintSolutionsTF{\checkedchoicebox}{\choicebox}}
%
% \PrintSolutionsTF and the {question} environment are provided
% by the ExSheets package
\begin{question}
\begin{multiplechoice}
\choice First choice
\choice Second choice
\choice[\correct] Third choice
\end{multiplechoice}
\end{question}
\begin{solution}[print]
\begin{multiplechoice}
\choice First choice
\choice Second choice
\choice[\correct] Third choice
\end{multiplechoice}
\end{solution}
\end{example}
The last example shows you two additional commands:
\begin{commands}
\command{choicebox}[\quad\choicebox]
Print an empty square.
\command{checkedchoicebox}[\quad\checkedchoicebox]
Print a crossed-out square.
\end{commands}
\section{Styling \Tasks}
Equivalent to the styling of \ExSheets\ \Tasks\ uses \pkg{xtemplate} to
declare additional instances for the lists.
\subsection{The \code{tasks} Object}\label{sec:tasks}
The object that's defined by \Tasks\ is the `tasks' object. This time there
are four instances available for the one template (again `default') that was
defined.
\subsubsection{Available Options}
This section only lists the options that can be used when defining an instance
of the `default' template. The following subsections will give some examples
of their usage.
\begin{sourcecode}
\DeclareTemplateInterface{tasks}{default}{3}
{
% option : type = default
enumerate : boolean = true ,
label : tokenlist ,
indent : length = 2.5em ,
counter-format : tokenlist = tsk[a]) ,
label-format : tokenlist ,
label-width : length = 1em ,
label-offset : length = .3333em ,
after-item-skip : skip = 1ex plus 1ex minus 1ex
}
\end{sourcecode}
\subsubsection{Predefined Instances}
This is rather brief this time:
\begin{sourcecode}
% ALPHABETIZE: a) b) c)
\DeclareInstance{tasks}{alphabetize}{default}{}
% available when `load-tasks=true':
% ITEMIZE:
\DeclareInstance{tasks}{itemize}{default}
{
enumerate = false ,
label-width = 1.125em
}
% ENUMERATE:
\DeclareInstance{tasks}{enumerate}{default}
{ counter-format = tsk. }
% MULTIPLECHOICE:
\DeclareInstance{tasks}{multiplechoice}{default}
{
enumerate = false ,
label = \choicebox ,
}
\end{sourcecode}
\end{document}
|