Debian Codegraph @

texmf-dist/source/latex/exframe/exframe.dtx

raw
1 %
2 % \iffalse meta-comment
3 %
4 % exframe.dtx Copyright (C) 2011-2026 Niklas Beisert
5 %
6 % This work may be distributed and/or modified under the
7 % conditions of the LaTeX Project Public License, either version 1.3
8 % of this license or (at your option) any later version.
9 % The latest version of this license is in
10 % https://www.latex-project.org/lppl.txt
11 % and version 1.3c or later is part of all distributions of LaTeX
12 % version 2008 or later.
13 %
14 % This work has the LPPL maintenance status `maintained'.
15 %
16 % The Current Maintainer of this work is Niklas Beisert.
17 %
18 % This work consists of the files exframe.dtx and exframe.ins
19 % and the derived files exframe.sty and exframe-samp.tex,
20 % exframe-ser.tex, exframe-ser-01.tex, exframe-ser-02.tex, exframe-ser-03.tex,
21 % exframe-ser-aa.tex, exframe-ser-pe.tex, exframe-ser-pf.tex,
22 % exframe-ser.sh, exframe-ser.mak.
23 %
24 %<package|samplesingle|samplemultimain>\NeedsTeXFormat{LaTeX2e}[1996-12-01]
25 %<package>\ProvidesPackage{exframe}[2026-03-23 v3.5.3 Framework for Exercise Problems]
26 %<samplesingle>\ProvidesFile{exframe-samp.tex}[2026-03-23 v3.5.3 standalone sample for exframe]
27 %<samplemultimain>\ProvidesFile{exframe-ser.tex}[2026-03-23 v3.5.3 multipart sample for exframe]
28 %<source>\ProvidesFile{exframe-src.tex}[2026-03-23 v3.5.3 exframe source code documentation]
29 %<manual>\ProvidesFile{exframe.tex}[2026-03-23 v3.5.3 exframe reference manual]
30 %<*main|manual|source>
31 \def\thepkg/{exframe}\def\thedate/{2026-03-23}\def\theversion/{v3.5.3}
32 \def\thecopyright/{2011\texorpdfstring{--}{-}2026 Niklas Beisert}
33 %<*main>
34 \ProvidesFile{\thepkg/.dtx}[\thedate/ \theversion/ \thepkg/ package main file]
35 %</main>
36 \PassOptionsToClass{10pt,a4paper}{article}
37 \documentclass{ltxdoc}
38
39 \usepackage[margin=35mm]{geometry}
40 \usepackage[hyperindex=false]{hyperref}
41 \usepackage{hyperxmp}
42 \usepackage[usenames]{color}
43 \usepackage{longtable}
44
45 %<*main>
46 \title{The \markpkg{\thepkg/} Package}
47 \hypersetup{pdftitle={The \thepkg/ Package}}
48 \hypersetup{pdfsubject={Documentation for the LaTeX2e Package \thepkg/}}
49 %</main>
50 %<manual>\title{The \markpkg{\thepkg/} Package\\Reference Manual}
51 %<manual>\hypersetup{pdftitle={The \thepkg/ Package -- Reference Manual}}
52 %<manual>\hypersetup{pdfsubject={Reference Manual for the LaTeX2e Package \thepkg/}}
53 %<source>\title{The \markpkg{\thepkg/} Package\\Source Code Documentation}
54 %<source>\hypersetup{pdftitle={The \thepkg/ Package -- Source Code Documentation}}
55 %<source>\hypersetup{pdfsubject={Documented Source for the LaTeX2e Package \thepkg/}}
56 \author{Niklas Beisert\\[2ex]
57 Institut f\"ur Theoretische Physik\\
58 Eidgen\"ossische Technische Hochschule Z\"urich\\
59 Wolfgang-Pauli-Strasse 27, 8093 Z\"urich, Switzerland\\[1ex]
60 \href{mailto:[email protected]}
61 {\texttt{[email protected]}}}
62 \hypersetup{pdfauthor={Niklas Beisert}}
63 \date{\theversion/: \markdate{\thedate/}\\[1ex]
64 \url{https://ctan.org/pkg/\thepkg/}\\[0.5ex]
65 \url{https://github.com/nbeisert/latex-pkg-nb}}
66
67 \hypersetup{pdflang={en-UK}}
68 \hypersetup{pdfurl={https://ctan.org/pkg/\thepkg/}}
69 \hypersetup{pdfcopyright={Copyright \thecopyright/.
70 This work may be distributed and/or modified under the
71 conditions of the LaTeX Project Public License, either version 1.3
72 of this license or (at your option) any later version.}}
73 \hypersetup{pdflicenseurl={https://www.latex-project.org/lppl.txt}}
74 \hypersetup{pdfcontactaddress={ETH Zurich, ITP, HIT K,
75 Wolfgang-Pauli-Strasse 27}}
76 \hypersetup{pdfcontactpostcode={8093}}
77 \hypersetup{pdfcontactcity={Zurich}}
78 \hypersetup{pdfcontactcountry={Switzerland}}
79 \hypersetup{pdfcontactemail={[email protected]}}
80 \hypersetup{pdfcontacturl={https://people.phys.ethz.ch/\xmptilde nbeisert/}}
81
82 \hypersetup{keeppdfinfo=true}
83 \hypersetup{pdfsource={}}
84 \AddToHook{begindocument/before}{\hypersetup{colorlinks=false}}
85 \hypersetup{urlbordercolor={.5 1 1}}
86 \hypersetup{linkbordercolor={1 .7 .7}}
87 \AddToHook{begindocument/before}{\hypersetup{pdfstartview=FitH}}
88
89 \parskip1ex
90 \parindent0pt
91 \edef\itemize{\unexpanded\expandafter{\itemize}\parskip0pt}
92
93 \newcommand{\markpkg}[1]{\textsf{#1}}
94 \newcommand{\markdate}[1]{\textsf{#1}}
95 \newcommand{\secref}[1]{\hyperref[#1]{section \ref*{#1}}}
96 \newcommand{\ctanref}[2]{\href{https://ctan.org/#1}{#2}}
97 \newcommand{\ctanpkg}[1]{\ctanref{pkg/#1}{\markpkg{#1}}}
98
99 \def\verbbar{\texttt{\char"7C}}
100 \def\verbpkg{\texttt{\thepkg/}}
101 \def\thepkgctan/{\ctanpkg{\thepkg/}}
102
103 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
105 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
106 \begin{document}
107
108 \maketitle
109
110 \begin{abstract}\noindent
111 \markpkg{exframe} is a \LaTeXe{} package
112 which provides a general purpose framework to describe and typeset
113 exercises and exam questions along with their solutions.
114 The package features mechanisms
115 to hide or postpone solutions,
116 to assign and handle points,
117 to collect problems on exercise sheets,
118 to store and use metadata
119 and to implement a consistent numbering.
120 It also provides a very flexible interface for configuring and customising
121 the formatting, layout and representation of the exercise content.
122 \end{abstract}
123
124 \begingroup
125 \parskip0ex
126 \tableofcontents
127 \endgroup
128
129
130 %<*main|manual>
131 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
132 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
133 \section{Introduction}
134
135 This package provides a framework to describe and typeset
136 exercises (homework problems, classroom exercises, quizzes, exam questions,
137 exercise questions in books and lecture notes, \ldots)
138 and their solutions or answers.
139 The aim of this package is to set up a few \LaTeX{} environments
140 into which questions and corresponding answers can be filled conveniently.
141 The main task of the package is to manage the text and data
142 that are provided in the source document,
143 perform some common operations on them,
144 and then output the content appropriately.
145 The package has the following goals, tasks and features:
146 %
147 \begin{itemize}
148 \item
149 The package is designed with generality in mind.
150 It is meant to be usable in many different situations.
151 The primary target is science and education, but it may well
152 be useful in other areas.
153
154 \item
155 The package defines a basic functional layout for the output
156 and provides many options to reshape the layout and formatting
157 according to the author's needs and wishes.
158
159 \item
160 The package can handle two layers of exercises:
161 main problems and subproblems.
162 The use of subproblems is optional.
163
164 \item
165 The display of solutions can be configured:
166 Solutions can be hidden for a hand-out version of exercise sheets.
167 When displayed, they may appear immediately,
168 collectively after the problem,
169 at the end of each sheet or at some manually defined location.
170
171 \item
172 The package can handle exercise sheets which combine several exercise problems:
173 A \LaTeX{} document can consist of an individual sheet
174 or of a collection of sheets (e.g.\ spanning a lecture course).
175 In the latter case, the document files can be set up
176 such that single sheets as well as a collection of all sheets can be compiled;
177 the package \ctanpkg{childdoc} may be of assistance.
178
179 \item
180 The package can handle points to be credited:
181 Points will be displayed according to the layout.
182 Overall points for a problem or a sheet can be added automatically.
183 Points can also be stored and used elsewhere.
184
185 \item
186 The package provides an interface to specify exercise metadata
187 (author, source, \ldots):
188 Some basic types of metadata are predefined and more specific metadata
189 categories can be added.
190
191 \item
192 The package can use alternative counters for equations
193 within solutions (and problems). This is to ensure a consistent
194 numbering independently of whether solutions are output or not.
195
196 \end{itemize}
197
198 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
199 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
200 \section{Usage}
201 \label{sec:usage}
202
203 To use the package \ctanpkg{exframe} add the command
204 %
205 \begin{center}
206 |\usepackage{exframe}|
207 \end{center}
208 %
209 to the preamble of the \LaTeX{} document.
210
211 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
212 \subsection{Exercise Environments}
213 \label{sec:environments}
214
215 The package provides four environments
216 to describe the main entities of exercise problems.
217 Additional information on the exercises can be provided
218 in the optional arguments to these environments
219 which will be discussed in the following sections.
220 Furthermore, a limited set of commands
221 is provided for control and extra features,
222 see the sections below for details.
223
224 \DescribeEnv{problem}
225 The |problem| environment describes
226 an exercise problem:
227 %
228 \begin{center}
229 \begin{tabular}{l}
230 |\begin{problem}[|\textit{opts}|]|\\
231 | |\textit{problem text and subproblems}\\
232 |\end{problem}|
233 \end{tabular}
234 \end{center}
235 %
236 As one of the many available options \textit{opts},
237 one can provide a title for the exercise by
238 specifying |title={|\textit{title}|}|.
239 If no title is given, the problem number will be displayed instead.
240 See \secref{sec:metadata} and \secref{sec:points}
241 for a description of the available options.
242
243 \DescribeEnv{subproblem}
244 The |subproblem| environment describes
245 a subproblem, part or an individual question of an exercise problem:
246 %
247 \begin{center}
248 \begin{tabular}{l}
249 |\begin{subproblem}[|\textit{opts}|]|\\
250 | |\textit{subproblem text}\\
251 |\end{subproblem}|
252 \end{tabular}
253 \end{center}
254 %
255 A |subproblem| environment must be contained within a |problem| environment
256 (however, a |problem| block need not contain |subproblem| blocks).
257
258 \DescribeEnv{solution}
259 The |solution| environment describes
260 the solution to a problem or a subproblem:
261 \begin{center}
262 \begin{tabular}{l}
263 |\begin{solution}[|\textit{opts}|]|\\
264 | |\textit{solution text}\\
265 |\end{solution}|
266 \end{tabular}
267 \end{center}
268 %
269 A |solution| environment should be
270 at the end of a |subproblem| or |problem| environment
271 (it is not mandatory to provide a |solution|).
272 It can be contained within the corresponding environment or it can follow it
273 (where needed, the option |forproblem| associates a |solution|
274 following a |subproblem| to the encompassing |problem|
275 rather than the preceding |subproblem|).
276 Depending on the choice of solution display, see \secref{sec:solutions},
277 the output may have a slightly different layout.
278 In terms of logic, it is preferred
279 to define a solution \emph{within} the corresponding environment;
280 this may also have some technical advantages and produce
281 a slightly better result in terms of layout.
282
283 \DescribeEnv{sheet}
284 The |sheet| environment describes an exercise sheet:
285 %
286 \begin{center}
287 \begin{tabular}{l}
288 |\begin{sheet}[|\textit{opts}|]|\\
289 | |\textit{sheet text and problems}\\
290 |\end{sheet}|
291 \end{tabular}
292 \end{center}
293 %
294 A sheet typically contains one or several problems
295 (it is not mandatory to group problems into a |sheet|).
296 There may or may not be additional auxiliary text introducing the problems.
297 A header will be added to the sheet according to the specified layout.
298
299 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
300 \subsection{Solution and Problem Display}
301 \label{sec:solutions}
302
303 There are several options to control the output of solutions
304 and of problems.
305
306 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
307 \DescribeMacro{solutions}
308 Most importantly, the display of solutions
309 can be disabled or enabled altogether:
310 %
311 \begin{center}
312 |\exercisesetup{solutions|[|=true|\textbar|false|]|}|
313 \end{center}
314 %
315 Solutions are hidden by default,
316 and their display needs to be activated explicitly
317 (it suffices to specify the option |solutions| without the value |true|).
318 It is also possible to control the display
319 by an analogous package option |solutions|,
320 see \secref{sec:options} for further information.
321
322 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
323 \DescribeMacro{\ifsolutions}
324 \DescribeMacro{onlysolutions}
325 The display of solutions is reflected by the conditional |\ifsolutions|.
326 As the hiding of solutions is performed automatically,
327 the conditional would typically be used to change some details,
328 e.g.\ for adjusting titles:
329 %
330 \begin{center}
331 |\ifsolutions Solutions\||else Exercises\||fi|
332 \end{center}
333 %
334 Alternatively, content to be processed only in solutions mode
335 can be enclosed in an |onlysolutions| block:
336 %
337 \begin{center}
338 \begin{tabular}{l}
339 |\begin{onlysolutions}|\\
340 |...|\\
341 |\end{onlysolutions}|
342 \end{tabular}
343 \end{center}
344 %
345 This structure can be useful to hide auxiliary text or material
346 if all solution content is to be stripped from a source file,
347 e.g.\ by an automated \textsf{sed} filter rule
348 (doubling of backslashes required for \textsf{sed}
349 as well as for shell script strings):
350 %
351 \begin{center}
352 \begin{tabular}{l}
353 |sed "/\\\\begin{solution}/,/\\\\end{solution}/d;"\|\\
354 |"/\\\\begin{onlysolutions}/,/\\\\end{onlysolutions}/d"|
355 \end{tabular}
356 \end{center}
357 %
358
359 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
360 \DescribeMacro{solutionequation}
361 As solutions can contain numbered equations
362 while the display of solutions can be switched on and off,
363 it is important to assign a different counter for equations within solutions
364 in order for the equation numbers to be stable.
365 A separate counter for equations within solutions is enabled by default.
366 It can be disabled by:
367 %
368 \begin{center}
369 |\exercisestyle{solutionequation=false}|
370 \end{center}
371 %
372 This option prepends the letter `S' to equation
373 numbers within solutions which are counted separately;
374 the display can be configured differently, see \secref{sec:layout}.
375
376 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
377 \DescribeMacro{solutionbelow}
378 \DescribeMacro{\insertsolutions}
379 The package allows to collect solutions
380 and defer their display to particular locations:
381 %
382 \begin{center}
383 |\exercisestyle{solutionbelow=|\textit{pos}|}|
384 \end{center}
385 %
386 The available choices for \textit{pos} are
387 to display solutions where they are defined (|here|),
388 defer them to the end of the current subproblem (|subproblem|),
389 problem (|problem|) or sheet (|sheet|)
390 or display them at a manually chosen location (|manual|).
391 Note that typically solutions are defined at the end of a (sub)problem
392 and therefore the choice |here| is similar to (|sub|)|problem|.
393 The latter form, however, makes sure that a solution
394 does not inherit the margin of the parent environment.
395 The alternate modes |problem*| and |subproblem*|
396 positions the solution \emph{after} the (sub)problem environment
397 such that it does not inherit any layout,
398 but also no definitions made in the parent environment.
399 In |manual| mode, all solutions are collected (with appropriate headers)
400 until they are output by the directive |\insertsolutions|.
401 If no solutions are stored in the buffer
402 (or if the mode is not |manual|), |\insertsolutions| has no effect.
403
404 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
405 \DescribeMacro{\writesolutions}
406 Another option to handle solutions is to write them to a file
407 for later use.
408 Writing to a file is initiated by:
409 %
410 \begin{center}
411 |\writesolutions[|\textit{filename}|]|
412 \end{center}
413 %
414 The optional argument describes the filename as \textit{filename}|.sol|;
415 no argument defaults to the main tex filename as |\jobname.sol|;
416 the extension |.sol| can be customised by the configuration |extsolutions|.
417 This mode overrides the |solutionbelow| behaviour described above;
418 all subsequent solutions are written to the file.
419 The file is closed by |\closesolutions| and the display of solutions
420 returns to manual mode.
421 It is not necessary to close a file as it will be closed
422 automatically by reading from a file, writing to another file
423 or by the end of the document.
424
425 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
426 \DescribeMacro{\readsolutions}
427 Solutions are read from a file by:
428 %
429 \begin{center}
430 |\readsolutions[|\textit{filename}|]|
431 \end{center}
432 %
433 This command outputs a sectional title
434 and reads the file via |\input{|\textit{filename}|.sol}|.
435
436 \medskip
437
438 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
439 \DescribeMacro{solutionbuf}
440 \DescribeMacro{problembuf}
441 \DescribeMacro{subproblembuf}
442 The package offers similar functionality to control the display of problems.
443 In order to have any control over the content of |problem| and |subproblem|
444 environments, the latter need to be read into an internal buffer.
445 Reading of solutions and problems to internal buffers is activated
446 or deactivated by:
447 %
448 \begin{center}
449 \begin{tabular}{l}
450 |\exercisesetup{solutionbuf|[|=true|\textbar|false|]|}|\\
451 |\exercisesetup{problembuf|[|=true|\textbar|false|]|}|\\
452 |\exercisesetup{subproblembuf|[|=true|\textbar|false|]|}|
453 \end{tabular}
454 \end{center}
455 %
456 By default, |solution| environments are read to an internal buffer,
457 while the content of [|sub|]|problem| environments is processed directly
458 by the \TeX\ engine.
459 Therefore, the below options to control the display
460 of [|sub|]|problem| environments
461 require the statement |\exercisesetup{|[|sub|]|problembuf}|.
462
463 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
464 \DescribeMacro{problemmanual}
465 \DescribeMacro{\insertproblems}
466 The immediate display of |problem| environments is controlled by:
467 %
468 \begin{center}
469 |\exercisestyle{problemmanual|[|=true|\textbar|false|]|}|
470 \end{center}
471 %
472 In the default automatic mode, problems are displayed directly
473 where they are declared.
474 In manual mode, problems are collected to an internal buffer,
475 and only displayed by issuing |\insertproblems|.
476
477 Note that |solution| environments should be
478 declared within the corresponding |problem| environment in order to
479 preserve their appropriate association.
480 The |solution| environment is then processed at the place
481 where the |problem| environment is displayed,
482 and it may (or may not) be deferred further.
483
484 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
485 \DescribeMacro{\writeproblems}
486 \DescribeMacro{\readproblems}
487 Problems can be written out to an external file for later usage.
488 The functionality is analogous to solutions
489 and uses the macros:
490 %
491 \begin{center}
492 \begin{tabular}{l}
493 |\writeproblems[|\textit{filename}|]|\\
494 |\readproblems[|\textit{filename}|]|
495 \end{tabular}
496 \end{center}
497 %
498 The optional argument describes the filename as \textit{filename}|.prb|;
499 no argument defaults to the main tex filename as |\jobname.prb|;
500 the extension |.prb| can be customised by the configuration |extproblems|.
501
502 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
503 \DescribeMacro{disable}
504 \DescribeMacro{insertproblemselect}
505 \DescribeMacro{insertsubproblemselect}
506 The display of a particular [|sub|]|problem|
507 can be suppressed altogether by an optional argument:
508 %
509 \begin{center}
510 |\begin{|[|sub|]|problem}[disable]|
511 \end{center}
512 %
513
514 This option can be exploited to automatically
515 suppress certain classes of problems as follows:
516 A hook function |insert|[|sub|]|problemselect| declared by:
517 %
518 \begin{center}
519 |\exerciseconfig{insert|[|sub|]|problemselect}[1]{|\textit{code}|}|
520 \end{center}
521 %
522 can call
523 |\set|[|sub|]|problemdata{disable}| whenever a problem is to be suppressed.
524 In order to decide, the optional argument of the [|sub|]|problem| environment
525 is passed on to the hook function as the single argument.
526 Note that the argument needs to be processed manually.
527
528 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
529 \subsection{Metadata}
530 \label{sec:metadata}
531
532 In a collection of exercise problems
533 it makes sense to keep track of metadata
534 for the overall collection as well as for individual problems
535 and potentially display some of them.
536 The framework defines a standard set of metadata fields
537 and offers functionality to add more specialised metadata fields.
538
539 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
540 \DescribeMacro{\exercisedata}
541 Global metadata is specified by the command:
542 %
543 \begin{center}
544 |\exercisedata{|\textit{data}|}|
545 \end{center}
546 %
547 The argument \textit{data}
548 is a comma-separated list of metadata specifications
549 in the form \textit{key}|={|\textit{value}|}|.
550 The standard set of global metadata keys consists of:
551 %
552 \begin{itemize}
553 \item |author|:
554 principal author(s) of the exercise collection;
555 also invokes the \LaTeX{} command |\author|;
556 will be written to pdf documents.
557 \item |title|:
558 title of the exercise collection;
559 also invokes the \LaTeX{} command |\title|;
560 will be written to pdf documents.
561 \item |date|:
562 date of the exercise collection;
563 also invokes the \LaTeX{} command |\date|;
564 will be written to pdf documents.
565 \item |subject|:
566 subject area of the exercise collection;
567 will be written to pdf documents.
568 \item |keyword|:
569 keyword(s) for the exercise collection;
570 will be written to pdf documents.
571 \item |course|:
572 title of the course (class, lecture, module, \ldots)
573 for the exercise collection.
574 \item |institution|:
575 institution (school, department, institute, university, \ldots)
576 offering the course or exercise collection.
577 \item |instructor|:
578 instructor(s) for the course or exercise;
579 this field refers to person(s) who organise
580 the corresponding course or exercises
581 whereas |author| refers to the principal creator of the material.
582 \item |period|:
583 period (year, season, date, term identifier, \ldots)
584 of the corresponding course.
585 \item |material|:
586 type of material
587 (exercises, homework assignments, exam, quizzes, solutions, \ldots).
588 \end{itemize}
589 %
590 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
591 \DescribeMacro{\defexercisedata}
592 Additional custom fields for global metadata can be created with:
593 %
594 \begin{center}
595 |\defexercisedata{|\textit{key}|}|
596 \end{center}
597 %
598
599 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
600 \DescribeMacro{\getexercisedata}
601 \DescribeMacro{\exercisedataempty}
602 Global metadata should typically be specified
603 somewhere at the top of the main document,
604 and it can be inserted wherever needed.
605 There are two commands to read and process metadata.
606 To insert the value of metadata field \textit{key} use:
607 %
608 \begin{center}
609 |\getexercisedata{|\textit{key}|}|
610 \end{center}
611 %
612 In some situations the output should depend on whether
613 a metadata has been filled
614 (e.g.\ to fill a default value or to display something else instead).
615 This can be checked with the conditional:
616 %
617 \begin{center}
618 |\exercisedataempty{|\textit{key}|}|%
619 |{|\textit{empty code}|}{|\textit{filled code}|}|
620 \end{center}
621 %
622 The \textit{empty code} is executed if no value
623 or an empty value has been specified;
624 otherwise the \textit{filled code} is executed.
625
626 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
627 \DescribeMacro{sheet}
628 \DescribeMacro{problem}
629 The package offers a similar mechanism to describe and use metadata
630 for sheets and problems:
631 %
632 \begin{center}
633 \begin{tabular}{l}
634 |\begin{sheet}[|\textit{opts}|]|\\
635 |\begin{problem}[|\textit{opts}|]|
636 \end{tabular}
637 \end{center}
638 %
639 The argument \textit{opt}
640 is a comma-separated list which can contain metadata specifications
641 in the form \textit{key}|={|\textit{value}|}|.
642 The standard set of metadata keys for sheets consists of:
643 %
644 \begin{itemize}
645 \item |due|:
646 indication of the due date for the exercise sheet.
647 \item |handout|:
648 indication of the handout date for the exercise sheet.
649 \item |title|:
650 specifies a title for the sheet;
651 when reading value (see below), returns composed title;
652 untitled sheets will be displayed by their number;
653 title will be written to pdf documents.
654 \item |rawtitle| (for reading only):
655 contains the raw title as specified by |title|.
656 \item |author|:
657 author(s) of the sheet;
658 will be written to pdf documents.
659 \item |editor|:
660 editor(s) of the sheet; this field refers to a person
661 who makes adjustments to the sheet
662 whereas |author| refers to the creator of the sheet.
663 \item |editdate|:
664 indication of the date when the sheet was last edited.
665 \end{itemize}
666 %
667 The standard set of metadata keys for problems consists of:
668 %
669 \begin{itemize}
670 \item |title|:
671 specifies a title for the problem;
672 when reading value (see below), returns composed title;
673 untitled problems will be displayed by their number.
674 \item |rawtitle| (for reading only):
675 contains the raw title as specified by |title|.
676 \end{itemize}
677 %
678
679 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
680 \DescribeMacro{\defsheetdata}
681 \DescribeMacro{\setsheetdata}
682 \DescribeMacro{\getsheetdata}
683 \DescribeMacro{\sheetdataempty}
684 \DescribeMacro{\defproblemdata}
685 \DescribeMacro{\setproblemdata}
686 \DescribeMacro{\getproblemdata}
687 \DescribeMacro{\problemdataempty}
688 Metadata for sheets can be used in the same way as the global metadata.
689 The following directives are analogous to |\defexercisedata|,
690 |\exercisedata|, |\getexercisedata| and |\exercisedataempty|:
691 %
692 \begin{center}
693 \begin{tabular}{l}
694 |\defsheetdata{|\textit{key}|}|\\
695 |\setsheetdata{|\textit{data}|}|\\
696 |\getsheetdata{|\textit{key}|}|\\
697 |\sheetdataempty{|\textit{key}|}|%
698 |{|\textit{empty code}|}{|\textit{filled code}|}|\\[1ex]
699 |\defproblemdata{|\textit{key}|}|\\
700 |\setproblemdata{|\textit{data}|}|\\
701 |\getproblemdata{|\textit{key}|}|\\
702 |\problemdataempty{|\textit{key}|}|%
703 |{|\textit{empty code}|}{|\textit{filled code}|}|
704 \end{tabular}
705 \end{center}
706 %
707
708 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
709 \DescribeMacro{pdfdata}
710 \DescribeMacro{\writeexercisedata}
711 The most relevant metadata can be written to
712 the metadata section of pdf files
713 (using pdf\LaTeX{} and the package \ctanpkg{hyperref}
714 whenever loaded).
715 This feature is configured by:
716 %
717 \begin{center}
718 |\exercisesetup{pdfdata|[|=auto|\textbar|manual|%
719 \textbar|sheet|\textbar|off|]|}|
720 \end{center}
721 %
722 The option |auto| writes the global metadata
723 |title|, |author|, |subject| and |keyword|
724 to the corresponding fields in the pdf file.
725 To make this work, these must be defined before the
726 |\begin{document}| directive.
727 The option |manual| allows to manually write these metadata
728 by the command |\writeexercisedata|.
729 It should be issued after the metadata have been set,
730 but before any content is written to the pdf file.
731 In other words, it can be anywhere in the document preamble
732 directly after |\begin{document}|,
733 or following a couple of content-free definitions at the beginning
734 of the document body (in case the metadata should be set
735 within the document body for some reason).
736 The option |sheet| writes out the metadata
737 at the beginning of the first |sheet| environment
738 (which should follow |\begin{document}| without any content in between).
739 This option is primarily for filling the
740 |author| and |title| fields with metadata
741 of a sheet rather than a collection of exercises.
742 Note that if no |author| is defined for the sheet,
743 the global metadata |author| is used.
744 The option |off| disables all writing of metadata.
745
746 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
747 \DescribeMacro{problem}
748 \DescribeMacro{subproblem}
749 \DescribeMacro{solution}
750 There is an additional mechanism to keep track of metadata
751 for problems, subproblems and solutions
752 which can be displayed in the opening line of these entities.
753 Displayed metadata serve two purposes:
754 they are used to describe the quality of a problem
755 or they are intended for internal documentation purposes.
756 Their output can be controlled individually,
757 e.g.\ only in development versions of a document.
758 Note that specifying a key more than once
759 will display the content multiple times
760 in the order in which they are encountered.
761 Displayed metadata are specified
762 at the top of the corresponding environment:
763 %
764 \begin{center}
765 \begin{tabular}{l}
766 |\begin{problem}[|\textit{opts}|]|\\
767 |\begin{subproblem}[|\textit{opts}|]|\\
768 |\begin{solution}[|\textit{opts}|]|
769 \end{tabular}
770 \end{center}
771 %
772
773 The standard set of displayed metadata keys consists of:
774 %
775 \begin{itemize}
776 \item |author|:
777 author(s) of the problem (or subproblem, solution).
778 \item |editor|:
779 editor(s) of the problem; this field refers to a person
780 who has made adjustments to the problem
781 whereas |author| refers to the creator of the problem.
782 \item |source|:
783 source of the problem;
784 in case the problem has been taken from elsewhere
785 (conceptually or literally).
786 \item |difficulty|:
787 indication of the level of difficulty of the problem.
788 \item |keyword|:
789 keyword(s) for the problem;
790 \item |comment|:
791 some comment on the problem.
792 \item |optional|
793 (display enabled by default):
794 whether addressing the problem is mandatory or optional;
795 by default the text will be displayed after the title
796 in italic shape.
797 \end{itemize}
798 %
799 By default, only the |optional| items are displayed,
800 all other types of items are hidden;
801 controlling the display for each type of item is described below.
802
803 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
804 \DescribeMacro{extdata}
805 Further displayed metadata keys
806 are defined by the package option |extdata|, see \secref{sec:options}:
807 %
808 \begin{itemize}
809 \item |review|:
810 field to review the aspects of the problem
811 (quality, length, appropriateness, difficulty, \ldots).
812 \item |recycle|:
813 indication of previous instances where this problem was used.
814 \item |timesolve|:
815 indication of the time needed to solve this problem (or subproblem).
816 \item |timepresent|:
817 indication of the time needed to present this problem
818 (or subproblem, solution).
819 \end{itemize}
820 %
821
822 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
823 \DescribeMacro{\showprobleminfo}
824 The display of the above metadata fields for a problem
825 (or subproblem, solution) is controlled by:
826 %
827 \begin{center}
828 |\showprobleminfo{|\textit{keys}|}|
829 \end{center}
830 %
831 Here \textit{keys} is a comma-separated list of keys to
832 be activated (\textit{key} or \textit{key}|=true|)
833 or deactivated (\textit{key}|=false|).
834
835 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
836 \DescribeMacro{\defprobleminfo}
837 Displayable metadata can be defined or adjusted by:
838 %
839 \begin{center}
840 |\defprobleminfo{|\textit{key}|}{|\textit{code}|}|
841 \end{center}
842 %
843 Here \textit{key} specifies the metadata field and
844 \textit{code} the code to display this type of metadata
845 where the argument |#1| represents the data to be displayed.
846
847 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
848 \DescribeMacro{insertprobleminfo}
849 \DescribeMacro{insertsubprobleminfo}
850 \DescribeMacro{insertsolutioninfo}
851 \DescribeMacro{\addprobleminfo}
852 \DescribeMacro{\addprobleminfo*}
853 Additional information can be injected into the opening line
854 of problems and solutions by the definitions:
855 %
856 \begin{center}
857 \begin{tabular}{l}
858 |\exerciseconfig{insertprobleminfo}{|\textit{code}|}|\\
859 |\exerciseconfig{insertsubprobleminfo}{|\textit{code}|}|\\
860 |\exerciseconfig{insertsolutioninfo}{|\textit{code}|}|
861 \end{tabular}
862 \end{center}
863 %
864 The hook code \textit{code} will be called after processing
865 the environment arguments. Information can be added to the opening line by:
866 %
867 \begin{center}
868 \begin{tabular}{l}
869 |\addprobleminfo{|\textit{info}|}|\\
870 |\addprobleminfo*{|\textit{info}|}|
871 \end{tabular}
872 \end{center}
873 %
874 The unstarred command adds information at the end of the opening line,
875 the starred version at the beginning (but after the title or identifier).
876
877 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
878 \subsection{Points}
879 \label{sec:points}
880
881 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
882 \DescribeMacro{points}
883 Exercise problems or certain parts of them
884 can be credited with points (credits, awards, \ldots).
885 The package provides an interface to specify and manage such points.
886 Points are declared by the option |points=|\textit{points}
887 for the environments |sheet|, |problem| and |subproblem|.
888 These numbers will be printed to the opening line of
889 problems and subproblems.
890
891 Note that the points should normally be integer numbers.
892 Fractional points are permissible as well,
893 but the internal storage by the \TeX{} engine is somewhat limited,
894 so that only fractions with powers of two as denominators
895 (.5, multiples of .25, .125, .0625, \ldots) are reliable.
896 More general fractional decimal numbers such as multiples of 0.2
897 will be subject to rounding errors and will not display nicely.
898
899 Bonus points can be specified in the format
900 |points=|[\textit{regular}][|+|\textit{bonus}].
901 By default, such points will be printed as
902 [\textit{regular}][|+|\textit{bonus}] where 0 components are omitted.
903
904 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
905 \DescribeMacro{problempointsat}
906 \DescribeMacro{subproblempointsat}
907 \DescribeMacro{solutionpointsat}
908 The location where points of problems and subproblems
909 shall be displayed can be adjusted individually by:
910 %
911 \begin{center}
912 \begin{tabular}{l}
913 |\exercisestyle{problempointsat=start|\textbar|start*|\textbar|margin|%
914 \textbar|end|\textbar|manual|\textbar|off}|\\
915 |\exercisestyle{subproblempointsat=start|\textbar|start*|\textbar|margin|%
916 \textbar|end|\textbar|manual|\textbar|off}|\\
917 |\exercisestyle{solutionpointsat=start|\textbar|start*|\textbar|margin|%
918 \textbar|end|\textbar|manual|\textbar|off}|
919 \end{tabular}
920 \end{center}
921 %
922 The default values are |start| and |end| for problems and subproblems,
923 respectively.
924 The option |start| displays points at
925 the very end of the opening line;
926 the option |start*| displays them at the start of it.
927 The option |end| displays points at the end of the
928 problem or subproblem text.
929 The option |margin| displays points in the margin.
930 The option |manual| displays points at a manually chosen location
931 specified by the directive |\showpoints|.
932 Note that |\showpoints| can also be used for the option |end|
933 to display the points prematurely
934 (e.g.\ if the text ends with a displayed equation,
935 it may make sense to display the points just before the equation).
936 The option |off| disables the display of points.
937
938 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
939 \DescribeMacro{\getsheetdata}
940 Points for sheets are only stored by the package;
941 they must displayed manually.
942 Within the corresponding |sheet| environment
943 the points can be accessed by:
944 %
945 \begin{center}
946 |\getsheetdata{points}|
947 \end{center}
948 %
949
950 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
951 \DescribeMacro{\getsheetpoints}
952 \DescribeMacro{\getproblempoints}
953 \DescribeMacro{\getsubproblempoints}
954 \DescribeMacro{\getsolutionpoints}
955 \DescribeMacro{\extractpoints}
956 \DescribeMacro{\switchpoints}
957 The package allows to read the point totals
958 for other sheets and problems:
959 %
960 \begin{center}
961 \begin{tabular}{l}
962 |\getsheetpoints{|[\textit{tag}]|}|\\
963 |\getproblempoints{|[\textit{tag}]|}|\\
964 |\getsubproblempoints{|[\textit{tag}]|}|\\
965 |\getsolutionpoints{}|
966 \end{tabular}
967 \end{center}
968 %
969 Here \textit{tag} is the tag assigned to the corresponding sheet or problem,
970 see \secref{sec:labels}.
971 An empty argument \textit{tag} refers to the current
972 sheet, (sub)problem or solution.
973 If bonus points are used, the points will be returned
974 in the format [\textit{regular}][|+|\textit{bonus}];
975 the components \textit{regular} and \textit{bonus}
976 can be extracted from the returned expression
977 by |\extractpoints| and |\extractpoints*|, respectively.
978 A convenient case switch of the returned value can be performed by:
979 %
980 \begin{center}
981 |\switchpoints{|\textit{reg}|}{|\textit{bonus}|}{|\textit{both}|}{|%
982 \textit{none}|}{|\textit{val}|}|
983 \end{center}
984 %
985 Here \textit{val} is the value returned from the points register,
986 \textit{reg} is displayed for purely regular points,
987 \textit{bonus} is displayed for purely bonus points,
988 \textit{both} is displayed for mixed points,
989 \textit{none} is displayed for no points.
990 In each of the four expressions,
991 |#1| will be replaced by the regular points
992 and |#2| by the bonus points.
993
994 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
995 \DescribeMacro{\awardpoints}
996 Grading instructions with points to be awarded
997 can be specified in the solution text by:
998 %
999 \begin{center}
1000 \begin{tabular}{l}
1001 |\awardpoints[|\textit{details}|]{|\textit{points}|}|\\
1002 |\awardpoints*[|\textit{details}|]{|\textit{points}|}|
1003 \end{tabular}
1004 \end{center}
1005 %
1006 Here \textit{details} is an optional text with further details,
1007 e.g.\ to explain under which conditions
1008 these points are to be awarded.
1009 The starred form is used to specify optional points or alternative paths
1010 with alternative grading instructions.
1011 These points will be marked and not be used for the computation of a total.
1012
1013 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1014 \DescribeMacro{warntext}
1015 The package attempts to add up
1016 the points of subproblems to the problem total
1017 and likewise the points of problems to the sheet total.
1018 The package also performs some sanity checks on the provided numbers:
1019 If points are specified for both subproblems and problems
1020 or for both problems and sheets, they will be compared.
1021 Also the points within solutions (excluding optional or alternative points)
1022 are added up and compared to the corresponding problem or subproblem.
1023 Furthermore the package checks whether points
1024 are defined for all subproblems within a problem
1025 or all problems within a sheet.
1026 Mismatches are reported as package warnings.
1027 As point mismatches can be rather severe,
1028 there is an option to write such warnings directly into
1029 the output document (to be removed before distribution):
1030 %
1031 \begin{center}
1032 |\exercisesetup{warntext|[|=true|\textbar|false|]|}|
1033 \end{center}
1034 %
1035
1036 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1037 \DescribeMacro{fracpoints}
1038 The package offers pretty display of fractional points
1039 with denominators 2, 4 and 8 by writing the decimal part
1040 as a fraction, e.g.\ 1.75 $\to$ 1$^3\mskip-4mu/\mskip-2mu_4$.
1041 This feature is enabled by:
1042 %
1043 \begin{center}
1044 |\exercisestyle{fracpoints}|
1045 \end{center}
1046 %
1047
1048 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1049 \subsection{Labels and Tags}
1050 \label{sec:labels}
1051
1052 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1053 \DescribeMacro{label}
1054 \LaTeX{} provides labels to make references to remote parts of the text.
1055 Labels can be set as usual by |\label{|\textit{label}|}| within the
1056 |problem|, |subproblems| and |sheet| environments.
1057 Alternatively, they can be specified
1058 as the environment option:
1059 %
1060 \begin{center}
1061 |label={|\textit{label}|}|
1062 \end{center}
1063 %
1064
1065 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1066 \DescribeMacro{tag}
1067 \DescribeMacro{\sheettag}
1068 \DescribeMacro{\problemtag}
1069 \DescribeMacro{\subproblemtag}
1070 The package provides an additional mechanism to tag sheets and problems.
1071 Each |sheet|, |problem| and |subproblem|
1072 can be assigned a unique tag \textit{tag} by
1073 the environment option:
1074 %
1075 \begin{center}
1076 |tag={|\textit{tag}|}|
1077 \end{center}
1078 %
1079 This tag is used for reading point totals
1080 as described in \secref{sec:points}.
1081 Furthermore, the macro |\sheettag|, |\problemtag| or |\subproblemtag|
1082 is set to the tag \textit{tag} within the current environment.
1083 If no tag is specified it defaults to the number
1084 of the current sheet or (sub)problem;
1085 note that this number can change by reordering sheets and problems
1086 and therefore it should not be used to identify the entity from
1087 other parts of the document.
1088
1089 A useful application for tags is to encapsulate labels
1090 within individual sheets and problems
1091 which are part of a collection of exercises.
1092 Labels which are composed as
1093 |\sheettag-|\textit{label} or
1094 |\problemtag-|\textit{label}
1095 can be considered local and will not clash with labels
1096 defined within a different environment.
1097 Within the same sheet or problem, local labels can be accessed
1098 by the same construction.
1099 They can also be accessed from remote parts of the document by fully
1100 expanding |\sheettag| or |\problemtag| for the desired target environment.
1101
1102 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1103 \DescribeMacro{autolabelsheet}
1104 \DescribeMacro{autolabelproblem}
1105 If unique tags are specified, the package can automatically create labels
1106 for sheets (|sheet:|\textit{tag}) and problems (|prob:|\textit{tag}) by:
1107 %
1108 \begin{center}
1109 \begin{tabular}{l}
1110 |\exercisesetup{autolabelsheet|[|=true|\textbar|false|]|}|\\
1111 |\exercisesetup{autolabelproblem|[|=true|\textbar|false|]|}|
1112 \end{tabular}
1113 \end{center}
1114 %
1115
1116 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1117 \DescribeMacro{\getsheetlist}
1118 \DescribeMacro{\getproblemlist}
1119 \DescribeMacro{\getsubproblemlist}
1120 Tags can also be used to process a list of sheets, problems and subproblems:
1121 %
1122 \begin{center}
1123 \begin{tabular}{l}
1124 |\getsheetlist{}|\\
1125 |\getproblemlist{|[\textit{sheet-tag}]\textbar|*}|\\
1126 |\getsubproblemlist{|[\textit{problem-tag}]|}|\\
1127 \end{tabular}
1128 \end{center}
1129 %
1130 These commands return a list of sheets, problems and subproblems tags,
1131 where each item is encapsulated in braces.
1132 The commands |\get|[|sub|]|problemlist| return the (sub)problems
1133 within the specified sheet or problem. If no argument is given,
1134 the current sheet or problem is assumed.
1135 |\getproblemlist*| returns the list of all problems.
1136
1137 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1138 \DescribeMacro{\exerciseloop}
1139 \DescribeMacro{\exerciseloopstr}
1140 \DescribeMacro{\exerciseloopret}
1141 \DescribeMacro{exerciseloop}
1142 The package defines two commands to walk through such a list:
1143 %
1144 \begin{center}
1145 \begin{tabular}{l}
1146 |\exerciseloop{|\textit{items}|}{|\textit{cmd}|}|\\
1147 |\exerciseloopstr[|\textit{ret}|]{|\textit{items}|}{|\textit{str}|}|
1148 \end{tabular}
1149 \end{center}
1150 %
1151 Here, \textit{items} is a list of items in braces,
1152 and |\exerciseloop| evaluates \textit{cmd}
1153 for each item of the list where `|#1|' is replaced by the item.
1154 The command |\exerciseloopstr| concatenates
1155 the evaluations of \textit{str}
1156 and returns the resulting string in the macro \textit{ret}
1157 (which defaults to |\exerciseloopret|).
1158 Both commands maintain a counter of items |exerciseloop|
1159 which can be accessed within \textit{cmd}/\textit{str} or
1160 after |\exerciseloop|[|str|] to obtain the total number of items
1161 in the list.
1162
1163 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1164 \subsection{Layout}
1165 \label{sec:layout}
1166
1167 The package provides a large number of parameters to adjust the
1168 display of exercises to a desired layout.
1169
1170 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1171 \DescribeMacro{\exerciseconfig}
1172 Configuration settings are declared and modified by the command:
1173 %
1174 \begin{center}
1175 |\exerciseconfig{|\textit{key}|}[|\textit{narg}|]{|\textit{value}|}|
1176 \end{center}
1177 %
1178 Here \textit{key} is a key and \textit{value} is its assigned value.
1179 Configuration options can also be macros with arguments in which case
1180 \textit{narg} is the number of arguments and \textit{value}
1181 is the macro definition using arguments |#|\textit{n}.
1182 The command |\exerciseconfig| therefore is analogous to
1183 |\|(|re|)|newcommand| except that the definitions are
1184 encapsulated by the package and any previous definition
1185 is overwritten without checking.
1186
1187 \DescribeMacro{\exerciseconfigappend}
1188 \DescribeMacro{\exerciseconfigprepend}
1189 In some cases it may be useful to be able to
1190 append or prepend to a (parameterless) definition by:
1191 %
1192 \begin{center}
1193 \begin{tabular}{l}
1194 |\exerciseconfigappend{|\textit{key}|}{|\textit{value}|}|\\
1195 |\exerciseconfigprepend{|\textit{key}|}{|\textit{value}|}|
1196 \end{tabular}
1197 \end{center}
1198
1199 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1200 \DescribeMacro{\getexerciseconfig}
1201 \DescribeMacro{\exerciseconfigempty}
1202 Configuration definitions can be read by:
1203 %
1204 \begin{center}
1205 |\getexerciseconfig{|\textit{key}|}|[\textit{arguments}]
1206 \end{center}
1207 %
1208 The number of arguments after |{|\textit{key}|}|
1209 must match the optional argument \textit{nargs} of the definition.
1210 Furthermore, it can be checked whether a configuration definition
1211 is empty:
1212 %
1213 \begin{center}
1214 |\exerciseconfigempty{|\textit{key}|}|%
1215 |{|\textit{empty code}|}{|\textit{filled code}|}|
1216 \end{center}
1217 %
1218 The \textit{empty code} is executed if no value
1219 or an empty value has been specified.
1220 Otherwise the \textit{filled code} is executed.
1221
1222 The package defines numerous layout configuration options.
1223 They are listed along with their original definition
1224 and a brief description
1225 in the configuration section of the source code documentation.
1226 %in \secref{sec:imp-config}.
1227 Some particular aspects are described in more detail
1228 in \secref{sec:guides}.
1229 The configuration includes options to:
1230 %
1231 \begin{itemize}
1232 \item
1233 adjust the language for the principal entities of this package
1234 like ``sheet(s)'', ``problem(s)'', ``solution(s)'', ``points(s)'';
1235 \item
1236 adjust the fonts styles of various parts of the text;
1237 \item
1238 adjust the spacing above, below, between various elements;
1239 \item
1240 define code to process data and insert text at various locations;
1241 \item
1242 compose text to be used in various situations;
1243 \item
1244 adjust the appearance of counters;
1245 \item
1246 adjust some other behaviour of the package.
1247 \end{itemize}
1248 %
1249 We will highlight a few examples in \secref{sec:examples}.
1250
1251 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1252 \subsection{Exercise Styles}
1253 \label{sec:styles}
1254
1255 The package provides a mechanism to define exercise styles
1256 which customise the display of exercises in some coordinated fashion.
1257
1258 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1259 \DescribeMacro{\exercisestyle}
1260 Style(s) are activated by the command:
1261 %
1262 \begin{center}
1263 |\exercisestyle{|\textit{styles}|}|
1264 \end{center}
1265 %
1266 Here \textit{styles} is a comma-separated list of styles,
1267 where each style is given by a pair \textit{style}[|={|\textit{argument}|}|].
1268 The package defines a couple of standard styles:
1269 %
1270 \begin{itemize}
1271 \item |solutionbelow=|\textit{pos}
1272 (can take values |here|, |subproblem|, |subproblem*|,
1273 |problem|, |problem*|, |sheet| and |manual|;
1274 initially set to |subproblem|) --
1275 positions the solutions below the indicated environments;
1276 see \secref{sec:solutions} for details.
1277
1278 \item |problempointsat=|\textit{pos}
1279 (can take values |start|, |start*|, |margin|, |end| and |manual|;
1280 initially set to |start|) --
1281 displays points in problems at the indicated location;
1282 see \secref{sec:points} for details.
1283
1284 \item |subproblempointsat=|\textit{pos}
1285 (can take values |start|, |start*|, |margin|, |end| and |manual|;
1286 initially set to |end|) --
1287 displays points in subproblems at the indicated location;
1288 see \secref{sec:points} for details.
1289
1290 \item |solutionpointsat=|\textit{pos}
1291 (can take values |start|, |start*|, |margin|, |end| and |manual|;
1292 initially set to |end|) --
1293 displays points in solutions at the indicated location;
1294 see \secref{sec:points} for details.
1295
1296 \item |problemby={|\textit{counter}|}| --
1297 number problems with the prefix \textit{counter},
1298 i.e.\ reset the problem counter whenever \textit{counter} increases
1299 and use a composite label \textit{counter}|.|\textit{problem}
1300 to identify problems.
1301
1302 \item |equationby={|\textit{counter}|}| --
1303 number the dedicated equation counters for sheets, problems and solutions
1304 with the prefix \textit{counter}.
1305
1306 \item |problembysheet| --
1307 number problems by sheet.
1308
1309 \item |equationbysheet| --
1310 number dedicated equations for sheets, problems and solutions by sheet;
1311 note that the main equation counter is unaffected by this setting,
1312 it therefore makes sense to also activate the style |sheetequation|
1313 or use |\counterwithin{equation}{sheet}|.
1314
1315 \item |pagebysheet| --
1316 number pages by sheet and denote pages by \textit{sheet}|.|\textit{page};
1317 this style is useful to generate stable page numbers for
1318 a collection of sheets.
1319
1320 \item |sheetequation|[|=true|\textbar|false|]
1321 (no value implies |true|, initially set to |false|) --
1322 use a dedicated equation counter within sheets.
1323
1324 \item |problemequation|[|=true|\textbar|false|]
1325 (no value implies |true|, initially set to |false|) --
1326 use a dedicated equation counter within problems.
1327
1328 \item |solutionequation|[|=true|\textbar|false|]
1329 (no value implies |true|, initially set to |true|) --
1330 use a dedicated equation counter within solutions.
1331
1332 \item |fracpoints|[|=true|\textbar|false|]
1333 (no value implies |true|, initially set to |false|) --
1334 display fractional points for denominators 2, 4, 8;
1335 see \secref{sec:points} for details.
1336
1337 \item |twoside|[|=true|\textbar|false|]
1338 (no value implies |true|, initially set to |false|) --
1339 enable/disable two-sided layout;
1340 in two-sided layout, sheets will start on odd pages
1341 and empty pages are added at the end of sheets
1342 to produce an even number of pages.
1343
1344 \item |subproblemdelimitem| --
1345 shift subproblem number delimiter `)' from subproblem label
1346 to subproblem item composition;
1347 needed if |\ref| to a subproblem |\label| should produce a bare identifier
1348 without a trailing `)';
1349 assumes (and restores) numbering |\alph| and delimiter `)'.
1350
1351 \end{itemize}
1352
1353 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1354 \DescribeMacro{extstyle}
1355 Further exercise styles
1356 are defined by the package option |extstyle|, see \secref{sec:options}:
1357 %
1358 \begin{itemize}
1359 \item |plainheader| --
1360 define a plain sheet header to display
1361 some essential exercise and sheet data:
1362 |course|, |institution|, |instructor|, |period| (optional), sheet |title|,
1363 see \secref{sec:metadata};
1364 the line below the header, font styles and spaces can be adjusted,
1365 see the definition
1366 in the styles section of the source code documentation.
1367 %in \secref{sec:imp-styles}.
1368
1369 \item |contents| --
1370 display sheets and problems in the table of contents
1371 (as sections and subsections).
1372
1373 \item |solutionsf| --
1374 display solutions in sans serif font family.
1375
1376 \item |solutiondimproblem| --
1377 dim the problem text whenever solutions are displayed.
1378
1379 \item |solutionsep| --
1380 separate the solutions from the remaining text by horizontal lines.
1381
1382 \end{itemize}
1383
1384 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1385 \DescribeMacro{\defexercisestyle}
1386 Custom styles can be defined by:
1387 %
1388 \begin{center}
1389 \begin{tabular}{l}
1390 |\defexercisestyle{|\textit{style}|}{|\textit{init}|}|\\
1391 |\defexercisestylearg[|\textit{default}|]{|\textit{style}|}{|\textit{init}|}|
1392 \end{tabular}
1393 \end{center}
1394 %
1395 This feature can be used to predefine certain aspects of
1396 the exercises layout.
1397 For example, different default page layouts could be declared in this way.
1398 The first version declares a style which is
1399 initialised by the code \textit{item} upon activation by
1400 |\exercisestyle{|\textit{style}[|=true|]|}|.
1401 Note that |\exercisestyle{|\textit{style}|=false}| does nothing.
1402 The second version declares a style which is activated by
1403 |\exercisestyle{|\textit{style}[|={|\textit{arg}|}|]|}|
1404 and which calls \textit{item} with the argument |#1| referring to \textit{arg}
1405 (or \textit{default} if no argument is given).
1406
1407 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1408 \subsection{Package Options}
1409 \label{sec:options}
1410
1411 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1412 \DescribeMacro{\exercisesetup}
1413 Features and options of general nature can be selected by the commands:
1414 %
1415 \begin{center}
1416 \begin{tabular}{rl}
1417 &|\usepackage[|\textit{opts}|]{exframe}|
1418 \\
1419 or&|\PassOptionsToPackage{|\textit{opts}|}{exframe}|
1420 \\
1421 or&|\exercisesetup{|\textit{opts}|}|
1422 \end{tabular}
1423 \end{center}
1424 %
1425 |\PassOptionsToPackage| must be used before |\usepackage|;
1426 |\exercisesetup| must be used afterwards.
1427 \textit{opts} is a comma-separated list of options.
1428
1429 The following options are available only when
1430 loading the package, i.e.\ they will not work
1431 within |\exercisesetup|:
1432 %
1433 \begin{itemize}
1434 \item |extdata|[|=true|\textbar|false|]
1435 (no value implies |true|, initially set to |false|) --
1436 define some more advanced metadata entries.
1437
1438 \item |extstyle|[|=true|\textbar|false|]
1439 (no value implies |true|, initially set to |false|) --
1440 define some more advanced styles.
1441
1442 \item |metastr|[|=true|\textbar|false|]
1443 (no value implies |true|, initially set to |false|) --
1444 load \ctanpkg{metastr} package and use to handle pdf metadata
1445 and basic internationalisation,
1446 see the metastr interaction section of the source code documentation
1447 %see \secref{sec:imp-metastr}
1448 for details.
1449
1450 \item |problemenv=|\textit{name} --
1451 redefine environment name |problem|.
1452 This and the following alike options may be useful in
1453 quickly adjusting existing sources to
1454 the \ctanpkg{exframe} framework
1455 if the original framework works similarly
1456 and no special features are used.
1457 Otherwise, it is highly advisable to leave the
1458 names of environments and counters
1459 defined by the package untouched.
1460
1461 \item |subproblemenv=|\textit{name} --
1462 redefine environment name |subproblem|.
1463
1464 \item |solutionenv=|\textit{name} --
1465 redefine environment name |solution|.
1466
1467 \item |sheetenv=|\textit{name} --
1468 redefine environment name |sheet|.
1469
1470 \item |problemcounter=|\textit{name} --
1471 redefine counter name |problem|.
1472
1473 \item |subproblemcounter=|\textit{name} --
1474 redefine counter name |subproblem|.
1475
1476 \item |solutioncounter=|\textit{name} --
1477 redefine counter name |solution|.
1478
1479 \item |sheetcounter=|\textit{name} --
1480 redefine counter name |sheet|.
1481
1482 \end{itemize}
1483 %
1484
1485 The following options can be specified by all three methods described above:
1486 %
1487 \begin{itemize}
1488 \item |solutions|[|=true|\textbar|false|]
1489 (no value implies |true|, initially set to |false|) --
1490 Enable/disable display of solutions.
1491 Sets the conditional |\ifsolutions| accordingly.
1492
1493 \item |pdfdata|[|=auto|\textbar|manual|\textbar|sheet|\textbar|off|]
1494 (no value implies |auto|, initially set to |auto|) --
1495 control writing most relevant metadata to pdf files;
1496 has no effect without package \ctanpkg{hyperref}.
1497
1498 \item |lineno|[|=true|\textbar|false|]
1499 (no value implies |true|, initially set to |false|) --
1500 enable/disable writing of line numbers as comments
1501 into solution files.
1502
1503 \item |twoside|[|=true|\textbar|false|]
1504 (no value implies |true|, initially set to |false|) --
1505 enable/disable two-sided layout;
1506 see \secref{sec:styles} for details.
1507
1508 \item |solutionhref|[|=true|\textbar|true|]
1509 (no value implies |true|, initially set to |false|) --
1510 enable/disable use of hyper-references from solutions
1511 to the corresponding problems;
1512 has no effect without package \ctanpkg{hyperref}.
1513
1514 \item |warntext|[|=true|\textbar|false|]
1515 (no value implies |true|, initially set to |false|) --
1516 enable/disable writing of relevant warning messages
1517 (points mismatch, point sums require update)
1518 into the document output for easier detection.
1519
1520 \item |autolabelsheet|[|=true|\textbar|false|]
1521 (no value implies |true|, initially set to |false|) --
1522 enable/disable automatically assigning labels
1523 (|sheet:\sheettag|; can be adjusted)
1524 to sheets according to their tag |\sheettag|.
1525
1526 \item |autolabelproblem|[|=true|\textbar|false|]
1527 (no value implies |true|, initially set to |false|) --
1528 enable/disable automatically assigning labels
1529 (|prob:\problemtag|; can be adjusted)
1530 to problems according to their tag |\problemtag|.
1531
1532 \item |solutionbuf|[|=true|\textbar|false|]
1533 (no value implies |true|, initially set to |true|) --
1534 enable/disable buffering for |solution| environments
1535 in order to control their display;
1536 disabling buffering can be helpful
1537 in debugging faulty |solution| environments;
1538 it might also resolve some tokenisation issues in special circumstances;
1539 note that the display of solutions cannot be suppressed
1540 with |\exercisesetup{solutions=false}| when buffering if disabled.
1541
1542 \item |problembuf|[|=true|\textbar|false|]
1543 (no value implies |true|, initially set to |false|) --
1544 enable/disable buffering for |problem| environments
1545 in order to control their display.
1546
1547 \item |subproblembuf|[|=true|\textbar|false|]
1548 (no value implies |true|, initially set to |false|) --
1549 enable/disable buffering for |subproblem| environments
1550 in order to control their display.
1551
1552 \item |emptytestchar=|\textit{char}
1553 (initially set to `|&|') --
1554 character to use for testing whether an argument |#1|
1555 is empty via |\if&#1&...\fi|;
1556 if `|&|' causes trouble within tables, could try `|@|' instead.
1557
1558 \end{itemize}
1559
1560 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1561 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1562 \section{Customisations}
1563 \label{sec:customisation}
1564
1565 This section attempts to shed some light on the rich array of options
1566 for layout customisations.
1567 It is not at all complete, but it provides an overview and
1568 illustrates selected aspects by means of guidance and examples.
1569
1570 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1571 \subsection{Guidance}
1572 \label{sec:guides}
1573
1574 The following provides some guidance on customisation options
1575 which might otherwise be hard to follow.
1576 Suggestions for topics to be expanded are welcome.
1577
1578 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1579 \paragraph{Package Philosophy.}
1580
1581 The philosophy of the present package is to
1582 define a low-level framework to describe exercises with solutions
1583 to be used in various situations.
1584 The aim is to provide the means to describe the content
1585 (problems, solutions, sheets) in a simple fashion
1586 and separate it from the various layout definitions and choices
1587 which will define the appearance of the content.
1588 The package itself provides a functional basic layout
1589 rather than an elaborate or particularly appealing one.
1590 However, it provides means to adjust the basic layout in many ways and
1591 to predefine custom layout schemes.
1592 The package is meant to collaborate with other packages
1593 which provide solutions for particular applications
1594 in order to produce an appealing layout for the given content.
1595
1596 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1597 \paragraph{Framework for Layout Customisation.}
1598
1599 The framework for defining the layout
1600 consists of an internal and a public component
1601 which allow for minor adjustments and major changes
1602 both with reasonable efforts.
1603
1604 The internal component implements some very coarse
1605 choices for the presentation of the content.
1606 It is hard-coded in the package
1607 (using internal macros starting with |exf@|)
1608 and its operation can be adjusted mainly through the available package options,
1609 see \secref{sec:options}, and through configuration switches
1610 for individual blocks.
1611
1612 The public framework uses a hierarchy of configuration macros
1613 defined by |\exerciseconfig|, see \secref{sec:layout}.
1614 The internal component interfaces with the public framework
1615 through a set of higher-level interface macros.
1616 These include macros which produce the desired text in a
1617 well-prescribed situation
1618 as well as macros which perform some \LaTeX\ operations
1619 such as adjusting presentation styles or modifying some variables.
1620 In many cases the structural higher-level macros have been set up to
1621 branch out to further lower-level macros prescribing presentation details.
1622
1623 The hierarchy has the following structure:
1624 High-level macros compose certain abstract elements
1625 into readable text, e.g.\ an intro/outro for some block of text
1626 made from space, decorations and abstract text elements.
1627 Medium-level macros compose elementary objects into abstract text elements,
1628 e.g.\ a header for some block of text
1629 composed from a label and a title with some space and delimiters in between.
1630 Low-level macros define elementary objects,
1631 such as delimiter characters, spaces, widths and words (translations).
1632
1633 The public framework has been set up such that
1634 elements at high, medium and low levels can be adjusted independently
1635 to arrive at a specific effect.
1636 For example, the composition of problem titles can be adjusted abstractly,
1637 but also the representation of a specific delimiter
1638 can be tweaked from `.' to `:';
1639 either change can be obtained by adjusting a single definition.
1640 This flexibility comes along with an unfortunate complexity
1641 to allow for adjustments to be implemented individually but also universally.
1642 Nevertheless, the implementation of the public configuration macros
1643 for a particular setup can be rather simple because the particular setup
1644 will neither use all of the available coarse layout choices
1645 nor all of the customisation options.
1646 For example, a higher-level macro for a problem title
1647 may directly produce the desired text without branching into
1648 further lower-level definitions.
1649 Also, only those higher-level macros which actually come to use
1650 in a particular setup will need to be implemented.
1651
1652 The following paragraphs provide guidance on aspects of the
1653 public framework. There is no complete manual for the framework,
1654 but a skilled \LaTeX\ tinkerer can find further information
1655 and pieces of code ready for tweaking in the implementation notes
1656 the configuration and styles sections of the source code documentation.
1657 %in \secref{sec:imp-config} and \secref{sec:imp-styles}.
1658
1659 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1660 \paragraph{Labels for Problems and Sheets.}
1661
1662 The package provides many methods with various names
1663 to customise labels for problem and solution blocks.
1664 These names follow certain patterns
1665 (but are sometimes stuck with odd assignments due to backward compatibility).
1666 The following guide describes which methods come to use
1667 in which situations.
1668
1669 The labels can be grouped into two categories,
1670 items and titles, and the corresponding methods are
1671 typically called |...item...| and |...title...|.
1672 Items are enumerative identifiers for the [sub]problems
1673 such as `1.', `b)' or `3iv)'.
1674 Titles serve as headers for [sub]problem or solution blocks
1675 which usually take the form ``Problem 1'', ``2.\ Fermat's Last''
1676 or simply ``c)'' for a subproblem.
1677 Titles may use the corresponding item, and display it together with
1678 the type, name or using a different punctuation
1679 depending on the situation.
1680
1681 \DescribeMacro{composetitleproblem}
1682 \DescribeMacro{composenamedproblem}
1683 \DescribeMacro{composebareproblem}
1684 The composition of problem titles through |composetitleproblem|
1685 depends mainly on whether an individual name is provided
1686 (|title| option to |problem| environment).
1687 The method passes on to |composenamedproblem| if a name is provided
1688 (second argument non-empty), otherwise to |composebareproblem|.
1689 It might also produce a plain name if no item is provided
1690 (first argument empty).
1691
1692 \DescribeMacro{composenamedproblemdelim}
1693 \DescribeMacro{composenamedproblemsep}
1694 \DescribeMacro{composebareproblemdelim}
1695 \DescribeMacro{composebareproblemsep}
1696 \DescribeMacro{composeitemproblemdelim}
1697 \DescribeMacro{composeitemproblemsep}
1698 Titles and items are separated by some space (|...sep|)
1699 and/or delimiting characters (|...delim|).
1700 The item within a named title is separated from the following name by
1701 |composenamedproblemdelim| and |composenamedproblemsep|.
1702 In an unnamed title, the type is separated from the following item by
1703 |composebareproblemsep|, and the item is followed by |composebareproblemdelim|.
1704 A plain item not used within a title is delimited by |composeitemproblemdelim|.
1705 The presentation of all titles and items
1706 is followed by |composeitemproblemsep|.
1707
1708 \DescribeMacro{composetocproblem}
1709 Problem titles can also be made to appear in the table of contents,
1710 their display is governed by |composetocproblem|
1711 which distinguishes between named and unnamed problems.
1712 The method uses the above delimiter |composenamedproblemdelim|
1713 but no other customisations because detailed layout
1714 will be less welcome in the table of contents.
1715
1716 \DescribeMacro{composetitlesheet}
1717 \DescribeMacro{composetocsheet}
1718 \DescribeMacro{composemetasheet}
1719 Sheet titles generated by |composetitlesheet| are similar
1720 to problem titles but simpler.
1721 They may or may not have a name, but there are no pre-defined delimiters.
1722 The two similar methods |composetocsheet| and |composemetasheet|
1723 govern the display of sheet titles in the table of contents
1724 and in pdf metadata, respectively.
1725
1726 \DescribeMacro{composeitemsubproblem}
1727 \DescribeMacro{composetitlesubproblem}
1728 \DescribeMacro{composeitemsubproblemdelim}
1729 \DescribeMacro{composeitemsubproblemsep}
1730 \DescribeMacro{countersubproblem}
1731 \DescribeMacro{subproblemdelimitem}
1732 Subproblem items and titles are simple as well because
1733 subproblems have no names.
1734 They are generated by |composeitemsubproblem| and |composetitlesubproblem|,
1735 respectively. The subproblem delimiter and separator
1736 are determined by |composeitemsubproblemdelim|
1737 and |composeitemsubproblemsep|, respectively.
1738 Note that the delimiter `)' within `b)' may be declared as either
1739 |composeitemsubproblemdelim| or as part of the subproblem counter
1740 defined in |countersubproblem|.
1741 This behaviour is governed by the style |subproblemdelimitem|.
1742
1743 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1744 \paragraph{Labels for Solutions.}
1745
1746 The display of appropriate solution items and titles is very complex
1747 as it depends on four factors:
1748 (i) The first factor is whether solutions are displayed as an itemised list
1749 or as a plain list.
1750 (ii) The second factor is whether solutions are
1751 displayed individually, grouped by problem
1752 or assembled as a list for multiple problems.
1753 (iii) The third factor is whether the solution corresponds
1754 to a problem or subproblem.
1755 (iv) A fourth factor is whether a solution is the first one within a problem.
1756 In addition, the list of solutions may have a title (v) and sections (vi).
1757 Let us discuss the relevant combinations.
1758
1759 \DescribeMacro{composetitlesolutions}
1760 \DescribeMacro{...solutionsproblemsingle}
1761 \DescribeMacro{...solutionsproblemmulti}
1762 The solution list title (``Solutions'') (v)
1763 generated by |composetitlesolutions| only applies to
1764 lists of (potentially) multiple problems (ii).
1765 The solution section title (vi) generated by |composetitlesolutionsproblem...|
1766 indicates the corresponding problem.
1767 It comes in two variants |...single| and |...multi|
1768 which distinguish a single problem (``Solution'')
1769 from a list of (potentially) multiple problems (``Problem 2'') (ii).
1770
1771 \DescribeMacro{skipsolutionitem}
1772 \DescribeMacro{skipsolutionitemsub}
1773 \DescribeMacro{composeitemsolution}
1774 \DescribeMacro{composeitemsolutionsub}
1775 \DescribeMacro{composeitemsolutionfirst}
1776 \DescribeMacro{...itemsolutionfirstsub}
1777 An itemised list of solutions (i) is invoked by a non-zero
1778 width |skipsolutionitem|[|sub|] (iii) for horizontal alignment
1779 of the solution text. In this case, solution items are displayed
1780 to the left of the line of horizontal alignment.
1781 These are generated by the configuration |composeitemsolution|[|sub|] (iii)
1782 irrespectively of the display mode (ii).
1783 By default, the current problem item is displayed as a section title (vi),
1784 therefore the solution items will only display
1785 the corresponding subproblem item
1786 leaving blank the solution items for problems.
1787 However, in an adjusted scheme without section titles (vi),
1788 the very first solution within a problem (iv)
1789 might additionally indicate the corresponding problem item
1790 |composeitemsolutionfirst|[|sub|] (iii).
1791
1792 \DescribeMacro{composetitlesolutionsingle}
1793 \DescribeMacro{composeitemsolutiondelim}
1794 An individual solution (ii) formally part of a plain list (i)
1795 starts with the title ``Solution:''
1796 which is generated by the method |composetitlesolutionsingle|.
1797 The delimiter `:' is defined by |composeitemsolutiondelim|.
1798
1799 \DescribeMacro{composetitlesolutionmulti}
1800 \DescribeMacro{...titlesolutionproblem}
1801 \DescribeMacro{...titlesolutionsubproblem}
1802 The title for a grouped solution (ii) within a plain list (i)
1803 is generated by the method |composetitlesolutionmulti|
1804 which forwards to |composetitlesolution|[|sub|]|problem| (iii).
1805 Again, by default, these methods only display the subproblem item
1806 because the problem item is provided as a section title (vi) instead.
1807
1808 \DescribeMacro{composetocsolution}
1809 \DescribeMacro{composetocsolutions}
1810 Items for the table of contents corresponding to
1811 solution lists and problem solutions
1812 are generated by |composetocsolution|[|s|].
1813
1814 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1815 \subsection{Examples}
1816 \label{sec:examples}
1817
1818 This section contains some sample customisations of the default (plain) layout
1819 which can be realised with moderate effort
1820 using the various tools provided by the package.
1821 Additional applications are shown in the sample files
1822 \verbpkg|-samp.tex| and \verbpkg|-ser.tex|.
1823 Suggestions for further applications are welcome.
1824
1825 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1826 \paragraph{Sheet Title.}
1827
1828 \DescribeMacro{insertsheettitle}
1829 An important setting is:
1830 %
1831 \begin{center}
1832 |\exerciseconfig{insertsheettitle}{|\textit{code}|}|
1833 \end{center}
1834 %
1835 The code \textit{code} is meant to print the title
1836 or header of an exercise sheet.
1837 The minimalistic default code |\centerline{\getsheetdata{title}}|
1838 merely prints the sheet title ``Sheet \#'' at the centre of a line.
1839 Commonly, one would replace this by a more elaborate header
1840 (potentially with some more information,
1841 appealing layout, logos, \ldots).
1842 In order to design a header template,
1843 it makes sense to retrieve data
1844 via |\getexercisedata| and |\getsheetdata|
1845 described in \secref{sec:metadata}.
1846 Likewise |\exercisedataempty| and |\sheetdataempty|
1847 can be used to display default values or alternative data
1848 if some particular data is not provided.
1849 An example is given by the |plainheader| extended style option defined
1850 in the styles section of the source code documentation.
1851 %in \secref{sec:imp-styles}.
1852
1853 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1854 \paragraph{Problem Title.}
1855
1856 \DescribeMacro{composetitleproblem}
1857 \DescribeMacro{composenamedproblem}
1858 \DescribeMacro{composebareproblem}
1859 Another noteworthy example is |composetitleproblem|
1860 to compose the title for a problem. It takes two parameters,
1861 the number and the title.
1862 The (somewhat simplified) default declarations are:
1863 %
1864 \begin{center}
1865 \begin{tabular}{l}
1866 |\exerciseconfig{composetitleproblem}[2]{\exerciseifempty{#2}|\\
1867 | {\getexerciseconfig{composebareproblem}{#1}}|\\
1868 | {\getexerciseconfig{composenamedproblem}{#1}{#2}}}|\\
1869 |\exerciseconfig{composebareproblem}[1]{\getexerciseconfig{termproblem}|\\
1870 | #1\getexerciseconfig{composebareproblemdelim}}|\\
1871 |\exerciseconfig{composenamedproblem}[2]|\\
1872 | {#1\getexerciseconfig{composenamedproblemdelim} #2}|
1873 \end{tabular}
1874 \end{center}
1875 %
1876 This checks whether the title is empty.
1877 If no title is given use the configuration |composebareproblem|
1878 to compose ``Problem \#'',
1879 where the term ``Problem'' is made abstract
1880 by the configuration |termproblem|
1881 (e.g.\ to support internationalisation).
1882 If a title is given use the configuration |composenamedproblem|
1883 to compose ``\#. \textit{title}''.
1884
1885 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1886 \paragraph{Conditionals.}
1887
1888 \DescribeMacro{\exerciseifempty}
1889 \DescribeMacro{\exerciseifnotempty}
1890 Handy conditional commands to check
1891 whether an expression \textit{expr} is empty are:
1892 %
1893 \begin{center}
1894 \begin{tabular}{l}
1895 |\exerciseifempty{|\textit{expr}|}|%
1896 |{|\textit{empty code}|}{|\textit{filled code}|}|\\
1897 |\exerciseifnotempty{|\textit{expr}|}|%
1898 |{|\textit{filled code}|}|
1899 \end{tabular}
1900 \end{center}
1901 %
1902 Their main purpose is to test
1903 whether some provided expression \textit{expt} is empty.
1904 They expand to the common \TeX{} constructs
1905 |\if&#1&#2\else#3\fi| and |\if&#1&\else#2\fi|
1906 which work assuming that \textit{expr} is not too exotic
1907 (e.g.\ it should not start with the character `|&|'
1908 and other special \TeX{} characters or macros are potentially dangerous;
1909 also using this within tables can be troublesome;
1910 the character `|&|' can be reconfigured by the package option |emptytestchar|).
1911
1912 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1913 \paragraph{Decorate Solutions with Boxes.}
1914
1915 \DescribeMacro{insertsolutionsbefore}
1916 \DescribeMacro{insertsolutionsafter}
1917 \DescribeMacro{composetitlesolution...}
1918 The following adjustment changes the
1919 presentation of solutions to be surrounded by boxes with background colour
1920 (thanks to Till Bargheer for the example).
1921 This yields an alternative presentation
1922 that visually distinguishes problem from solution content.
1923
1924 The adjustment uses the package \ctanpkg{tcolorbox}
1925 to supply such boxes. The coloured box environment |tcolorbox| is invoked
1926 by the customisations |insertsolutionsbefore| and |...after|
1927 which are called just before and after a block of solutions is:
1928 %
1929 \begin{center}
1930 \begin{tabular}{l}
1931 |\RequirePackage{tcolorbox}|\\
1932 |\tcbuselibrary{breakable}|\\
1933 |\exerciseconfig{insertsolutionsbefore}{%|\\
1934 | \begin{tcolorbox}[breakable,boxrule=0.25pt]}|\\
1935 |\exerciseconfig{insertsolutionsafter}{\end{tcolorbox}}|\\
1936 |\exerciseconfig{composetitlesolutionsingle}[2]{}|
1937 \end{tabular}
1938 \end{center}
1939 %
1940 With the highlighting of solutions by boxes,
1941 the default introductory statement ``Solution:''
1942 (when |solutionbelow| is |here| or |subproblem|)
1943 of a solution block becomes obsolete.
1944 This is achieved by removing the content of |composetitlesolutionsingle|
1945 (or similar composition definitions if |solutionbelow| is set otherwise).
1946
1947 \DescribeMacro{solutionpointsat}
1948 \DescribeMacro{insertpointsmargin}
1949 Note that displaying points in the margin would have to be adjusted
1950 because the plain \LaTeX\ command |\marginpar| does not work
1951 inside a |tcolorbox| (due to nested floats).
1952 If this combination is desired,
1953 one should adjust the placement of margin paragraphs
1954 to the package \ctanpkg{marginnote}:
1955 %
1956 \begin{center}
1957 \begin{tabular}{l}
1958 |\exercisestyle{solutionpointsat=margin}|\\
1959 |\RequirePackage{marginnote}|\\
1960 |\exerciseconfig{insertpointsmargin}[1]{\marginnote{\footnotesize#1}}|
1961 \end{tabular}
1962 \end{center}
1963
1964 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1965 \iffalse
1966 \paragraph{Further Ideas.}
1967
1968 \begin{itemize}
1969 \item Optional Starred
1970 \item Collections
1971 \item Keep list of tags per sheet. Code to loop through list. Manuel Benz
1972 \end{itemize}
1973
1974 \fi
1975
1976 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1977 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1978 \section{Information}
1979
1980 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1981 \subsection{Copyright}
1982
1983 Copyright \copyright{} \thecopyright/
1984
1985 This work may be distributed and/or modified under the
1986 conditions of the \LaTeX{} Project Public License, either version 1.3
1987 of this license or (at your option) any later version.
1988 The latest version of this license is in
1989 \url{https://www.latex-project.org/lppl.txt}
1990 and version 1.3c or later is part of all distributions of \LaTeX{}
1991 version 2008 or later.
1992
1993 This work has the LPPL maintenance status `maintained'.
1994
1995 The Current Maintainer of this work is Niklas Beisert.
1996
1997 This work consists of the files
1998 |README.txt|, \verbpkg|.ins| and \verbpkg|.dtx|
1999 as well as the derived files listed below.
2000
2001 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2002 \subsection{Files and Installation}
2003
2004 The package consists of the files:
2005 %
2006 \begin{longtable}{ll}
2007 |README.txt| & readme file \\
2008 \verbpkg|.ins| & installation file \\
2009 \verbpkg|.dtx| & source file \\
2010 \verbpkg|.sty| & package file \\
2011 \verbpkg|.tex| & reference manual file \\
2012 \verbpkg|.pdf| & reference manual \\
2013 \verbpkg|-src.tex| & source code documentation file \\
2014 \verbpkg|-src.pdf| & source code documentation \\
2015 \verbpkg|-samp.tex| & sample file \\
2016 \verbpkg|-ser.tex| & multipart sample main file \\
2017 \verbpkg|-ser-0|\textit{n}|.tex| & multipart sample sheet
2018 \textit{n}=|1|, |2|, |3| \\
2019 \verbpkg|-ser-aa.tex| & multipart sample unused problems \\
2020 \verbpkg|-ser-p|\textit{x}|.tex| & multipart sample problem
2021 \textit{x}=|e|, |f| \\
2022 \verbpkg|-ser.sh| & multipart sample compile script \\
2023 \verbpkg|-ser.mak| & multipart sample makefile \\
2024 \end{longtable}
2025 %
2026 The distribution consists of the files
2027 |README.txt|, \verbpkg|.ins| and \verbpkg|.dtx|.
2028 %
2029 \begin{itemize}
2030 \item
2031 Run \LaTeX{} on \verbpkg|.ins| to create the package \verbpkg|.sty|
2032 and further documentation files.
2033 \item
2034 Copy the file \verbpkg|.sty| to an appropriate directory of your \LaTeX{}
2035 distribution, e.g.\ \textit{texmf-root}|/tex/latex/|\verbpkg.
2036 \item
2037 Alternatively, you may copy \verbpkg|.sty| to your project directory.
2038 \item
2039 Run (pdf)\LaTeX{} on \verbpkg|.dtx|
2040 to compile the documentation \verbpkg|.pdf| (this file).
2041 \end{itemize}
2042
2043 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2044 \subsection{Related Packages}
2045
2046 The package makes use of other packages available at CTAN:
2047 %
2048 \begin{itemize}
2049 \item
2050 This package relies on some functionality of the package \ctanpkg{verbatim}
2051 to read verbatim code from the \LaTeX{} source without expansion of macros.
2052 Compatibility with the \ctanpkg{verbatim} package
2053 has been tested with v1.5q (\markdate{2014-10-28}).
2054 \item
2055 This package uses the package \ctanpkg{xkeyval}
2056 to process the options for the package, environments and macros.
2057 Compatibility with the \ctanpkg{xkeyval} package
2058 has been tested with v2.7a (\markdate{2014-12-03}).
2059 \item
2060 This package can use the package \ctanpkg{hyperref}
2061 to include hyperlinks between problems and solutions.
2062 Compatibility with the \ctanpkg{hyperref} package
2063 has been tested with v6.88e (\markdate{2018-11-30}).
2064 \item
2065 This package can use the package \ctanpkg{amstext}
2066 (which is automatically loaded by \ctanpkg{amsmath})
2067 to display text within equations.
2068 Compatibility with the \ctanpkg{amstext} package
2069 has been tested with v2.01 (\markdate{2000-06-29}).
2070 \item
2071 This package uses the command |\currfilename|
2072 provided by the package \ctanpkg{currfile} (if available and loaded)
2073 to indicate the \LaTeX{} source file in the generated metapost file.
2074 Compatibility with the \ctanpkg{currfile} package
2075 has been tested with v0.7c (\markdate{2015-04-23}).
2076 \item
2077 This package can use the package \ctanpkg{metastr}
2078 to write pdf metadata and to handle basic translations.
2079 Compatibility with the \ctanpkg{metastr} package
2080 has been tested with v1.0 (\markdate{2020-02-06}).
2081 \end{itemize}
2082
2083 There are several other \LaTeX{} packages
2084 which offer a similar functionality
2085 varying largely in scope and sophistication:
2086 %
2087 \begin{itemize}
2088 \item
2089 The package \ctanpkg{exsheets}
2090 and its successor \ctanpkg{xsim}
2091 provide a \LaTeX{} 3 style for typesetting exercises with solutions.
2092 They offer options to
2093 hide or delay solutions,
2094 print only specific problems,
2095 deal with points,
2096 specify metadata,
2097 handle exercise collections,
2098 as well as some more specific options.
2099 They allow to adjust the layout and choose among predefined ones.
2100 \item
2101 The package \ctanpkg{exercise}
2102 provides a style for typesetting exercises with solutions.
2103 It offers many options to
2104 hide or delay solutions,
2105 print only specific problems,
2106 specify some metadata
2107 as well as some more specific options.
2108 It allows to customise the layout.
2109 \item
2110 The package \ctanpkg{exercises}
2111 provides a style for typesetting exercises with solutions.
2112 It offers options to hide solutions and deal with points.
2113 It allows basic customisation of the layout.
2114 \item
2115 The package \ctanpkg{exam}
2116 provides a document class for typesetting exams conveniently.
2117 It offers many options to hide solutions, deal with points
2118 and deal with other exam-specific tasks.
2119 It allows to adjust the layout and choose among predefined ones.
2120 \item
2121 The package \ctanpkg{probsoln}
2122 provides a style for typesetting exercises with solutions
2123 which are stored in a collection.
2124 It offers options to
2125 hide solutions
2126 and to assemble problems from an external collection.
2127 \item
2128 The packages
2129 \ctanpkg{uebungsblatt},
2130 \ctanpkg{uassign},
2131 \ctanpkg{mathexam},
2132 \ctanpkg{exsol},
2133 \href{https://github.com/mbauman/homework}{\markpkg{homework}},
2134 \href{https://gist.github.com/jhwilson/1278588}{\markpkg{jhwhw}}
2135 provide basic functionality for somewhat more particular situations.
2136 \end{itemize}
2137 %
2138 See CTAN categories \ctanref{topic/exercise}{exercise}
2139 and \ctanref{topic/exam}{exam}
2140 for further up-to-date packages.
2141
2142 The philosophy of the present package is to
2143 define a low-level framework to describe exercises with solutions
2144 to be used in various situations.
2145 The aim is to provide the means to describe the content
2146 (problems, solutions, sheets) in a simple fashion
2147 and separate it from the various layout definitions and choices
2148 which will define the appearance of the content.
2149 The interface was designed to reduce potential conflict
2150 with other packages and definitions.
2151 The package itself provides a functional basic layout
2152 rather than an elaborate or particularly appealing one.
2153 However, it provides means to adjust the basic layout in many ways and
2154 to predefine custom layout schemes.
2155 The package offers most of the functionality of the above packages,
2156 but (presently) misses out on some more advanced features.
2157 See \secref{sec:customisation} on customisation assistance and examples
2158 and \secref{sec:suggestions} for feature suggestions.
2159
2160 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2161 \subsection{Feature Suggestions}
2162 \label{sec:suggestions}
2163
2164 The following is a list of features which may be useful for future
2165 versions of this package:
2166 %
2167 \begin{itemize}
2168 \item
2169 Define structures for multiple-choice questions.
2170 \item
2171 Add more guidance to \secref{sec:guides} on customisation settings.
2172 \item
2173 Add more examples of customisation settings to achieve specific goals
2174 to \secref{sec:examples}.
2175 Please send suggestions.
2176 \item
2177 Option to hide problem text while maintaining access to embedded solutions
2178 (for a version containing only solutions):
2179 this is difficult to implement because the problem environment
2180 cannot simply be discarded, but would have to be scanned very carefully
2181 for the embedded solution;
2182 instead process problems to some document and save solutions to file,
2183 then read solutions from different document.
2184 \end{itemize}
2185
2186 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2187 \subsection{Revision History}
2188
2189 \iffalse
2190
2191 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2192 \paragraph{vN.N.N+:} \markdate{20YY-MM-DD}
2193
2194 \begin{itemize}
2195 \item
2196 \ldots
2197 \end{itemize}
2198
2199 \fi
2200
2201 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2202 \paragraph{v3.5.3:} \markdate{2026-03-23}
2203
2204 \begin{itemize}
2205 \item
2206 split off source code documentation into separate document \verbpkg|-src|
2207 \item
2208 package maintenance
2209 \end{itemize}
2210
2211 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2212 \paragraph{v3.5.2:} \markdate{2026-01-22}
2213
2214 \begin{itemize}
2215 \item
2216 distinguish between problem, subproblem and solutions
2217 for display of points in margin
2218 \end{itemize}
2219
2220 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2221 \paragraph{v3.5.1:} \markdate{2025-03-25}
2222
2223 \begin{itemize}
2224 \item
2225 maintenance and manual update
2226 \end{itemize}
2227
2228 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2229 \paragraph{v3.5:} \markdate{2024-10-18}
2230
2231 \begin{itemize}
2232 \item
2233 more convenient delimiter configuration |compose...delim| for various items
2234 \item
2235 composition of problem titles in |composetitleproblem|
2236 split up further into the configurations |composebareproblem|
2237 and |composenamedproblem|;
2238 to enable delimiter `.' for problems without a name, use
2239 %
2240 \begin{center}
2241 |\exerciseconfig{composebareproblemdelim}{.}|
2242 \end{center}
2243 %
2244 \item
2245 style |subproblemdelimitem| added
2246 to shift delimiter `)' from subproblem reference labels
2247 to subproblem item composition.
2248 \item
2249 |composetitlesolutionsproblemmulti| improved
2250 (thanks to Daniel Wegmann for pointing out insufficient behaviour)
2251 \item
2252 option |forproblem| for |solution|
2253 to release association to previous subproblem
2254 \item
2255 option to |disable| particular subproblems and solutions
2256 including following |solution| block
2257 \item
2258 handling of first solutions within a problem block
2259 \end{itemize}
2260
2261 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2262 \paragraph{v3.4:} \markdate{2020-02-24}
2263
2264 \begin{itemize}
2265 \item
2266 lists of sheets, problems and subproblems;
2267 list iterators
2268 \item
2269 tags for subproblems, tag customisation
2270 \item
2271 interaction with package \ctanpkg{metastr}
2272 \item
2273 minor fixes
2274 \end{itemize}
2275
2276 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2277 \paragraph{v3.31:} \markdate{2020-01-11}
2278
2279 \begin{itemize}
2280 \item
2281 |onlysolutions| environment for solution mode content
2282 \item
2283 sample multipart setup streamlined
2284 \end{itemize}
2285
2286 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2287 \paragraph{v3.3:} \markdate{2019-06-15}
2288
2289 \begin{itemize}
2290 \item
2291 control display of |problem| environments via
2292 package option |problembuf|:
2293 manual display, write to file, disable individual problems
2294 \item
2295 |solutionbelow| mode |here*| superseded by
2296 package option |solutionbuf|
2297 \item
2298 display total points within solution: |solutionpointsat|
2299 (thanks to Till Bargheer for suggestion)
2300 \item
2301 read points for current sheet, (sub)problem and solution
2302 (thanks to Johannes Hahn for suggestion)
2303 \item
2304 case switch for bonus points
2305 (thanks to Johannes Hahn for suggestion)
2306 \item
2307 option to |disable| particular problems,
2308 control by hook function
2309 (thanks to Manuel Benz for suggestion)
2310 \item
2311 provided interface |\showfracpoints| and |\exerciseconfig{frac}|
2312 for fractional points display
2313 \item
2314 filename extensions configurable
2315 \end{itemize}
2316
2317 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2318 \paragraph{v3.2:} \markdate{2019-05-01}
2319
2320 \begin{itemize}
2321 \item
2322 bonus points can be specified as
2323 |points=|[\textit{regular}][|+|\textit{bonus}]
2324 \item
2325 |solutionbelow| mode |here*| added
2326 for direct processing of the solution environment
2327 \item
2328 multipart sample added
2329 \end{itemize}
2330
2331 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2332 \paragraph{v3.11:} \markdate{2019-04-15}
2333
2334 \begin{itemize}
2335 \item
2336 fix interaction with
2337 package \ctanpkg{calc}
2338 (thanks to Johannes Hahn for bug report)
2339 \item
2340 fix style |fracpoints| in combination
2341 with some [|sub|]|problempointsat| choices
2342 (thanks to Johannes Hahn for bug report)
2343 \item
2344 fix spacing for [|sub|]|problempointsat=margin|
2345 (thanks to Johannes Hahn for bug report)
2346 \end{itemize}
2347
2348 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2349 \paragraph{v3.1:} \markdate{2019-01-21}
2350
2351 \begin{itemize}
2352 \item
2353 alternate placement modes for solutions
2354 \item
2355 fixed expansion of problem title
2356 \item
2357 reset font size for problem text
2358 \end{itemize}
2359
2360 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2361 \paragraph{v3.0:} \markdate{2019-01-16}
2362
2363 \begin{itemize}
2364 \item
2365 renamed to \verbpkg|.sty|
2366 \item
2367 first version published on CTAN
2368 \item
2369 overhaul and streamline interface
2370 \item
2371 solution processing remodelled
2372 \item
2373 changed metadata handling
2374 \item
2375 changed and generalised points handling
2376 \item
2377 generalised sectioning layout
2378 \item
2379 changed layout specification model
2380 \item
2381 insert hyperlinks using \ctanpkg{hyperref}
2382 \item
2383 manual, example and installation package added
2384 \end{itemize}
2385
2386 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2387 \paragraph{v2.0 -- v2.6:} \markdate{2014-10-03} -- \markdate{2018-11-05}
2388
2389 \begin{itemize}
2390 \item
2391 changed metadata interface
2392 \item
2393 broadened scope
2394 \item
2395 added more layout options
2396 \item
2397 added more metadata
2398 \item
2399 added sheet and problem tags
2400 \item
2401 add and remember points
2402 \end{itemize}
2403
2404 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2405 \paragraph{v1.1 -- v1.6:} \markdate{2014-08-07} -- \markdate{2014-09-14}
2406
2407 \begin{itemize}
2408 \item
2409 renamed to |nbprob.sty|
2410 \item
2411 added metadata
2412 \item
2413 added points
2414 \item
2415 added layout configuration
2416 \item
2417 removed specific macros
2418 \end{itemize}
2419
2420 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2421 \paragraph{v1.0 -- v1.02:} \markdate{2011-09-23} -- \markdate{2013-03-17}
2422
2423 \begin{itemize}
2424 \item
2425 first version as |problems.cls|
2426 \item
2427 dedicated layout and macros for author's exercise sheets
2428 \end{itemize}
2429
2430 %</main|manual>
2431 %<*main>
2432 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2433 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2434 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2435
2436 \appendix
2437 %</main>
2438 %<*main|source>
2439 \raggedright
2440 \settowidth\MacroIndent{\rmfamily\scriptsize 0000\ }
2441
2442 \DocInput{\thepkg/.dtx}
2443 %</main|source>
2444
2445 \end{document}
2446 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2447 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2448 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2449 %</main|manual|source>
2450 % \fi
2451 %
2452 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2453 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2454 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2455 %
2456 %
2457 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2458 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2459 % \section{Standalone Sample}
2460 % \label{sec:samplesingle}
2461 % \iffalse
2462 %<*samplesingle>
2463 % \fi
2464 %
2465 % This section provides an example of how to use
2466 % some of the \ctanpkg{exframe} features.
2467 % The resulting layout will be somewhat messy
2468 % due to a random selection of features.
2469 %
2470 % This example file describes a single exercise sheet.
2471 % The other sheet of the series would be declared
2472 % analogously in independent documents.
2473 %
2474 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2475 % \paragraph{Preamble.}
2476 %
2477 % Standard document class:
2478 % \begin{macrocode}
2479 \documentclass[12pt]{article}
2480 % \end{macrocode}
2481
2482 % Use package \ctanpkg{geometry} to set the page layout;
2483 % adjust the paragraph shape:
2484 % \begin{macrocode}
2485 \usepackage{geometry}
2486 \geometry{layout=a4paper}
2487 \geometry{paper=a4paper}
2488 \geometry{margin=2.5cm}
2489 \parindent0pt
2490 \parskip0.5ex
2491 % \end{macrocode}
2492
2493 % Include \ctanpkg{amstext}, \ctanpkg{hyperref} packages:
2494 % \begin{macrocode}
2495 \usepackage{amstext}
2496 \usepackage{hyperref}
2497 % \end{macrocode}
2498
2499 % May include \ctanpkg{metastr} package;
2500 % below code adjusts to whether or not present:
2501 % \begin{macrocode}
2502 \PassOptionsToPackage{loadlang=en|de}{metastr}
2503 \PassOptionsToPackage{course=true}{metastr}
2504 %%\usepackage{metastr}
2505 %%\metasetlang{de}
2506 % \end{macrocode}
2507
2508 % Include \ctanpkg{exframe} package:
2509 % \begin{macrocode}
2510 \usepackage[extstyle]{exframe}
2511 % \end{macrocode}
2512
2513 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2514 % \paragraph{Solutions Switch.}
2515 %
2516 % It will be useful to have the switch to turn on/off
2517 % the display of solutions near the top
2518 % of the source file, potentially with the opposite setting commented out:
2519 % \begin{macrocode}
2520 \exercisesetup{solutions=false}
2521 %%\exercisesetup{solutions=true}
2522 % \end{macrocode}
2523
2524 % Automatically put labels for (sub)problems:
2525 % \begin{macrocode}
2526 \exercisesetup{autolabelproblem=true}
2527 % \end{macrocode}
2528
2529 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2530 % \paragraph{Layout Declarations.}
2531 %
2532 % The following layout declarations adjust the general layout
2533 % of exercise sheets. They may as well be moved into an include file.
2534 %
2535 % Declare a header for exercise sheets
2536 % to display several relevant pieces of data;
2537 % display points total:
2538 % \begin{macrocode}
2539 \exercisestyle{plainheader}
2540 \exerciseconfig{composeheaderbelowright}{\getsheetdata{points}}%
2541 % \end{macrocode}
2542
2543 % Make the delimiter `)' part of the subproblem item
2544 % rather than the subproblem label:
2545 % \begin{macrocode}
2546 \exercisestyle{subproblemdelimitem}
2547 % \end{macrocode}
2548
2549 % Redefine the appearance of some counters;
2550 % sheets should be labelled by capital roman numerals,
2551 % subproblems by lowercase roman numerals;
2552 % declare the widest subproblem item to be expected:
2553 % \begin{macrocode}
2554 \exerciseconfig{countersheet}{\Roman{sheet}}
2555 \exerciseconfig{countersubproblem}{\roman{subproblem}}
2556 \exerciseconfig{countersubproblemmax}{vii}
2557 % \end{macrocode}
2558
2559 % Automatically display an asterisk for all
2560 % subproblems with bonus points only;
2561 % remove space to separate items:
2562 % \begin{macrocode}
2563 \exerciseconfig{insertsubprobleminfo}{%
2564 \switchpoints{}{\addprobleminfo*{%
2565 \hspace{-\getexerciseconfig{skipsubprobleminfo}}*}}%
2566 {}{}{\getsubproblempoints{}}}
2567 % \end{macrocode}
2568
2569 % Redefine the terms to be used for sheet(s);
2570 % here, a German version:
2571 % \begin{macrocode}
2572 \ifdefined\metaset
2573 \metasetterm[en]{sheet}{Exercise Sheet}
2574 \metasetterm[en]{sheets}{Exercise Sheets}
2575 \metasetterm[de]{sheet}{\"Ubungsblatt}
2576 \metasetterm[de]{sheets}{\"Ubungsbl\"atter}
2577 \else
2578 \exerciseconfig{termsheet}{\"Ubungsblatt}
2579 \exerciseconfig{termsheets}{\"Ubungsbl\"atter}
2580 \fi
2581 % \end{macrocode}
2582
2583 % Display points for problems in the margin;
2584 % change margin display to use the left margin;
2585 % use the abbreviated form `$n$p.':
2586 % \begin{macrocode}
2587 \exercisestyle{problempointsat=margin}
2588 \reversemarginpar
2589 \exerciseconfig{composepointsmargin}[1]{#1p.}
2590 \exerciseconfig{composepointspairmargin}[2]{%
2591 \ifdim#2pt=0pt#1p.%
2592 \else\ifdim#1pt=0pt+#2p.%
2593 \else#1+#2p.%
2594 \fi\fi}
2595 % \end{macrocode}
2596
2597 % Change the basic font style for all titles to be bold sans-serif:
2598 % \begin{macrocode}
2599 \exerciseconfig{styletitle}{\sffamily\bfseries}
2600 % \end{macrocode}
2601
2602 % Add a significant amount of space below problems:
2603 % \begin{macrocode}
2604 \exerciseconfig{skipproblembelow}{1.5cm}
2605 % \end{macrocode}
2606
2607 % Display half points as fractions:
2608 % \begin{macrocode}
2609 \exercisestyle{fracpoints}
2610 % \end{macrocode}
2611 % Show solutions below each problem
2612 % (may try alternatives |subproblem| or |sheet|):
2613 % \begin{macrocode}
2614 \exercisestyle{solutionbelow=problem}
2615 % \end{macrocode}
2616 % Indent solutions for subproblems:
2617 % \begin{macrocode}
2618 \exerciseconfig{skipsolutionitemsub}{-1pt}
2619 % \end{macrocode}
2620 % Separate solutions by horizontal lines (extended style):
2621 % \begin{macrocode}
2622 \exercisestyle{solutionsep}
2623 % \end{macrocode}
2624
2625 % Write metadata for sheet:
2626 % \begin{macrocode}
2627 \exercisesetup{pdfdata=sheet}
2628 % \end{macrocode}
2629
2630 % Set title and author for pdf metadata;
2631 % |title| is |course| plus |material| or sheet title;
2632 % |author| is |instructor| or sheet author plus |institution|:
2633 % \begin{macrocode}
2634 \ifdefined\metaset
2635 \metaset[sep]{subtitle}{, }
2636 \metaset{subtitle}{\ifsolutions\metatranslate[#1]{solutions} \fi%
2637 \metaif[use]{sheettitle}
2638 {\metapick[#1]{sheettitle}}
2639 {\metapick[#1]{material}}}
2640 \metaset{author}{\exerciseifempty{\getsheetdata{author}}%
2641 {\metapick[#1]{instructor}}{\metapick[#1]{sheetauthor}},
2642 \metapick[#1]{institution}}
2643 \else
2644 \exerciseconfig{composemetasheet}[2]{\getexercisedata{course},
2645 \ifsolutions\getexerciseconfig{termsolutions} \fi%
2646 \exerciseifempty{#2}{\getexerciseconfig{termsheet} #1}{#2}}
2647 \exercisedata{title=%
2648 {\getexercisedata{course},
2649 \ifsolutions\getexercisedata{solutions} \fi%
2650 \getexercisedata{material}}}
2651 \exercisedata{author=%
2652 {\getexercisedata{instructor}, \getexercisedata{institution}}}
2653 \fi
2654 % \end{macrocode}
2655
2656 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2657 % \paragraph{Exercise Series Data.}
2658 %
2659 % Set some data on the current series:
2660 % \begin{macrocode}
2661 \ifdefined\metaset
2662 \metaset{institution}{Katharinen-Volksschule}
2663 \metaset[de]{course}{Mathematik}
2664 \metaset[en]{course}{Mathematics}
2665 \metaset{instructor}{J.\ G.\ B\"uttner}
2666 \metaset{period}{ca.\ 1786}
2667 \metaset[de]{material}{\"Ubungsaufgaben}
2668 \metaset[en]{material}{Exercise Problems}
2669 \else
2670 \exercisedata{institution={Katharinen-Volksschule}}
2671 \exercisedata{course={Mathematik}}
2672 \exercisedata{instructor={J.\ G.\ B\"uttner}}
2673 \exercisedata{period={ca.\ 1786}}
2674 \exercisedata{material={\"Ubungsaufgaben}}
2675 \fi
2676 % \end{macrocode}
2677
2678 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2679 % \paragraph{Body.}
2680 %
2681 % \begin{macrocode}
2682 \begin{document}
2683 % \end{macrocode}
2684
2685 % Start sheet number 5:
2686 % \begin{macrocode}
2687 \begin{sheet}[number=5,label={sheet5}]
2688 % \end{macrocode}
2689
2690 % Start a problem with a title:
2691 % \begin{macrocode}
2692 \begin{problem}[title={Sums},points=99+4]
2693 % \end{macrocode}
2694
2695 % Summary of points:
2696 % \begin{macrocode}
2697 \exerciseloopstr{\getsubproblemlist{}}{c}%
2698 \hfill\begin{tabular}{c|\exerciseloopret|c}
2699 \exerciseloop{\getsubproblemlist{}}
2700 {&\ref{\getexerciseconfig{labelsubproblem}{#1}}}
2701 &\ref{prob:\problemtag}\\\hline
2702 \getexerciseconfig{termpoints}
2703 \exerciseloop{\getsubproblemlist{}}{&\extractpoints{\getsubproblempoints{#1}}}
2704 &\extractpoints{\getproblempoints{}}
2705 \\
2706 extra
2707 \exerciseloop{\getsubproblemlist{}}{&\extractpoints*{\getsubproblempoints{#1}}}
2708 &\extractpoints*{\getproblempoints{}}
2709 \end{tabular}
2710 % \end{macrocode}
2711
2712 % Some introduction to the problem:
2713 % \begin{macrocode}
2714 This problem deals with sums and series.
2715 % \end{macrocode}
2716
2717 % A subproblem with a local label:
2718 % \begin{macrocode}
2719 \begin{subproblem}[points=2,difficulty=simple,label={\problemtag-simplesum}]
2720 Compute the sum
2721 \showpoints
2722 \begin{equation}
2723 1+2+3.
2724 \end{equation}
2725 % \end{macrocode}
2726
2727 % Provide a solution for the subproblem (within the subproblem environment):
2728 % \begin{macrocode}
2729 \begin{solution}
2730 The result is
2731 \begin{equation}
2732 1+2+3=6.
2733 \end{equation}
2734 \end{solution}
2735 % \end{macrocode}
2736
2737 % End subproblem:
2738 % \begin{macrocode}
2739 \end{subproblem}
2740 % \end{macrocode}
2741
2742 % Another subproblem:
2743 % \begin{macrocode}
2744 \begin{subproblem}[points=97+0.5,difficulty=lengthy]
2745 Compute the sum
2746 \begin{equation}
2747 1+2+3+\ldots+98+99+100.
2748 \end{equation}
2749 Keep calm and calculate!
2750 %%That ought to keep him occupied for a while
2751 \end{subproblem}
2752 % \end{macrocode}
2753
2754 % Provide a solution for the previous subproblem
2755 % (layout may differ slightly from declaration within);
2756 % declare author:
2757 % \begin{macrocode}
2758 \begin{solution}[author={C.\ F.\ Gau\ss}]
2759 We use the result $1+2+3=6$ from part \ref{\problemtag-simplesum})
2760 to jumpstart the calculation. The remaining sums yield
2761 \awardpoints*[1 for each remaining sum]{97}
2762 \begin{equation}
2763 6+4+5+\ldots+99+100=5050.
2764 \end{equation}
2765 Alternatively the summands can be grouped into pairs as follows:
2766 \begin{align}
2767 1+100&=101,\\
2768 2+99&=101,\\
2769 3+98&=101,\\
2770 \ldots &\nonumber\\
2771 50+51&=101.
2772 \end{align}
2773 These amount to 50 times the same number 101.
2774 Therefore the sum equals
2775 \begin{equation}
2776 1+2+\ldots+99+100=50\cdot 101=5050.
2777 \end{equation}
2778 \textit{Ligget se!} \awardpoints{97+0.5}
2779 \end{solution}
2780 % \end{macrocode}
2781
2782 % Some text between subproblems:
2783 % \begin{macrocode}
2784 You may give the final part a try:
2785 % \end{macrocode}
2786
2787 % Final subproblem; this one is optional:
2788 % \begin{macrocode}
2789 \begin{subproblem}[optional={optional},
2790 difficulty={requires inspiration},points={+3.5}]
2791 Compute the series
2792 \showpoints
2793 \begin{equation}
2794 1+2+3+\ldots
2795 \end{equation}
2796 % \end{macrocode}
2797
2798 % Provide a solution:
2799 % \begin{macrocode}
2800 \begin{solution}
2801 The series is divergent, so the result is $\infty$ \awardpoints{+1}.
2802 \par
2803 However, after subtracting the divergent part,
2804 the result clearly is
2805 \begin{equation}
2806 \zeta(-1)=-\frac{1}{12}\,,
2807 \end{equation}
2808 where the zeta-function $\zeta(s)$ is defined by
2809 \begin{equation}
2810 \zeta(s):=\sum_{k=1}^\infty \frac{1}{k^s}\,.
2811 \end{equation}
2812 This definition holds only for $s>1$ where the sum is convergent,
2813 but one can continue the complex analytic function to $s<0$
2814 \awardpoints{+1.5}.
2815 \par
2816 Another way of understanding the result
2817 is to use the indefinite summation formula
2818 for arbitrary exponent $s$ in the summand
2819 (which also follows from the Euler--MacLaurin formula)
2820 \begin{equation}
2821 \sum_n n^s
2822 = \frac{n^{s+1}}{s+1}
2823 -\sum_{j=0}^s \frac{\zeta(j-s)\,s!}{(s-j)!\,j!}\,n^j
2824 = \ldots - \zeta(-s)\,n^0.
2825 \end{equation}
2826 Curiously, the constant term with $j=0$ is just the desired result
2827 but with the wrong sign
2828 (in fact, the constant term of an indefinite sum is ambiguous;
2829 for the claim we merely set $j=0$
2830 in the expression which holds for others values of $j$)
2831 \awardpoints{+0.5}.
2832 In order to understand the sign,
2833 we propose that the above formula describes the regularised result
2834 for the sum with limits $+\infty$ and $n$
2835 \begin{equation}
2836 \sum_{k=+\infty}^n k^s
2837 \simeq \frac{n^{s+1}}{s+1}
2838 -\sum_{j=0}^s \frac{\zeta(j-s)\,s!}{(s-j)!\,j!}\,n^j.
2839 \end{equation}
2840 Then we flip the summation limits of the desired sum
2841 to bring it into the above form
2842 \awardpoints{+0.5}
2843 \begin{equation}
2844 \sum_{k=1}^\infty k^s
2845 = -\sum_{k=\infty}^0 k^s
2846 \simeq \zeta(-s).
2847 \end{equation}
2848 \end{solution}
2849 % \end{macrocode}
2850
2851 % End subproblem:
2852 % \begin{macrocode}
2853 \end{subproblem}
2854 % \end{macrocode}
2855
2856 % End problem:
2857 % \begin{macrocode}
2858 \end{problem}
2859 % \end{macrocode}
2860
2861 % Another problem; this one is untitled:
2862 % \begin{macrocode}
2863 \begin{problem}[points=1, difficulty=insane]
2864 Show that the equation
2865 \begin{equation}
2866 a^3+b^3=c^3
2867 \end{equation}
2868 has no positive integer solutions.
2869 \end{problem}
2870 % \end{macrocode}
2871
2872 % A solution can also follow a problem
2873 % (but the layout may be slightly different,
2874 % e.g.\ here the space below the problem will
2875 % appear before the solution):
2876 % \begin{macrocode}
2877 \begin{solution}
2878 \normalmarginpar
2879 This is beyond the scope of this example.
2880 \marginpar{\footnotesize\raggedright does not fit here.\par}
2881 \end{solution}
2882 % \end{macrocode}
2883
2884 % Summary of points per problem and per subproblem for grading:
2885 % \begin{macrocode}
2886 \ifsolutions\else
2887 \textbf{Grading:}\par
2888 \exerciseloopstr{\getproblemlist{}}{|c}
2889 \begin{tabular}{|c|\exerciseloopret||c|}\hline
2890 \getexerciseconfig{termsheet} \ref{sheet5}
2891 \exerciseloop{\getproblemlist{*}}
2892 {&\ref{\getexerciseconfig{labelproblem}{#1}}}
2893 &total
2894 \\\hline
2895 value
2896 \exerciseloop{\getproblemlist{*}}
2897 {&\extractpoints{\getproblempoints{#1}}}%
2898 &\extractpoints{\getsheetpoints{}}
2899 \\\hline
2900 \exerciseloop{\getproblemlist{*}}{&}
2901 &\\\hline
2902 \end{tabular}\qquad
2903 \exerciseloop{\getproblemlist{*}}{
2904 \exerciseloopstr{\getsubproblemlist{#1}}{|c}
2905 \ifnum\value{exerciseloop}>0\relax
2906 \begin{tabular}{|c|\exerciseloopret||c|}\hline
2907 \getexerciseconfig{termproblem} \ref{\getexerciseconfig{labelproblem}{#1}}
2908 \exerciseloop{\getsubproblemlist{#1}}
2909 {&\ref{\getexerciseconfig{labelsubproblem}{##1}}}
2910 &total
2911 \\\hline
2912 value
2913 \exerciseloop{\getsubproblemlist{#1}}
2914 {&\extractpoints{\getsubproblempoints{##1}}}%
2915 &\extractpoints{\getproblempoints{#1}}
2916 \\\hline
2917 \exerciseloop{\getsubproblemlist{#1}}{&}
2918 &\\\hline
2919 \end{tabular}\quad
2920 \fi
2921 }
2922 \fi
2923 % \end{macrocode}
2924
2925 % End sheet:
2926 % \begin{macrocode}
2927 \end{sheet}
2928 % \end{macrocode}
2929
2930 % End of document body:
2931 % \begin{macrocode}
2932 \end{document}
2933 % \end{macrocode}
2934 % \iffalse
2935 %</samplesingle>
2936 % \fi
2937 %
2938 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2939 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2940 % \section{Multipart Sample}
2941 % \label{sec:samplemulti}
2942 %
2943 % The second example describes a series of exercise sheets
2944 % which can be compiled as a collection or as individual sheets.
2945 % This example describes a versatile setup
2946 % with several convenient features;
2947 % most of these features can be adjusted or removed easily as they
2948 % mostly enhance the setup and do not interact with each other strongly.
2949 %
2950 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2951 % \subsection{Main File}
2952 % \label{sec:samplemultimain}
2953 % \iffalse
2954 %<*samplemultimain>
2955 % \fi
2956 %
2957 % The main source file is called \verbpkg|-ser.tex|.
2958 % It is referenced at several places within the setup,
2959 % and when changing the name they need to be adjusted accordingly.
2960 %
2961 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2962 % \paragraph{childdoc Mechanism.}
2963 %
2964 % The setup uses the package \ctanpkg{childdoc} to allow compilation
2965 % of the series as a whole or in parts and with various sets of options:
2966 % \begin{macrocode}
2967 \input{childdoc.def}
2968 \childdocmain{}
2969 % \end{macrocode}
2970
2971 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2972 % \paragraph{Compilation Switches.}
2973 %
2974 % Define compilation switches and declare their default settings.
2975 % |\printsol| controls whether solutions should be printed or not;
2976 % by default solutions are activated for compilation of a part,
2977 % but not for the complete document.
2978 % |\draftver| controls whether the final version of
2979 % the document is to be compiled;
2980 % concretely this affects the compilations of metapost figures, see below:
2981 % \begin{macrocode}
2982 \ifchilddoc
2983 \providecommand{\printsol}{y}
2984 \else
2985 \providecommand{\printsol}{n}
2986 \fi
2987 \providecommand{\draftver}{y}
2988 \newif\ifdraft\if\draftver y\drafttrue\else\draftfalse\fi
2989 % \end{macrocode}
2990
2991 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2992 % \paragraph{Preamble.}
2993 %
2994 % Standard document class:
2995 % \begin{macrocode}
2996 \documentclass[12pt]{article}
2997 % \end{macrocode}
2998
2999 % \begin{macrocode}
3000 % \ctanpkg{graphicx} package to display license logo:
3001 \RequirePackage{graphicx}
3002 % \end{macrocode}
3003
3004 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3005 % \paragraph{hyperref Package.}
3006 %
3007 % Use the \ctanpkg{hyperref} package.
3008 % Declare some options, e.g.\ use bookmarks only for complete document:
3009 % \begin{macrocode}
3010 \PassOptionsToPackage{bookmarks=\ifchilddoc false\else true\fi}{hyperref}
3011 \PassOptionsToPackage{bookmarksopen=true}{hyperref}
3012 \RequirePackage{hyperref}
3013 % \end{macrocode}
3014
3015 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3016 % \paragraph{metastr Package.}
3017 %
3018 % Use the \ctanpkg{metastr} package to handle
3019 % metadata and copyright information;
3020 % disable usage of \ctanpkg{hyperxmp} package if not installed;
3021 % write auxiliary pdf metadata and rights information:
3022 % \begin{macrocode}
3023 \ifdraft
3024 \PassOptionsToPackage{draft}{metastr}
3025 \fi
3026 \IfFileExists{hyperxmp.sty}{}{\PassOptionsToPackage{hyperxmp=false}{metastr}}
3027 \RequirePackage[course]{metastr}
3028 \metaset[aux]{writepdf}{}
3029 \metaset[rights]{writepdf}{}
3030 % \end{macrocode}
3031
3032 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3033 % \paragraph{exframe Package.}
3034 %
3035 % Invoke \ctanpkg{exframe} with extended data and styles:
3036 % \begin{macrocode}
3037 \RequirePackage[extdata,extstyle]{exframe}
3038 % \end{macrocode}
3039
3040 % Set solutions switch and declare two-sided layout only
3041 % if no solutions are printed;
3042 % do not use solution buffer in draft mode
3043 % for easier identification of potential compile errors:
3044 % \begin{macrocode}
3045 \if\printsol n
3046 \exercisesetup{solutions=false}
3047 \exercisesetup{twoside=true}
3048 \else
3049 \exercisesetup{solutions=true}
3050 \exercisesetup{twoside=false}
3051 \ifdraft
3052 \exercisesetup{solutionbuf=false}
3053 \fi
3054 \fi
3055 % \end{macrocode}
3056
3057 % Might want to display some metadata (only for partial compile):
3058 % \begin{macrocode}
3059 %%\if\printsol n\else\showprobleminfo{author,source,recycle}\fi
3060 % \end{macrocode}
3061
3062 % Set some options. Automatically assign labels to problems.
3063 % Include sheets and problems in table of contents.
3064 % Separate solutions by horizontal rules.
3065 % Count problems, equations and pages by sheet
3066 % (unless compiling single problem).
3067 % Collect solutions below each problem.
3068 % Write pdf metadata for sheet when compiling single sheet:
3069 % \begin{macrocode}
3070 \exercisesetup{autolabelproblem}
3071 \exercisestyle{contents,solutionsep}
3072 \ifchilddocmanual\else
3073 \exercisestyle{pagebysheet,problembysheet,equationbysheet,sheetequation}
3074 \fi
3075 \exercisestyle{solutionbelow={problem}}
3076 \ifchilddoc\ifchilddocmanual\else\exercisesetup{pdfdata=sheet}\fi\fi
3077 % \end{macrocode}
3078
3079 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3080 % \paragraph{Language.}
3081 %
3082 % Redefine some terms:
3083 % \begin{macrocode}
3084 \metasetlang{en-GB}
3085
3086 \metasetterm[en]{sheet}{sheet}
3087 \metasetterm[en]{sheets}{sample sheets}
3088 \metasetterm[en]{solution}{Solution}
3089 \metasetterm[en]{solutions}{solutions}
3090 % \end{macrocode}
3091
3092 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3093 % \paragraph{Layout Definitions.}
3094 %
3095 % Set page dimensions and layout:
3096 % \begin{macrocode}
3097 \RequirePackage[a4paper,margin=2.5cm]{geometry}
3098 \pagestyle{plain}
3099 % \end{macrocode}
3100 % Remove paragraph indentation:
3101 % \begin{macrocode}
3102 \setlength\parindent{0pt}
3103 \setlength\parskip{\smallskipamount}
3104 % \end{macrocode}
3105 % Show overfull lines:
3106 % \begin{macrocode}
3107 \setlength\overfullrule{5pt}
3108 % \end{macrocode}
3109 % Define turn page over mark; hide when printing solutions:
3110 % \begin{macrocode}
3111 \newcommand{\turnover}{\ifsolutions\else\vfill%
3112 \hfill{\mathversion{bold}$\longrightarrow$}\newpage\fi}
3113 % \end{macrocode}
3114
3115 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3116 % \paragraph{Sheet Banner.}
3117 %
3118 % Use standard sheet banner;
3119 % show sheet |editdate| below banner (if declared);
3120 % when compiling single sheet, display sheet due date instead:
3121 % \begin{macrocode}
3122 \exercisestyle{plainheader}
3123 \exerciseconfig{composeheaderbelowright}
3124 {\sheetdataempty{editdate}{}{version: \getsheetdata{editdate}}}
3125 \ifchilddoc\ifsolutions\else
3126 \exerciseconfig{composeheaderbelowright}
3127 {\sheetdataempty{due}{}{due: \getsheetdata{due}}}
3128 \fi\fi
3129 % \end{macrocode}
3130
3131 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3132 % \paragraph{Lorem.}
3133 %
3134 % Define a macro |\lorem| to write out some paragraph of text
3135 % for the example:
3136 % \begin{macrocode}
3137 \def\lorem{Lorem ipsum dolor sit amet, consectetur adipisici elit,
3138 sed eiusmod tempor incidunt ut labore et dolore magna aliqua.
3139 Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
3140 nisi ut aliquid ex ea commodi consequat.
3141 Quis aute iure reprehenderit in voluptate velit esse
3142 cillum dolore eu fugiat nulla pariatur.
3143 Excepteur sint obcaecat cupiditat non proident,
3144 sunt in culpa qui officia deserunt mollit anim id est laborum.\par}
3145 % \end{macrocode}
3146
3147 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3148 % \paragraph{metapost Setup.}
3149 %
3150 % Use package \ctanpkg{mpostinl} (if available)
3151 % to include some metapost figures within the source of the problems:
3152 % \begin{macrocode}
3153 \IfFileExists{mpostinl.sty}{\RequirePackage{mpostinl}}{}
3154 \ifdefined\mpostsetup
3155 % \end{macrocode}
3156
3157 % Setup \ctanpkg{mpostinl}.
3158 % Use checksums to invoke metapost only when figures change.
3159 % Process all figures individually and immediately when in
3160 % draft mode for child documents (avoids a second compilation pass).
3161 % Number figures within sheet to provide a stable numbering
3162 % upon insertion/deletion of new figures or partial compilation:
3163 % \begin{macrocode}
3164 \mpostsetup{checksum}
3165 \ifchilddoc\ifdraft\mpostsetup{now,nowall}\fi\fi
3166 \ifchilddocmanual\else\mpostsetup{numberwithin={sheet}}\fi
3167 % \end{macrocode}
3168
3169 % Global metapost definitions.
3170 % Define some latex macro to demonstrate
3171 % usage of latex for typesetting labels.
3172 % Define some global metapost variables,
3173 % |paths| is an array of path variables,
3174 % |xu| serves as a length unit to
3175 % scale individual figures
3176 % (use |interim xu:=...;| to set scale for local figure only),
3177 % |pensize| changes the size of the pen,
3178 % |fillshape| fills and outlines a shape:
3179 % \begin{macrocode}
3180 \mpostsetup{globaldef=true}
3181 \begin{mposttex}
3182 \def\figure{figure}
3183 \end{mposttex}
3184 \begin{mpostdef}
3185 path paths[];
3186 newinternal numeric xu;
3187 xu:=1cm;
3188 def pensize(expr s)=withpen pencircle scaled s enddef;
3189 def fillshape(expr p,c)=
3190 fill p withcolor c;
3191 draw p
3192 enddef;
3193 \end{mpostdef}
3194 \mpostsetup{globaldef=false}
3195 % \end{macrocode}
3196
3197 % Close optional \ctanpkg{mpostinl} processing:
3198 % \begin{macrocode}
3199 \fi
3200 % \end{macrocode}
3201
3202 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3203 % \paragraph{Document Data.}
3204 %
3205 % Set document data for series of problem sheets:
3206 % \begin{macrocode}
3207 \metaset{course}{exframe package samples}
3208 \metaset{instructor}{N.\ Beisert}
3209 \metaset{author}{Niklas Beisert, \metapick[#1]{institution}}
3210 \metaset{institution}{exframe academy}
3211 \metaset{period}{spring 2019}
3212 \metaset{copyrightdate}{2019--2026}
3213 % \end{macrocode}
3214
3215 % For child documents declare part of:
3216 % \begin{macrocode}
3217 \ifchilddoc
3218 \metaset{partof}{\metatranslate[#1]{sheets} \metapick[#1]{course}}
3219 \fi
3220 % \end{macrocode}
3221
3222 % Assemble some entries from given data:
3223 % \begin{macrocode}
3224 \metaset[sep]{draft}{ -- }
3225 \metaset[sep]{subtitle}{, }
3226 \metaset{material}{\ifsolutions\metatranslate[#1]{solutions} \fi%
3227 \metatranslate[#1]{sheets}}
3228 \exerciseconfig{composetitlesheet}[2]{\exerciseifempty{#2}%
3229 {\ifsolutions\metaterm{solutions}\else\metaterm{sheet}\fi\ #1}%
3230 {\ifsolutions\metaterm{solutions} \fi #2}}
3231 \metaset{sheettitle}{\ifsolutions\metatranslate[#1]{solutions} \fi%
3232 \exerciseifempty{\getsheetdata{rawtitle}}%
3233 {\metatranslate[#1]{sheet} \thesheet}%
3234 {\getsheetdata{rawtitle}}}
3235 \metaset{subject}{Lecture Series,
3236 \metapick[#1]{institution}, \metapick[#1]{period}}
3237 % \end{macrocode}
3238
3239 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3240 % \paragraph{License.}
3241 %
3242 % It is good practice to specify a copyright line
3243 % and a license for the document:
3244 % \begin{macrocode}
3245 \metaset{copyrightowner}{\metapick[#1]{author}}
3246 \ifchilddoc
3247 \metacopyright{doc}
3248 \else
3249 \metacopyright{doc-parts}
3250 \fi
3251 \metaset{licenseprovider}{of \metapick[#1]{institution}}
3252 \metalicense{consent}
3253 % \end{macrocode}
3254
3255 % Apply Creative Commons BY-SA license
3256 % under certain conditions (no solutions, final version):
3257 % \begin{macrocode}
3258 \ifsolutions\else\ifdraft\else
3259 \metalicensecc{by-sa}
3260 \fi\fi
3261 % \end{macrocode}
3262
3263 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3264 % \paragraph{Body.}
3265 %
3266 % Start document body:
3267 % \begin{macrocode}
3268 \begin{document}
3269 % \end{macrocode}
3270
3271 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3272 % \paragraph{Single Problem Display.}
3273 %
3274 % The following code handles the compilation
3275 % of individual problems from their own source file.
3276 % Make sure to leave the conditional before issuing |\end{document}|:
3277 % \begin{macrocode}
3278 \def\tmp{}
3279 \ifchilddocmanual
3280 \def\tmp{\end{document}}
3281 \input{\childdocname}
3282 \fi\tmp
3283 % \end{macrocode}
3284
3285 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3286 % \paragraph{Frontmatter.}
3287 %
3288 % Do not print frontmatter for individual sheets.
3289 % Define a plain page counter for frontmatter:
3290 % \begin{macrocode}
3291 \setcounter{section}{-1}
3292 \begingroup\ifchilddoc\else
3293 \renewcommand{\thepage}{\arabic{page}}
3294 % \end{macrocode}
3295
3296 % Prepare a title page to display some relevant data:
3297 % \begin{macrocode}
3298 \pdfbookmark[1]{\metaterm{title}}{title}
3299 \thispagestyle{empty}
3300 \vspace*{\fill}
3301 \begin{center}
3302 \metapick[course]{titletext}
3303 \end{center}
3304 \vspace*{\fill}\vspace*{\fill}
3305 \newpage
3306 % \end{macrocode}
3307
3308 % Prepare a copyright and license page using data specified above:
3309 % \begin{macrocode}
3310 \phantomsection\pdfbookmark[1]{\metaterm{copyright}}{copyright}
3311 \thispagestyle{empty}
3312 \vspace*{\fill}\vspace*{\fill}
3313 \begin{center}\begin{minipage}{11cm}\raggedright
3314 \metapick[print]{rightstext}
3315 \end{minipage}\end{center}
3316 \vspace*{\fill}\vspace*{\fill}\vspace*{\fill}
3317 \newpage
3318 % \end{macrocode}
3319
3320 % Print table of contents:
3321 % \begin{macrocode}
3322 \makeatletter\renewcommand\@pnumwidth{2.4em}\makeatother
3323 \setcounter{tocdepth}{2}
3324 \phantomsection\pdfbookmark[1]{\metaterm{contents}}{contents}
3325 {\parskip0pt\tableofcontents}
3326 \exercisecleardoublepage\setcounter{page}{1}
3327 % \end{macrocode}
3328
3329 % End of frontmatter:
3330 % \begin{macrocode}
3331 \fi\endgroup
3332 % \end{macrocode}
3333
3334 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3335 % \paragraph{Include Sheets.}
3336 %
3337 % Include problem sheets:
3338 % \begin{macrocode}
3339 \include{exframe-ser-01}
3340 \include{exframe-ser-02}
3341 \include{exframe-ser-03}
3342 % \end{macrocode}
3343
3344 % Include sheet to collect unused problems
3345 % (only process for individual sheets, i.e.\ itself):
3346 % \begin{macrocode}
3347 \def\jobnameunused{exframe-ser-aa}
3348 \ifx\childdocname\jobnameunused\include{\jobnameunused}\fi
3349 % \end{macrocode}
3350
3351 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3352 % \paragraph{End.}
3353 %
3354 % End of document body:
3355 % \begin{macrocode}
3356 \end{document}
3357 % \end{macrocode}
3358 %
3359 % \iffalse
3360 %</samplemultimain>
3361 % \fi
3362 %
3363 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3364 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3365 % \subsection{Sheet File}
3366 % \label{sec:samplemultisheets}
3367 % \iffalse
3368 %<*samplemultisheet1|samplemultisheet2|samplemultisheet3|samplemultisheeta>
3369 % \fi
3370 %
3371 % Provide some source files
3372 % \verbpkg|-ser-01.tex|, \verbpkg|-ser-02.tex|,
3373 % \verbpkg|-ser-03.tex|, \verbpkg|-ser-aa.tex|
3374 % for problem sheets.
3375 %
3376 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3377 % \paragraph{childdoc Mechanism.}
3378 %
3379 % Instruct the package \ctanpkg{childdoc} to compile
3380 % only the present sheet if source is compiled by latex:
3381 % \begin{macrocode}
3382 %%\providecommand{\printsol}{n}
3383 \input{childdoc.def}
3384 \childdocof{exframe-ser}
3385 % \end{macrocode}
3386 % \iffalse
3387 %</samplemultisheet1|samplemultisheet2|samplemultisheet3|samplemultisheeta>
3388 %<samplemultiprobleme|samplemultiproblemf>%%\providecommand{\printsol}{n}
3389 %<samplemultiprobleme|samplemultiproblemf>\input{childdoc.def}
3390 %<samplemultiprobleme|samplemultiproblemf>\childdocby{exframe-ser}
3391 %<*samplemultisheet1>
3392 % \fi
3393 % The parameter of |\childdocof| must match the main file name \verbpkg|-ser|.
3394 % Uncommenting the commented line suppressed printing of the solution.
3395
3396 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3397 % \paragraph{Sheet Environment.}
3398 %
3399 % Declare a sheet with intended due date:
3400 % \begin{macrocode}
3401 \begin{sheet}[due={2019-04-29}]
3402 % \end{macrocode}
3403 % Adjust due date for each sheet.
3404 % For sheet containing unused problems \verbpkg|-ser-aa.tex|,
3405 % declare a sheet |title={unused problems}| instead of due date.
3406 % \iffalse
3407 %</samplemultisheet1>
3408 %<samplemultisheet2>\begin{sheet}[due={2019-05-06}]
3409 %<samplemultisheet3>\begin{sheet}[due={2019-05-13}, title={last sheet}]
3410 %<samplemultisheeta>\begin{sheet}[title={unused problems}]
3411 %<*samplemultisheet1>
3412 % \fi
3413
3414 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3415 % \paragraph{Problems.}
3416 %
3417 % Start a problem:
3418 % \begin{macrocode}
3419 \begin{problem}[title={Sample A}]
3420 % \end{macrocode}
3421 %
3422 % \iffalse
3423 %</samplemultisheet1>
3424 %<samplemultisheet2>\begin{problem}[title={Sample C}]
3425 %<samplemultisheet3>\input{exframe-ser-pe}
3426 %<samplemultisheeta>\begin{problem}[title={Sample X}]
3427 %<samplemultiprobleme>\begin{problem}[title={Sample E}]
3428 %<*samplemultisheet1|samplemultisheet2|samplemultisheeta|samplemultiprobleme>
3429 % \fi
3430
3431 % Let us declare a figure using \ctanpkg{mpostinl} (if available).
3432 % Denote it by the label \textit{tag}|-fig|,
3433 % where \textit{tag} is the tag of the problem
3434 % (in order to avoid potential conflicts with other problems;
3435 % \textit{tag} is assigned automatically or by specifying
3436 % the option |tag| for the |problem| environment).
3437 % Also declare a figure \textit{tag}|-solfig| for use within the solution:
3438 % \begin{macrocode}
3439 \ifdefined\mpostuse
3440 \begin{mpostfig}[label={\problemtag-fig}]
3441 interim xu:=1.5cm;
3442 paths[1]:=fullcircle scaled 1xu;
3443 fillshape(paths[1], 0.7white) pensize(1pt);
3444 label(btex \figure etex, center(paths[1]));
3445 \end{mpostfig}
3446 \begin{onlysolutions}
3447 \begin{mpostfig}[label={\problemtag-solfig}]
3448 interim xu:=1.5cm;
3449 paths[1]:=fullcircle scaled 1xu;
3450 paths[2]:=((subpath (-2,2) of paths[1])--cycle) shifted (+0.5xu,0);
3451 paths[3]:=((subpath (2,6) of paths[1])--cycle) shifted (-0.5xu,0);
3452 fillshape(paths[2], 0.7white) pensize(1pt);
3453 fillshape(paths[3], 0.7white) pensize(1pt);
3454 \end{mpostfig}
3455 \end{onlysolutions}
3456 \fi
3457 % \end{macrocode}
3458
3459 % Write a problem body with figure, some subproblems and a solution:
3460 % \begin{macrocode}
3461 \lorem
3462
3463 \begin{subproblem}
3464 \lorem
3465 \begin{center}
3466 \ifdefined\mpostuse\mpostuse{\problemtag-fig}\else figure\fi
3467 \end{center}
3468 \lorem
3469 \end{subproblem}
3470
3471 \begin{solution}
3472 \lorem
3473 \begin{center}
3474 \ifdefined\mpostuse\mpostuse{\problemtag-solfig}\else figure\fi
3475 \end{center}
3476 \lorem
3477 \end{solution}
3478
3479 \begin{subproblem}
3480 \lorem
3481 \end{subproblem}
3482
3483 \begin{solution}
3484 \lorem
3485 \end{solution}
3486
3487 \lorem
3488
3489 \begin{subproblem}
3490 \lorem
3491 \end{subproblem}
3492
3493 \begin{solution}
3494 \lorem
3495 \end{solution}
3496 % \end{macrocode}
3497
3498 % End the problem:
3499 % \begin{macrocode}
3500 \end{problem}
3501 % \end{macrocode}
3502 % \iffalse
3503 %</samplemultisheet1|samplemultisheet2|samplemultisheeta|samplemultiprobleme>
3504 %<*samplemultisheet1|samplemultisheet2|samplemultisheet3|samplemultisheeta>
3505 % \fi
3506
3507 % Start new page:
3508 % \begin{macrocode}
3509 \turnover
3510 % \end{macrocode}
3511
3512 % \iffalse
3513 %</samplemultisheet1|samplemultisheet2|samplemultisheet3|samplemultisheeta>
3514 %<*samplemultisheet1>
3515 % \fi
3516 % Write a second problem to accompany the first one:
3517 % \begin{macrocode}
3518 \begin{problem}
3519 % \end{macrocode}
3520 %
3521 % \iffalse
3522 %</samplemultisheet1>
3523 %<samplemultisheet2>\begin{problem}[title={Sample D}]
3524 %<samplemultisheet3>\input{exframe-ser-pf}
3525 %<samplemultisheeta>\begin{problem}[title={Sample Y}]
3526 %<samplemultiproblemf>\begin{problem}[title={Sample F}]
3527 %<*samplemultisheet1|samplemultisheet2|samplemultisheeta|samplemultiproblemf>
3528 % \fi
3529
3530 % Problem body without a figure;
3531 % this time the |solution| environments are
3532 % included in the |subproblem| environments:
3533 % \begin{macrocode}
3534 \lorem
3535
3536 \begin{subproblem}
3537 \lorem
3538 \begin{solution}
3539 \lorem
3540 \end{solution}
3541 \end{subproblem}
3542
3543 \begin{subproblem}
3544 \lorem
3545 \begin{solution}
3546 \lorem
3547 \end{solution}
3548 \end{subproblem}
3549 % \end{macrocode}
3550
3551 % End the problem:
3552 % \begin{macrocode}
3553 \end{problem}
3554 % \end{macrocode}
3555
3556 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3557 % \paragraph{End Sheet.}
3558 % \iffalse
3559 %</samplemultisheet1|samplemultisheet2|samplemultisheeta|samplemultiproblemf>
3560 %<*samplemultisheet1|samplemultisheet2|samplemultisheet3|samplemultisheeta>
3561 % \fi
3562 % End the sheet:
3563 % \begin{macrocode}
3564 \end{sheet}
3565 % \end{macrocode}
3566
3567 % \iffalse
3568 %</samplemultisheet1|samplemultisheet2|samplemultisheet3|samplemultisheeta>
3569 % \fi
3570 %
3571 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3572 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3573 % \subsection{Individual Problem Files}
3574 % \label{sec:samplemultisheet3}
3575 % \iffalse
3576 %<*discard>
3577 % \fi
3578 %
3579 % It may be more convenient to define each problem in an individual file,
3580 % so that a sheet can be composed by including the appropriate
3581 % problem files.
3582 % In such a setup, the \ctanpkg{childdoc} mechanism
3583 % allows to compile each problem individually.
3584 %
3585 % To that end, prepare a file \verbpkg|-ser-p|\textit{nn}|.tex|
3586 % containing the |problem| environment.
3587 % This file should start with:
3588 % \begin{macrocode}
3589 %%\providecommand{\printsol}{n}
3590 \input{childdoc.def}
3591 \childdocby{exframe-ser}
3592 % \end{macrocode}
3593 % and end with |\endinput|.
3594 % Then compose the problem sheet
3595 % by including the appropriate set of problem files
3596 % via |\input{exframe-ser-p|\textit{nn}|}|.
3597 %
3598 % In the example, a sheet file \verbpkg|-ser-03.tex|
3599 % includes two problem files \verbpkg|-ser-pe.tex| and \verbpkg|-ser-pf.tex|.
3600 %
3601 % \iffalse
3602 %</discard>
3603 % \fi
3604 %
3605 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3606 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3607 % \subsection{Make Scripts}
3608 % \label{sec:samplemultimake}
3609 % \iffalse
3610 %<*samplemultiscript>
3611 % \fi
3612 %
3613 % The setup allows the compilation in various modes for editing purposes.
3614 % In order to generate and update a complete set of documents for distribution
3615 % (all individual sheets and a collection of sheets;
3616 % with and without solutions),
3617 % it makes sense to use the software development utility |make|.
3618 % The compilation of individual components is simplified
3619 % by a |bash| shell script.
3620 %
3621 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3622 % \paragraph{Compile Script.}
3623 %
3624 % The |bash| shell script \verbpkg|-ser.sh| compiles one part of
3625 % the collection of problem sheets in a given mode.
3626 %
3627 % Shebang for |bash| script:
3628 % \begin{macrocode}
3629 #!/bin/bash
3630 % \end{macrocode}
3631
3632 % Configure and declare variables with default values.
3633 % |srcmain| defines the name of the main source file;
3634 % |srcsec|\textit{nn} defines the name of the sheet source file;
3635 % |trglist| defines the target file names;
3636 % |trgsol| defines the target modes;
3637 % |sheets| is a list of allowable sheet identifiers \textit{nn}:
3638 % \begin{macrocode}
3639 srcmain="exframe-ser"
3640 srcsec="exframe-ser-"
3641 trglist=(Problems Solutions)
3642 trgsol=(n y)
3643 secnum="01 02 03 aa"
3644 % \end{macrocode}
3645
3646 % Display usage:
3647 % \begin{macrocode}
3648 if [ -z $1 ]
3649 then
3650 echo "Usage:
3651 $0 number [version]
3652 number: number of sheet, 0 for combined document
3653 version: 0 for problems, 1 for solutions
3654 $0 filename
3655 filename: target file to be compiled"
3656 exit 1
3657 fi
3658 % \end{macrocode}
3659 % \iffalse$\fi
3660
3661 % Configure and declare variables with default values.
3662 % |num| takes the sheet number;
3663 % |ver| takes the compile mode;
3664 % \begin{macrocode}
3665 num="$1"
3666 ver="$2"
3667 nl=$'\n'
3668 secokay=""
3669 make=".pdf"
3670 % \end{macrocode}
3671 % \iffalse$\fi
3672
3673 % Check if the parameter matches any of the acceptable output file names:
3674 % \begin{macrocode}
3675 for v in "${trglist[@]}"
3676 do
3677 if [[ $num =~ ^$v ]]
3678 then
3679 ver=$v
3680 num=${num#$v}
3681 if [[ $num =~ ^.*\.tex$ ]]; then make=".tex"; fi
3682 num=${num%%.*}
3683 fi
3684 done
3685 % \end{macrocode}
3686 % \iffalse$\fi
3687
3688 % Ensure that |num| is a two-digit number, prepend `0' otherwise:
3689 % \begin{macrocode}
3690 if [[ $num =~ ^[0-9]$ ]]; then num="0$num"; fi
3691 if [[ $num == "00" ]]; then num=""; fi
3692 % \end{macrocode}
3693
3694 % Check whether |num| is acceptable:
3695 % \begin{macrocode}
3696 if [[ -z $num ]]; then secokay="okay"; fi
3697 for v in $secnum
3698 do
3699 if [[ "$num" == "$v" ]]; then secokay="okay"; fi
3700 done
3701 % \end{macrocode}
3702
3703 % Otherwise display error message and exit:
3704 % \begin{macrocode}
3705 if [[ -z $secokay ]]
3706 then
3707 echo "error: unknown sheet"
3708 exit 1
3709 fi
3710 % \end{macrocode}
3711 % \iffalse$\fi
3712
3713 % Disable newline character for command line tex code:
3714 % \begin{macrocode}
3715 if [[ "$make" == ".pdf" ]]; then nl=""; fi
3716 % \end{macrocode}
3717 % \iffalse$\fi
3718
3719 % Function to compile a component.
3720 % Set up \ctanpkg{childdoc} mechanism according to desired component.
3721 % Compile two passes, first in |-draftmode|.
3722 % Suppress messages by |mpost|.
3723 % Display warning messages in log file:
3724 % \begin{macrocode}
3725 function docompile
3726 {
3727 if [[ -z $num ]]
3728 then
3729 job="$srcmain"
3730 fwd="\\childdocforward{$srcmain}"
3731 else
3732 job="$srcsec$num"
3733 fwd="\\childdocforward[$srcmain]{$srcsec$num}"
3734 fi
3735 body="\\def\\jobname{$job}$optdef\\input{childdoc.def}$fwd"
3736 for pass in first main extra
3737 do
3738 par="";
3739 if [[ "$pass" == "first" ]]; then par="-draftmode"; fi
3740 drop="This is|entering extended mode|\\write18"
3741 drop="$drop|Preloading the plain mem file|mpost\.mp|plain\.mp"
3742 pdflatex -shell-escape -interaction=batchmode $par \
3743 -jobname "$trg" "$body" | grep -vE "$drop"
3744 if [[ "$pass" != "main" ]]; then continue; fi
3745 if ! (grep -E -q "may have changed|rerunfilecheck Warning" "$trg.log")
3746 then break; fi
3747 done
3748 grep -E "^! |Warning|Error|Undefined|Overfull|Underfull" "$trg.log"
3749 }
3750 % \end{macrocode}
3751 % \iffalse$\fi
3752
3753 % Function to generate a \ctanpkg{childdoc} compile file with specific options:
3754 % \begin{macrocode}
3755 function writesource
3756 {
3757 if [[ -z $num ]]
3758 then
3759 fwd="\\childdocforward{$srcmain}"
3760 else
3761 fwd="\\childdocforwardprefix[$srcmain]{$target}{$srcsec}"
3762 fi
3763 body="$optdef\\input{childdoc.def}$nl$fwd"
3764 echo "$body" > $trg.tex
3765 }
3766 % \end{macrocode}
3767 % \iffalse$\fi
3768
3769 % Translate versions to parameter values,
3770 % configure variables and select appropriate function for intended task:
3771 % \begin{macrocode}
3772 for i in "${!trglist[@]}"
3773 do
3774 if [[ -z $ver || "$ver" == "${trglist[$i]}" || $ver = $i ]]
3775 then
3776 target="${trglist[$i]}"
3777 sol="${trgsol[$i]}"
3778 trg="$target$num"
3779 optdef="\\def\\draftver{n}$nl\\def\\printsol{$sol}$nl"
3780 if [[ "$make" == ".pdf" ]]; then docompile; else writesource; fi
3781 fi
3782 done
3783 % \end{macrocode}
3784 % \iffalse$\fi
3785
3786 % Finish with blank line:
3787 % \begin{macrocode}
3788 echo
3789 % \end{macrocode}
3790 %
3791 % \iffalse
3792 %</samplemultiscript>
3793 % \fi
3794 %
3795 % \iffalse
3796 %<*samplemultimake>
3797 % \fi
3798 %
3799 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3800 % \paragraph{Makefile.}
3801 %
3802 % \catcode9=13\def^^I{~~~~~~~~}
3803 %
3804 % Define a make file \verbpkg|-ser.mak| for the project.
3805 % The compilation is then started by
3806 % |make -f exframe-ser.mak| \ldots.
3807 % More conveniently, in a single-project setup within the directory,
3808 % this file would be called |Makefile| in which case it suffices
3809 % to just run |make| \ldots.
3810 %
3811 % Configuration definitions:
3812 % \begin{macrocode}
3813 SRCMAIN = exframe-ser
3814 SRCSEC = exframe-ser-
3815 SRCPRB = exframe-ser-p
3816 SCRIPT = exframe-ser.sh
3817 MAKEFILE = exframe-ser.mak
3818 TRGLIST = Problems Solutions
3819 SECNUM = 01 02 03 aa
3820 PREREQS = $(SRCMAIN).tex
3821
3822 SRCSECFILES = $(SECNUM:%=$(SRCSEC)%.tex)
3823 TRGMAINFILES = $(foreach trg,$(TRGLIST),$(trg).pdf)
3824 TRGSECFILES = $(foreach trg,$(TRGLIST),$(trg).pdf $(SECNUM:%=$(trg)%.pdf))
3825 GENFILES = $(foreach trg,$(TRGLIST),$(trg).tex $(SECNUM:%=$(trg)%.tex))
3826 BAKFILES = $(PREREQS) $(SRCSECFILES) $(GENFILES)\
3827 $(MAKEFILE) $(SCRIPT) $(SRCPRB)*
3828 % \end{macrocode}
3829 % \iffalse$\fi
3830
3831 % Define some abstract targets;
3832 % |default| is the default target when no parameters are given:
3833 % \begin{macrocode}
3834 default: sheets ;
3835 main: $(TRGMAINFILES) ;
3836 sheets: $(TRGSECFILES) ;
3837 sheet%: $(foreach trg,$(TRGLIST),$(trg)%.pdf) ;
3838 all: main sheets ;
3839 sources: $(GENFILES) ;
3840 % \end{macrocode}
3841 % \iffalse$\fi
3842
3843 % Compile particular files via \verbpkg|-ser.sh| bash script.
3844 % Note that command lines have to start with a tab character
3845 % (represented by 8 spaces here):
3846 % \begin{macrocode}
3847 $(TRGMAINFILES): $(SRCSECFILES) $(PREREQS)
3848 bash ./$(SCRIPT) $@
3849 $(word 1,$(TRGLIST))%.pdf: $(SRCSEC)%.tex $(PREREQS)
3850 bash ./$(SCRIPT) $@
3851 $(word 2,$(TRGLIST))%.pdf: $(SRCSEC)%.tex $(PREREQS)
3852 bash ./$(SCRIPT) $@
3853 $(GENFILES):
3854 bash ./$(SCRIPT) $@
3855 % \end{macrocode}
3856 % \iffalse$\fi
3857
3858 % Touch main file for recompile:
3859 % \begin{macrocode}
3860 touch:
3861 touch $(SRCMAIN).tex
3862 % \end{macrocode}
3863 % \iffalse$\fi
3864 % Define |clean| target to remove all intermediate compilation files:
3865 % \begin{macrocode}
3866 clean:
3867 rm -f $(foreach ext,.aux .log,$(SECNUM:%=$(SRCSEC)%$(ext)))
3868 rm -f $(foreach trg,$(TRGLIST),$(SECNUM:%=$(trg)%.log) $(trg).log)
3869 rm -f $(foreach ext,.aux .log .out .toc,$(SRCMAIN)$(ext))
3870 rm -f $(foreach ext,.mp .mpx -*.mps,$(SRCMAIN)$(ext))
3871 rm -f $(foreach ext,-tmp.log -tmp.mp -tmp.mpx,$(SRCMAIN)$(ext))
3872 rm -f mpxerr.tex mpxerr.log mpxerr.dvi texput.log
3873 rm -f $(patsubst %,$(SRCPRB)*%,.aux .log .mp .mpx -*.mps)
3874 rm -f $(patsubst %,$(SRCPRB)*%,-tmp.log -tmp.mp -tmp.mpx)
3875 % \end{macrocode}
3876 % Define |clean-bak| target to remove all backup files
3877 % ending in `|~|' or `|.bak|':
3878 % \begin{macrocode}
3879 clean-bak:
3880 rm -f $(BAKFILES:%=%~) $(BAKFILES:%=%.bak)
3881 % \end{macrocode}
3882 % Define |clean-all| target to remove all generated files
3883 % for a clean source directory:
3884 % \begin{macrocode}
3885 clean-all: clean
3886 rm -f $(TRGSECFILES) $(TRGMAINFILES) $(GENFILES)
3887 rm -f $(SECNUM:%=$(SRCSEC)%.pdf) $(SRCMAIN).pdf
3888 rm -f $(SRCPRB)*.pdf
3889 % \end{macrocode}
3890 % \iffalse$\fi
3891 % \catcode9=9
3892 %
3893 % \iffalse
3894 %</samplemultimake>
3895 % \fi
3896 %
3897 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3898 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3899 % \section{Implementation}
3900 % \label{sec:implementation}
3901 % \iffalse
3902 %<*package>
3903 % \fi
3904 %
3905 % This section describes the package \verbpkg|.sty|.
3906
3907 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3908 % \subsection{General Definitions}
3909 % \label{sec:imp-def}
3910 %
3911 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3912 % \paragraph{Required Packages.}
3913 %
3914 % The package loads the package
3915 % \ctanpkg{verbatim} and \ctanpkg{xkeyval}
3916 % if not yet present.
3917 % \ctanpkg{verbatim} is used for solution environment reading
3918 % and \ctanpkg{xkeyval} is used for extended options processing:
3919 % \begin{macrocode}
3920 \RequirePackage{verbatim}
3921 \RequirePackage{xkeyval}
3922 % \end{macrocode}
3923
3924 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3925 % \paragraph{General Definitions.}
3926 %
3927 % \macro{\exf@empty}
3928 % Define an empty macro for comparison by |\ifx|:
3929 % \begin{macrocode}
3930 \def\exf@empty{}
3931 % \end{macrocode}
3932
3933 % \macro{\exf@exptwo}
3934 % A macro to conveniently expand the third token in line:
3935 % \begin{macrocode}
3936 \def\exf@exptwo#1{\expandafter#1\expandafter}
3937 % \end{macrocode}
3938 % \macro{\exf@exparg}
3939 % A macro to conveniently expand the first token
3940 % of an argument following arbitrary code:
3941 % \begin{macrocode}
3942 \long\def\exf@expswitch#1#2{#2{#1}}
3943 \long\def\exf@exparg#1#2{\exf@exptwo\exf@expswitch{#2}{#1}}
3944 % \end{macrocode}
3945 % \macro{\exf@csdo}
3946 % \macro{\exf@csdotwo}
3947 % Some macros to conveniently expand |\csname| arguments
3948 % before expanding the macro:
3949 % \begin{macrocode}
3950 \def\exf@csdo#1#2{\expandafter#1\csname#2\endcsname}
3951 \def\exf@csdotwo#1#2#3{\exf@exptwo#1#2\csname#3\endcsname}
3952 % \end{macrocode}
3953 % \macro{\exf@csor}
3954 % A macro to return |\csname| or default if not exists:
3955 % \begin{macrocode}
3956 \def\exf@csor#1#2{\ifcsname#1\endcsname\csname#1\endcsname\else#2\fi}
3957 % \end{macrocode}
3958
3959 % \macro{\exf@append@def}
3960 % \macro{\exf@prepend@def}
3961 % Add definitions to macros (after or before original content):
3962 % \begin{macrocode}
3963 \long\def\exf@append@def#1#2{\exf@exptwo\def#1\expandafter{#1#2}}
3964 \long\def\exf@prepend@switch#1#2#3{#2{#3#1}}
3965 \long\def\exf@prepend@def#1#2{\exf@exptwo\exf@prepend@switch{#1}{\def#1}{#2}}
3966 % \end{macrocode}
3967
3968 % \macro{\exf@expsetkeys}
3969 % A version of |\setkeys| from \ctanpkg{xkeyval} which expands first:
3970 % \begin{macrocode}
3971 \newcommand{\exf@expsetkeys}[2]{\edef\exf@tmp{#2}%
3972 \exf@exparg{\setkeys{#1}}{\exf@tmp}}
3973 % \end{macrocode}
3974
3975 % \macro{\exf@isif}
3976 % Execute |#3| if content of macro |#1| equals |#2|:
3977 % \begin{macrocode}
3978 \newcommand{\exf@ifis}[3]%
3979 {\def\exf@tmp{#2}\ifx#1\exf@tmp#3\fi}
3980 % \end{macrocode}
3981
3982 % \macro{\exf@href}
3983 % Display text with hyperreference passed by macro |#1|
3984 % (in case \ctanpkg{hyperref} is loaded
3985 % and the reference is defined and not empty):
3986 % \begin{macrocode}
3987 \newcommand{\exf@href}[2]{%
3988 \ifdefined#1\ifx#1\exf@empty#2\else%
3989 \ifdefined\hyperlink\protect\hyperlink{#1}{#2}\else#2\fi\fi\else#2\fi}
3990 % \end{macrocode}
3991
3992 % \macro{\exf@text}
3993 % \macro{\exf@ensuretext}
3994 % Two macros to display text in math mode.
3995 % |exf@text| is a wrapper for |\text| of \ctanpkg{amstext}
3996 % in case the latter package is loaded.
3997 % |exf@ensuretext| makes sure the text is set in text mode
3998 % or within an |\mbox| in math math:
3999 % \begin{macrocode}
4000 \newcommand{\exf@text}[1]{\ifdefined\text\text{#1}\else#1\fi}
4001 \newcommand{\exf@ensuretext}[1]{\ifmmode\mbox{#1}\else#1\fi}
4002 % \end{macrocode}
4003
4004 % \macro{\exf@addcontentsline}
4005 % Add a line to the table of contents unless macro in argument |#1| is empty:
4006 % \begin{macrocode}
4007 \newcommand{\exf@addcontentsline}[2]{%
4008 \ifx#1\exf@empty\else\addcontentsline{toc}{#1}{#2}\fi}
4009 % \end{macrocode}
4010
4011 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4012 % \paragraph{Auxiliary File Data Storage.}
4013 %
4014 % \macro{\exf@notedata}
4015 % Process stored data by handler:
4016 % \begin{macrocode}
4017 \newcommand{\exf@notedata}[3]{\csname exf@notedata@#1\endcsname{#2}{#3}}
4018 % \end{macrocode}
4019 % Make sure the macros in code written to the |.aux| file exist:
4020 % \begin{macrocode}
4021 \AtBeginDocument{\immediate\write\@auxout{%
4022 \string\providecommand{\string\exf@notedata}[3]{}}}
4023 % \end{macrocode}
4024 % \macro{\exf@writedata}
4025 % Write data to the |.aux| file:
4026 % \begin{macrocode}
4027 \newcommand{\exf@writedata}[3]%
4028 {\immediate\write\@auxout{\string\exf@notedata{#1}{#2}{#3}}}
4029 % \end{macrocode}
4030
4031 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4032 % \subsection{Package Setup}
4033 % \label{sec:imp-setup}
4034 %
4035 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4036 % \paragraph{Initialisation Options.}
4037 %
4038 % \macro{exframe.sty}
4039 % Some setup options are available while loading the package only.
4040 %
4041 % Configure names of main environments and counters:
4042 % \begin{macrocode}
4043 \def\exf@problemname{problem}
4044 \def\exf@subproblemname{sub\exf@problemname}
4045 \def\exf@solutionname{solution}
4046 \def\exf@sheetname{sheet}
4047 \def\exf@problemcounter{problem}
4048 \def\exf@subproblemcounter{sub\exf@problemcounter}
4049 \def\exf@solutioncounter{solution}
4050 \def\exf@sheetcounter{sheet}
4051 \define@key{exframe.sty}{problemenv}{\def\exf@problemname{#1}}
4052 \define@key{exframe.sty}{subproblemenv}{\def\exf@subproblemname{#1}}
4053 \define@key{exframe.sty}{solutionenv}{\def\exf@solutionname{#1}}
4054 \define@key{exframe.sty}{sheetenv}{\def\exf@sheetname{#1}}
4055 \define@key{exframe.sty}{problemcounter}{\def\exf@problemcounter{#1}}
4056 \define@key{exframe.sty}{subproblemcounter}{\def\exf@subproblemcounter{#1}}
4057 \define@key{exframe.sty}{solutioncounter}{\def\exf@solutioncounter{#1}}
4058 \define@key{exframe.sty}{sheetcounter}{\def\exf@sheetcounter{#1}}
4059 % \end{macrocode}
4060 % Whether to provide some extended configuration options
4061 % (available while loading only):
4062 % \begin{macrocode}
4063 \define@boolkey{exframe.sty}[exf@]{extdata}[true]{}
4064 \define@boolkey{exframe.sty}[exf@]{extstyle}[true]{}
4065 % \end{macrocode}
4066 % Whether to load package \ctanpkg{metastr}
4067 % (available while loading only):
4068 % \begin{macrocode}
4069 \define@boolkey{exframe.sty}[exf@]{metastr}[true]{}
4070 % \end{macrocode}
4071
4072 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4073 % \paragraph{Setup Options.}
4074 %
4075 % \macro{exf@setup}
4076 % All remaining setup options are available
4077 % also when the package is already loaded.
4078 %
4079 % Main switch for solutions:
4080 % \begin{macrocode}
4081 \define@boolkey{exf@setup}[]{solutions}[true]{}
4082 % \end{macrocode}
4083 % Switch for writing pdf metadata:
4084 % \begin{macrocode}
4085 \define@choicekey{exf@setup}{pdfdata}%
4086 {auto,manual,sheet,off}[auto]{\def\exf@metadata{#1}}
4087 \def\exf@metadata{auto}
4088 % \end{macrocode}
4089 % Write line number indicators to output file:
4090 % \begin{macrocode}
4091 \define@boolkey{exf@setup}[exf@]{lineno}[true]{}
4092 % \end{macrocode}
4093 % Prepare two-sided sheets:
4094 % \begin{macrocode}
4095 \define@boolkey{exf@setup}[exf@]{twoside}[true]{}
4096 % \end{macrocode}
4097 % Generate hyperreferences from solutions to corresponding problems:
4098 % \begin{macrocode}
4099 \define@boolkey{exf@setup}[exf@]{solutionhref}[true]{}
4100 \exf@solutionhreftrue
4101 % \end{macrocode}
4102 % Automatically generate labels for sheets and problems:
4103 % \begin{macrocode}
4104 \define@boolkey{exf@setup}[exf@]{autolabelsheet}[true]{}
4105 \define@boolkey{exf@setup}[exf@]{autolabelproblem}[true]{}
4106 % \end{macrocode}
4107 % Write warning message to document for better detection of inconsistencies:
4108 % \begin{macrocode}
4109 \define@boolkey{exf@setup}[exf@]{warntext}[true]{}
4110 % \end{macrocode}
4111 % Activate buffering of solutions:
4112 % \begin{macrocode}
4113 \define@boolkey{exf@setup}[exf@]{solutionbuf}[true]{}
4114 \exf@solutionbuftrue
4115 % \end{macrocode}
4116 % Activate buffering of problems:
4117 % \begin{macrocode}
4118 \define@boolkey{exf@setup}[exf@]{problembuf}[true]{}
4119 % \end{macrocode}
4120 % Activate buffering of subproblems:
4121 % \begin{macrocode}
4122 \define@boolkey{exf@setup}[exf@]{subproblembuf}[true]{}
4123 % \end{macrocode}
4124 % \macro{\exf@emptytestchar}
4125 % Redefine character for testing emptyness:
4126 % \begin{macrocode}
4127 \def\exf@emptytestchar{&}
4128 \define@key{exf@setup}{emptytestchar}{\def\exf@emptytestchar{#1}}
4129 % \end{macrocode}
4130
4131 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4132 % \paragraph{Processing.}
4133 %
4134 % Process global options while loading package:
4135 % \begin{macrocode}
4136 \ProcessOptionsX<exframe.sty,exf@setup>
4137 % \end{macrocode}
4138
4139 % \macro{\exercisesetup}
4140 % Configure package when package is already loaded:
4141 % \begin{macrocode}
4142 \newcommand{\exercisesetup}[1]{\exf@expsetkeys{exf@setup}{#1}}
4143 % \end{macrocode}
4144
4145 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4146 % \paragraph{Additional Packages.}
4147 %
4148 % Load \ctanpkg{metastr} package if desired:
4149 % \begin{macrocode}
4150 \ifexf@metastr
4151 \PassOptionsToPackage{course=true}{metastr}
4152 \RequirePackage{metastr}
4153 \fi
4154 % \end{macrocode}
4155
4156 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4157 % \paragraph{Solutions Only Processing.}
4158 %
4159 % \macro{onlysolutions}
4160 % Process block only in solutions mode:
4161 % \begin{macrocode}
4162 \newenvironment{onlysolutions}%
4163 {\ifsolutions\else%
4164 \let\endonlysolutions\endcomment%
4165 \expandafter\comment\fi}%
4166 {}
4167 % \end{macrocode}
4168
4169 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4170 % \subsection{Configuration}
4171 % \label{sec:imp-config}
4172 %
4173 % This section defines and describes the various configuration options
4174 % provided by the package. It also serves as a manual,
4175 % and most code can be recycled and adjusted for individual configurations:
4176 %
4177 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4178 % \paragraph{Definitions.}
4179 %
4180 % \macro{\exerciseconfig}
4181 % Set a configuration macro;
4182 % store definition in |exf@config@#2|;
4183 % use |\newcommand| for macros with arguments,
4184 % but (non-long) |\def| for plain definitions:
4185 % \begin{macrocode}
4186 \newcommand{\exerciseconfig}[1]{%
4187 \@ifnextchar[{\exf@configopt{#1}}{\exf@confignoopt{#1}}}
4188 \long\def\exf@configopt#1[#2]#3{%
4189 \exf@csdo\def{exf@config@#1}{}%
4190 \exf@csdo\renewcommand{exf@config@#1}[#2]{#3}}%
4191 \long\def\exf@confignoopt#1#2{\exf@csdo\def{exf@config@#1}{#2}}
4192 % \end{macrocode}
4193 % \macro{\exerciseconfigappend}
4194 % \macro{\exerciseconfigprepend}
4195 % Append to a (parameterless) configuration macro:
4196 % \begin{macrocode}
4197 \newcommand{\exerciseconfigappend}[2]{%
4198 \exf@csdo\exf@append@def{exf@config@#1}{#2}}
4199 \newcommand{\exerciseconfigprepend}[2]{%
4200 \exf@csdo\exf@prepend@def{exf@config@#1}{#2}}
4201 % \end{macrocode}
4202 % \macro{\getexerciseconfig}
4203 % Get configuration macro:
4204 % \begin{macrocode}
4205 \newcommand{\getexerciseconfig}[1]{\csname exf@config@#1\endcsname}
4206 % \end{macrocode}
4207 % \macro{\exerciseconfigempty}
4208 % Test whether configuration macro |#1| is empty;
4209 % execute |#2| if empty, otherwise execute |#3|:
4210 % \begin{macrocode}
4211 \newcommand{\exerciseconfigempty}[3]{\exf@csdo\ifx{exf@config@#1}\exf@empty%
4212 #2\else#3\fi}
4213 % \end{macrocode}
4214
4215 % \macro{\exerciseifemtpy}
4216 % \macro{\exerciseifnotempty}
4217 % Code to test whether |#1| (expanded) is empty;
4218 % execute |#2| if empty, otherwise execute |#3|:
4219 % \begin{macrocode}
4220 \long\def\exerciseifempty#1#2#3{%
4221 \if\exf@emptytestchar#1\exf@emptytestchar#2\else#3\fi}
4222 \long\def\exerciseifnotempty#1#2{%
4223 \if\exf@emptytestchar#1\exf@emptytestchar\else#2\fi}
4224 % \end{macrocode}
4225
4226 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4227 % \paragraph{Terms.}
4228 %
4229 % \macro{term...}
4230 % Terms for sheet, problem, solution and points
4231 % (for adjustment or internationalisation):
4232 % \begin{macrocode}
4233 \exerciseconfig{termsheet}{Sheet}
4234 \exerciseconfig{termsheets}{Sheets}
4235 \exerciseconfig{termproblem}{Problem}
4236 \exerciseconfig{termproblems}{Problems}
4237 \exerciseconfig{termsolution}{Solution}
4238 \exerciseconfig{termsolutions}{Solutions}
4239 \exerciseconfig{termpoint}{point}
4240 \exerciseconfig{termpoints}{points}
4241 % \end{macrocode}
4242
4243 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4244 % \paragraph{Formatting Styles.}
4245 %
4246 % \macro{style...}
4247 % Formatting styles to be applied for various parts of text.
4248 % Different styles will be applied in sequence from more general
4249 % to more specific.
4250 %
4251 % Basic style for all exercise text:
4252 % \begin{macrocode}
4253 \exerciseconfig{styletext}{\normalsize\normalfont}
4254 % \end{macrocode}
4255 % Style for problems:
4256 % \begin{macrocode}
4257 \exerciseconfig{styletextproblem}{}
4258 % \end{macrocode}
4259 % Style for solutions:
4260 % \begin{macrocode}
4261 \exerciseconfig{styletextsolution}{\footnotesize}
4262 % \end{macrocode}
4263 % Basic style for titles:
4264 % \begin{macrocode}
4265 \exerciseconfig{styletitle}{\bfseries}
4266 % \end{macrocode}
4267 % Style for problem titles:
4268 % \begin{macrocode}
4269 \exerciseconfig{styletitleproblem}{\large}
4270 % \end{macrocode}
4271 % Style for subproblem titles:
4272 % \begin{macrocode}
4273 \exerciseconfig{styletitlesubproblem}{}
4274 % \end{macrocode}
4275 % Style for solution titles:
4276 % \begin{macrocode}
4277 \exerciseconfig{styletitlesolution}{}
4278 % \end{macrocode}
4279 % Style for problem section title in solution block:
4280 % \begin{macrocode}
4281 \exerciseconfig{styletitlesolutionsproblem}{\small}
4282 % \end{macrocode}
4283 % Style for solution block title:
4284 % \begin{macrocode}
4285 \exerciseconfig{styletitlesolutions}{\normalsize}
4286 % \end{macrocode}
4287 % Style for problem block title:
4288 % \begin{macrocode}
4289 \exerciseconfig{styletitleproblems}{\Large}
4290 % \end{macrocode}
4291
4292 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4293 % \paragraph{Spacing.}
4294 %
4295 % \macro{skip...}
4296 % Spaces related to various elements.
4297 % Vertical space is typically combined with space declared elsewhere
4298 % using |\addvspace|.
4299 %
4300 % Space above problem environment:
4301 % \begin{macrocode}
4302 \exerciseconfig{skipproblemabove}{3.25ex plus 1ex minus 1.5ex}
4303 % \end{macrocode}
4304 % Space below problem environment:
4305 % \begin{macrocode}
4306 \exerciseconfig{skipproblembelow}{3pt plus 1pt minus 1pt}
4307 % \end{macrocode}
4308 % Space below or after problem title;
4309 % positive numbers generate vertical space
4310 % (problem body is started in new paragraph),
4311 % negative numbers generate horizontal space
4312 % (problem body continues on opening line):
4313 % \begin{macrocode}
4314 \exerciseconfig{skipproblemtitle}{3pt plus 1pt minus 1pt}
4315 % \end{macrocode}
4316 % Horizontal space between items in the problem opening line:
4317 % \begin{macrocode}
4318 \exerciseconfig{skipprobleminfo}{0.5em}
4319 % \end{macrocode}
4320 % Space for problem item and indentation;
4321 % |0pt| means no indentation and direct display of title;
4322 % positive numbers define an absolute amount;
4323 % |-1pt| (or any negative number) computes the amount of indentation
4324 % from the width of (standard) item plus separator:
4325 % \begin{macrocode}
4326 \exerciseconfig{skipproblemitem}{0pt}
4327 % \end{macrocode}
4328
4329 % Spaces related to subproblem environment;
4330 % analogous to spaces related to problem environment,
4331 % see above:
4332 % \begin{macrocode}
4333 \exerciseconfig{skipsubproblemabove}{1.5ex plus 0.5ex minus 1ex}
4334 \exerciseconfig{skipsubproblembelow}{1.5ex plus 0.5ex minus 1ex}
4335 \exerciseconfig{skipsubproblemtitle}{-1em}
4336 \exerciseconfig{skipsubprobleminfo}{0.25em}
4337 \exerciseconfig{skipsubproblemitem}{-1pt}
4338 % \end{macrocode}
4339
4340 % Spaces related to solution environment;
4341 % analogous to spaces related to problem environment,
4342 % \begin{macrocode}
4343 \exerciseconfig{skipsolutionabove}{0ex}
4344 \exerciseconfig{skipsolutionbelow}{1.5ex plus 0.5ex minus 1ex}
4345 \exerciseconfig{skipsolutiontitle}{-0.5em}
4346 \exerciseconfig{skipsolutioninfo}{0.25em}
4347 % \end{macrocode}
4348 % |skipsolutionitem| and |skipsolutionitemsub|
4349 % are analogous to |skipproblemitem| described above;
4350 % they apply to solutions corresponding to problems and subproblems,
4351 % respectively:
4352 % \begin{macrocode}
4353 \exerciseconfig{skipsolutionitem}{0pt}
4354 \exerciseconfig{skipsolutionitemsub}{0pt}
4355 % \end{macrocode}
4356
4357 % Spaces related to solution blocks;
4358 % space above and below a solution block:
4359 % \begin{macrocode}
4360 \exerciseconfig{skipsolutionsabove}{1.5ex plus 0.5ex minus 1ex}
4361 \exerciseconfig{skipsolutionsbelow}{1.5ex plus 0.5ex minus 1ex}
4362 % \end{macrocode}
4363 % Space above problem titles in a solution block:
4364 % \begin{macrocode}
4365 \exerciseconfig{skipsolutionsproblemabove}{1.0ex plus 0ex minus 0.5ex}
4366 % \end{macrocode}
4367 % Space following problem titles in a solution block
4368 % (with legacy definition):
4369 % \begin{macrocode}
4370 \exerciseconfig{skipsolutionsproblemtitle}{1.0ex plus 0ex minus 0.5ex}
4371 \exerciseconfig{skipsolutionsproblem}{\exf@config@skipsolutionsproblemtitle}
4372 % \end{macrocode}
4373 % Space following title of a solution block:
4374 % \begin{macrocode}
4375 \exerciseconfig{skipsolutionstitle}{1.0ex plus 0ex minus 0.5ex}
4376 % \end{macrocode}
4377
4378 % Spaces related to problem blocks;
4379 % space above and below a problem block:
4380 % \begin{macrocode}
4381 \exerciseconfig{skipproblemsabove}{1.5ex plus 0.5ex minus 1ex}
4382 \exerciseconfig{skipproblemsbelow}{1.5ex plus 0.5ex minus 1ex}
4383 % \end{macrocode}
4384 % Space following title of a problem block:
4385 % \begin{macrocode}
4386 \exerciseconfig{skipproblemstitle}{1.0ex plus 0ex minus 0.5ex}
4387 % \end{macrocode}
4388
4389 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4390 % \paragraph{Hook Code.}
4391 %
4392 % \macro{insert...}
4393 % Code to process data and to insert text at various points of processing.
4394 %
4395 % Code to generate the title for a sheet;
4396 % minimalistic default to display the sheet title:
4397 % \begin{macrocode}
4398 \exerciseconfig{insertsheettitle}{\centerline{\getsheetdata{title}}}
4399 % \end{macrocode}
4400 % Code to clear the page at the start and at the end of a new sheet:
4401 % \begin{macrocode}
4402 \exerciseconfig{insertsheetclearpage}{\exercisecleardoublepage}
4403 % \end{macrocode}
4404 % Code to insert before a sheet is displayed:
4405 % \begin{macrocode}
4406 \exerciseconfig{insertsheetbefore}{}
4407 % \end{macrocode}
4408 % Code to insert after a sheet is displayed:
4409 % \begin{macrocode}
4410 \exerciseconfig{insertsheetafter}{}
4411 % \end{macrocode}
4412 % Code to insert before a solution block is displayed:
4413 % \begin{macrocode}
4414 \exerciseconfig{insertsolutionsbefore}{}
4415 % \end{macrocode}
4416 % Code to insert after a solution block is displayed:
4417 % \begin{macrocode}
4418 \exerciseconfig{insertsolutionsafter}{}
4419 % \end{macrocode}
4420 % Code to insert before a problem block is displayed:
4421 % \begin{macrocode}
4422 \exerciseconfig{insertproblemsbefore}{}
4423 % \end{macrocode}
4424 % Code to insert after a problem block is displayed:
4425 % \begin{macrocode}
4426 \exerciseconfig{insertproblemsafter}{}
4427 % \end{macrocode}
4428 % Code to insert before a problem is displayed:
4429 % \begin{macrocode}
4430 \exerciseconfig{insertproblembefore}{}
4431 % \end{macrocode}
4432 % Code to insert after a problem is displayed:
4433 % \begin{macrocode}
4434 \exerciseconfig{insertproblemafter}{}
4435 % \end{macrocode}
4436 % Code to insert between a problem and its solution
4437 % (if style |solutionbelow| is |problem|):
4438 % \begin{macrocode}
4439 \exerciseconfig{insertproblemsolution}{}
4440 % \end{macrocode}
4441 % Code to insert text into the problem opening line
4442 % by means of |\addprobleminfo|:
4443 % \begin{macrocode}
4444 \exerciseconfig{insertprobleminfo}{}
4445 % \end{macrocode}
4446 % Code to determine the display of problems:
4447 % \begin{macrocode}
4448 \exerciseconfig{insertproblemselect}[1]{}
4449 % \end{macrocode}
4450 % Analogous definitions for subproblems:
4451 % \begin{macrocode}
4452 \exerciseconfig{insertsubproblembefore}{}
4453 \exerciseconfig{insertsubproblemafter}{}
4454 \exerciseconfig{insertsubprobleminfo}{}
4455 \exerciseconfig{insertsubproblemsolution}{}
4456 \exerciseconfig{insertsubproblemselect}[1]{}
4457 % \end{macrocode}
4458 % Analogous definitions for solutions:
4459 % \begin{macrocode}
4460 \exerciseconfig{insertsolutionbefore}{}
4461 \exerciseconfig{insertsolutionafter}{}
4462 \exerciseconfig{insertsolutioninfo}{}
4463 % \end{macrocode}
4464
4465 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4466 % \paragraph{Text Composition for Environments.}
4467 %
4468 % \macro{compose...}
4469 % Macros to generate text for various situations.
4470 % Preferably the output is plain text without formatting,
4471 % but in some situations it may be required to
4472 % address formatting in these macros.
4473 %
4474 % Default separator for items:
4475 % \begin{macrocode}
4476 \exerciseconfig{composeitemsep}{\ }
4477 % \end{macrocode}
4478 % Compose sheet title;
4479 % arguments are sheet number and raw title (empty if not specified);
4480 % default is ``Sheet |#1|'' or given title ``|#2|'':
4481 % \begin{macrocode}
4482 \exerciseconfig{composetitlesheet}[2]%
4483 {\exerciseifempty{#2}{\getexerciseconfig{termsheet} #1}{#2}}
4484 % \end{macrocode}
4485 % Compose sheet title for pdf metadata;
4486 % arguments are sheet number and raw title:
4487 % \begin{macrocode}
4488 \exerciseconfig{composemetasheet}[2]%
4489 {\getexerciseconfig{composetitlesheet}{#1}{#2}}
4490 % \end{macrocode}
4491 % Compose sheet title for table of contents;
4492 % arguments are sheet number and raw title:
4493 % \begin{macrocode}
4494 \exerciseconfig{composetocsheet}[2]%
4495 {\exerciseifempty{#2}{\getexerciseconfig{termsheet} #1}{#2}}
4496 % \end{macrocode}
4497 % Problem item separator, delimiter:
4498 % \begin{macrocode}
4499 \exerciseconfig{composeitemproblemsep}{\getexerciseconfig{composeitemsep}}
4500 \exerciseconfig{composeitemproblemdelim}{.}
4501 % \end{macrocode}
4502 % Compose problem item; argument is problem number:
4503 % \begin{macrocode}
4504 \exerciseconfig{composeitemproblem}[1]%
4505 {#1\getexerciseconfig{composeitemproblemdelim}}
4506 % \end{macrocode}
4507 % Unnamed problem separator, delimiter:
4508 % \begin{macrocode}
4509 \exerciseconfig{composebareproblemsep}{ }
4510 \exerciseconfig{composebareproblemdelim}{}
4511 % \end{macrocode}
4512 % Compose unnamed problem title; arguments are problem number and name;
4513 % includes exception for legacy behaviour:
4514 % \begin{macrocode}
4515 \exerciseconfig{composebareproblem}[1]%
4516 {\getexerciseconfig{termproblem}\getexerciseconfig{composebareproblemsep}%
4517 \ifx\exf@config@composebareproblemdelim\exf@config@composeitemproblemdelim%
4518 \getexerciseconfig{composeitemproblem}{#1}\else%
4519 #1\getexerciseconfig{composebareproblemdelim}\fi}
4520 % \end{macrocode}
4521 % Named problem separator, delimiter:
4522 % \begin{macrocode}
4523 \exerciseconfig{composenamedproblemsep}{ }
4524 \exerciseconfig{composenamedproblemdelim}{.}
4525 % \end{macrocode}
4526 % Compose named problem title; arguments are problem number and name;
4527 % includes exception for legacy behaviour:
4528 % \begin{macrocode}
4529 \exerciseconfig{composenamedproblem}[2]%
4530 {\ifx\exf@config@composenamedproblemdelim\exf@config@composeitemproblemdelim%
4531 \getexerciseconfig{composeitemproblem}{#1}\else%
4532 #1\getexerciseconfig{composenamedproblemdelim}\fi%
4533 \getexerciseconfig{composenamedproblemsep}#2}
4534 % \end{macrocode}
4535 % Compose problem title;
4536 % arguments are problem number (empty if item is split off)
4537 % and raw title (empty if not specified);
4538 % default is ``Problem |#1|'' or ``|#1|. |#2|'':
4539 % \begin{macrocode}
4540 \exerciseconfig{composetitleproblem}[2]{\exerciseifempty{#1}%
4541 {\exerciseifempty{#2}{}{#2}}%
4542 {\exerciseifempty{#2}{\getexerciseconfig{composebareproblem}{#1}}%
4543 {\getexerciseconfig{composenamedproblem}{#1}{#2}}}}
4544 % \end{macrocode}
4545 % Compose problem title for table of contents;
4546 % arguments are problem number and raw title:
4547 % \begin{macrocode}
4548 \exerciseconfig{composetocproblem}[2]%
4549 {\exerciseifempty{#2}{\getexerciseconfig{termproblem} #1}%
4550 {#1\getexerciseconfig{composenamedproblemdelim} #2}}
4551 % \end{macrocode}
4552 % Subproblem item separator, delimiter:
4553 % \begin{macrocode}
4554 \exerciseconfig{composeitemsubproblemsep}{\getexerciseconfig{composeitemsep}}
4555 \exerciseconfig{composeitemsubproblemdelim}{}
4556 % \end{macrocode}
4557 % Compose subproblem item; argument is subproblem number:
4558 % \begin{macrocode}
4559 \exerciseconfig{composeitemsubproblem}[1]%
4560 {#1\getexerciseconfig{composeitemsubproblemdelim}}
4561 % \end{macrocode}
4562 % Compose subproblem title;
4563 % argument is subproblem number:
4564 % \begin{macrocode}
4565 \exerciseconfig{composetitlesubproblem}[1]%
4566 {\getexerciseconfig{composeitemsubproblem}{#1}}
4567 % \end{macrocode}
4568 % Solution item separator, delimiter:
4569 % \begin{macrocode}
4570 \exerciseconfig{composeitemsolutionsep}{\getexerciseconfig{composeitemsep}}
4571 \exerciseconfig{composeitemsolutiondelim}{:}
4572 % \end{macrocode}
4573 % Compose solution item; arguments are problem and subproblem number:
4574 % \begin{macrocode}
4575 \exerciseconfig{composeitemsolution}[2]{}
4576 \exerciseconfig{composeitemsolutionsub}[2]%
4577 {\getexerciseconfig{composeitemsubproblem}{#2}}
4578 % \end{macrocode}
4579 % Compose solution item for first solution in a problem section;
4580 % arguments are problem and subproblem number:
4581 % \begin{macrocode}
4582 \exerciseconfig{composeitemsolutionfirst}[2]%
4583 {\getexerciseconfig{composeitemsolution}{#1}{#2}}
4584 \exerciseconfig{composeitemsolutionfirstsub}[2]%
4585 {\getexerciseconfig{composeitemsolutionsub}{#1}{#2}}
4586 % \end{macrocode}
4587 % Compose title for single solution
4588 % (solution intro if |solutionbelow| is |here| or |subproblem|);
4589 % arguments are corresponding problem and subproblem number:
4590 % \begin{macrocode}
4591 \exerciseconfig{composetitlesolutionsingle}[2]%
4592 {\getexerciseconfig{termsolution}%
4593 \getexerciseconfig{composeitemsolutiondelim}}
4594 % \end{macrocode}
4595 % Compose title for one out of several solutions
4596 % (solution intro if |solutionbelow| is |problem|, |sheet| or |manual|);
4597 % arguments are corresponding problem and subproblem number:
4598 % \begin{macrocode}
4599 \exerciseconfig{composetitlesolutionproblem}[1]{}
4600 \exerciseconfig{composetitlesolutionsubproblem}[2]%
4601 {\getexerciseconfig{composeitemsubproblem}{#2}}
4602 \exerciseconfig{composetitlesolutionmulti}[2]{\exerciseifempty{#2}%
4603 {\getexerciseconfig{composetitlesolutionproblem}{#1}}%
4604 {\getexerciseconfig{composetitlesolutionsubproblem}{#1}{#2}}}
4605 % \end{macrocode}
4606 % Compose table of contents line for solution;
4607 % arguments are problem number and raw title:
4608 % \begin{macrocode}
4609 \exerciseconfig{composetocsolution}[2]%
4610 {\getexerciseconfig{composetocproblem}{#1}{#2}}
4611 % \end{macrocode}
4612 % Compose title for solution block:
4613 % \begin{macrocode}
4614 \exerciseconfig{composetitlesolutions}%
4615 {\getexerciseconfig{termsolutions}}
4616 % \end{macrocode}
4617 % Compose title for problem block:
4618 % \begin{macrocode}
4619 \exerciseconfig{composetitleproblems}%
4620 {\getexerciseconfig{termproblems}}
4621 % \end{macrocode}
4622 % Compose table of contents line for solution block:
4623 % \begin{macrocode}
4624 \exerciseconfig{composetocsolutions}%
4625 {\getexerciseconfig{composetitlesolutions}}
4626 % \end{macrocode}
4627 % Compose table of contents line for problem block:
4628 % \begin{macrocode}
4629 \exerciseconfig{composetocproblems}%
4630 {\getexerciseconfig{composetitleproblems}}
4631 % \end{macrocode}
4632 % Compose sectional title for solution following a single problem
4633 % (problem section intro if |solutionbelow| is |problem|);
4634 % arguments are problem number and raw title:
4635 % \begin{macrocode}
4636 \exerciseconfig{composetitlesolutionsproblemsingle}[2]%
4637 {\getexerciseconfig{termsolution}}
4638 % \end{macrocode}
4639 % Compose sectional title for solution of one problem within a solution block
4640 % (problem section intro if |solutionbelow| is |sheet| or |manual|);
4641 % arguments are problem number and raw title:
4642 % \begin{macrocode}
4643 \exerciseconfig{composetitlesolutionsproblemmulti}[2]%
4644 {\exerciseifempty{#2}{\getexerciseconfig{composebareproblem}{#1}}%
4645 {\getexerciseconfig{composenamedproblem}{#1}{#2}}}
4646 % \end{macrocode}
4647 % Compose label:
4648 % \begin{macrocode}
4649 \exerciseconfig{composeitemsolutionlabel}[2]{#1#2}
4650 % \end{macrocode}
4651
4652 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4653 % \paragraph{Points.}
4654 %
4655 % Compose number of points:
4656 % \begin{macrocode}
4657 \exerciseconfig{composepointsnum}[1]{#1}
4658 % \end{macrocode}
4659 % Compose number of points followed by `points';
4660 % use singular `point' for $1$:
4661 % \begin{macrocode}
4662 \exerciseconfig{composepoints}[1]{\getexerciseconfig{composepointsnum}{#1}~%
4663 \ifdim #1pt=1pt\getexerciseconfig{termpoint}%
4664 \else\getexerciseconfig{termpoints}\fi}
4665 % \end{macrocode}
4666 % Compose points declaration for use in opening line:
4667 % \begin{macrocode}
4668 \exerciseconfig{composepointsstart}[1]{(\getexerciseconfig{composepoints}{#1})}
4669 % \end{macrocode}
4670 % Compose points declaration for use in margin:
4671 % \begin{macrocode}
4672 \exerciseconfig{composepointsmargin}[1]{\getexerciseconfig{composepoints}{#1}}
4673 % \end{macrocode}
4674 % Compose points declaration for use in text:
4675 % \begin{macrocode}
4676 \exerciseconfig{composepointsbody}[1]{(\getexerciseconfig{composepoints}{#1})}
4677 % \end{macrocode}
4678 % Compose points declaration for use in sheet data:
4679 % \begin{macrocode}
4680 \exerciseconfig{composepointssheet}[1]{%
4681 \exerciseifnotempty{#1}{\getexerciseconfig{composepoints}{#1}}}
4682 % \end{macrocode}
4683 % Compose points declaration for solution with comment:
4684 % \begin{macrocode}
4685 \exerciseconfig{composepointsaward}[2]%
4686 {(\getexerciseconfig{composepoints}{#1}\exerciseifnotempty{#2}{; #2})}
4687 % \end{macrocode}
4688 % Compose alternative points for solution declaration with comment:
4689 % \begin{macrocode}
4690 \exerciseconfig{composepointsawardalt}[2]%
4691 {(\getexerciseconfig{composepoints}{#1}*\exerciseifnotempty{#2}{; #2})}
4692 % \end{macrocode}
4693
4694 % Compose pairs of points; omit 0 components:
4695 % \begin{macrocode}
4696 \exerciseconfig{composepointspair}[2]{%
4697 \ifdim#2pt=0pt%
4698 \getexerciseconfig{composepoints}{#1}%
4699 \else\ifdim#1pt=0pt%
4700 +\getexerciseconfig{composepoints}{#2}%
4701 \else%
4702 \getexerciseconfig{composepointsnum}{#1}+%
4703 \getexerciseconfig{composepointsnum}{#2}~%
4704 \getexerciseconfig{termpoints}%
4705 \fi\fi}
4706 % \end{macrocode}
4707 % Compose pairs of points for designated use;
4708 % recycle plain definition if no bonus points given:
4709 % \begin{macrocode}
4710 \exerciseconfig{composepointspairbody}[2]{%
4711 \ifdim#2pt=0pt\getexerciseconfig{composepointsbody}{#1}\else%
4712 (\getexerciseconfig{composepointspair}{#1}{#2})\fi}
4713 \exerciseconfig{composepointspairstart}[2]{%
4714 \ifdim#2pt=0pt\getexerciseconfig{composepointsstart}{#1}\else%
4715 (\getexerciseconfig{composepointspair}{#1}{#2})\fi}
4716 \exerciseconfig{composepointspairmargin}[2]{%
4717 \ifdim#2pt=0pt\getexerciseconfig{composepointsmargin}{#1}\else%
4718 \getexerciseconfig{composepointspair}{#1}{#2}\fi}
4719 \exerciseconfig{composepointspairsheet}[2]{%
4720 \ifdim#2pt=0pt\getexerciseconfig{composepointssheet}{#1}\else%
4721 \getexerciseconfig{composepointspair}{#1}{#2}\fi}
4722 \exerciseconfig{composepointspairaward}[3]{%
4723 \ifdim#2pt=0pt\getexerciseconfig{composepointsaward}{#1}{#3}\else%
4724 (\getexerciseconfig{composepointspair}{#1}{#2}%
4725 \exerciseifnotempty{#3}{; #3})\fi}
4726 \exerciseconfig{composepointspairawardalt}[3]{%
4727 \ifdim#2pt=0pt\getexerciseconfig{composepointsawardalt}{#1}{#3}\else%
4728 (\getexerciseconfig{composepointspair}{#1}{#2}*%
4729 \exerciseifnotempty{#3}{; #3})\fi}
4730 % \end{macrocode}
4731 % Compose pairs of points for designated situations:
4732 % \begin{macrocode}
4733 \exerciseconfig{composepointspairbodyproblem}[2]{%
4734 \getexerciseconfig{composepointspairbody}{#1}{#2}}
4735 \exerciseconfig{composepointspairbodysubproblem}[2]{%
4736 \getexerciseconfig{composepointspairbody}{#1}{#2}}
4737 \exerciseconfig{composepointspairbodysolution}[2]{%
4738 \getexerciseconfig{composepointspairbody}{#1}{#2}}
4739 \exerciseconfig{composepointspairstartproblem}[2]{%
4740 \getexerciseconfig{composepointspairstart}{#1}{#2}}
4741 \exerciseconfig{composepointspairstartsubproblem}[2]{%
4742 \getexerciseconfig{composepointspairstart}{#1}{#2}}
4743 \exerciseconfig{composepointspairstartsolution}[2]{%
4744 \getexerciseconfig{composepointspairstart}{#1}{#2}}
4745 \exerciseconfig{composepointspairmarginproblem}[2]{%
4746 \getexerciseconfig{composepointspairmargin}{#1}{#2}}
4747 \exerciseconfig{composepointspairmarginsubproblem}[2]{%
4748 \getexerciseconfig{composepointspairmargin}{#1}{#2}}
4749 \exerciseconfig{composepointspairmarginsolution}[2]{%
4750 \getexerciseconfig{composepointspairmargin}{#1}{#2}}
4751 % \end{macrocode}
4752
4753 % Display points in the margin:
4754 % \begin{macrocode}
4755 \exerciseconfig{insertpointsmargin}[1]{\marginpar{\footnotesize #1}}
4756 \exerciseconfig{insertpointsmarginproblem}[1]{%
4757 \getexerciseconfig{insertpointsmargin}{#1}}
4758 \exerciseconfig{insertpointsmarginsubproblem}[1]{%
4759 \getexerciseconfig{insertpointsmargin}{#1}}
4760 \exerciseconfig{insertpointsmarginsolution}[1]{%
4761 \getexerciseconfig{insertpointsmargin}{#1}}
4762 % \end{macrocode}
4763
4764 % Display warning about points mismatch:
4765 % \begin{macrocode}
4766 \exerciseconfig{insertwarnpoints}[3]%
4767 {\textbf{points mismatch for #1 (#2 determined vs.\ #3 given)}}
4768 % \end{macrocode}
4769 % Display warning about points changed:
4770 % \begin{macrocode}
4771 \exerciseconfig{insertwarnpointsrerun}[1]%
4772 {\textbf{points changed for #1 (please recompile)}}
4773 % \end{macrocode}
4774
4775 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4776 % \paragraph{Counters.}
4777 %
4778 % Define counter display via configuration interface:
4779 % \begin{macrocode}
4780 \exerciseconfig{countersheet}{\arabic{\exf@sheetcounter}}
4781 \exerciseconfig{counterproblem}{\arabic{\exf@problemcounter}}
4782 \exerciseconfig{counterproblemmax}{10}
4783 \exerciseconfig{countersubproblem}{\alph{\exf@subproblemcounter})}
4784 \exerciseconfig{countersubproblemmax}{m)}
4785 \exerciseconfig{countersheetequation}{\arabic{equation}}
4786 \exerciseconfig{counterproblemequation}{P\arabic{equation}}
4787 \exerciseconfig{countersolutionequation}{S\arabic{equation}}
4788 % \end{macrocode}
4789
4790 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4791 % \paragraph{Further Definitions.}
4792 %
4793 % \macro{tagsheet}
4794 % \macro{tagproblem}
4795 % \macro{tagsubproblem}
4796 % Templates for automatic generation of tags:
4797 % \begin{macrocode}
4798 \exerciseconfig{tagsheet}{\arabic{\exf@sheetcounter}}
4799 \exerciseconfig{tagproblem}{\csname the\exf@problemcounter\endcsname}
4800 \exerciseconfig{tagsubproblem}{\problemtag-\arabic{\exf@subproblemcounter}}
4801 % \end{macrocode}
4802
4803 % \macro{labelsheet}
4804 % \macro{labelproblem}
4805 % \macro{labelsubproblem}
4806 % Templates for automatic generation of labels from tags:
4807 % \begin{macrocode}
4808 \exerciseconfig{labelsheet}[1]{sheet:#1}
4809 \exerciseconfig{labelproblem}[1]{prob:#1}
4810 \exerciseconfig{labelsubproblem}[1]{\getexerciseconfig{labelproblem}{#1}}
4811 % \end{macrocode}
4812
4813 % \macro{toclevel...}
4814 % Table of contents levels for sheets, problems,
4815 % solutions of problems and solution blocks;
4816 % empty means no writing to table of contents:
4817 % \begin{macrocode}
4818 \exerciseconfig{toclevelsheet}{}
4819 \exerciseconfig{toclevelproblem}{}
4820 \exerciseconfig{toclevelproblems}{}
4821 \exerciseconfig{toclevelsolution}{}
4822 \exerciseconfig{toclevelsolutions}{}
4823 % \end{macrocode}
4824
4825 % \macro{extsolutions}
4826 % \macro{extproblems}
4827 % Filename extension for solution and problem blocks:
4828 % \begin{macrocode}
4829 \exerciseconfig{extsolutions}{.sol}
4830 \exerciseconfig{extproblems}{.prb}
4831 % \end{macrocode}
4832
4833 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4834 % \subsection{Styles}
4835 % \label{sec:imp-styles}
4836 %
4837 % Styles are meant as a way to adjust
4838 % several configuration options at the same time
4839 % to achieve a consistent layout in some regard.
4840 % Useful examples can be found among the
4841 % extended exercise styles.
4842 % They can serve a starting point for further
4843 % custom styles.
4844 %
4845 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4846 % \paragraph{Exercise Styles Code.}
4847 %
4848 % \macro{\defexercisestylearg}
4849 % Define a style with an argument:
4850 % \begin{macrocode}
4851 \newcommand{\defexercisestylearg}[3][]{%
4852 \def\exf@tmp{#1}\ifx\exf@tmp\exf@empty%
4853 \define@key{exf@style}{#2}{#3}\else%
4854 \define@key{exf@style}{#2}[#1]{#3}\fi}
4855 % \end{macrocode}
4856 % \macro{\defexercisestyle}
4857 % Define a style with a boolean argument;
4858 % execute code onlf if true:
4859 % \begin{macrocode}
4860 \newcommand{\defexercisestyle}[2]{%
4861 \exf@csdotwo\long\def{exf@style@code@#1}{#2}%
4862 \exf@exparg{\define@boolkey{exf@style}[exf@style@]{#1}[true]}%
4863 {\csname ifexf@style@#1\endcsname\csname exf@style@code@#1\endcsname\fi}}
4864 % \end{macrocode}
4865 % \macro{\exercisestyle}
4866 % Process styles:
4867 % \begin{macrocode}
4868 \newcommand{\exercisestyle}[1]{\exf@expsetkeys{exf@style}{#1}}
4869 % \end{macrocode}
4870
4871 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4872 % \paragraph{Default Exercise Styles.}
4873 %
4874 % \macro{problemmanual}
4875 % Delay display of problems:
4876 % \begin{macrocode}
4877 \define@boolkey{exf@style}[exf@]{problemmanual}[true]{}
4878 \exf@problemmanualfalse
4879 % \end{macrocode}
4880 %
4881 % \macro{solutionbelow}
4882 % Choose location for solutions:
4883 % \begin{macrocode}
4884 \def\exf@solutionbelow{subproblem}
4885 \define@choicekey{exf@style}{solutionbelow}%
4886 {here,subproblem,subproblem*,problem,problem*,sheet,manual}%
4887 {\ifexf@solfile@open\else\gdef\exf@solutionbelow{#1}\fi}
4888 % \end{macrocode}
4889 %
4890 % \macro{sheetequation}
4891 % \macro{problemequation}
4892 % \macro{solutionequation}
4893 % Use separate equation counters for sheets, problems and solutions:
4894 % \begin{macrocode}
4895 \defexercisestyle{sheetequation}{}
4896 \defexercisestyle{problemequation}{}
4897 \defexercisestyle{solutionequation}{}
4898 \exf@style@solutionequationtrue
4899 % \end{macrocode}
4900 %
4901 % \macro{problempointsat}
4902 % \macro{subproblempointsat}
4903 % \macro{solutionpointsat}
4904 % Choose where points of (sub)problems and solutions are displayed:
4905 % \begin{macrocode}
4906 \def\exf@pointsat{start}
4907 \define@choicekey{exf@style}{problempointsat}%
4908 {start,start*,margin,end,manual,off}{\def\exf@pointsat{#1}}
4909 \define@choicekey{exf@style}{pointsat}%
4910 {start,start*,margin,end,manual,off}{\def\exf@pointsat{#1}}
4911 \def\exf@subpointsat{end}
4912 \define@choicekey{exf@style}{subproblempointsat}%
4913 {start,start*,margin,end,manual,off}{\def\exf@subpointsat{#1}}
4914 \define@choicekey{exf@style}{subpointsat}%
4915 {start,start*,margin,end,manual,off}{\def\exf@subpointsat{#1}}
4916 \def\exf@solpointsat{off}
4917 \define@choicekey{exf@style}{solutionpointsat}%
4918 {start,start*,margin,end,manual,off}{\def\exf@solpointsat{#1}}
4919 \define@choicekey{exf@style}{solpointsat}%
4920 {start,start*,margin,end,manual,off}{\def\exf@solpointsat{#1}}
4921 % \end{macrocode}
4922 %
4923 % \macro{problemby}
4924 % \macro{equationby}
4925 % Declare problems or equations as subcounter of other counter:
4926 % \begin{macrocode}
4927 \defexercisestylearg{problemby}{\exf@numberproblemwithin{#1}}
4928 \defexercisestylearg{equationby}{\exf@numberequationwithin{#1}}
4929 % \end{macrocode}
4930 %
4931 % \macro{pagebysheet}
4932 % \macro{problembysheet}
4933 % \macro{equationbysheet}
4934 % Number pages, problems or equations by sheet:
4935 % \begin{macrocode}
4936 \defexercisestyle{pagebysheet}{%
4937 \def\thepage{\csname the\exf@sheetcounter\endcsname.\arabic{page}}%
4938 \def\theHpage{\csname theH\exf@sheetcounter\endcsname.\arabic{page}}%
4939 \exerciseconfigappend{insertsheetbefore}{\setcounter{page}{1}}}
4940 \defexercisestyle{problembysheet}%
4941 {\exf@numberproblemwithin{\exf@sheetcounter}}
4942 \defexercisestyle{equationbysheet}%
4943 {\exf@numberequationwithin{\exf@sheetcounter}}
4944 % \end{macrocode}
4945 %
4946 % \macro{fracpoints}
4947 % Use vulgar fractions to display binary fractional points:
4948 % \begin{macrocode}
4949 \defexercisestyle{fracpoints}%
4950 {\exerciseconfig{composepointsnum}[1]{\protect\showfracpoints{##1}}}
4951 % \end{macrocode}
4952 %
4953 % \macro{twoside}
4954 % Use two-sided layout for sheets:
4955 % \begin{macrocode}
4956 \defexercisestylearg[true]{twoside}{\exercisesetup{twoside={#1}}}
4957 % \end{macrocode}
4958 %
4959 % \macro{subproblemdelimitem}
4960 % to append delimiter `)' to subproblem reference labels
4961 % Use two-sided layout for sheets:
4962 % \begin{macrocode}
4963 \defexercisestyle{subproblemdelimitem}%
4964 {\exerciseconfig{composeitemsubproblemdelim}{)}%
4965 \exerciseconfig{countersubproblem}{\alph{\exf@subproblemcounter}}%
4966 \exerciseconfig{countersubproblemmax}{m}}
4967 % \end{macrocode}
4968
4969 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4970 % \paragraph{Extended Exercise Styles.}
4971 %
4972 % Declare more specific styles:
4973 % \begin{macrocode}
4974 \ifexf@extstyle
4975 % \end{macrocode}
4976 %
4977 % \macro{contents}
4978 % Add sheets and problems to table of contents:
4979 % \begin{macrocode}
4980 \defexercisestyle{contents}{%
4981 \exerciseconfig{toclevelsheet}{section}%
4982 \exerciseconfig{toclevelproblem}{subsection}}
4983 % \end{macrocode}
4984 % \macro{solutionsf}
4985 % Use sans serif font for solutions:
4986 % \begin{macrocode}
4987 \defexercisestyle{solutionsf}{%
4988 \exerciseconfigappend{styletextsolution}{\sffamily\let\itshape\slshape}}
4989 % \end{macrocode}
4990 % \macro{solutiondimproblem}
4991 % Dim problem text if solutions are displayed:
4992 % \begin{macrocode}
4993 \defexercisestyle{solutiondimproblem}{%
4994 \RequirePackage{color}%
4995 \exerciseconfigappend{styletextsolution}{\color[gray]{0}}%
4996 \exerciseconfigappend{styletextproblem}{\color[gray]{0.2}}}
4997 % \end{macrocode}
4998 % \macro{solutionsep}
4999 % Separate solutions by horizontal lines:
5000 % \begin{macrocode}
5001 \defexercisestyle{solutionsep}{%
5002 \exerciseconfig{insertsolutionsbefore}{\hrule\nopagebreak[3]\vspace{0.5ex}}%
5003 \exerciseconfig{insertsolutionsafter}%
5004 {\removelastskip\nopagebreak[3]\vspace{1.0ex}\hrule}}
5005 % \end{macrocode}
5006 % \macro{plainheader}
5007 % Declare a simple sheet header with some configurable options;
5008 % the configuration options |styleheader...| define font styles,
5009 % |skipheaderbelow| the space below the header and
5010 % |composeheaderbelow...| some auxiliary text to be displayed
5011 % on the line below the header:
5012 % \begin{macrocode}
5013 \defexercisestyle{plainheader}{%
5014 \exerciseconfig{styleheadertitle}{\Large\bfseries}%
5015 \exerciseconfig{styleheadercourse}{\sffamily}%
5016 \exerciseconfig{styleheaderbelow}{\footnotesize}%
5017 \exerciseconfig{skipheaderbelow}{3ex}%
5018 \exerciseconfig{composeheaderbelowleft}{}%
5019 \exerciseconfig{composeheaderbelowright}{}%
5020 \exerciseconfig{composeheaderbelowcenter}{}%
5021 \exerciseconfig{insertsheettitle}{\noindent%
5022 \begin{minipage}{\textwidth}%
5023 {\getexerciseconfig{styleheadertitle}%
5024 \makebox[0pt][l]{\getexercisedata{course}}%
5025 \hfill\makebox[0pt][r]{\getsheetdata{title}}\par}%
5026 {\getexerciseconfig{styleheadercourse}%
5027 \makebox[0pt][l]{\getexercisedata{institution}%
5028 \exercisedataempty{period}{}{, \getexercisedata{period}}}%
5029 \hfill\makebox[0pt][r]{\getexercisedata{instructor}}%
5030 \vphantom{g}\par}%
5031 \hrule%
5032 {\def\tmp{}%
5033 \exerciseconfigempty{composeheaderbelowleft}{}{\def\tmp{.}}%
5034 \exerciseconfigempty{composeheaderbelowcenter}{}{\def\tmp{.}}%
5035 \exerciseconfigempty{composeheaderbelowright}{}{\def\tmp{.}}%
5036 \exerciseifnotempty{\tmp}%
5037 {\getexerciseconfig{styleheaderbelow}\vphantom{\^A}%
5038 \makebox[0pt][l]{\getexerciseconfig{composeheaderbelowleft}}%
5039 \hfill\makebox[0pt][c]{\getexerciseconfig{composeheaderbelowcenter}}%
5040 \hfill\makebox[0pt][r]{\getexerciseconfig{composeheaderbelowright}}%
5041 \vspace*{-\baselineskip}\vspace*{-\parskip}\par}}%
5042 \end{minipage}%
5043 \par\addvspace{\getexerciseconfig{skipheaderbelow}}}}
5044 % \end{macrocode}
5045 %
5046 % Done with extended styles:
5047 % \begin{macrocode}
5048 \fi
5049 % \end{macrocode}
5050
5051 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5052 % \subsection{Metadata}
5053 % \label{sec:imp-metadata}
5054 %
5055 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5056 % \paragraph{Global Metadata Code.}
5057 %
5058 % \macro{\defexercisedata}
5059 % Declare global metadata field
5060 % by defining a key \textit{key} in category |exf@data|
5061 % that stores the chosen value in |\exf@data@|\textit{key}:
5062 % \begin{macrocode}
5063 \newcommand{\defexercisedata}[1]{%
5064 \exf@csdo\def{exf@data@#1}{}%
5065 \define@key{exf@data}{#1}%
5066 {\exf@csdo\gdef{exf@data@#1}{##1}}}
5067 % \end{macrocode}
5068 % \macro{\exercisedata}
5069 % Process key-value pairs:
5070 % \begin{macrocode}
5071 \newcommand{\exercisedata}[1]{\setkeys{exf@data}{#1}}
5072 % \end{macrocode}
5073 % \macro{\getexercisedata}
5074 % Read global metadata:
5075 % \begin{macrocode}
5076 \newcommand{\getexercisedata}[1]{\csname exf@data@#1\endcsname}
5077 % \end{macrocode}
5078 % \macro{\exercisedataempty}
5079 % Check whether the field is empty:
5080 % \begin{macrocode}
5081 \newcommand{\exercisedataempty}[3]{\exf@csdo\ifx{exf@data@#1}\exf@empty%
5082 #2\else#3\fi}
5083 % \end{macrocode}
5084
5085 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5086 % \paragraph{Global Metadata Declarations.}
5087 %
5088 % Declare fields corresponding to standard pdf metadata:
5089 % \begin{macrocode}
5090 \defexercisedata{author}
5091 \defexercisedata{title}
5092 \defexercisedata{subject}
5093 \defexercisedata{keyword}
5094 % \end{macrocode}
5095 % Declare additional general purpose fields:
5096 % \begin{macrocode}
5097 \defexercisedata{date}
5098 % \end{macrocode}
5099 % Declare metadata related to courses:
5100 % \begin{macrocode}
5101 \defexercisedata{instructor}
5102 \defexercisedata{course}
5103 \defexercisedata{institution}
5104 \defexercisedata{period}
5105 \defexercisedata{material}
5106 % \end{macrocode}
5107 % Overwrite standard definitions for |author|, |title|, |date|
5108 % to also fill ordinary \LaTeX{} structures:
5109 % \begin{macrocode}
5110 \define@key{exf@data}{author}{\gdef\exf@data@author{#1}\author{#1}}
5111 \define@key{exf@data}{title}{\gdef\exf@data@title{#1}\title{#1}}
5112 \define@key{exf@data}{date}{\gdef\exf@data@date{#1}\date{#1}}
5113 % \end{macrocode}
5114
5115 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5116 % \paragraph{Sheet Metadata.}
5117 %
5118 % \macro{\defsheetdata}
5119 % Declare sheet metadata field
5120 % by defining a key \textit{key} in category |exf@sheet|
5121 % that stores the chosen value in |\exf@data@sheet@|\textit{key}:
5122 % \begin{macrocode}
5123 \newcommand{\defsheetdata}[1]{%
5124 \exf@csdo\def{exf@data@sheet@#1}{}%
5125 \define@key{exf@sheet}{#1}%
5126 {\exf@csdo\def{exf@data@sheet@#1}{##1}}}
5127 % \end{macrocode}
5128 % \macro{\setsheetdata}
5129 % Set sheet metadata:
5130 % \begin{macrocode}
5131 \newcommand{\setsheetdata}[1]{\setkeys{exf@sheet}{#1}}
5132 % \end{macrocode}
5133 % \macro{\getsheetdata}
5134 % Read sheet metadata:
5135 % \begin{macrocode}
5136 \newcommand{\getsheetdata}[1]{\csname exf@data@sheet@#1\endcsname}
5137 % \end{macrocode}
5138 % \macro{\sheetdataempty}
5139 % Check whether the field is empty:
5140 % \begin{macrocode}
5141 \newcommand{\sheetdataempty}[3]{\exf@csdo\ifx{exf@data@sheet@#1}\exf@empty%
5142 #2\else#3\fi}
5143 % \end{macrocode}
5144
5145 % Declare general purpose fields:
5146 % \begin{macrocode}
5147 \defsheetdata{due}
5148 \defsheetdata{handout}
5149 \defsheetdata{editdate}
5150 \defsheetdata{author}
5151 \defsheetdata{editor}
5152 % \end{macrocode}
5153
5154 % Special title processing:
5155 % \begin{macrocode}
5156 \def\exf@data@sheet@rawtitle{}
5157 \define@key{exf@sheet}{title}{\def\exf@data@sheet@rawtitle{#1}}
5158 \def\exf@data@sheet@title{\exf@config@composetitlesheet%
5159 {\csname the\exf@sheetcounter\endcsname}{\exf@data@sheet@rawtitle}}%
5160 % \end{macrocode}
5161 % Special points processing:
5162 % \begin{macrocode}
5163 \def\exf@data@sheet@points{\ifdefined\exf@sheet@points%
5164 \expandafter\exf@config@composepointspairsheet\exf@sheet@points\fi}%
5165 % \end{macrocode}
5166
5167 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5168 % \paragraph{Problem Metadata.}
5169 %
5170 % \macro{\defproblemdata}
5171 % Declare problem metadata field
5172 % by defining a key \textit{key} in category |exf@problem|
5173 % that stores the chosen value in |\exf@data@problem@|\textit{key}:
5174 % \begin{macrocode}
5175 \newcommand{\defproblemdata}[1]{%
5176 \exf@csdo\def{exf@data@problem@#1}{}%
5177 \define@key{exf@problem}{#1}%
5178 {\exf@csdo\def{exf@data@problem@#1}{##1}}}
5179 % \end{macrocode}
5180 % \macro{\setproblemdata}
5181 % Set problem metadata:
5182 % \begin{macrocode}
5183 \newcommand{\setproblemdata}[1]{\setkeys{exf@problem,exf@scanproblem}{#1}}
5184 % \end{macrocode}
5185 % \macro{\setsubproblemdata}
5186 % Set subproblem metadata:
5187 % \begin{macrocode}
5188 \newcommand{\setsubproblemdata}[1]{%
5189 \setkeys{exf@subproblem,exf@scansubproblem}{#1}}
5190 % \end{macrocode}
5191 % \macro{\getproblemdata}
5192 % Read problem metadata:
5193 % \begin{macrocode}
5194 \newcommand{\getproblemdata}[1]{\csname exf@data@problem@#1\endcsname}
5195 % \end{macrocode}
5196 % \macro{\problemdataempty}
5197 % Check whether the field is empty:
5198 % \begin{macrocode}
5199 \newcommand{\problemdataempty}[3]{\exf@csdo\ifx{exf@data@problem@#1}\exf@empty%
5200 #2\else#3\fi}
5201 % \end{macrocode}
5202
5203 % Special title processing:
5204 % \begin{macrocode}
5205 \def\exf@data@problem@rawtitle{}
5206 \define@key{exf@problem}{title}{\def\exf@data@problem@rawtitle{#1}}
5207 \def\exf@data@problem@title{\exf@config@composetitleproblem{%
5208 \csname the\exf@problemcounter\endcsname}{\exf@data@problem@rawtitle}}%
5209 % \end{macrocode}
5210
5211 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5212 % \paragraph{Problem Environment Code.}
5213 %
5214 % \macro{\exf@addmargin}
5215 % Define a length for environment margin:
5216 % \begin{macrocode}
5217 \newskip\exf@addmargin
5218 % \end{macrocode}
5219
5220 % \macro{\exf@section}
5221 % Write out problem opening line followed by some amount of skip
5222 % (positive dimensions add vertical space,
5223 % negative dimensions add horizontal space);
5224 % protected expand argument if in horizontal mode
5225 % (because it will be held until text is output
5226 % and some definitions may become invalid):
5227 % \begin{macrocode}
5228 \newcommand{\exf@section}[2]{%
5229 \ifdim\glueexpr#1\relax<0pt%
5230 \protected@edef\exf@tmp{#2}%
5231 \else%
5232 \def\exf@tmp{#2}%
5233 \fi%
5234 \exf@exparg{\@startsection{}{}{0pt}{0pt}{#1}{}*}{\exf@tmp}}
5235 % \end{macrocode}
5236
5237 % \macro{\exf@init@block}
5238 % Clean info buffer, define amount of skip between items:
5239 % \begin{macrocode}
5240 \newcommand{\exf@init@block}[1]{%
5241 \def\exf@intro{}\def\exf@intro@skip{#1}%
5242 \exf@addmargin0pt\def\exf@introitem{}}
5243 % \end{macrocode}
5244 % \macro{\exf@append@intro}
5245 % Append to info buffer:
5246 % \begin{macrocode}
5247 \newcommand{\exf@append@intro}[1]%
5248 {\exf@append@def\exf@intro{#1\hspace{\exf@intro@skip}}}
5249 % \end{macrocode}
5250 % \macro{\exf@prepend@intro}
5251 % Prepend to info buffer:
5252 % \begin{macrocode}
5253 \newcommand{\exf@prepend@intro}[1]%
5254 {\exf@prepend@def\exf@intro{#1\hspace{\exf@intro@skip}}}
5255 % \end{macrocode}
5256 % \macro{\exf@open@block}
5257 % Open environment, set margin, compose opening line:
5258 % \begin{macrocode}
5259 \newcommand{\exf@open@block}[1]{%
5260 \advance\leftskip\exf@addmargin%
5261 \advance\linewidth-\exf@addmargin%
5262 \advance\@totalleftmargin\exf@addmargin%
5263 \ifx\exf@intro\exf@empty%
5264 \exf@section{0pt}{\exf@introitem}%
5265 \else%
5266 \exf@section{#1}{\exf@introitem\exf@intro\unskip}%
5267 \fi}%
5268 % \end{macrocode}
5269 % \macro{\exf@close@block}
5270 % Close environment, undo margin:
5271 % \begin{macrocode}
5272 \newcommand{\exf@close@block}{%
5273 \advance\leftskip-\exf@addmargin%
5274 \advance\linewidth\exf@addmargin%
5275 \advance\@totalleftmargin-\exf@addmargin}%
5276 % \end{macrocode}
5277
5278 % \macro{\addprobleminfo}
5279 % Interface to append or prepend to info buffer:
5280 % \begin{macrocode}
5281 \newcommand{\addprobleminfo}{\@ifstar\exf@prepend@intro\exf@append@intro}
5282 % \end{macrocode}
5283
5284 % \macro{\exf@addinfoswitch}
5285 % Add a switch for displaying problem info:
5286 % \begin{macrocode}
5287 \newcommand{\exf@addinfoswitch}[1]%
5288 {\define@boolkey{exf@infoswitch}[exf@showdata@]{#1}[true]{}}
5289 % \end{macrocode}
5290 % \macro{\defprobleminfo}
5291 % Declare a problem info field,
5292 % add corresponding info switch,
5293 % process key-value pair if switch activated:
5294 % \begin{macrocode}
5295 \newcommand{\defprobleminfo}[2]{%
5296 \exf@addinfoswitch{#1}%
5297 \exerciseconfig{compose@probleminfo@#1}[1]{#2}%
5298 \exf@exparg{\define@key{exf@probleminfo}{#1}}%
5299 {\csname ifexf@showdata@#1\endcsname\exf@append@intro{%
5300 \csname exf@config@compose@probleminfo@#1\endcsname{##1}}\fi}}
5301 % \end{macrocode}
5302 % \macro{\showprobleminfo}
5303 % Process info switches, expand argument first:
5304 % \begin{macrocode}
5305 \newcommand{\showprobleminfo}[1]{\exf@expsetkeys{exf@infoswitch}{#1}}
5306 % \end{macrocode}
5307
5308 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5309 % \paragraph{Problem Info Declarations.}
5310 %
5311 % Declare general purpose fields:
5312 % \begin{macrocode}
5313 \defprobleminfo{optional}{\emph{#1:}}
5314 \showprobleminfo{optional}
5315 \defprobleminfo{difficulty}{(#1)}
5316 % \end{macrocode}
5317
5318 % Declare fields for internal information (mostly):
5319 % \begin{macrocode}
5320 \defprobleminfo{comment}{#1}
5321 \defprobleminfo{author}{$\langle$#1$\rangle$}
5322 \defprobleminfo{editor}{$\{$#1$\}$}
5323 \defprobleminfo{source}{[#1]}
5324 \defprobleminfo{keyword}{\#(#1)}
5325 % \end{macrocode}
5326
5327 % Declare more specific fields:
5328 % \begin{macrocode}
5329 \ifexf@extdata
5330 \defprobleminfo{review}{#1}
5331 \defprobleminfo{recycle}{[[#1]]}
5332 \defprobleminfo{timesolve}{\{#1\}}
5333 \defprobleminfo{timepresent}{\{\!\{#1\}\!\}}
5334 \fi
5335 % \end{macrocode}
5336
5337 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5338 % \paragraph{Write Metadata to PDF Files.}
5339 %
5340 % \macro{\exf@writemetadata}
5341 % Write Metadata to PDF Files in case \ctanpkg{hyperref} is available:
5342 % \begin{macrocode}
5343 \newcommand{\exf@writemetadata}{%
5344 \ifdefined\hypersetup%
5345 % \end{macrocode}
5346 % Write author, title, subject and keywords:
5347 % \begin{macrocode}
5348 \ifx\exf@data@author\exf@empty\else%
5349 \hypersetup{pdfauthor={\exf@data@author}}\fi%
5350 \ifx\exf@data@title\exf@empty\else%
5351 \hypersetup{pdftitle={\exf@data@title}}\fi%
5352 \ifx\exf@data@subject\exf@empty\else%
5353 \hypersetup{pdfsubject={\exf@data@subject}}\fi%
5354 \ifx\exf@data@keyword\exf@empty\else%
5355 \hypersetup{pdfkeywords={\exf@data@keyword}}\fi%
5356 \fi}
5357 % \end{macrocode}
5358
5359 % Automatic writing at |\begin{document}|:
5360 % \begin{macrocode}
5361 \AtBeginDocument{\exf@ifis\exf@metadata{auto}%
5362 {\exf@writemetadata\gdef\exf@metadata{off}}}
5363 % \end{macrocode}
5364
5365 % \macro{\writeexercisedata}
5366 % Write metadata manually:
5367 % \begin{macrocode}
5368 \newcommand{\writeexercisedata}{\exf@ifis\exf@metadata{manual}%
5369 {\exf@writemetadata\gdef\exf@metadata{off}}}
5370 % \end{macrocode}
5371
5372 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5373 % \subsection{Counters}
5374 % \label{sec:imp-counter}
5375 %
5376 % \macro{sheet}
5377 % \macro{problem}
5378 % \macro{subproblem}
5379 % \macro{solution}
5380 % Define main counters (with customised names if necessary)
5381 % and equation counters:
5382 % \begin{macrocode}
5383 \newcounter{\exf@sheetcounter}
5384 \newcounter{\exf@problemcounter}
5385 \newcounter{\exf@subproblemcounter}[\exf@problemcounter]
5386 \newcounter{\exf@solutioncounter}[\exf@problemcounter]
5387 \newcount\exf@eqsav
5388 \newcounter{exf@sheetequation}
5389 \newcounter{exf@problemequation}
5390 \newcounter{exf@solutionequation}
5391 % \end{macrocode}
5392
5393 % Implement counter display;
5394 % take care of corresponding \ctanpkg{hyperref} labels:
5395 % \begin{macrocode}
5396 \exf@csdo\def{the\exf@sheetcounter}{\exf@config@countersheet}
5397 \exf@csdo\def{the\exf@problemcounter}{\exf@config@counterproblem}
5398 \exf@csdo\def{the\exf@subproblemcounter}{\exf@config@countersubproblem}
5399 \def\theexf@sheetequation{\exf@config@countersheetequation}
5400 \def\theHexf@sheetequation{sheet.\arabic{equation}}
5401 \def\theexf@problemequation{\exf@config@counterproblemequation}
5402 \def\theHexf@problemequation{prob.\arabic{equation}}
5403 \def\theexf@solutionequation{\exf@config@countersolutionequation}
5404 \def\theHexf@solutionequation{sol.\arabic{equation}}
5405 % \end{macrocode}
5406
5407 % \macro{\exf@numberproblemwithin}
5408 % Declare problem counter as subcounter of |#1|:
5409 % \begin{macrocode}
5410 \newcommand{\exf@numberproblemwithin}[1]{%
5411 \@addtoreset{\exf@problemcounter}{#1}%
5412 \exf@csdo\def{the\exf@problemcounter}%
5413 {\csname the#1\endcsname.\exf@config@counterproblem}%
5414 \edef\exf@tmp{#1}%
5415 \ifx\exf@tmp\exf@sheetcounter%
5416 \exerciseconfig{tagproblem}{\ifdefined\sheettag\sheettag-\fi%
5417 \arabic{\exf@problemcounter}}%
5418 \else%
5419 \exerciseconfig{tagproblem}{\csname the#1\endcsname-%
5420 \arabic{\exf@problemcounter}}%
5421 \fi}
5422 % \end{macrocode}
5423
5424 % \macro{\exf@numberequationwithin}
5425 % Declare various new equation counters as subcounter of |#1|;
5426 % take care of corresponding \ctanpkg{hyperref} labels:
5427 % \begin{macrocode}
5428 \newcommand{\exf@numberequationwithin}[1]{%
5429 \@addtoreset{exf@sheetequation}{#1}%
5430 \def\theexf@sheetequation%
5431 {\csname the#1\endcsname.\exf@config@countersheetequation}%
5432 \def\theHexf@sheetequation%
5433 {\csname theH#1\endcsname.sheet.\arabic{equation}}%
5434 \@addtoreset{exf@problemequation}{#1}%
5435 \def\theexf@problemequation%
5436 {\csname the#1\endcsname.\exf@config@counterproblemequation}%
5437 \def\theHexf@problemequation%
5438 {\csname theH#1\endcsname.prob.\arabic{equation}}%
5439 \@addtoreset{exf@solutionequation}{#1}%
5440 \def\theexf@solutionequation%
5441 {\csname the#1\endcsname.\exf@config@countersolutionequation}%
5442 \def\theHexf@solutionequation%
5443 {\csname theH#1\endcsname.sol.\arabic{equation}}}
5444 % \end{macrocode}
5445
5446 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5447 % \subsection{Buffers}
5448 % \label{sec:imp-buffer}
5449 %
5450 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5451 % \paragraph{File Output.}
5452 %
5453 % \macro{\ifexf@solfile@open}
5454 % Conditional whether output files are presently in use:
5455 % \begin{macrocode}
5456 \newif\ifexf@solfile@open\exf@solfile@openfalse
5457 \newif\ifexf@probfile@open\exf@probfile@openfalse
5458 % \end{macrocode}
5459 % \macro{\exf@solfile}
5460 % Reserve file handles:
5461 % \begin{macrocode}
5462 \newwrite\exf@solfile
5463 \newwrite\exf@probfile
5464 % \end{macrocode}
5465
5466 % \macro{\exf@writeline}
5467 % Write a line to the file:
5468 % \begin{macrocode}
5469 \newcommand{\exf@writeline}[2]{\immediate\write#1{#2}}
5470 % \end{macrocode}
5471
5472 % \macro{\exf@linesep}
5473 % Return a separator line:
5474 % \begin{macrocode}
5475 \newcommand{\exf@linesep}%
5476 {\@percentchar---------------------------------------}
5477 % \end{macrocode}
5478 % \macro{\exf@lineno}
5479 % Return current position in source file;
5480 % display line number and source file name
5481 % (if available via package \ctanpkg{currfile}):
5482 % \begin{macrocode}
5483 \newcommand{\exf@lineno}{\@percentchar%
5484 \ifdefined\currfilename\currfilename\space\fi%
5485 l.\the\inputlineno}
5486 % \end{macrocode}
5487
5488 % \macro{\exf@start@solfile}
5489 % Open a new solution file |#1.sol| (do nothing if already open);
5490 % indicate source, switch to manual solution display mode:
5491 % \begin{macrocode}
5492 \newcommand{\exf@start@solfile}[1]{%
5493 \ifexf@solfile@open\else%
5494 \exercisestyle{solutionbelow=manual}%
5495 \global\exf@solfile@opentrue%
5496 \edef\exf@tmp{#1}%
5497 \immediate\openout\exf@solfile\exf@tmp\exf@config@extsolutions\relax%
5498 \exf@writeline\exf@solfile{\@percentchar%
5499 generated from file `\jobname' by exframe.sty}%
5500 \ifexf@lineno\exf@writeline\exf@solfile{\exf@lineno}\fi%
5501 \exf@writeline\exf@solfile{}%
5502 \fi}
5503 % \end{macrocode}
5504
5505 % \macro{\exf@close@solfile}
5506 % Close solution file (if open);
5507 % indicate position, close and reset variables:
5508 % \begin{macrocode}
5509 \newcommand{\exf@close@solfile}{%
5510 \ifexf@solfile@open%
5511 \ifexf@lineno\exf@writeline\exf@solfile{\exf@linesep}%
5512 \exf@writeline\exf@solfile{\exf@lineno}\fi%
5513 \exf@writeline\exf@solfile{\@backslashchar endinput}%
5514 \immediate\closeout\exf@solfile%
5515 \global\exf@solfile@openfalse%
5516 \fi}
5517 % \end{macrocode}
5518
5519 % \macro{\exf@start@probfile}
5520 % Open a new problem file |#1.prb| (do nothing if already open);
5521 % indicate source, switch to manual problem display mode:
5522 % \begin{macrocode}
5523 \newcommand{\exf@start@probfile}[1]{%
5524 \ifexf@probfile@open\else%
5525 \global\exf@probfile@opentrue%
5526 \edef\exf@tmp{#1}%
5527 \immediate\openout\exf@probfile\exf@tmp\exf@config@extproblems\relax%
5528 \exf@writeline\exf@probfile{\@percentchar%
5529 generated from file `\jobname' by exframe.sty}%
5530 \ifexf@lineno\exf@writeline\exf@probfile{\exf@lineno}\fi%
5531 \exf@writeline\exf@probfile{}%
5532 \fi}
5533 % \end{macrocode}
5534
5535 % \macro{\exf@close@probfile}
5536 % Close problem file (if open);
5537 % indicate position, close and reset variables:
5538 % \begin{macrocode}
5539 \newcommand{\exf@close@probfile}{%
5540 \ifexf@probfile@open%
5541 \ifexf@lineno\exf@writeline\exf@probfile{\exf@linesep}%
5542 \exf@writeline\exf@probfile{\exf@lineno}\fi%
5543 \exf@writeline\exf@probfile{\@backslashchar endinput}%
5544 \immediate\closeout\exf@probfile%
5545 \global\exf@probfile@openfalse%
5546 \fi}
5547 % \end{macrocode}
5548
5549 % Make sure to properly close files at the end:
5550 % \begin{macrocode}
5551 \AtEndDocument{\exf@close@solfile\exf@close@probfile}
5552 % \end{macrocode}
5553
5554 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5555 % \paragraph{Buffers.}
5556 %
5557 % \macro{\exf@solbuf}
5558 % \macro{\exf@probbuf}
5559 % \macro{\exf@subprobbuf}
5560 % \macro{\ifexf@solbuf@clean}
5561 % \macro{\ifexf@probbuf@clean}
5562 % Declare token buffers for storing problems and solutions
5563 % and conditionals indicating whether the buffers have been used:
5564 % \begin{macrocode}
5565 \newtoks\exf@solbuf
5566 \newtoks\exf@probbuf
5567 \newtoks\exf@subprobbuf
5568 \newif\ifexf@solbuf@clean\exf@solbuf@cleantrue
5569 \newif\ifexf@probbuf@clean\exf@probbuf@cleantrue
5570 % \end{macrocode}
5571 % \macro{\exf@clear@solbuf}
5572 % \macro{\exf@clear@probbuf}
5573 % \macro{\exf@clear@subprobbuf}
5574 % Clear a buffer and mark clean:
5575 % \begin{macrocode}
5576 \def\exf@clear@solbuf{\global\exf@solbuf@cleantrue\global\exf@solbuf={}}
5577 \def\exf@clear@probbuf{\global\exf@probbuf@cleantrue\global\exf@probbuf={}}
5578 \def\exf@clear@subprobbuf{\global\exf@subprobbuf={}}
5579 % \end{macrocode}
5580
5581 % \macro{\exf@append@buf}
5582 % Append tokens to buffer:
5583 % \begin{macrocode}
5584 \def\exf@append@buf#1#2{\global#1=\expandafter{\the#1#2}}
5585 % \end{macrocode}
5586 % \macro{\exf@addline}
5587 % Add a protected expanded line to the buffer:
5588 % \begin{macrocode}
5589 \def\exf@addline#1#2{{\protected@edef\exf@tmp{#2}%
5590 \exf@exparg{\exf@append@buf#1}{\exf@tmp^^J}}}
5591 % \end{macrocode}
5592 % \macro{\exf@source@buf}
5593 % Source a buffer into the document:
5594 % \begin{macrocode}
5595 \def\exf@source@buf#1{\exf@exptwo\scantokens{\the#1}}
5596 % \end{macrocode}
5597 % \macro{\exf@write@buf}
5598 % Write the buffer into the solution file:
5599 % \begin{macrocode}
5600 \def\exf@write@buf#1#2{\exf@writeline#1{\the#2}}
5601 % \end{macrocode}
5602
5603 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5604 % \paragraph{Verbatim Processing.}
5605 %
5606 % \macro{\exf@verbatim}
5607 % Start reading the buffer from the environment body:
5608 % \begin{macrocode}
5609 \newcommand{\exf@verbatim}{%
5610 \begingroup%
5611 \@bsphack%
5612 \let\do\@makeother\dospecials%
5613 \catcode`\^^M\active%
5614 \def\verbatim@processline{\exf@exptwo\exf@verbatim@process%
5615 {\the\verbatim@line^^J}}%
5616 \verbatim@start}
5617 % \end{macrocode}
5618
5619 % \macro{\exf@endverbatim}
5620 % Stop reading the buffer:
5621 % \begin{macrocode}
5622 \newcommand{\exf@endverbatim}{\@esphack\endgroup}
5623 % \end{macrocode}
5624
5625 % \macro{\exf@scanblock}
5626 % Scan an optional argument from a verbatim environment;
5627 % allow for an empty environment and an empty first line;
5628 % argument |#1| is macro to be called eventually:
5629 % \begin{macrocode}
5630 \def\exf@scanblock#1{%
5631 % \end{macrocode}
5632 % Check for empty first line:
5633 % \begin{macrocode}
5634 \@ifnextchar\par{\exf@scanblock@par{#1}}{\exf@scanblock@sel{#1}}}
5635 % \end{macrocode}
5636 % Handle empty first line, implies no optional argument:
5637 % \begin{macrocode}
5638 \long\def\exf@scanblock@par#1\par{\exf@scanblock@sel{#1}[]}
5639 % \end{macrocode}
5640 % Check for optional argument (|[|) and for environment ending (|\end|):
5641 % \begin{macrocode}
5642 \def\exf@scanblock@sel#1{\@ifnextchar[{\exf@scanblock@opt{#1}}%
5643 {\@ifnextchar\end{\exf@scanblock@end{#1}}{\exf@scanblock@noopt{#1}}}}
5644 % \end{macrocode}
5645 % Handle empty environment, hopefully environment matches (otherwise?!):
5646 % \begin{macrocode}
5647 \def\exf@scanblock@end#1\end#2{%
5648 \def\exf@tmp{#2}\ifx\exf@tmp\@currenvir%
5649 \def\exf@verbatim{}\def\exf@endverbatim{}%
5650 \fi%
5651 #1{}{\scantokens{\end{#2}}}}
5652 % \end{macrocode}
5653 % Pass on without and with optional argument;
5654 % pass on optional argument and any token scanned prematurely:
5655 % \begin{macrocode}
5656 \def\exf@scanblock@noopt#1#2{#1{}{\scantokens#2}}
5657 \def\exf@scanblock@opt#1[#2]{#1{#2}{}}
5658 % \end{macrocode}
5659
5660 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5661 % \subsection{Points}
5662 % \label{sec:imp-points}
5663 %
5664 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5665 % \paragraph{Points Arithmetic.}
5666 %
5667 % \macro{\exf@addtopoints}
5668 % Add points |#2|+|#3| to macro |#1| using metric register:
5669 % \begin{macrocode}
5670 \newcommand{\exf@addtopoints}[3]{%
5671 \ifdefined#1\else\def#1{{0}{0}}\fi%
5672 \dimen@\dimexpr\expandafter\@firstoftwo#1pt\relax%
5673 \advance\dimen@\dimexpr#2pt\relax%
5674 \edef\exf@tmp{\strip@pt\dimen@}%
5675 \dimen@\dimexpr\expandafter\@secondoftwo#1pt\relax%
5676 \advance\dimen@\dimexpr#3pt%
5677 \xdef#1{{\exf@tmp}{\strip@pt\dimen@}}}
5678 % \end{macrocode}
5679 %
5680 % \macro{\exf@pointsmismatch}
5681 % Execute |#3| if points disagree:
5682 % \begin{macrocode}
5683 \newcommand{\exf@pointsmismatch}[3]{%
5684 \let\exf@tmp\@undefined%
5685 \ifdim\expandafter\@firstoftwo#1pt=\expandafter\@firstoftwo#2pt\else%
5686 \def\exf@tmp{}\fi%
5687 \ifdim\expandafter\@secondoftwo#1pt=\expandafter\@secondoftwo#2pt\else%
5688 \def\exf@tmp{}\fi%
5689 \ifdefined\exf@tmp#3\fi}
5690 % \end{macrocode}
5691
5692 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5693 % \paragraph{Points Expansion.}
5694 %
5695 % \macro{\exf@outpoints}
5696 % If points macro |#3| is set,
5697 % expand |#3|, pass on as |#1{\protect#2}#3| and clear |#3| globally:
5698 % \begin{macrocode}
5699 \def\exf@outpoints#1#2#3{\ifdefined#3%
5700 \exf@exptwo\exf@outpoints@switch{#3}{#1}{#2}%
5701 \global\let#3\@undefined\fi}
5702 \def\exf@outpoints@switch#1#2#3{#2{\protect#3#1}}
5703 % \end{macrocode}
5704
5705 % \macro{\exf@scanpoints}
5706 % Call as |\exf@scanpoints#1|[\textit{regular}][|+|\textit{bonus}]|++@| to
5707 % write |{|\textit{regular}|}{|\textit{bonus}|}| into |#1|;
5708 % fill with 0 if empty:
5709 % \begin{macrocode}
5710 \def\exf@scanpoints#1#2+#3+#4@{%
5711 \edef#1{\if @#2@0\else#2\fi}%
5712 \edef#1{{#1}{\if @#3@0\else#3\fi}}}
5713 % \end{macrocode}
5714 % \macro{\exf@formatpoints}
5715 % Format as [|#1|][|+#2|]; remove 0 components:
5716 % \begin{macrocode}
5717 \def\exf@formatpoints#1#2{\ifdim#2pt=0pt#1\else%
5718 \ifdim#1pt=0pt+#2\else#1+#2\fi\fi}
5719 % \end{macrocode}
5720
5721 % \macro{\extractpoints}
5722 % Extract main (plain) or bonus (starred) part from saved points register:
5723 % \begin{macrocode}
5724 \newcommand{\extractpoints}{\@ifstar{\exf@extractpoints\@secondoftwo}%
5725 {\exf@extractpoints\@firstoftwo}}
5726 \newcommand{\exf@extractpoints}[2]{\edef\exf@tmp{#2}%
5727 \exf@exptwo\exf@scanpoints\exf@tmp\exf@tmp++@%
5728 \expandafter#1\exf@tmp}
5729 % \end{macrocode}
5730
5731 % \macro{\switchpoints}
5732 % Extract main (plain) and bonus (starred) part from points,
5733 % and execute one of three:
5734 % \begin{macrocode}
5735 \newcommand{\switchpoints}[5]{\edef\exf@tmp{#5}%
5736 \exf@exptwo\exf@scanpoints\exf@tmp\exf@tmp++@%
5737 \expandafter\exf@switchpoints\exf@tmp{#1}{#2}{#3}{#4}}
5738 \newcommand{\exf@switchpoints}[6]{%
5739 \ifdim#2pt=0pt\ifdim#1pt=0pt\def\exf@tmp##1##2{#6}%
5740 \else\def\exf@tmp##1##2{#3}\fi%
5741 \else\ifdim#1pt=0pt\def\exf@tmp##1##2{#4}%
5742 \else\def\exf@tmp##1##2{#5}\fi\fi\exf@tmp{#1}{#2}}
5743 % \end{macrocode}
5744
5745 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5746 % \paragraph{Tools.}
5747 %
5748 % \macro{\exf@makepointsmarginproblem}
5749 % \macro{\exf@makepointsmarginsubproblem}
5750 % \macro{\exf@makepointsmarginsolution}
5751 % Combination to typeset points in margin:
5752 % \begin{macrocode}
5753 \newcommand{\exf@makepointsmarginproblem}[2]{%
5754 \exf@config@insertpointsmarginproblem{%
5755 \exf@config@composepointspairmarginproblem{#1}{#2}}}
5756 \newcommand{\exf@makepointsmarginsubproblem}[2]{%
5757 \exf@config@insertpointsmarginsubproblem{%
5758 \exf@config@composepointspairmarginsubproblem{#1}{#2}}}
5759 \newcommand{\exf@makepointsmarginsolution}[2]{%
5760 \exf@config@insertpointsmarginsolution{%
5761 \exf@config@composepointspairmarginsolution{#1}{#2}}}
5762 % \end{macrocode}
5763
5764 % \macro{\exf@warnmismatch}
5765 % If points |#3| and |#4| are defined and disagree,
5766 % issue a warning message:
5767 % \begin{macrocode}
5768 \newcommand{\exf@warnmismatch}[4]{%
5769 \ifdefined#4\ifdefined#3\exf@pointsmismatch#3#4{%
5770 \let\exf@tmp\PackageWarning%
5771 \ifx#1\exf@solutionname\let\exf@tmp\PackageWarningNoLine\fi%
5772 \exf@tmp{exframe}{points mismatch %
5773 (\expandafter\exf@formatpoints#3 determined %
5774 vs. \expandafter\exf@formatpoints#4 given) %
5775 for #1 \csname the#2\endcsname}%
5776 \ifexf@warntext\edef\exf@tmp{%
5777 {\expandafter\exf@formatpoints#3}{\expandafter\exf@formatpoints#4}}%
5778 \exf@exptwo\exf@config@insertwarnpoints#1\exf@tmp\fi}%
5779 \fi\fi}
5780 % \end{macrocode}
5781 %
5782 % \macro{\exf@warnrerun}
5783 % If points |#3| and |#4| are defined and disagree,
5784 % issue advice to recompile:
5785 % \begin{macrocode}
5786 \newcommand{\exf@warnrerun}[4]{%
5787 \ifdefined#4\ifdefined#3\exf@pointsmismatch#3#4{%
5788 \PackageWarning{exframe}{points changed %
5789 for #1 \csname the#2\endcsname; rerun to fix}%
5790 \ifexf@warntext\exf@config@insertwarnpointsrerun#1\fi}%
5791 \fi\fi}
5792 % \end{macrocode}
5793
5794 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5795 % \paragraph{Binary Rational Numbers.}
5796 %
5797 % \macro{\exf@splitsign}
5798 % \macro{\exf@splitdecimal}
5799 % Split a decimal float number into sign, integer and fractional part:
5800 % \begin{macrocode}
5801 \def\exf@splitsign#1-#2-#3&{\def\exf@splitnum{#1#2}\def\exf@splitminus{#3}}
5802 \def\exf@splitdecimal#1.#2.#3&{\def\exf@splitint{#1}\def\exf@splitdec{#2}}
5803 % \end{macrocode}
5804
5805 % \macro{\showfracpoints}
5806 % Display a float number as a fraction
5807 % with denominators 2, 4 or 8 when possible;
5808 % first split number, complete missing zeros and handle cases:
5809 % \begin{macrocode}
5810 \newcommand{\showfracpoints}[1]{%
5811 \edef\exf@tmp{#1}%
5812 \expandafter\exf@splitsign\exf@tmp--&%
5813 \expandafter\exf@splitdecimal\exf@splitnum..&%
5814 \if @\exf@splitint @\def\exf@splitint{0}\fi%
5815 \if @\exf@splitdec @\def\exf@splitdec{0}\fi%
5816 \def\exf@tmp{\exf@splitint.\exf@splitdec}%
5817 \ifnum\exf@splitdec=0\def\exf@tmp{\exf@splitint}\fi%
5818 \ifnum\exf@splitdec=5\def\exf@tmp{\exf@config@frac{\exf@splitint}{1}{2}}\fi%
5819 \ifnum\exf@splitdec=25\def\exf@tmp{\exf@config@frac{\exf@splitint}{1}{4}}\fi%
5820 \ifnum\exf@splitdec=75\def\exf@tmp{\exf@config@frac{\exf@splitint}{3}{4}}\fi%
5821 \ifnum\exf@splitdec=125\def\exf@tmp{\exf@config@frac{\exf@splitint}{1}{8}}\fi%
5822 \ifnum\exf@splitdec=375\def\exf@tmp{\exf@config@frac{\exf@splitint}{3}{8}}\fi%
5823 \ifnum\exf@splitdec=625\def\exf@tmp{\exf@config@frac{\exf@splitint}{5}{8}}\fi%
5824 \ifnum\exf@splitdec=875\def\exf@tmp{\exf@config@frac{\exf@splitint}{7}{8}}\fi%
5825 \ifx\exf@splitminus\exf@empty\else$\exf@splitminus$\fi\exf@tmp}
5826 % \end{macrocode}
5827
5828 % \macro{\exf@config@frac}
5829 % Display a vulgar fraction
5830 % such as 12$^3\mskip-4mu/\mskip-2mu_4$:
5831 % \begin{macrocode}
5832 \newcommand{\exf@config@frac}[3]{%
5833 \ifnum#1=0\relax\else#1\fi%
5834 \ifnum#2=0\relax\else$%
5835 ^{\exf@text{#2}}%
5836 \mskip-4mu/\mskip-2mu%
5837 _{\exf@text{#3}}$\fi}
5838 % \end{macrocode}
5839
5840 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5841 % \paragraph{Sheet Points Code.}
5842 %
5843 % \macro{\exf@notedata@sheetpoints}
5844 % Store a sheet point number in a macro:
5845 % \begin{macrocode}
5846 \newcommand{\exf@notedata@sheetpoints}[2]{%
5847 \exf@csdo\gdef{exf@sheetpoints@#1}{#2}}
5848 % \end{macrocode}
5849 % \macro{\exf@writesheetpoints}
5850 % Write sheet points to the |.aux| file:
5851 % \begin{macrocode}
5852 \newcommand{\exf@writesheetpoints}[2]%
5853 {\exf@writedata{sheetpoints}{\sheettag}{\exf@formatpoints{#1}{#2}}}
5854 % \end{macrocode}
5855 % \macro{\getsheetpoints}
5856 % Read points for current sheet or from |.aux| file:
5857 % \begin{macrocode}
5858 \newcommand{\getsheetpoints}[1]{\if @#1@%
5859 \ifdefined\exf@sheet@points%
5860 \expandafter\exf@formatpoints\exf@sheet@points\else 0\fi%
5861 \else\exf@csor{exf@sheetpoints@#1}{0}\fi}
5862 % \end{macrocode}
5863
5864 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5865 % \paragraph{Problem Points Code.}
5866 %
5867 % \macro{\exf@notedata@problempoints}
5868 % Store a problem point number in a macro:
5869 % \begin{macrocode}
5870 \newcommand{\exf@notedata@problempoints}[2]{%
5871 \exf@csdo\gdef{exf@problempoints@#1}{#2}}
5872 % \end{macrocode}
5873 % \macro{\exf@writeproblempoints}
5874 % Write problem points to the |.aux| file:
5875 % \begin{macrocode}
5876 \newcommand{\exf@writeproblempoints}[2]%
5877 {\exf@writedata{problempoints}{\problemtag}{\exf@formatpoints{#1}{#2}}}
5878 % \end{macrocode}
5879 % \macro{\getproblempoints}
5880 % Read points for current problem or from |.aux| file:
5881 % \begin{macrocode}
5882 \newcommand{\getproblempoints}[1]{\if @#1@%
5883 \ifdefined\exf@problem@points%
5884 \expandafter\exf@formatpoints\exf@problem@points\else 0\fi%
5885 \else\exf@csor{exf@problempoints@#1}{0}\fi}
5886 % \end{macrocode}
5887
5888 % \macro{\showpoints}
5889 % Show points within a problem or subproblem:
5890 % \begin{macrocode}
5891 \newcommand{\showpoints}{%
5892 \ifdefined\exf@in@solution\exf@outpoints{\exf@ensuretext}%
5893 {\exf@config@composepointspairbodysolution}{\exf@solution@points@show}%
5894 \else\ifdefined\exf@in@subproblem\exf@outpoints{\exf@ensuretext}%
5895 {\exf@config@composepointspairbodysubproblem}{\exf@subproblem@points@show}%
5896 \else\ifdefined\exf@in@problem\exf@outpoints{\exf@ensuretext}%
5897 {\exf@config@composepointspairbodyproblem}{\exf@problem@points@show}%
5898 \fi\fi\fi}
5899 % \end{macrocode}
5900
5901 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5902 % \paragraph{Subproblem Points Code.}
5903 %
5904 % \macro{\exf@notedata@subproblempoints}
5905 % Store a subproblem point number in a macro:
5906 % \begin{macrocode}
5907 \newcommand{\exf@notedata@subproblempoints}[2]{%
5908 \exf@csdo\gdef{exf@subproblempoints@#1}{#2}}
5909 % \end{macrocode}
5910 % \macro{\exf@writesubproblempoints}
5911 % Write subproblem points to the |.aux| file:
5912 % \begin{macrocode}
5913 \newcommand{\exf@writesubproblempoints}[2]%
5914 {\exf@writedata{subproblempoints}%
5915 {\subproblemtag}{\exf@formatpoints{#1}{#2}}}
5916 % \end{macrocode}
5917 % \macro{\getsubproblempoints}
5918 % Read points for current subproblem:
5919 % \begin{macrocode}
5920 \newcommand{\getsubproblempoints}[1]{\if @#1@%
5921 \ifdefined\exf@subproblem@points%
5922 \expandafter\exf@formatpoints\exf@subproblem@points\else 0\fi%
5923 \else\exf@csor{exf@subproblempoints@#1}{0}\fi}
5924 % \end{macrocode}
5925
5926 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5927 % \paragraph{Solution Points Code.}
5928 %
5929 % \macro{\exf@awardpointsalt}
5930 % Award points for alternative or optional solution;
5931 % does not count towards solution total:
5932 % \begin{macrocode}
5933 \newcommand{\exf@awardpointsalt}[2][]{\exf@scanpoints\exf@tmp#2++@%
5934 \exf@exptwo\exf@ensuretext{%
5935 \expandafter\exf@config@composepointspairawardalt\exf@tmp{#1}}}
5936 % \end{macrocode}
5937 % \macro{\exf@awardpointsreg}
5938 % Award points for regular solution;
5939 % counts towards solution total:
5940 % \begin{macrocode}
5941 \newcommand{\exf@awardpointsreg}[2][]{\exf@scanpoints\exf@tmp#2++@%
5942 \exf@exptwo\exf@addtopoints\exf@solution@points@total\exf@tmp%
5943 \exf@scanpoints\exf@tmp#2++@%
5944 \exf@exptwo\exf@ensuretext{%
5945 \expandafter\exf@config@composepointspairaward\exf@tmp{#1}}}
5946 % \end{macrocode}
5947 % \macro{\awardpoints}
5948 % Award points within solution with optional starred form:
5949 % \begin{macrocode}
5950 \newcommand{\awardpoints}{\@ifstar\exf@awardpointsalt\exf@awardpointsreg}
5951 % \end{macrocode}
5952
5953 % \macro{\getsolutionpoints}
5954 % Read points for current solution:
5955 % \begin{macrocode}
5956 \newcommand{\getsolutionpoints}[1]{\if @#1@%
5957 \ifdefined\exf@solution@points%
5958 \expandafter\exf@formatpoints\exf@solution@points\else 0\fi%
5959 \else 0\fi}
5960 % \end{macrocode}
5961
5962 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5963 % \subsection{Tag Lists}
5964 % \label{sec:imp-taglist}
5965 %
5966 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5967 % \paragraph{Loop Lists.}
5968 %
5969 % \macro{exerciseloop}
5970 % \macro{exf@loopdepth}
5971 % Counters for item number within list and depth of loop nesting:
5972 % \begin{macrocode}
5973 \newcounter{exerciseloop}
5974 \newcounter{exf@loopdepth}
5975 % \end{macrocode}
5976
5977 % \macro{exf@listwalk}
5978 % Step through a list;
5979 % call the callback function |#1| with current item |#2|:
5980 % \begin{macrocode}
5981 \def\exf@listwalk#1#2{\if @#2@\def\exf@tmp{}\else%
5982 \def\exf@tmp{#1{#2}\exf@listwalk#1}\fi\exf@tmp}
5983 % \end{macrocode}
5984
5985 % \macro{\exerciseloop}
5986 % Loop through a list of items in braces |#1|
5987 % which is expanded first;
5988 % store code |#2| to be executed in a callback function
5989 % (need to use different callback function for each loop depth,
5990 % callback function must be global to work within table cells);
5991 % initialise item counter:
5992 % \begin{macrocode}
5993 \newcommand{\exerciseloop}[2]{\addtocounter{exf@loopdepth}{1}%
5994 \setcounter{exerciseloop}{0}%
5995 \exf@csdo\gdef{exf@listcallback@\roman{exf@loopdepth}}##1%
5996 {\stepcounter{exerciseloop}#2}%
5997 \edef\exf@tmp{#1}%
5998 \exf@csdotwo\exf@exptwo\exf@listwalk%
5999 {exf@listcallback@\roman{exf@loopdepth}}\exf@tmp{}%
6000 \addtocounter{exf@loopdepth}{-1}}
6001 % \end{macrocode}
6002 % \macro{\exerciseloopstr}
6003 % Loop through list and save result to |\exerciseloopret|
6004 % (or optional argument |#1|):
6005 % \begin{macrocode}
6006 \newcommand{\exerciseloopstr}[3][\exerciseloopret]{%
6007 \def#1{}\exerciseloop{#2}{\protected@edef#1{#1#3}}}
6008 % \end{macrocode}
6009
6010 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6011 % \paragraph{Lists Management.}
6012 %
6013 % \macro{\exf@notedata@sheet}
6014 % Store a sheet tag:
6015 % \begin{macrocode}
6016 \def\exf@sheetlist{}
6017 \newcommand{\exf@notedata@sheet}[2]{%
6018 \xdef\exf@sheetlist{\exf@sheetlist{#1}}}
6019 % \end{macrocode}
6020 % \macro{\exf@notedata@problem}
6021 % Store a problem tag:
6022 % \begin{macrocode}
6023 \def\exf@problemlist{}
6024 \newcommand{\exf@notedata@problem}[2]{%
6025 \xdef\exf@problemlist{\exf@problemlist{#1}}%
6026 \if @#2@\else%
6027 \ifcsname exf@problemlist@#2\endcsname\else%
6028 \exf@csdo\gdef{exf@problemlist@#2}{}\fi%
6029 \exf@csdo\xdef{exf@problemlist@#2}%
6030 {\csname exf@problemlist@#2\endcsname{#1}}%
6031 \fi}
6032 % \end{macrocode}
6033 % \macro{\exf@notedata@subproblem}
6034 % Store a subproblem tag:
6035 % \begin{macrocode}
6036 \newcommand{\exf@notedata@subproblem}[2]{%
6037 \ifcsname exf@subproblemlist@#2\endcsname\else%
6038 \exf@csdo\gdef{exf@subproblemlist@#2}{}\fi%
6039 \exf@csdo\xdef{exf@subproblemlist@#2}%
6040 {\csname exf@subproblemlist@#2\endcsname{#1}}}
6041 % \end{macrocode}
6042
6043 % \macro{\getsheetlist}
6044 % \macro{\getproblemlist}
6045 % \macro{\getsubproblemlist}
6046 % Get list of sheet tags,
6047 % problem tags (all, within current or particular sheet),
6048 % subproblem tags (within current or particular problem):
6049 % \begin{macrocode}
6050 \newcommand{\getsheetlist}[1]{\exf@sheetlist}
6051 \newcommand{\getproblemlist}[1]{\if @#1@%
6052 \ifdefined\sheettag\exf@csor{exf@problemlist@\sheettag}{}%
6053 \else\exf@problemlist\fi%
6054 \else%
6055 \if *#1\exf@problemlist\else\exf@csor{exf@problemlist@#1}{}\fi%
6056 \fi}
6057 \newcommand{\getsubproblemlist}[1]{\if @#1@%
6058 \exf@csor{exf@subproblemlist@\problemtag}{}\else%
6059 \exf@csor{exf@subproblemlist@#1}{}\fi}
6060 % \end{macrocode}
6061
6062
6063 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6064 % \subsection{Sheet Environment}
6065 % \label{sec:imp-sheet}
6066 %
6067 % \macro{exf@sheet}
6068 % Define options for |sheet| environment:
6069 % \begin{macrocode}
6070 \define@key{exf@sheet}{points}{\exf@scanpoints\exf@sheet@points#1++@}
6071 \define@key{exf@sheet}{number}{\setcounter{\exf@sheetcounter}{#1}%
6072 \addtocounter{\exf@sheetcounter}{-1}\refstepcounter{\exf@sheetcounter}}
6073 \define@key{exf@sheet}{label}{\def\exf@label{#1}}
6074 \define@key{exf@sheet}{tag}{\def\sheettag{#1}}
6075 % \end{macrocode}
6076
6077 % \macro{sheet}
6078 % Define |sheet| environment (potentially using custom name):
6079 % \begin{macrocode}
6080 \newenvironment{\exf@sheetname}[1][]{%
6081 % \end{macrocode}
6082 % Insert hook code to clear page, step counter:
6083 % \begin{macrocode}
6084 \exf@config@insertsheetclearpage%
6085 \refstepcounter{\exf@sheetcounter}%
6086 % \end{macrocode}
6087 % Use equation counter for sheets:
6088 % \begin{macrocode}
6089 \ifexf@style@sheetequation%
6090 \exf@eqsav\value{equation}\relax%
6091 \setcounter{equation}{\value{exf@sheetequation}}%
6092 \let\theequation\theexf@sheetequation%
6093 \let\theHequation\theHexf@sheetequation%
6094 \fi%
6095 % \end{macrocode}
6096 % Reset optional arguments, process arguments:
6097 % \begin{macrocode}
6098 \let\exf@sheet@points\@undefined%
6099 \def\sheettag{\getexerciseconfig{tagsheet}}%
6100 \let\exf@sheet@points@total\@undefined%
6101 \let\exf@label\@undefined%
6102 \setkeys{exf@sheet}{#1}%
6103 % \end{macrocode}
6104 % Process automatic and manual labels:
6105 % \begin{macrocode}
6106 \ifexf@autolabelsheet\label{\exf@config@labelsheet{\sheettag}}\fi%
6107 \ifdefined\exf@label\label{\exf@label}\fi%
6108 \exf@writedata{sheet}{\sheettag}{}%
6109 % \end{macrocode}
6110 % Set points from explicit input or from |.aux| storage:
6111 % \begin{macrocode}
6112 \ifdefined\exf@sheet@points%
6113 \let\exf@sheet@points@given\exf@empty%
6114 \else%
6115 \let\exf@sheet@points@given\@undefined%
6116 \ifcsname exf@sheetpoints@\sheettag\endcsname%
6117 \exf@csdotwo\let\exf@tmp{exf@sheetpoints@\sheettag}%
6118 \exf@exptwo\exf@scanpoints\exf@sheet@points\exf@tmp++@%
6119 \fi\fi%
6120 % \end{macrocode}
6121 % Process metadata:
6122 % \begin{macrocode}
6123 \exf@ifis\exf@metadata{sheet}{{%
6124 \ifx\exf@data@sheet@author\exf@empty\else%
6125 \let\exf@data@author\exf@data@sheet@author\fi%
6126 \def\exf@data@title{\exf@config@composemetasheet%
6127 {\csname the\exf@sheetcounter\endcsname}{\exf@data@sheet@rawtitle}}%
6128 \exf@writemetadata}\gdef\exf@metadata{off}}%
6129 % \end{macrocode}
6130 % Insert hook code:
6131 % \begin{macrocode}
6132 \exf@config@insertsheetbefore%
6133 % \end{macrocode}
6134 % Add table of contents line:
6135 % \begin{macrocode}
6136 \ifx\exf@config@toclevelsheet\exf@empty\else%
6137 \ifdefined\phantomsection\phantomsection\fi\fi%
6138 \exf@addcontentsline{\exf@config@toclevelsheet}%
6139 {\exf@config@composetocsheet{\csname the\exf@sheetcounter\endcsname}%
6140 {\exf@data@sheet@rawtitle}}%
6141 % \end{macrocode}
6142 % Write sheet title:
6143 % \begin{macrocode}
6144 \exf@config@insertsheettitle}%
6145 % \end{macrocode}
6146 % End of environment;
6147 % perform sanity check on total points if given explicitly:
6148 % \begin{macrocode}
6149 {\ifdefined\exf@sheet@points@given%
6150 \exf@warnmismatch{\exf@sheetname}{\exf@sheetcounter}%
6151 {\exf@sheet@points@total}{\exf@sheet@points}%
6152 % \end{macrocode}
6153 % Test whether points have changed since last compile:
6154 % \begin{macrocode}
6155 \else%
6156 \exf@warnrerun{\exf@sheetname}{\exf@sheetcounter}%
6157 {\exf@sheet@points@total}{\exf@sheet@points}%
6158 % \end{macrocode}
6159 % Store points:
6160 % \begin{macrocode}
6161 \let\exf@sheet@points\exf@sheet@points@total%
6162 \fi%
6163 % \end{macrocode}
6164 % Write sheet points to |.aux| file:
6165 % \begin{macrocode}
6166 \ifdefined\exf@sheet@points%
6167 \expandafter\exf@writesheetpoints\exf@sheet@points%
6168 \fi%
6169 % \end{macrocode}
6170 % Insert solutions:
6171 % \begin{macrocode}
6172 \exf@ifis\exf@solutionbelow{sheet}{\insertsolutions}%
6173 % \end{macrocode}
6174 % Insert hook code:
6175 % \begin{macrocode}
6176 \exf@config@insertsheetafter%
6177 \exf@config@insertsheetclearpage%
6178 % \end{macrocode}
6179 % Restore original equation counter:
6180 % \begin{macrocode}
6181 \ifexf@style@sheetequation%
6182 \setcounter{exf@sheetequation}{\value{equation}}%
6183 \setcounter{equation}{\exf@eqsav}%
6184 \fi%
6185 % \end{macrocode}
6186 % Done:
6187 % \begin{macrocode}
6188 \ignorespacesafterend}
6189 % \end{macrocode}
6190
6191 % \macro{\exercisecleardoublepage}
6192 % Clear the current page, clear even page with a totally empty page:
6193 % \begin{macrocode}
6194 \newcommand{\exercisecleardoublepage}{%
6195 \clearpage\ifexf@twoside\ifodd\value{page}\else%
6196 \thispagestyle{empty}\hbox{}\newpage\fi\fi}
6197 % \end{macrocode}
6198
6199 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6200 % \subsection{Problem Environment}
6201 % \label{sec:imp-problem}
6202 %
6203 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6204 % \paragraph{Print Problems.}
6205 %
6206 % \macro{exf@problem}
6207 % Define options for |problem| environment:
6208 % \begin{macrocode}
6209 \define@key{exf@problem}{points}{\exf@scanpoints\exf@problem@points#1++@}
6210 \define@key{exf@problem}{label}{\def\exf@label{#1}}
6211 \define@key{exf@problem}{tag}{\def\problemtag{#1}}
6212 \define@key{exf@problem}{sollabel}{\xdef\exf@sollabel{#1}}
6213 % \end{macrocode}
6214
6215 % \macro{printproblem}
6216 % Define |printproblem| environment:
6217 % \begin{macrocode}
6218 \newenvironment{printproblem}[1]{%
6219 % \end{macrocode}
6220 % Start with new paragraph, set text style, add vspace:
6221 % \begin{macrocode}
6222 \par\exf@config@styletext\addvspace{\exf@config@skipproblemabove}%
6223 % \end{macrocode}
6224 % Step problem counter:
6225 % \begin{macrocode}
6226 \refstepcounter{\exf@problemcounter}%
6227 % \end{macrocode}
6228 % Insert hook code:
6229 % \begin{macrocode}
6230 \exf@config@insertproblembefore%
6231 % \end{macrocode}
6232 % Begin inner group, mark in problem:
6233 % \begin{macrocode}
6234 \begingroup%
6235 \def\exf@in@problem{}%
6236 % \end{macrocode}
6237 % Use equation counter for problems:
6238 % \begin{macrocode}
6239 \ifexf@style@problemequation%
6240 \exf@eqsav\value{equation}\relax%
6241 \setcounter{equation}{\value{exf@problemequation}}%
6242 \let\theequation\theexf@problemequation%
6243 \let\theHequation\theHexf@problemequation%
6244 \fi%
6245 % \end{macrocode}
6246 % Initialise variables, process arguments:
6247 % \begin{macrocode}
6248 \exf@init@block{\exf@config@skipprobleminfo}%
6249 \def\problemtag{\getexerciseconfig{tagproblem}}%
6250 \let\exf@problem@points\@undefined%
6251 \let\exf@label\@undefined%
6252 \global\let\exf@sollabel\@undefined%
6253 \let\exf@problem@points@total\@undefined%
6254 \setkeys{exf@problem,exf@probleminfo,exf@scanproblem}{#1}%
6255 % \end{macrocode}
6256 % Process automatic and manual labels:
6257 % \begin{macrocode}
6258 \ifexf@autolabelproblem\label{\exf@config@labelproblem{\problemtag}}\fi%
6259 \ifdefined\exf@label\label{\exf@label}\fi%
6260 \exf@writedata{problem}{\problemtag}{\ifdefined\sheettag\sheettag\fi}%
6261 % \end{macrocode}
6262 % Mark for new solution section; remember problem counter, title:
6263 % \begin{macrocode}
6264 \global\let\exf@problem@solfirst\exf@empty%
6265 \xdef\exf@prevprob{\csname the\exf@problemcounter\endcsname}%
6266 \ifcsname theH\exf@problemcounter\endcsname%
6267 \xdef\exf@prevprobhref{\exf@problemcounter.%
6268 \csname theH\exf@problemcounter\endcsname}%
6269 \fi%
6270 \ifx\exf@data@problem@rawtitle\exf@empty%
6271 \global\let\exf@prevprobtitle\@undefined%
6272 \else%
6273 \protected@xdef\exf@prevprobtitle{\exf@data@problem@rawtitle}%
6274 \fi%
6275 \exf@clear@prevsubprob%
6276 % \end{macrocode}
6277 % Set points from explicit input or from |.aux| storage:
6278 % \begin{macrocode}
6279 \ifdefined\exf@problem@points%
6280 \let\exf@problem@points@given\exf@empty%
6281 \else%
6282 \let\exf@problem@points@given\@undefined%
6283 \ifcsname exf@problempoints@\problemtag\endcsname%
6284 \exf@csdotwo\let\exf@tmp{exf@problempoints@\problemtag}%
6285 \exf@exptwo\exf@scanpoints\exf@problem@points\exf@tmp++@%
6286 \fi\fi%
6287 \global\let\exf@prevpoints\exf@problem@points%
6288 \let\exf@problem@points@show\@undefined%
6289 \ifdefined\exf@problem@points%
6290 \let\exf@problem@points@show\exf@problem@points%
6291 \fi%
6292 % \end{macrocode}
6293 % Disable points display if desired:
6294 % \begin{macrocode}
6295 \exf@ifis\exf@pointsat{off}{\let\exf@problem@points@show\@undefined}%
6296 % \end{macrocode}
6297 % Display points in opening line if desired;
6298 % expand points into argument and remove points:
6299 % \begin{macrocode}
6300 \exf@ifis\exf@pointsat{start}{\exf@outpoints{\exf@append@intro}%
6301 {\exf@config@composepointspairstartproblem}{\exf@problem@points@show}}%
6302 \exf@ifis\exf@pointsat{start*}{\exf@outpoints{\exf@prepend@intro}%
6303 {\exf@config@composepointspairstartproblem}{\exf@problem@points@show}}%
6304 % \end{macrocode}
6305 % Insert hook code, set problem body style:
6306 % \begin{macrocode}
6307 \exf@config@insertprobleminfo%
6308 \exf@config@styletextproblem%
6309 % \end{macrocode}
6310 % Write title without item:
6311 % \begin{macrocode}
6312 \exf@addmargin\glueexpr\exf@config@skipproblemitem\relax%
6313 \ifdim\exf@addmargin=0pt%
6314 \exf@prepend@intro{{%
6315 \exf@config@styletitle\exf@config@styletitleproblem%
6316 \exf@config@composetitleproblem{\csname the\exf@problemcounter\endcsname}%
6317 {\exf@data@problem@rawtitle}}}%
6318 % \end{macrocode}
6319 % Write item with fixed total width or item width plus space:
6320 % \begin{macrocode}
6321 \else%
6322 \ifdim\exf@addmargin<0pt%
6323 \settowidth\exf@addmargin{%
6324 \exf@config@styletitle\exf@config@styletitleproblem%
6325 \exf@config@composeitemproblem{\exf@config@counterproblemmax}%
6326 \exf@config@composeitemproblemsep}%
6327 \fi%
6328 % \end{macrocode}
6329 % Define item label:
6330 % \begin{macrocode}
6331 \def\exf@introitem{\makebox[0cm][r]{%
6332 \exf@config@styletitle\exf@config@styletitleproblem%
6333 \exf@config@composeitemproblem{\csname the\exf@problemcounter\endcsname}%
6334 \exf@config@composeitemproblemsep}}%
6335 % \end{macrocode}
6336 % Compose title:
6337 % \begin{macrocode}
6338 \ifx\exf@data@problem@rawtitle\exf@empty\else%
6339 \exf@prepend@intro{{%
6340 \exf@config@styletitle\exf@config@styletitleproblem%
6341 \exf@config@composetitleproblem{\exf@empty}{\exf@data@problem@rawtitle}}}%
6342 \fi%
6343 \fi%
6344 % \end{macrocode}
6345 % Write points into margin if desired;
6346 % expand points into argument and remove points:
6347 % \begin{macrocode}
6348 \exf@ifis\exf@pointsat{margin}{%
6349 \exf@outpoints{\exf@prepend@def\exf@introitem}%
6350 {\exf@makepointsmarginproblem}{\exf@problem@points@show}}%
6351 % \end{macrocode}
6352 % Write out opening line:
6353 % \begin{macrocode}
6354 \exf@open@block{\exf@config@skipproblemtitle}%
6355 % \end{macrocode}
6356 % Add table of contents line:
6357 % \begin{macrocode}
6358 \exf@addcontentsline{\exf@config@toclevelproblem}%
6359 {\exf@config@composetocproblem{\csname the\exf@problemcounter\endcsname}%
6360 {\exf@data@problem@rawtitle}}%
6361 % \end{macrocode}
6362 % Done:
6363 % \begin{macrocode}
6364 \@afterindentfalse}%
6365 % \end{macrocode}
6366 % End environment, show points if desired:
6367 % \begin{macrocode}
6368 {\exf@ifis\exf@pointsat{end}{\showpoints}%
6369 % \end{macrocode}
6370 % Perform sanity checks on total points if given explicitly:
6371 % \begin{macrocode}
6372 \ifdefined\exf@problem@points@given%
6373 \exf@warnmismatch{\exf@problemname}{\exf@problemcounter}%
6374 {\exf@problem@points@total}{\exf@problem@points}%
6375 % \end{macrocode}
6376 % Warn if calculated total points have changed:
6377 % \begin{macrocode}
6378 \else%
6379 \exf@warnrerun{\exf@problemname}{\exf@problemcounter}%
6380 {\exf@problem@points@total}{\exf@problem@points}%
6381 % \end{macrocode}
6382 % Read computed total points:
6383 % \begin{macrocode}
6384 \let\exf@problem@points\exf@problem@points@total%
6385 \fi%
6386 % \end{macrocode}
6387 % Write points to |.aux| file; add to sheet total:
6388 % \begin{macrocode}
6389 \ifdefined\exf@problem@points%
6390 \expandafter\exf@writeproblempoints\exf@problem@points%
6391 \exf@exptwo\exf@addtopoints\exf@sheet@points@total\exf@problem@points%
6392 % \end{macrocode}
6393 % Warn if no points given for present problem but previously:
6394 % \begin{macrocode}
6395 \else\ifdefined\exf@sheet@points@total%
6396 \PackageWarning{exframe}{no points defined for \exf@problemname}%
6397 \fi\fi%
6398 % \end{macrocode}
6399 % Solutions to subproblems must be declared within problem environment:
6400 % \begin{macrocode}
6401 \exf@clear@prevsubprob%
6402 % \end{macrocode}
6403 % End paragraph and environment:
6404 % \begin{macrocode}
6405 \par\exf@close@block%
6406 % \end{macrocode}
6407 % Display solution if desired:
6408 % \begin{macrocode}
6409 \exf@ifis\exf@solutionbelow{problem}{%
6410 \exf@config@insertproblemsolution%
6411 \exf@showsolutions{\exf@config@composetitlesolutionmulti}{}}%
6412 % \end{macrocode}
6413 % Restore original equation counter:
6414 % \begin{macrocode}
6415 \ifexf@style@problemequation%
6416 \setcounter{exf@problemequation}{\value{equation}}%
6417 \setcounter{equation}{\exf@eqsav}%
6418 \fi%
6419 % \end{macrocode}
6420 % End inner group:
6421 % \begin{macrocode}
6422 \endgroup%
6423 % \end{macrocode}
6424 % Insert hook code, vertical skip:
6425 % \begin{macrocode}
6426 \exf@config@insertproblemafter%
6427 \addvspace{\exf@config@skipproblembelow}%
6428 % \end{macrocode}
6429 % Display solution if desired:
6430 % \begin{macrocode}
6431 \exf@ifis\exf@solutionbelow{problem*}{%
6432 \exf@showsolutions{\exf@config@composetitlesolutionmulti}{}}%
6433 % \end{macrocode}
6434 % Done:
6435 % \begin{macrocode}
6436 \ignorespacesafterend}
6437 % \end{macrocode}
6438
6439 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6440 % \paragraph{Read Problem Environment.}
6441 %
6442 % \macro{exf@scanproblem}
6443 % Define options for scanning |problem| environment:
6444 % \begin{macrocode}
6445 \define@boolkey{exf@scanproblem}[exf@scanproblem@]{disable}[true]{}
6446 % \end{macrocode}
6447
6448 % \macro{exf@problem@direct}
6449 % Define direct output version of |problem| environment;
6450 % pass on to |printproblem| environment:
6451 % \begin{macrocode}
6452 \newenvironment{exf@problem@direct}[1][]%
6453 {\printproblem{#1}}{\endprintproblem\ignorespacesafterend}
6454 % \end{macrocode}
6455
6456 % \macro{exf@problem@scan}
6457 % \macro{exf@scanproblem}
6458 % Define scan version of |problem| environment;
6459 % use |\exf@scanblock| to properly parse optional argument
6460 % and pass on to |exf@scanproblem|:
6461 % \begin{macrocode}
6462 \newenvironment{exf@problem@scan}%
6463 {\exf@scanblock{\exf@scanproblem}}{\endexf@scanproblem}%
6464 \newenvironment{exf@scanproblem}[2]{%
6465 % \end{macrocode}
6466 % Determine problem display:
6467 % \begin{macrocode}
6468 \global\exf@scanproblem@disablefalse%
6469 \setkeys*{exf@scanproblem}{#1}%
6470 \exf@config@insertproblemselect{#1}%
6471 \ifexf@scanproblem@disable\global\exf@scanproblem@disabletrue\fi%
6472 % \end{macrocode}
6473 % Circumvent problem display:
6474 % \begin{macrocode}
6475 \ifexf@scanproblem@disable%
6476 \def\exf@verbatim@process{\@gobble}%
6477 \else%
6478 % \end{macrocode}
6479 % Write separator and |printproblem| environment to buffer:
6480 % \begin{macrocode}
6481 \ifexf@lineno\exf@addline\exf@probbuf{\exf@linesep}%
6482 \exf@addline\exf@probbuf{\exf@lineno}\fi%
6483 \exf@addline\exf@probbuf%
6484 {\@backslashchar begin{printproblem}{#1}}%
6485 % \end{macrocode}
6486 % Start verbatim processing:
6487 % \begin{macrocode}
6488 \def\exf@verbatim@process{\exf@append@buf\exf@probbuf}%
6489 \fi%
6490 \exf@verbatim#2}%
6491 % \end{macrocode}
6492 % End verbatim processing; close |printproblem| environment:
6493 % \begin{macrocode}
6494 {\exf@endverbatim%
6495 \ifexf@scanproblem@disable\else%
6496 \exf@addline\exf@probbuf{\@backslashchar end{printproblem}}%
6497 \global\exf@probbuf@cleanfalse%
6498 \fi%
6499 % \end{macrocode}
6500 % Write buffer to file if output file open:
6501 % \begin{macrocode}
6502 \ifexf@probfile@open%
6503 \exf@write@buf\exf@probfile\exf@probbuf%
6504 \exf@clear@probbuf%
6505 \fi%
6506 % \end{macrocode}
6507 % Output buffer immediately:
6508 % \begin{macrocode}
6509 \ifexf@problemmanual\else%
6510 \exf@source@buf\exf@probbuf%
6511 \exf@clear@probbuf%
6512 \fi%
6513 % \end{macrocode}
6514 % Done:
6515 % \begin{macrocode}
6516 \ignorespacesafterend}
6517 % \end{macrocode}
6518
6519 % \macro{problem}
6520 % Define |problem| environment (potentially using custom name)
6521 % to choose between direct and buffered version:
6522 % \begin{macrocode}
6523 \newenvironment{\exf@problemname}%
6524 {\ifexf@problembuf\let\exf@tmp\exf@problem@scan%
6525 \else\let\exf@tmp\exf@problem@direct\fi%
6526 \exf@tmp}%
6527 {\ifexf@problembuf\let\exf@tmp\endexf@problem@scan%
6528 \else\let\exf@tmp\endexf@problem@direct\fi%
6529 \exf@tmp}
6530 % \end{macrocode}
6531
6532 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6533 % \subsection{Problem Blocks}
6534 % \label{sec:imp-problems}
6535 %
6536 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6537 % \paragraph{Problem Block Handling.}
6538 %
6539 % \macro{\exf@problemstitle}
6540 % Compose the title for a problem block section:
6541 % \begin{macrocode}
6542 \newcommand{\exf@problemstitle}{%
6543 % \end{macrocode}
6544 % Check whether title is empty:
6545 % \begin{macrocode}
6546 \protected@edef\exf@problemstitleexp{\exf@config@composetitleproblems}%
6547 \ifx\exf@problemstitleexp\exf@empty\else%
6548 % \end{macrocode}
6549 % Output section line:
6550 % \begin{macrocode}
6551 \exf@section{\exf@config@skipproblemstitle}%
6552 {\exf@config@styletitle\exf@config@styletitleproblems%
6553 \exf@problemstitleexp}%
6554 \exf@addcontentsline{\exf@config@toclevelproblems}%
6555 {\exf@config@composetocproblems}%
6556 \fi}
6557 % \end{macrocode}
6558
6559 % \macro{\exf@showproblemsin}
6560 % Output problem block intro:
6561 % \begin{macrocode}
6562 \newcommand{\exf@showproblemsin}{%
6563 % \end{macrocode}
6564 % Set problem body style; add vertical space; insert hook code:
6565 % \begin{macrocode}
6566 \par\exf@config@styletext\addvspace{\exf@config@skipproblemsabove}%
6567 \exf@config@insertproblemsbefore}
6568 % \end{macrocode}
6569
6570 % \macro{\exf@showproblemsout}
6571 % Output problem block outro:
6572 % \begin{macrocode}
6573 \newcommand{\exf@showproblemsout}{%
6574 % \end{macrocode}
6575 % Insert hook code; close paragraph; add vertical space:
6576 % \begin{macrocode}
6577 \exf@config@insertproblemsafter%
6578 \par\exf@config@styletext\addvspace{\exf@config@skipproblemsbelow}}
6579 % \end{macrocode}
6580
6581 % \macro{\exf@showproblems}
6582 % Output problem block in buffer:
6583 % \begin{macrocode}
6584 \newcommand{\exf@showproblems}{%
6585 % \end{macrocode}
6586 % Do nothing if buffer is empty (avoid titles):
6587 % \begin{macrocode}
6588 \ifexf@probbuf@clean\else\begingroup%
6589 % \end{macrocode}
6590 % Execute output problem block intro:
6591 % \begin{macrocode}
6592 \exf@showproblemsin%
6593 \exf@problemstitle%
6594 % \end{macrocode}
6595 % Source and clear buffer:
6596 % \begin{macrocode}
6597 \exf@source@buf\exf@probbuf%
6598 \exf@clear@probbuf%
6599 % \end{macrocode}
6600 % Execute output problem block outro:
6601 % \begin{macrocode}
6602 \exf@showproblemsout%
6603 \endgroup\fi}
6604 % \end{macrocode}
6605
6606 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6607 % \paragraph{Problems Buffer Interface.}
6608 %
6609 % \macro{\writeproblems}
6610 % Open a file |#1.prb| for writing problems;
6611 % default is present main file name:
6612 % \begin{macrocode}
6613 \newcommand{\writeproblems}[1][\jobname]{%
6614 \exf@close@probfile\exf@start@probfile{#1}}
6615 % \end{macrocode}
6616
6617 % \macro{\closeproblems}
6618 % Close problems output file (if open):
6619 % \begin{macrocode}
6620 \newcommand{\closeproblems}{\exf@close@probfile}
6621 % \end{macrocode}
6622
6623 % \macro{\readproblems}
6624 % Read problems from file |#1.prb|;
6625 % default is present main file name;
6626 % switch layout and add heading:
6627 % \begin{macrocode}
6628 \newcommand{\readproblems}[1][\jobname]{\exf@close@probfile%
6629 \begingroup%
6630 \exf@config@styletext\exf@config@styletextproblem%
6631 \exf@problemstitle%
6632 \input{#1\exf@config@extproblems}%
6633 \endgroup}
6634 % \end{macrocode}
6635
6636 % \macro{\insertproblems}
6637 % Show problems buffer:
6638 % \begin{macrocode}
6639 \newcommand{\insertproblems}{\exf@showproblems}
6640 % \end{macrocode}
6641
6642 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6643 % \subsection{Subproblem Environment}
6644 % \label{sec:imp-subproblem}
6645 %
6646 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6647 % \paragraph{Print Subproblems.}
6648 %
6649 % \macro{exf@subproblem}
6650 % Define options for |subproblem| environment:
6651 % \begin{macrocode}
6652 \define@key{exf@subproblem}{points}{\exf@scanpoints\exf@subproblem@points#1++@}
6653 \define@key{exf@subproblem}{label}{\def\exf@label{#1}}
6654 \define@key{exf@subproblem}{tag}{\def\subproblemtag{#1}}
6655 % \end{macrocode}
6656
6657 % \macro{printsubproblem}
6658 % Define |printsubproblem| environment:
6659 % \begin{macrocode}
6660 \newenvironment{printsubproblem}[1]{%
6661 % \end{macrocode}
6662 % Start with new paragraph, set text style, add vspace and step counter:
6663 % \begin{macrocode}
6664 \par{\exf@config@styletext\addvspace{\exf@config@skipsubproblemabove}}%
6665 \refstepcounter{\exf@subproblemcounter}%
6666 % \end{macrocode}
6667 % Insert hook code:
6668 % \begin{macrocode}
6669 \exf@config@insertsubproblembefore%
6670 % \end{macrocode}
6671 % Start inner group, mark in subproblem:
6672 % \begin{macrocode}
6673 \begingroup%
6674 \def\exf@in@subproblem{}%
6675 % \end{macrocode}
6676 % Initialise variables, process arguments:
6677 % \begin{macrocode}
6678 \exf@init@block{\exf@config@skipsubprobleminfo}%
6679 \def\subproblemtag{\getexerciseconfig{tagsubproblem}}%
6680 \let\exf@subproblem@points\@undefined%
6681 \let\exf@label\@undefined%
6682 \setkeys{exf@subproblem,exf@probleminfo,exf@scansubproblem}{#1}%
6683 % \end{macrocode}
6684 % Process automatic and manual labels:
6685 % \begin{macrocode}
6686 \ifexf@autolabelproblem\label{\exf@config@labelsubproblem%
6687 {\subproblemtag}}\fi%
6688 \ifdefined\exf@label\label{\exf@label}\fi%
6689 \exf@writedata{subproblem}{\subproblemtag}{\problemtag}%
6690 % \end{macrocode}
6691 % Remember subproblem counter for solution:
6692 % \begin{macrocode}
6693 \xdef\exf@prevsubprob{\csname the\exf@subproblemcounter\endcsname}%
6694 \ifcsname theH\exf@subproblemcounter\endcsname%
6695 \xdef\exf@prevsubprobhref{\exf@subproblemcounter.%
6696 \csname theH\exf@subproblemcounter\endcsname}%
6697 \fi%
6698 % \end{macrocode}
6699 % Remember points for display;
6700 % disable points display if desired:
6701 % \begin{macrocode}
6702 \let\exf@subproblem@points@show\@undefined%
6703 \ifdefined\exf@subproblem@points%
6704 \let\exf@subproblem@points@show\exf@subproblem@points\fi%
6705 \exf@ifis\exf@subpointsat{off}{\let\exf@subproblem@points@show\@undefined}%
6706 % \end{macrocode}
6707 % Write points to |.aux| file; add to problem total:
6708 % \begin{macrocode}
6709 \ifdefined\exf@subproblem@points%
6710 \global\let\exf@prevpoints\exf@subproblem@points%
6711 \expandafter\exf@writesubproblempoints\exf@subproblem@points%
6712 \exf@exptwo\exf@addtopoints\exf@problem@points@total\exf@subproblem@points%
6713 % \end{macrocode}
6714 % Warn if no points given for present subproblem but previously:
6715 % \begin{macrocode}
6716 \else\ifdefined\exf@problem@points@total%
6717 \PackageWarning{exframe}{no points defined for \exf@subproblemname}%
6718 \fi\fi%
6719 % \end{macrocode}
6720 % Display points in opening line if desired;
6721 % expand points into argument and remove points:
6722 % \begin{macrocode}
6723 \exf@ifis\exf@subpointsat{start}{\exf@outpoints{\exf@append@intro}%
6724 {\exf@config@composepointspairstartsubproblem}{\exf@subproblem@points@show}}%
6725 \exf@ifis\exf@subpointsat{start*}{\exf@outpoints{\exf@prepend@intro}%
6726 {\exf@config@composepointspairstartsubproblem}{\exf@subproblem@points@show}}%
6727 % \end{macrocode}
6728 % Insert hook code:
6729 % \begin{macrocode}
6730 \exf@config@insertsubprobleminfo%
6731 % \end{macrocode}
6732 % Write opening line without item:
6733 % \begin{macrocode}
6734 \exf@addmargin\glueexpr\exf@config@skipsubproblemitem\relax%
6735 \ifdim\exf@addmargin=0pt%
6736 \exf@prepend@intro{{%
6737 \exf@config@styletitle\exf@config@styletitlesubproblem%
6738 \exf@config@composetitlesubproblem{%
6739 \csname the\exf@subproblemcounter\endcsname}}}%
6740 % \end{macrocode}
6741 % Write item with fixed total width or item width plus space:
6742 % \begin{macrocode}
6743 \else%
6744 \ifdim\exf@addmargin<0pt%
6745 \settowidth\exf@addmargin{%
6746 \exf@config@styletitle\exf@config@styletitlesubproblem%
6747 \exf@config@composeitemsubproblem{\exf@config@countersubproblemmax}%
6748 \exf@config@composeitemsubproblemsep}%
6749 \fi%
6750 % \end{macrocode}
6751 % Define item label:
6752 % \begin{macrocode}
6753 \def\exf@introitem{\makebox[0cm][r]{%
6754 \exf@config@styletitle\exf@config@styletitlesubproblem%
6755 \exf@config@composeitemsubproblem%
6756 {\csname the\exf@subproblemcounter\endcsname}%
6757 \exf@config@composeitemsubproblemsep}}%
6758 \fi%
6759 % \end{macrocode}
6760 % Write points into margin if desired;
6761 % expand points into argument and remove points:
6762 % \begin{macrocode}
6763 \exf@ifis\exf@subpointsat{margin}{%
6764 \exf@outpoints{\exf@prepend@def\exf@introitem}%
6765 {\exf@makepointsmarginsubproblem}{\exf@subproblem@points@show}}%
6766 % \end{macrocode}
6767 % Write out opening line:
6768 % \begin{macrocode}
6769 \exf@open@block{\exf@config@skipsubproblemtitle}%
6770 % \end{macrocode}
6771 % Done:
6772 % \begin{macrocode}
6773 \@afterindentfalse}%
6774 % \end{macrocode}
6775 % End environment, show points if desired:
6776 % \begin{macrocode}
6777 {\exf@ifis\exf@subpointsat{end}{\showpoints}%
6778 % \end{macrocode}
6779 % End paragraph and environment:
6780 % \begin{macrocode}
6781 \par\exf@close@block%
6782 % \end{macrocode}
6783 % Display solution if desired:
6784 % \begin{macrocode}
6785 \exf@ifis\exf@solutionbelow{subproblem*}{%
6786 \exf@config@insertsubproblemsolution%
6787 \exf@showsolutions{\exf@config@composetitlesolutionsingle}{}}%
6788 % \end{macrocode}
6789 % End inner group:
6790 % \begin{macrocode}
6791 \endgroup%
6792 % \end{macrocode}
6793 % Insert hook code, vertical skip:
6794 % \begin{macrocode}
6795 \exf@config@insertsubproblemafter%
6796 {\exf@config@styletext\addvspace{\exf@config@skipsubproblembelow}}%
6797 % \end{macrocode}
6798 % Display solution if desired:
6799 % \begin{macrocode}
6800 \exf@ifis\exf@solutionbelow{subproblem}{%
6801 \exf@showsolutions{\exf@config@composetitlesolutionsingle}{}}%
6802 % \end{macrocode}
6803 % Done:
6804 % \begin{macrocode}
6805 \ignorespacesafterend}
6806 % \end{macrocode}
6807
6808 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6809 % \paragraph{Read Subproblem Environment.}
6810 %
6811 % \macro{exf@scansubproblem}
6812 % Define options for scanning |subproblem| environment:
6813 % \begin{macrocode}
6814 \define@boolkey{exf@scansubproblem}[exf@scansubproblem@]{disable}[true]{}
6815 % \end{macrocode}
6816
6817 % \macro{exf@subproblem@direct}
6818 % Define direct output version of |subproblem| environment;
6819 % pass on to |printsubproblem| environment:
6820 % \begin{macrocode}
6821 \newenvironment{exf@subproblem@direct}[1][]%
6822 {\printsubproblem{#1}}{\endprintsubproblem\ignorespacesafterend}
6823 % \end{macrocode}
6824
6825 % \macro{exf@subproblem@scan}
6826 % \macro{exf@scansubproblem}
6827 % Define scan version of |subproblem| environment;
6828 % use |\exf@scanblock| to properly parse optional argument
6829 % and pass on to |exf@scansubproblem|:
6830 % \begin{macrocode}
6831 \newenvironment{exf@subproblem@scan}%
6832 {\exf@scanblock{\exf@scansubproblem}}{\endexf@scansubproblem}%
6833 \newenvironment{exf@scansubproblem}[2]{%
6834 % \end{macrocode}
6835 % Determine subproblem display:
6836 % \begin{macrocode}
6837 \global\exf@scansubproblem@disablefalse%
6838 \setkeys*{exf@scansubproblem}{#1}%
6839 \exf@config@insertsubproblemselect{#1}%
6840 \ifexf@scansubproblem@disable\global\exf@scansubproblem@disabletrue\fi%
6841 % \end{macrocode}
6842 % Circumvent subproblem display:
6843 % \begin{macrocode}
6844 \exf@clear@subprobbuf%
6845 \ifexf@scansubproblem@disable%
6846 \global\let\exf@prevsubprob\exf@empty%
6847 \def\exf@verbatim@process{\@gobble}%
6848 \else%
6849 % \end{macrocode}
6850 % Write |printsubproblem| environment to buffer:
6851 % \begin{macrocode}
6852 \exf@addline\exf@subprobbuf%
6853 {\@backslashchar begin{printsubproblem}{#1}}%
6854 % \end{macrocode}
6855 % Start verbatim processing:
6856 % \begin{macrocode}
6857 \def\exf@verbatim@process{\exf@append@buf\exf@subprobbuf}%
6858 \fi%
6859 \exf@verbatim#2}%
6860 % \end{macrocode}
6861 % End verbatim processing; close |printsubproblem| environment:
6862 % \begin{macrocode}
6863 {\exf@endverbatim%
6864 \ifexf@scansubproblem@disable\else%
6865 \exf@addline\exf@subprobbuf{\@backslashchar end{printsubproblem}}%
6866 \fi%
6867 % \end{macrocode}
6868 % Output buffer immediately:
6869 % \begin{macrocode}
6870 \exf@source@buf\exf@subprobbuf%
6871 % \end{macrocode}
6872 % Done:
6873 % \begin{macrocode}
6874 \ignorespacesafterend}
6875 % \end{macrocode}
6876
6877 % \macro{subproblem}
6878 % Define |subproblem| environment (potentially using custom name)
6879 % to choose between direct and buffered version:
6880 % \begin{macrocode}
6881 \newenvironment{\exf@subproblemname}%
6882 {\ifexf@subproblembuf\let\exf@tmp\exf@subproblem@scan%
6883 \else\let\exf@tmp\exf@subproblem@direct\fi%
6884 \exf@tmp}%
6885 {\ifexf@subproblembuf\let\exf@tmp\endexf@subproblem@scan%
6886 \else\let\exf@tmp\endexf@subproblem@direct\fi%
6887 \exf@tmp}
6888 % \end{macrocode}
6889
6890 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6891 % \subsection{Solution Environment}
6892 % \label{sec:imp-solution}
6893 %
6894 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6895 % \paragraph{Print Solutions.}
6896 %
6897 % \macro{exf@solution}
6898 % Define options for |solution| environment:
6899 % \begin{macrocode}
6900 \define@key{exf@solution}{prob}{\def\exf@solprob{#1}}
6901 \define@key{exf@solution}{subprob}{\def\exf@solsubprob{#1}}
6902 \define@key{exf@solution}{problemtag}{\def\problemtag{#1}}
6903 \define@key{exf@solution}{sheettag}{\def\sheettag{#1}}
6904 \define@key{exf@solution}{href}{\def\exf@solhref{#1}}
6905 \define@key{exf@solution}{label}{\def\exf@label{#1}}
6906 \define@key{exf@solution}{points}{\exf@scanpoints\exf@solution@points#1++@}
6907 \define@key{exf@solution}{probtitle}{\def\exf@solprobtitle{#1}}
6908 \define@key{exf@solution}{firstsol}[]{\let\exf@solfirst\exf@empty}
6909 % \end{macrocode}
6910
6911 % \macro{printsolution}
6912 % Define |printsolution| environment
6913 % to display a previously read |solution| environment;
6914 % this works analogously to |problem| and |subproblem|:
6915 % \begin{macrocode}
6916 \newenvironment{printsolution}[1]{%
6917 % \end{macrocode}
6918 % Start new paragraph, add vertical space:
6919 % \begin{macrocode}
6920 \par{\exf@config@styletext\addvspace{\exf@config@skipsolutionabove}}%
6921 % \end{macrocode}
6922 % Insert hook code:
6923 % \begin{macrocode}
6924 \exf@config@insertsolutionbefore%
6925 % \end{macrocode}
6926 % Use equation counter for solutions:
6927 % \begin{macrocode}
6928 \ifexf@style@solutionequation%
6929 \exf@eqsav\value{equation}\relax%
6930 \setcounter{equation}{\value{exf@solutionequation}}%
6931 \let\theequation\theexf@solutionequation%
6932 \let\theHequation\theHexf@solutionequation%
6933 \fi%
6934 % \end{macrocode}
6935 % Start a group, initialise variables, process arguments:
6936 % \begin{macrocode}
6937 \begingroup%
6938 \def\exf@in@solution{}%
6939 \def\exf@solprob{}%
6940 \def\exf@solsubprob{}%
6941 \let\exf@solfirst\@undefined%
6942 \let\exf@label\@undefined%
6943 \let\exf@solution@points\@undefined%
6944 \let\exf@solution@points@total\@undefined%
6945 \def\exf@solhref{}%
6946 \exf@init@block{\exf@config@skipsolutioninfo}%
6947 \setkeys{exf@solution,exf@probleminfo,exf@scansolution}{#1}%
6948 % \end{macrocode}
6949 % Set solution counter to reflect associated problem:
6950 % \begin{macrocode}
6951 \exf@csdo\def{the\exf@solutioncounter}%
6952 {\exf@config@composeitemsolutionlabel{\exf@solprob}{\exf@solsubprob}}%
6953 \refstepcounter{\exf@solutioncounter}%
6954 % \end{macrocode}
6955 % Set label:
6956 % \begin{macrocode}
6957 \ifdefined\exf@label\label{\exf@label}\fi%
6958 % \end{macrocode}
6959 % Remember points for display;
6960 % disable points display if desired:
6961 % \begin{macrocode}
6962 \let\exf@solution@points@show\@undefined%
6963 \ifdefined\exf@solution@points%
6964 \let\exf@solution@points@show\exf@solution@points\fi%
6965 \exf@ifis\exf@solpointsat{off}{\let\exf@solution@points@show\@undefined}%
6966 % \end{macrocode}
6967 % Display points in opening line if desired;
6968 % expand points into argument and remove points:
6969 % \begin{macrocode}
6970 \exf@ifis\exf@solpointsat{start}{\exf@outpoints{\exf@append@intro}%
6971 {\exf@config@composepointspairstartsolution}{\exf@solution@points@show}}%
6972 \exf@ifis\exf@solpointsat{start*}{\exf@outpoints{\exf@prepend@intro}%
6973 {\exf@config@composepointspairstartsolution}{\exf@solution@points@show}}%
6974 % \end{macrocode}
6975 % Insert hook code, set solution body style:
6976 % \begin{macrocode}
6977 \exf@config@insertsolutioninfo%
6978 \exf@config@styletext\exf@config@styletextsolution%
6979 % \end{macrocode}
6980 % Determine solution for problem or subproblem:
6981 % \begin{macrocode}
6982 \exf@addmargin\glueexpr\ifx\exf@solsubprob\exf@empty%
6983 \exf@config@skipsolutionitem\else\exf@config@skipsolutionitemsub\fi\relax%
6984 % \end{macrocode}
6985 % Write title without item:
6986 % \begin{macrocode}
6987 \ifdim\exf@addmargin=0pt%
6988 \protected@edef\exf@solution@title{%
6989 \exf@composetitle{\exf@solprob}{\exf@solsubprob}}%
6990 \ifx\exf@solsubprob\exf@empty\ifdefined\exf@solfirst\else%
6991 \let\exf@solution@title\exf@empty\fi\fi%
6992 \ifx\exf@solution@title\exf@empty\else%
6993 \exf@prepend@intro{{%
6994 \exf@config@styletitle\exf@config@styletitlesolution%
6995 \ifexf@solutionhref\exf@href{\exf@solhref}%
6996 {\exf@solution@title}\else\exf@solution@title\fi}}%
6997 \fi%
6998 % \end{macrocode}
6999 % Write item with fixed total width or item width plus space:
7000 % \begin{macrocode}
7001 \else%
7002 \ifdim\exf@addmargin<0pt%
7003 \settowidth\exf@addmargin{%
7004 \exf@config@styletitle\exf@config@styletitlesolution%
7005 \ifx\exf@solsubprob\exf@empty%
7006 \let\exf@tmp\exf@config@composeitemsolutionfirst\else%
7007 \let\exf@tmp\exf@config@composeitemsolutionfirstsub\fi%
7008 \protected@edef\exf@solution@item{\exf@tmp%
7009 {\exf@config@counterproblemmax}{\exf@config@countersubproblemmax}}%
7010 \ifx\exf@solution@item\exf@empty\else%
7011 \exf@solution@item\exf@config@composeitemsolutionsep\fi}%
7012 \fi%
7013 % \end{macrocode}
7014 % Set item label depending on problem or subproblem:
7015 % \begin{macrocode}
7016 \ifx\exf@solsubprob\exf@empty\ifdefined\exf@solfirst%
7017 \let\exf@tmp\exf@config@composeitemsolutionfirst\else%
7018 \let\exf@tmp\exf@config@composeitemsolution\fi%
7019 \else\ifdefined\exf@solfirst%
7020 \let\exf@tmp\exf@config@composeitemsolutionfirstsub\else%
7021 \let\exf@tmp\exf@config@composeitemsolutionsub\fi\fi%
7022 \protected@edef\exf@solution@item{\exf@tmp{\exf@solprob}{\exf@solsubprob}}%
7023 % \end{macrocode}
7024 % Define item label:
7025 % \begin{macrocode}
7026 \def\exf@introitem{\ifx\exf@solution@item\exf@empty\else\makebox[0cm][r]{%
7027 \exf@config@styletitle\exf@config@styletitlesubproblem%
7028 \ifexf@solutionhref\exf@href{\exf@solhref}{\exf@solution@item}%
7029 \else\exf@solution@item\fi%
7030 \exf@config@composeitemproblemsep}\fi}%
7031 \fi%
7032 % \end{macrocode}
7033 % Write points into margin if desired;
7034 % expand points into argument and remove points:
7035 % \begin{macrocode}
7036 \exf@ifis\exf@solpointsat{margin}{%
7037 \exf@outpoints{\exf@prepend@def\exf@introitem}%
7038 {\exf@makepointsmarginsolution}{\exf@solution@points@show}}%
7039 % \end{macrocode}
7040 % Write out opening line:
7041 % \begin{macrocode}
7042 \exf@open@block{\exf@config@skipsolutiontitle}%
7043 % \end{macrocode}
7044 % Done:
7045 % \begin{macrocode}
7046 \@afterindentfalse}%
7047 % \end{macrocode}
7048 % End environment, show points if desired, perform sanity check:
7049 % \begin{macrocode}
7050 {\exf@ifis\exf@solpointsat{end}{\showpoints}%
7051 \exf@warnmismatch{\exf@solutionname}{\exf@solutioncounter}%
7052 {\exf@solution@points@total}{\exf@solution@points}%
7053 % \end{macrocode}
7054 % End paragraph and envionment:
7055 % \begin{macrocode}
7056 \par\exf@close@block%
7057 % \end{macrocode}
7058 % Restore original equation counter:
7059 % \begin{macrocode}
7060 \ifexf@style@solutionequation%
7061 \setcounter{exf@solutionequation}{\value{equation}}%
7062 \setcounter{equation}{\exf@eqsav}%
7063 \fi%
7064 % \end{macrocode}
7065 % End inner group:
7066 % \begin{macrocode}
7067 \endgroup%
7068 % \end{macrocode}
7069 % Vertical skip, insert hook code:
7070 % \begin{macrocode}
7071 {\exf@config@styletext\addvspace{\exf@config@skipsolutionbelow}}%
7072 \exf@config@insertsolutionafter%
7073 % \end{macrocode}
7074 % Done:
7075 % \begin{macrocode}
7076 \ignorespacesafterend}
7077 % \end{macrocode}
7078
7079 % \macro{\solutionssection}
7080 % Define a section for a problem within a solution block:
7081 % \begin{macrocode}
7082 \newcommand{\solutionssection}[1]{\begingroup%
7083 % \end{macrocode}
7084 % Initialise variables, process arguments:
7085 % \begin{macrocode}
7086 \def\exf@solprob{}%
7087 \def\exf@solsubprob{}%
7088 \def\exf@solprobtitle{}%
7089 \let\exf@label\@undefined%
7090 \let\exf@solhref\@undefined%
7091 \setkeys{exf@solution,exf@scansolution}{#1}%
7092 % \end{macrocode}
7093 % Select title (and table of contents entry)
7094 % corresponding to multiple problems vs.\ single problem:
7095 % \begin{macrocode}
7096 \let\exf@composesectitle\exf@config@composetitlesolutionsproblemmulti%
7097 \exf@ifis\exf@solutionbelow{problem}{\let\exf@composesectitle%
7098 \exf@config@composetitlesolutionsproblemsingle}%
7099 \exf@ifis\exf@solutionbelow{problem*}{\let\exf@composesectitle%
7100 \exf@config@composetitlesolutionsproblemsingle}%
7101 \def\exf@solutionstoc{\exf@addcontentsline{\exf@config@toclevelsolution}%
7102 {\exf@config@composetocsolution{\exf@solprob}{\exf@solprobtitle}}}%
7103 % \end{macrocode}
7104 % Write section line:
7105 % \begin{macrocode}
7106 \addvspace{\exf@config@skipsolutionsproblemabove}%
7107 \exf@solutionssection{\exf@config@styletitlesolutionsproblem}%
7108 {\exf@composesectitle{\exf@solprob}{\exf@solprobtitle}}%
7109 {\exf@config@skipsolutionsproblemtitle}%
7110 {\exf@solutionstoc}{\exf@label}{\exf@solhref}%
7111 \endgroup}
7112 % \end{macrocode}
7113
7114 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7115 % \paragraph{Read Solution Environment.}
7116 %
7117 % \macro{exf@scansolution}
7118 % Define options for scanning |solution| environment:
7119 % \begin{macrocode}
7120 \define@key{exf@scansolution}{forproblem}[]{\exf@clear@prevsubprob}
7121 \define@boolkey{exf@scansolution}[exf@scansolution@]{disable}[true]{}
7122 % \end{macrocode}
7123
7124 % \macro{\exf@clear@prevsubprob}
7125 % Clear previous subproblem register:
7126 % \begin{macrocode}
7127 \newcommand{\exf@clear@prevsubprob}{%
7128 \global\let\exf@prevsubprob\@undefined%
7129 \global\let\exf@prevsubprobhref\@undefined%
7130 \global\let\exf@prevpoints\@undefined%
7131 \global\exf@scansubproblem@disablefalse}
7132 % \end{macrocode}
7133
7134 % \macro{\exf@process@solsec}
7135 % If this is the first solution within a problem section,
7136 % write section heading to buffer:
7137 % \begin{macrocode}
7138 \newcommand{\exf@process@solsec}{%
7139 \def\exf@probarg{\ifdefined\exf@prevprob prob={\exf@prevprob}\fi%
7140 \ifdefined\exf@prevprobtitle,probtitle={\exf@prevprobtitle}\fi%
7141 \ifdefined\exf@prevprobhref,href={\exf@prevprobhref}\fi%
7142 \ifdefined\exf@sollabel,label={\exf@sollabel}\fi}%
7143 \exf@ifis\exf@solutionbelow{here}{\let\exf@probarg\@undefined}%
7144 \exf@ifis\exf@solutionbelow{subproblem}{\let\exf@probarg\@undefined}%
7145 \exf@ifis\exf@solutionbelow{subproblem*}{\let\exf@probarg\@undefined}%
7146 \ifdefined\exf@probarg%
7147 \ifexf@lineno\exf@addline\exf@solbuf{\exf@linesep}%
7148 \exf@addline\exf@solbuf{\exf@lineno}\fi%
7149 \exf@addline\exf@solbuf{\@backslashchar solutionssection{\exf@probarg}}%
7150 \exf@addline\exf@solbuf{}%
7151 \fi}
7152 % \end{macrocode}
7153
7154 % \macro{\exf@generate@solprobarg}
7155 % Declare additional arguments to |printsolution|
7156 % to describe corresponding problem and tags:
7157 % \begin{macrocode}
7158 \newcommand{\exf@generate@solprobarg}{%
7159 \edef\exf@solprobarg{%
7160 \ifdefined\exf@problem@solfirst firstsol,\fi%
7161 \ifdefined\exf@prevprob prob={\exf@prevprob},\fi%
7162 \ifdefined\exf@prevsubprob subprob={\exf@prevsubprob},%
7163 \ifdefined\exf@prevsubprobhref href={\exf@prevsubprobhref},\fi%
7164 \else%
7165 \ifdefined\exf@prevprobhref href={\exf@prevprobhref},\fi%
7166 \fi%
7167 \ifdefined\exf@prevpoints points=%
7168 {\expandafter\exf@formatpoints\exf@prevpoints},\fi%
7169 \ifdefined\sheettag sheettag={\sheettag},\fi%
7170 \ifdefined\problemtag problemtag={\problemtag},\fi}}
7171 % \end{macrocode}
7172
7173 % \macro{exf@solution@direct}
7174 % Define direct output version of |solution| environment;
7175 % pass on to |printsolution| environment:
7176 % \begin{macrocode}
7177 \newenvironment{exf@solution@direct}[1][]%
7178 {\showpoints%
7179 \exf@generate@solprobarg%
7180 \global\let\exf@problem@solfirst\@undefined%
7181 \exf@clear@prevsubprob%
7182 \exf@showsolutionsin%
7183 \let\exf@composetitle\exf@config@composetitlesolutionsingle%
7184 \exf@exptwo\printsolution{\exf@solprobarg#1}}%
7185 {\endprintsolution%
7186 \exf@showsolutionsout%
7187 \ignorespacesafterend}
7188 % \end{macrocode}
7189
7190 % \macro{exf@solution@scan}
7191 % \macro{exf@scansolution}
7192 % Define scan version of |solution| environment;
7193 % use |\exf@scanblock| to properly parse optional argument
7194 % and pass on to |exf@scansolution|:
7195 % \begin{macrocode}
7196 \newenvironment{exf@solution@scan}%
7197 {\exf@scanblock{\exf@scansolution}}{\endexf@scansolution}%
7198 \newenvironment{exf@scansolution}[2]{%
7199 % \end{macrocode}
7200 % Determine solution association and display:
7201 % \begin{macrocode}
7202 \exf@scansolution@disablefalse%
7203 \setkeys*{exf@scansolution}{#1}%
7204 \ifdefined\exf@prevsubprob%
7205 \ifexf@scansubproblem@disable\exf@scansolution@disabletrue\fi%
7206 \else%
7207 \ifexf@scanproblem@disable\exf@scansolution@disabletrue\fi%
7208 \fi%
7209 % \end{macrocode}
7210 % Circumvent solution display:
7211 % \begin{macrocode}
7212 \ifexf@scansolution@disable%
7213 \exf@clear@prevsubprob%
7214 \def\exf@verbatim@process{\@gobble}%
7215 \else%
7216 % \end{macrocode}
7217 % If solution is to be displayed immediately,
7218 % make sure to display points first;
7219 % insert solution section heading in buffer;
7220 % compose additional arguments to |printsolution|:
7221 % \begin{macrocode}
7222 \exf@ifis\exf@solutionbelow{here}{\showpoints}%
7223 \exf@generate@solprobarg%
7224 \ifdefined\exf@problem@solfirst\exf@process@solsec\fi%
7225 \global\let\exf@problem@solfirst\@undefined%
7226 \exf@clear@prevsubprob%
7227 % \end{macrocode}
7228 % Write separator and |printsolution| environment to buffer:
7229 % \begin{macrocode}
7230 \ifexf@lineno\exf@addline\exf@solbuf{\exf@linesep}%
7231 \exf@addline\exf@solbuf{\exf@lineno}\fi%
7232 \exf@addline\exf@solbuf%
7233 {\@backslashchar begin{printsolution}{\exf@solprobarg#1}}%
7234 % \end{macrocode}
7235 % Start verbatim processing:
7236 % \begin{macrocode}
7237 \def\exf@verbatim@process{\exf@append@buf\exf@solbuf}%
7238 \fi%
7239 \exf@verbatim#2}%
7240 % \end{macrocode}
7241 % End verbatim processing; close |printsolution| environment:
7242 % \begin{macrocode}
7243 {\exf@endverbatim%
7244 \ifexf@scansolution@disable\else%
7245 \exf@addline\exf@solbuf{\@backslashchar end{printsolution}}%
7246 \global\exf@solbuf@cleanfalse%
7247 \fi%
7248 % \end{macrocode}
7249 % Write buffer to file if output file open:
7250 % \begin{macrocode}
7251 \ifexf@solfile@open%
7252 \exf@write@buf\exf@solfile\exf@solbuf%
7253 \exf@clear@solbuf%
7254 \fi%
7255 % \end{macrocode}
7256 % Drop buffer if solutions not to be displayed:
7257 % \begin{macrocode}
7258 \ifsolutions\else\exf@clear@solbuf\fi%
7259 % \end{macrocode}
7260 % Display solution immediately in various cases:
7261 % \begin{macrocode}
7262 \exf@ifis\exf@solutionbelow{here}{%
7263 \exf@showsolutions{\exf@config@composetitlesolutionsingle}{}}%
7264 \ifdefined\exf@in@subproblem\else%
7265 \exf@ifis\exf@solutionbelow{subproblem}{%
7266 \exf@showsolutions{\exf@config@composetitlesolutionsingle}{}}%
7267 \exf@ifis\exf@solutionbelow{subproblem*}{%
7268 \exf@showsolutions{\exf@config@composetitlesolutionsingle}{}}\fi%
7269 \ifdefined\exf@in@problem\else%
7270 \exf@ifis\exf@solutionbelow{problem}{%
7271 \exf@showsolutions{\exf@config@composetitlesolutionmulti}{}}%
7272 \exf@ifis\exf@solutionbelow{problem*}{%
7273 \exf@showsolutions{\exf@config@composetitlesolutionmulti}{}}\fi%
7274 % \end{macrocode}
7275 % Done:
7276 % \begin{macrocode}
7277 \ignorespacesafterend}
7278 % \end{macrocode}
7279
7280 % \macro{solution}
7281 % Define |solution| environment (potentially using custom name)
7282 % to choose between direct and buffered version:
7283 % \begin{macrocode}
7284 \newenvironment{\exf@solutionname}%
7285 {\ifexf@solutionbuf\let\exf@tmp\exf@solution@scan%
7286 \else\let\exf@tmp\exf@solution@direct\fi%
7287 \exf@tmp}%
7288 {\ifexf@solutionbuf\let\exf@tmp\endexf@solution@scan%
7289 \else\let\exf@tmp\endexf@solution@direct\fi%
7290 \exf@tmp}
7291 % \end{macrocode}
7292
7293 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7294 % \subsection{Solution Blocks}
7295 % \label{sec:imp-solutions}
7296 %
7297 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7298 % \paragraph{Solution Block Handling.}
7299 %
7300 % \macro{\exf@solutionssection}
7301 % Output solution block section:
7302 % \begin{macrocode}
7303 \newcommand{\exf@solutionssection}[6]{%
7304 % \end{macrocode}
7305 % Check whether title is empty:
7306 % \begin{macrocode}
7307 \protected@edef\exf@solutionstitleexp{#2}%
7308 \ifx\exf@solutionstitleexp\exf@empty\else%
7309 % \end{macrocode}
7310 % Define a label:
7311 % \begin{macrocode}
7312 \ifdefined#5%
7313 \exf@csdo\def{the\exf@solutioncounter}%
7314 {\exf@config@composeitemsolutionlabel{\exf@solprob}{\exf@solsubprob}}%
7315 \refstepcounter{\exf@solutioncounter}\label{#5}%
7316 \fi%
7317 % \end{macrocode}
7318 % Output section line:
7319 % \begin{macrocode}
7320 \exf@section{#3}{\exf@config@styletitle\exf@config@styletitlesolution#1%
7321 \ifexf@solutionhref\exf@href{#6}{\exf@solutionstitleexp}%
7322 \else\exf@solutionstitleexp\fi}#4%
7323 \fi}
7324 % \end{macrocode}
7325
7326 % \macro{\exf@solutionstitle}
7327 % Compose the title for a solution block:
7328 % \begin{macrocode}
7329 \newcommand{\exf@solutionstitle}{\exf@solutionssection%
7330 {\exf@config@styletitlesolutions}{%
7331 \exf@config@composetitlesolutions}{\exf@config@skipsolutionstitle}%
7332 {\exf@addcontentsline{\exf@config@toclevelsolutions}%
7333 {\exf@config@composetocsolutions}}{\@undefined}{\@undefined}}
7334 % \end{macrocode}
7335
7336 % \macro{\exf@showsolutionsin}
7337 % Output solution block intro:
7338 % \begin{macrocode}
7339 \newcommand{\exf@showsolutionsin}{%
7340 % \end{macrocode}
7341 % Set solution body style; add vertical space; insert hook code:
7342 % \begin{macrocode}
7343 \par\exf@config@styletext\addvspace{\exf@config@skipsolutionsabove}%
7344 \exf@config@styletextsolution%
7345 \exf@config@insertsolutionsbefore}
7346 % \end{macrocode}
7347
7348 % \macro{\exf@showsolutionsout}
7349 % Output solution block outro:
7350 % \begin{macrocode}
7351 \newcommand{\exf@showsolutionsout}{%
7352 % \end{macrocode}
7353 % Insert hook code; close paragraph; add vertical space:
7354 % \begin{macrocode}
7355 \exf@config@insertsolutionsafter%
7356 \par\exf@config@styletext\addvspace{\exf@config@skipsolutionsbelow}}
7357 % \end{macrocode}
7358
7359 % \macro{\exf@showsolutions}
7360 % Output solution block in buffer:
7361 % \begin{macrocode}
7362 \newcommand{\exf@showsolutions}[2]{%
7363 % \end{macrocode}
7364 % Do nothing if buffer is empty (avoid titles):
7365 % \begin{macrocode}
7366 \ifexf@solbuf@clean\else\begingroup%
7367 % \end{macrocode}
7368 % Execute output solution block intro:
7369 % \begin{macrocode}
7370 \exf@showsolutionsin%
7371 \let\exf@composetitle#1%
7372 #2%
7373 % \end{macrocode}
7374 % Source and clear buffer:
7375 % \begin{macrocode}
7376 \exf@source@buf\exf@solbuf%
7377 \exf@clear@solbuf%
7378 % \end{macrocode}
7379 % Execute output solution block outro:
7380 % \begin{macrocode}
7381 \exf@showsolutionsout%
7382 \endgroup\fi}
7383 % \end{macrocode}
7384
7385 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7386 % \paragraph{Solutions Buffer Interface.}
7387 %
7388 % \macro{\writesolutions}
7389 % Open a file |#1.sol| for writing solutions;
7390 % default is present main file name:
7391 % \begin{macrocode}
7392 \newcommand{\writesolutions}[1][\jobname]{%
7393 \exf@close@solfile\exf@start@solfile{#1}}
7394 % \end{macrocode}
7395
7396 % \macro{\closesolutions}
7397 % Close solutions output file (if open):
7398 % \begin{macrocode}
7399 \newcommand{\closesolutions}{\exf@close@solfile}
7400 % \end{macrocode}
7401
7402 % \macro{\readsolutions}
7403 % Read solutions from file |#1.sol|;
7404 % default is present main file name;
7405 % switch layout and add heading:
7406 % \begin{macrocode}
7407 \newcommand{\readsolutions}[1][\jobname]{\exf@close@solfile%
7408 \ifsolutions\begingroup%
7409 \exf@config@styletext\exf@config@styletextsolution%
7410 \let\exf@composetitle\exf@config@composetitlesolutionmulti%
7411 \exf@solutionstitle%
7412 \input{#1\exf@config@extsolutions}%
7413 \endgroup\fi}
7414 % \end{macrocode}
7415
7416 % \macro{\insertsolutions}
7417 % Show solutions buffer:
7418 % \begin{macrocode}
7419 \newcommand{\insertsolutions}{\exf@showsolutions%
7420 {\exf@config@composetitlesolutionmulti}{\exf@solutionstitle}}
7421 % \end{macrocode}
7422
7423 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7424 % \subsection{Interaction with metastr}
7425 % \label{sec:imp-metastr}
7426 %
7427 % This package transfers some functionality
7428 % to the package \ctanpkg{metastr} when loaded
7429 % previously (preferably with package option |course|)
7430 % by the package option |metastr|.
7431 % The following changes apply:
7432 % \begin{itemize}
7433 % \item
7434 % The terms specified by the configuration options |term...|,
7435 % see \secref{sec:imp-config},
7436 % are transferred to the corresponding term registers
7437 % |\metaterm{...}| in \ctanpkg{metastr}.
7438 % This can facilitate internationalisation,
7439 % and suitable words for English, German, French and Spanish are provided.
7440 % \item
7441 % Metadata should be filled via |\metaset| rather than |\exercisedata|.
7442 % The present package will read it from the \ctanpkg{metastr} registers.
7443 % \item
7444 % Basic pdf metadata is written automatically or manually.
7445 % This is done via |\metawritepdfinfo|,
7446 % consequently, automatic writing of these basic metadata
7447 % is disabled in \ctanpkg{metastr}.
7448 % \item
7449 % Sheet-specific metadata (package option |pdfdata=sheet|)
7450 % is handled via the \ctanpkg{metastr} registers |sheettitle| and |sheetdata|
7451 % rather than |composemetasheet|.
7452 % \end{itemize}
7453 %
7454 % Apply modifications only when package \ctanpkg{metastr} is loaded:
7455 % \begin{macrocode}
7456 \ifdefined\metaset
7457 % \end{macrocode}
7458
7459 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7460 % \paragraph{Transfer Metadata.}
7461 %
7462 % Import basic data from \ctanpkg{metastr}:
7463 % \begin{macrocode}
7464 \exercisedata{author={\metapick[]{author}}}
7465 \exercisedata{title={\metapick[]{title}}}
7466 \exercisedata{subject={\metapick[]{subject}}}
7467 \exercisedata{keyword={\metapick[]{keyword}}}
7468 \exercisedata{date={\metapick[]{date}}}
7469 % \end{macrocode}
7470 % Import course data from \ctanpkg{metastr}:
7471 % \begin{macrocode}
7472 \ifdefined\mstr@def@course
7473 \exercisedata{course={\metapick[]{course}}}
7474 \exercisedata{instructor={\metapick[]{instructor}}}
7475 \exercisedata{institution={\metapick[]{institution}}}
7476 \exercisedata{period={\metapick[]{period}}}
7477 \exercisedata{material={\metapick[]{material}}}
7478 \fi
7479 % \end{macrocode}
7480
7481 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7482 % \paragraph{Sheet Data.}
7483 %
7484 % \macro{sheettitle}
7485 % \macro{sheetauthor}
7486 % Registers for sheet title and author:
7487 % \begin{macrocode}
7488 \metadef{sheettitle}
7489 \metadef{sheetauthor}
7490 % \end{macrocode}
7491
7492 % \macro{\exf@writemetadata}
7493 % Write pdf metadata via \ctanpkg{metastr} package,
7494 % let \ctanpkg{exframe} initiate process (especially for sheet):
7495 % \begin{macrocode}
7496 \metaunset[info]{writepdf}
7497 \def\exf@writemetadata{%
7498 \exf@ifis\exf@metadata{sheet}{\metaset[use]{sheettitle}{}}%
7499 \metawritepdfinfo%
7500 \exf@ifis\exf@metadata{sheet}{\metaunset[use]{sheettitle}}}
7501 % \end{macrocode}
7502
7503 % Fill registers:
7504 % \begin{macrocode}
7505 \metaset{sheetauthor}{\exerciseifempty{\getsheetdata{author}}%
7506 {\metapick[#1]{instructor}}{\getsheetdata{author}}}
7507 \metaset{sheettitle}{\exerciseifempty{\getsheetdata{rawtitle}}%
7508 {\metatranslate[#1]{sheet} \thesheet}%
7509 {\getsheetdata{rawtitle}}}
7510 \metaset{author}{\exerciseifempty{\getsheetdata{author}}%
7511 {\metapick[#1]{instructor}}{\metapick[#1]{sheetauthor}}}
7512 \metaset{subtitle}{%
7513 \metaif[use]{sheettitle}%
7514 {\metapick[#1]{sheettitle}}%
7515 {\metapick[#1]{material}}}
7516 % \end{macrocode}
7517
7518 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7519 % \paragraph{Terms.}
7520 %
7521 % \macro{term...}
7522 % Transfer term definitions to \ctanpkg{metastr}:
7523 % \begin{macrocode}
7524 \exerciseconfig{termsheet}{\metaterm{sheet}}
7525 \exerciseconfig{termsheets}{\metaterm{sheets}}
7526 \exerciseconfig{termproblem}{\metaterm{problem}}
7527 \exerciseconfig{termproblems}{\metaterm{problems}}
7528 \exerciseconfig{termsolution}{\metaterm{solution}}
7529 \exerciseconfig{termsolutions}{\metaterm{solutions}}
7530 \exerciseconfig{termpoint}{\metaterm{point}}
7531 \exerciseconfig{termpoints}{\metaterm{points}}
7532 % \end{macrocode}
7533
7534 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7535 % \paragraph{Translations.}
7536 %
7537 % English:
7538 % \begin{macrocode}
7539 \ifdefined\mstr@lang@en
7540 \metasetterm[en]{sheet}{Sheet}
7541 \metasetterm[en]{sheets}{Sheets}
7542 \metasetterm[en]{problem}{Problem}
7543 \metasetterm[en]{problems}{Problems}
7544 \metasetterm[en]{solution}{Solution}
7545 \metasetterm[en]{solutions}{Solutions}
7546 \metasetterm[en]{point}{point}
7547 \metasetterm[en]{points}{points}
7548 \fi
7549 % \end{macrocode}
7550
7551 % German:
7552 % \begin{macrocode}
7553 \ifdefined\mstr@lang@de
7554 \metasetterm[de]{sheet}{Blatt}
7555 \metasetterm[de]{sheets}{Blätter}
7556 \metasetterm[de]{problem}{Aufgabe}
7557 \metasetterm[de]{problems}{Aufgaben}
7558 \metasetterm[de]{solution}{L\"osung}
7559 \metasetterm[de]{solutions}{L\"osungen}
7560 \metasetterm[de]{point}{Punkt}
7561 \metasetterm[de]{points}{Punkte}
7562 \fi
7563 % \end{macrocode}
7564
7565 % French:
7566 % \begin{macrocode}
7567 \ifdefined\mstr@lang@fr
7568 \metasetterm[fr]{sheet}{Feuille}
7569 \metasetterm[fr]{sheets}{Feuilles}
7570 \metasetterm[fr]{problem}{Probl\`eme}
7571 \metasetterm[fr]{problems}{Probl\`emes}
7572 \metasetterm[fr]{solution}{Solution}
7573 \metasetterm[fr]{solutions}{Solutions}
7574 \metasetterm[fr]{point}{point}
7575 \metasetterm[fr]{points}{points}
7576 \fi
7577 % \end{macrocode}
7578
7579 % Spanish:
7580 % \begin{macrocode}
7581 \ifdefined\mstr@lang@es
7582 \metasetterm[es]{sheet}{Hoja}
7583 \metasetterm[es]{sheets}{Hojas}
7584 \metasetterm[es]{problem}{Problema}
7585 \metasetterm[es]{problems}{Problemas}
7586 \metasetterm[es]{solution}{Solucion}
7587 \metasetterm[es]{solutions}{Soluciones}
7588 \metasetterm[es]{point}{punto}
7589 \metasetterm[es]{points}{puntos}
7590 \fi
7591 % \end{macrocode}
7592
7593 % Close \ctanpkg{metastr} conditional:
7594 % \begin{macrocode}
7595 \fi
7596 % \end{macrocode}
7597
7598 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7599 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7600 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7601 % \iffalse
7602 %</package>
7603 % \fi
7604 %
7605 \endinput