summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/exercisebank/exercisebank.sty
blob: fec5d392ed3ecd699c2dcd9daafd508a118977f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
% Source (with comments) can be found at https://github.com/Strauman/exercisebank/
%% The LaTeX package exercisebank - version v0.2.1 (2018/09/24) - build 95
%% exercisebank.sty: Exercise bank
%% -------------------------------------------------------------------------------------------
%% Copyright (c) 2018 by Andreas Storvik Strauman <andreas dot s dot strauman at uit dot no>
%% -------------------------------------------------------------------------------------------
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of LaTeX
%% version 2008/05/04 or later.
%% This work has the LPPL maintenance status `author-maintained'.
%% This work consists of all files listed in README
\ProvidesPackage{exercisebank}[2018/09/24 v0.2.1 Creates a setup that gives freedom in making sets and exercises.]
\xdef\exbank@quiet{1}
\def\exercisebankversion{v0.2.1 - Build 95}
\PackageWarningNoLine{exercisebank-v0.2.1}{This package is in the beta stage, and if something unexpected happens please, oh pretty please, report it to https://github.com/Strauman/exercisebank. Thank you!}
\@ifundefined{ownLineNoSpacesGotIt}{\@latex@warning{Compilation wont work unless \string\end{problem} and \string\end{solution} are on their own lines and without any spaces. This warning can be removed by doing \string\def\string\ownLineNoSpacesGotIt{} before \@backslashchar usepackage{exercisebank}}
}{}
\gdef\setExercisesDir#1{\@latex@error{\string\setExercisesDir is deprecated. Use \string\exercisebanksetup{exercise directory=#1} instead}{}\stop\bye
}
\@ifundefined{exercisesDir}{\gdef\@exercisesDir{.}
}{}
\global\let\incl = \input
\usepackage{xstring}
\usepackage{pgffor}
\usepackage{scrextend}
\usepackage{comment}
\usepackage{calc}
\usepackage{pgfpages}
\usepackage{geometry}
\usepackage{listofitems}
\usepackage{trimspaces}
\usepackage{needspace}
\edef\@isTrue{1}
\edef\@isFalse{0}
\gdef\exb@int@isin#1#2#3#4{%
	\def\needle{#1}
	\def\haystack{#2}
	\ifx\haystack\empty\relax#4\else%
		\def\isFalse{0}%
		\let\isInList = \isFalse%
		\IfInteger{\needle}{}{\@latex@error{ISIN: Can't look for part problem that is not numeric: `\needle' in `\haystack'!}{}\bye\stop}%
		\IfInteger{\haystack}{			\ifnum\haystack=\needle\relax%
				#3%
			\else%
				#4%
			\fi%
}{			\foreach\pp in #2{%
					\ifnum\pp=\needle\relax%
						\gdef\isInList{1}%
						#3%
					\fi%
}%
			\if\isInList\isFalse%
				#4%
			\fi%
}%
	\fi}
\gdef\exb@warn{\PackageWarningNoLine{exercisebank-v0.2.1}}
\gdef\exb@err#1{\PackageError{exercisebank}{#1}{}}
\newif\ifexb@isInList
\newcounter{exb@isin@dots}
\gdef\exb@isin#1#2#3#4{\@dinfo{running isin}
	\global\exb@isInListfalse
	\xdef\needle{#1}
	\xdef\haystack{#2}
	\def\whenfalse{#4}
	\def\whentrue{#3}
	\ifx\haystack\empty\relax#4\else%
		\readlist*\items\haystack%
		\foreachitem\itm\in\items{%
			\ifnum\pdfstrcmp{\needle}{\itm}=\z@\relax%
				\global\exb@isInListtrue%
				#3\fi%
}%
		\ifexb@isInList\else%
			#4
		\fi\fi%
}
\gdef\strif#1#2{%
	\ifnum\pdfstrcmp{#1}{#2}=\z@\relax%
}
\let\ea = \expandafter
\begingroup\lccode`\|=`\\
\lowercase{\endgroup\def\removebs#1{\if#1|\else#1\fi}}
\gdef\exbank@macroname#1{\expandafter\removebs\string#1}
\gdef\@noneofone#1{}
\gdef\@noneoftwo#1#2{}
{\globaldefs=1\newcommand\@opt@gobble[2][]{}}
\@ifundefined{exbank@verbose}{	\global\let\@dinfo\@gobble
	\global\let\@dinfomode\@opt@gobble
}{	\bgroup
	\globaldefs=1\newcommand\@dinfo[2][]{%
			\@latex@warning{--INFO:#2}%
}%
	\egroup%
}
\@ifundefined{exbank@quiet}{	\gdef\@dlog#1{\@latex@warning{::DEBUG:#1}}%
}{	\global\let\@dlog\@noneofone%
}
\gdef\shownextchar#1{\@latex@warning{NEXT:\string#1}#1}
\newcommand\ex@before[2]{	\edef #1{\unexpanded{#2}\unexpanded\expandafter{#1}}
}
\newcommand{\exb@lmargin}[2]{\strut\vadjust{\exb@domark{#1}{#2}}}
\newcommand{\exb@domark}[2]{%
	\hbox to #2{		\vbox to 0pt{				\kern-\dp\strutbox
				\smash{\llap{#1}}
				\vss
}%
}
}
\newif\ifexb@isintersection
\def\exb@intersection@any#1#2#3#4{%
	\global\exb@isintersectionfalse%
	\edef\listarg{#1}%
	\ifx\listarg\empty\@dlog{RELAX}#4\else%
	\readlist*\needlelist{#1}%
		\foreachitem\needle\in\needlelist{%
			\exb@isin{\needle}{#2}{\global\exb@isintersectiontrue}{}%
}%
		\ifexb@isintersection#3\else#4\fi%
		\fi%
}
\gdef\@makespacesignored{%
\global\let\@oldtilde~%
\gdef~{}%
\global\catcode`\^^M=9\relax%
\global\catcode`\^^J=9\relax%
\global\catcode`\ =9\relax%
}
\gdef\@makespacesnormal{%
\global\let~\@oldtilde%
\global\catcode`\^^M=5\relax%
\global\catcode`\^^J=12\relax%
\global\catcode`\ =10\relax%
}
\let\nextPar\everypar
\newtoks\everypar
\nextPar{\the\everypar}
\def\AtNextPar#1{\nextPar\expandafter{\the\nextPar\nextPar{\the\everypar}#1}}
\edef\@isTrue{1}
\edef\@isFalse{0}
\gdef\ShowNumbers{\gdef\@displayMetaCounter{\isTrue}}
\gdef\exb@showtags{\isFalse}
\gdef\ShowTags{\gdef\exb@showtags{\isTrue}}
\gdef\exb@printCurrentTags{Tags: \exb@currentTags~}
\gdef\ShowFilenames{\At\VeryBeginProblem{\exerciseFile\\}}
\gdef\@DisplaySolutions{\@isFalse}
\gdef\DisplaySolutions{\xdef\@DisplaySolutions{\isTrue}\@latex@warning{Showing solutions}}
\gdef\ifDisplaySolutions{\if\@DisplaySolutions\@isTrue}
\gdef\@SolutionsOnly{\@isFalse}
\gdef\SolutionsOnly{\xdef\@SolutionsOnly{\@isTrue}\DisplaySolutions}
\gdef\exb@currentPoints{0}
\newif\ifexbank@if@needspace
\global\exbank@if@needspacetrue
\pgfkeys{/exbanksetup/.is family, /exbanksetup,
default/.style = {  part problems = On,
  tighten paragraphs = True,
  problem header={\normalsize\Large\bfseries\@tr{Problem}~\theproblemcounter},
  part problem header={\large\textbf{(\theproblemcounter\alph{partproblemcounter})}},
  part problem header suffix={},
  solution header={\large{\textbf{\@tr{Solution}:}}},
  exercise directory=.,
  figure root directory=\@exercisesDir,
  style margins=On,
  problem needs space=0.2\paperheight,
  no needspace/.is if={exbank@if@needspace},
  no needspace/.default = false
},
exercise directory/.estore in = \@exercisesDir, %
figure root directory/.estore in = \@figrootDir, %
front page/.estore in = \exb@frontpage,
front page=\@isFalse,
problem header/.store in = \exbank@opt@problemHeader,
part problem header/.store in = \exbank@opt@partProblemHeader,
solution header/.store in = \exbank@opt@solutionHeader,
problem needs space/.store in = \exbank@opt@problemneedspace,
part problem header suffix/.store in=\exb@partproblem@header@suffix,
part problems/.style = {switches/#1/.get = \exbank@opt@partProblems},
tighten paragraphs/.style = {switches/#1/.get = \exbank@opt@tightenparagraphs},
style margins/.style={switches/#1/.get = \exbank@opt@doMargins},
switches/.cd,
  On/.initial = \@isTrue,
  on/.initial = \@isTrue,
  T/.initial =  \@isTrue,
  True/.initial =  \@isTrue,
  Off/.initial = \@isFalse,
  off/.initial = \@isFalse,
  F/.initial = \@isFalse,
  False/.initial = \@isFalse,
}
\newcommand\exercisebanksetup[1]{  \pgfkeys{/exbanksetup, #1}%
}
\exercisebanksetup{default}
\AtBeginDocument{\xdef\tpd{\the\prevdepth}}
\gdef\tighten@paragraph{%
\if\exbank@opt@tightenparagraphs\@isTrue\relax%
      \filbreak%
\fi%
}
\gdef\tighten@paragraph@solutions{%
\if\exbank@opt@tightenparagraphs\@isTrue\relax%
  \if\@SolutionsOnly\@isFalse
    \if\@DisplaySolutions\@isTrue
      \filbreak%
    \fi
  \fi
\fi%
}
\gdef\tighten@paragraph@always{%
\if\exbank@opt@tightenparagraphs\@isTrue\relax%
\filbreak%
\fi%
}
\pgfkeys{ /exbanki18n/.is family, /exbanki18n,
  default/.style = {Problem = Problem, Solution = Solution},
  Problem/.estore in = \@tr@Problem,
  Solution/.estore in = \@tr@Solution
}
\newcommand{\translateExBank}[1]{  \pgfkeys{/exbanki18n, default, #1}%
}
\translateExBank{}
\gdef\@tr#1{%
\@ifundefined{@tr@#1}{#1}{%
  \csname @tr@#1\endcsname%
}%
}
\let\ea = \expandafter
\begingroup\lccode`\|=`\\
\lowercase{\endgroup\def\removebs#1{\if#1|\else#1\fi}}
\ifcsname at@verbose\endcsname
\global\def\@triggerLog#1{\@latex@warning{--\string\TRIGGER: #1}}%
\else
\global\let\@triggerLog\@gobble%
\fi
\newcommand{\At}[2]{  \edef\mname{\exbank@macroname{#1}}%
  \ifcsname At@\mname\endcsname%
    \ea\g@addto@macro\csname At@\mname\endcsname{#2}%
  \else%
    \ea\gdef\csname At@\mname\endcsname{#2}%
    \AtEndDocument{%
        \expandafter\let\csname At@\mname\endcsname\relax%
}
  \fi%
}
\newcommand{\Trigger}[1]{%
  \edef\mname{\exbank@macroname{#1}}%
  \ea\@ifundefined{At@\mname}{}{%
  \@triggerLog{\mname}\csname At@\mname\endcsname%
}%
}
\xdef\figuresPath{\@figrootDir/}
\gdef\fileInputPath{}
\gdef\fileInputBase{}
\providecommand*{\input@path}{}
\g@addto@macro\input@path{{\fileInputBase}{\fileInputPath}}
\At\PathControl{  \xdef\figuresPath{\@figrootDir/}
  \edef\exfile{\exerciseFile}
  \expandafter\filename@parse{\exfile}
  \xdef\fileInputPath{\figuresPath\filename@area}
  \xdef\fileInputBase{\figuresPath\filename@area\filename@base/}
  \graphicspath{{\fileInputBase}{\fileInputPath}}
  \@ifundefined{input@path}{\gdef\input@path{{\fileInputBase}{\fileInputPath}}}{}
}
\newlength{\pMarginBelow}
\newlength{\pMarginAbove}
\newlength{\pMarginLeft}
\newlength{\ppMarginBelow}
\newlength{\ppMarginAbove}
\newlength{\ppMargin}
\newlength{\introMargin}
\newlength{\solutionMarginLeft}
\newlength{\solutionMarginAbove}
\edef\defaultLeftMargin{\the\dimexpr1in+\hoffset}
\setlength{\ppMargin}{0.5em}
\setlength{\pMarginLeft}{-\ppMargin-2.5em}
\setlength{\solutionMarginLeft}{\ppMargin}
\setlength{\solutionMarginAbove}{1em}
\setlength{\pMarginBelow}{0em}
\setlength{\pMarginAbove}{\baselineskip}
\setlength{\introMargin}{-1.5em}
\setlength{\ppMarginBelow}{\baselineskip}
\setlength{\ppMarginAbove}{0em}
\setlength\parindent{0pt}
\newbox\ppmarkbox
\newlength\markskip
\setlength\markskip{4\baselineskip}
\def\solMargin{\dimexpr\ppMargin\relax}
\def\vsSize{1em}
\def\vs{\vspace{\vsSize}}
\newcounter{problemcounter}
\setcounter{problemcounter}{0}
\newcounter{partproblemcounter}
\At\VeryBeginProblem{%
	\if\exbank@opt@tightenparagraphs\@isTrue\relax%
	\ifexbank@if@needspace\needspace{\exbank@opt@problemneedspace}\fi%
	\vskip-2\baselineskip\relax%
	\fi%
	\stepcounter{problemcounter}%
	\setcounter{partproblemcounter}{0}%
	\vspace*{\pMarginAbove}%
  \strut\vadjust{\vbox to 0pt{\if\exbank@opt@doMargins\@isTrue\hskip\pMarginLeft\fi{\exbank@opt@problemHeader}\vss}}\par%
	\vspace*{\the\dimexpr\baselineskip+\pMarginBelow}%
}
\At\EndProblem{%
\tighten@paragraph%
}%
\At\VeryBeginPartproblem{%
\@dinfo{Triggered Beginning Part Problem (\string\VeryBeginPartproblem)}%
	\stepcounter{partproblemcounter}%
	\@dinfo{Generating title for part problem}%
	\gdef\exb@prePPHead{}%
	\gdef\exb@postPPHead{}%
	\if\@displayMetaCounter\@isTrue\relax%
		\gdef\exb@prePPHead{{\Large\themetacounter}:}%
	\fi%
	\if\exb@showtags\isTrue%
		\gdef\exb@postPPHead{\exb@printCurrentTags}%
	\fi%
\ifnum\pdfstrcmp{\exbank@opt@doMargins}{\@isTrue}=\z@\relax%
\newbox\nobox%
\gdef\exb@pp@lefttag{\leavevmode{\smash{\llap{{\exb@prePPHead\exbank@opt@partProblemHeader\Trigger\PartProblemHeaderSuffix}\hskip\ppMargin}\exb@postPPHead}}}%
\else%
\gdef\exb@pp@lefttag{{\exbank@opt@partProblemHeader\Trigger\PartProblemHeaderSuffix}}%
\fi%
\AtNextPar{\exb@pp@lefttag}%
\ignorespaces}%
\At\EndPartproblem{%
	\vspace*{\pMarginBelow}%
	\tighten@paragraph\par%
}
\At\BeginSolution{\hfill\break\vspace*{\solutionMarginAbove}{\exbank@opt@solutionHeader}}
\At\EndSolution{}
\newif\ifexb@opthides
\providecommand\exb@currentTags{}
\pgfkeys{/exbank/problems/.cd,%
default/.style={hide=false,tag=\relax},%
hide/.is if={exb@opthides},%
tags/.estore in=\exb@currentTags,%
tag/.code={\pgfkeysalso{tags={#1}}}%
}
\def\nextproblem{\pgfqkeys{/exbank/problems}}
\At\EndProblem{%
\if\exbank@opt@tightenparagraphs\@isTrue\relax%
  \if\@SolutionsOnly\@isFalse%
    \if\@DisplaySolutions\@isTrue%
      \penalty-300%
    \fi%
  \fi%
\fi%
}
\@ifundefined{figure}{}{\edef\figure{\unexpanded{\tighten@paragraph@always}\unexpanded\expandafter{\figure}}
}
\@ifundefined{endfigure}{}{\g@addto@macro\endfigure{\tighten@paragraph@always}
}
\gdef\isFalse{0}
\gdef\isTrue{1}
\gdef\DisplayProblem{\isTrue}
\gdef\@displayMetaCounter{\isFalse}
\AtBeginDocument{  \if\@DisplaySolutions\isFalse
    \@latex@warning{Hiding solutions. Show them with \string\DisplaySolutions}
  \fi
}
\global\let\do@ProcessCutFile = \ProcessCutFile
\newif\ifexb@isdisplaying
\newif\ifexb@hidenextsol
\global\exb@hidenextsolfalse
\gdef\exb@ifshowproblem#1#2{\exb@isdisplayingfalse\ifnum\pdfstrcmp{\DisplayProblem}{\@isTrue}=\z@\ifexb@opthides\else\exb@isdisplayingtrue\fi\fi%
\ifexb@isdisplaying#1\else#2\fi}
\gdef\showhideproblem#1{%
\exb@ifshowproblem{\let\ProcessCutFile\do@ProcessCutFile#1\global\exb@hidenextsolfalse}{\def\ProcessCutFile{}\global\exb@hidenextsoltrue}%
}
\generalcomment{problem}{%
  \edef\DisplaySolution{\@DisplaySolutions}%
  \stepcounter{metacounter}%
  \@dinfo{problem: Triggering \string\DecideProblemDisplay}%
  \Trigger\DecideProblemDisplay%
  \@dinfo{problem:Executing - \string\showhideproblem}%
     \showhideproblem{%
        \if\exbank@opt@partProblems\isTrue
            \Trigger\BeginPartproblem%
            \Trigger\VeryBeginPartproblem%
        \else%
            \Trigger\BeginProblem%
            \Trigger\VeryBeginProblem%
        \fi%
}%
}{\@dinfo{Ending problem env}%
    \if\DisplayProblem\@isTrue\relax%
      \if\exbank@opt@partProblems\@isTrue\relax%
        \Trigger\EndPartproblem%
        \tighten@paragraph\fi%
      \else
        \Trigger\EndProblem%
    \fi%
\@dinfo{Ended problem env}%
}
\g@addto@macro\AfterproblemComment{\nextproblem{default}\ignorespaces}%
\generalcomment{solution}{\@dinfo{START solution ENV}%
\Trigger\AtBeginSolutionHard
\begingroup
  \if\@DisplaySolutions\isTrue
    \if\DisplayProblem\isFalse
      \xdef\DisplaySolution{\isFalse}
    \fi
  \fi
  \if\DisplaySolution\isTrue
    \ifexb@hidenextsol\else\Trigger\BeginSolution\fi
  \else
    \def\ProcessCutFile{}
  \fi
}{%
\if\DisplaySolution\isTrue
\Trigger\EndSolution
\tighten@paragraph@solutions
\vspace*{0.5em}
\fi
\endgroup
\Trigger\EndSolutionHard\@dinfo{END solution ENV}%
}
\g@addto@macro\AftersolutionComment{\ignorespaces}
\def\intromargin#1{%
\if\exbank@opt@doMargins\@isTrue%
\gdef\endintromargin{\endlist\endgroup}%
\begingroup\list{}{\leftmargin#1}\item[]%
\else%
\relax\global\let\endintromargin=\relax\fi%
}
\generalcomment{intro}{\@dinfo{START intro ENV}%
  \if\@countIntros\isTrue%
    \stepcounter{metacounter}%
    \Trigger\DecideProblemDisplay%
    \gdef\exb@pre@intro{}%
    \gdef\exb@post@intro{}%
    \if\@displayMetaCounter\isTrue\relax%
    \gdef\exb@pre@intro{{\leavevmode{\llap{{\Large\themetacounter}:\hspace*{-\pMarginLeft}}}}\ignorespaces}%
    \fi%
    \if\exb@showtags\isTrue%
    \xdef\exb@post@intro{\exb@printCurrentTags}%
    \fi%
    \if\@spriteMode\@isTrue%
      \if\introarg\@isTrue%
        \stepcounter{partproblemcounter}%
      \fi%
    \fi%
    \gdef\@displayIntro{\@isFalse}
    \showhideproblem{%
      \tighten@paragraph%
      \Trigger\BeginIntro\exb@pre@intro\exb@post@intro%
      \gdef\@displayIntro{\@isTrue}
}%
  \exb@ifshowproblem{\intromargin{-1em}}{}
  \else%
  \intromargin{-1em}
  \fi%
}{  \if\@countIntros\isTrue%
    \Trigger\EndIntro%
    \exb@ifshowproblem{\endintromargin}{}
  \else
    \endintromargin
  \fi%
  \@dinfo{END intro ENV}\ignorespaces%
}
\g@addto@macro\AfterintroComment{\nextproblem{default}\ignorespaces}
\def\squeeze{  \newlength{\marginw}
  \setlength{\marginw}{1.5cm}
  \newgeometry{margin=\marginw}
  \renewcommand{\topfraction}{0.85}
  \renewcommand{\bottomfraction}{0.85}
  \renewcommand{\textfraction}{0.1}
  \renewcommand{\floatpagefraction}{0.85}
  \renewcommand{\dbltopfraction}{0.85}
  \renewcommand{\dblfloatpagefraction}{.85}
  \setcounter{topnumber}{25}
  \setcounter{bottomnumber}{25}
  \setcounter{totalnumber}{25}
  \setcounter{dbltopnumber}{25}
  \renewcommand{\baselinestretch}{0.9}
  \let\markeverypar\everypar
  \newtoks\everypar
  \everypar\markeverypar
  \markeverypar{\the\everypar\looseness=-1\relax}
  \g@addto@macro\define@newfont{%
    \fontdimen2\font@name=0.8\fontdimen2\font@name
}%
  \fontdimen2\font@name=0.8\fontdimen2\font@name
    \thinmuskip=0mu plus 3mu
    \medmuskip=1mu plus 4mu
    \thickmuskip=2mu plus 5mu
    \abovedisplayskip=0pt plus 3pt
    \belowdisplayskip=0pt plus 3pt
    \abovedisplayshortskip=0pt plus 3pt
    \belowdisplayshortskip=0pt plus 3pt
}
\let\ea = \expandafter
\newcounter{metacounter}
\setcounter{metacounter}{0}
\gdef\exb@emptyList{0}
\newif\ifexb@tagbuildmode
\global\exb@tagbuildmodefalse
\global\let\emptyList\exb@emptyList
\global\let\exb@tagList\exb@emptyList
\gdef\ifppMode#1{  \def\mname{\exbank@macroname{#1}}
  \strif\mname\ppMode
}
\gdef\isppMode#1#2{  \edef\mname{\exbank@macroname{#1}}
  \strif{\exbank@macroname{#1}}{\ppMode}\relax#2\fi
}
\gdef\@ifppMode#1{%
\ifnum\pdfstrcmp{\exbank@macroname{#1}}{\ppMode}=\z@%
\expandafter\@firstofone%
\else%
\expandafter\@noneofone%
\fi%
}%
\def\pm@Exclude{exclude}
\def\pm@Select{select}
\def\pm@Normal{normal}
\let\ipm\@ifppMode
\let\T@\isTrue
\let\F@\isFalse
\At\DecideProblemDisplay{%
    \ifnum\pdfstrcmp{\ppList}{\emptyList}=\z@\relax%
      \xdef\DisplayProblem{\ipm\exclude\T@\ipm\select\F@}
    \fi
    \exb@int@isin{\themetacounter}{\ppList}{      \xdef\DisplayProblem{\ipm\exclude\F@\ipm\select\T@\ipm\normal\T@}
}{      \xdef\DisplayProblem{\ipm\exclude\T@\ipm\select\F@\ipm\normal\T@}
}
\ifexb@tagbuildmode
\ifnum\pdfstrcmp{\DisplayProblem}{\T@}=\z@\relax%
\exb@intersection@any{\exb@currentTags}{\exb@tagList}{\global\exb@opthidesfalse}{\global\exb@opthidestrue}%
\fi
\fi
}
\gdef\introarg{\@isFalse}
\gdef\noheadarg{\@isFalse}
\pgfkeys{ /makeset/.is family, /makeset,
 default/.style = {},
 intro/.style = {introarg=\@isTrue},
 nointro/.style = {introarg=\@isFalse},
 nohead/.style = {noheadarg=\@isTrue},
 head/.style = {noheadarg=\@isFalse},
 introarg/.estore in = \introarg,
 noheadarg/.estore in = \noheadarg
}
\gdef\makesetdefaults#1{%
\edef\exb@setpgfkeys{{\unexpanded\expandafter{/makeset/default/.style = {#1}}}}%
\expandafter\pgfkeys\exb@setpgfkeys%
}
\pgfkeys{/makeset/override/.cd,
intro/.code = {\gdef\introarg{\@isTrue}\ea\gdef\csname setlist@\exb@currentSetID @intro\endcsname{\@isTrue}},
nointro/.code = {\gdef\introarg{\@isFalse}\ea\gdef\csname setlist@\exb@currentSetID @intro\endcsname{\@isFalse}},
nohead/.code = {\gdef\noheadarg{\@isTrue}\ea\gdef\csname setlist@\exb@currentSetID @nohead\endcsname{\@isTrue}}
}
\gdef\@listOfSets{}
\gdef\@spriteMode{\isFalse}
\gdef\exbank@spriteSets{\emptyList}
\long\gdef\spritesets#1{  \gdef\exbank@spriteSets{#1}
}
\global\let\exlist@protect\noexpand
\newcommand\makeset[3][]{  \xdef\thissetid{#2}
  \ea\xdef\csname setkeys@\thissetid\endcsname{#1}
  \pgfkeys{/makeset, default, #1}%
  \if\introarg\isTrue%
    \gdef\introarg{\isTrue}
    \ea\gdef\csname setlist@#2@intro\endcsname{\isTrue}
  \fi
  \if\noheadarg\isTrue%
    \ea\gdef\csname setlist@#2@nohead\endcsname{\isTrue}
  \fi
  \ea\gdef\csname setlist@#2\endcsname{\exlist@protect{#3}}
  \def\setmacro{\unexpanded\expandafter{\csname setlist@#2\endcsname}}
  \g@addto@macro\@listOfSets{,#2}
}
\long\gdef\about#1{}
\newcommand\sprite[1][4]{\squeeze
\gdef\@spriteMode{\isTrue}
\long\def\about##1{{\Large\textbf{About}:\\[1.1em]##1\\[1.5em]}}
\pgfpagesuselayout{#1 on 1}[a4paper,border shrink=5mm]
\ifnum\pdfstrcmp{\exbank@spriteSets}{\emptyList}=\z@\relax%
  \edef\sprite@setlist{\ea\@secondoftwo\@listOfSets}
  \readlist*\list@sprite@setlist\sprite@setlist
  \foreachitem\set\in\list@sprite@setlist{    \edef\theset{{\set}}
    \if\theset\empty\relax\else%
    \buildset{\set}%
    \fi%
}
\else
  \edef\sprite@setlist{\exbank@spriteSets}
  \readlist*\list@sprite@setlist\sprite@setlist
  \foreachitem\set\in\list@sprite@setlist{    \edef\theset{{\set}}
    \if\theset\empty\relax\else%
    \buildex{\set}%
    \fi%
}
\fi
}
\gdef\exbank@setEnv@normal#1{\exbank@setEnv{#1}{normal}
}
\newcommand{\exbank@setEnv}[3][{-1}]{  \if\@spriteMode\isFalse%
    \gdef\ppList{#1}
    \gdef\exerciseFile{#2}
    \gdef\ppMode{#3}
  \else
    \gdef\ppList{\emptyList}
    \gdef\exerciseFile{#2}
    \gdef\ppMode{\pm@Normal}
  \fi
}
\global\let\ex@protect\noexpand
\long\gdef\exec#1{:\ex@protect{#1}}
\gdef\exb@def@makeset@cmd#1{\@ifnextchar[{\@exb@def@makeset@cmd{#1}}{\@exb@def@makeset@cmd{#1}[0]}}
\gdef\@exb@def@makeset@cmd#1[#2]#3{\def\ncArgs{#1[#2]}%
\bgroup\globaldefs=1\ea\newcommand\ncArgs{\exec{#3}}\egroup%
}
\def\exbank@def@makeset@command{\exb@warn{\string\exbank@def@makeset@command\space is deprecated and will be removed in versions >= 0.3.0. Use \string\exb@def@makeset@cmd}\exb@def@makeset@cmd}
\let\DeclareExerciseCommand\exb@def@makeset@cmd
\newcommand{\exclude}[2]{[{#2}]{#1}{exclude}}
\newcommand{\select}[2]{[{#2}]{#1}{select}}
\newcommand{\orderedselect}[2]{%
\readlist*\thelist\csv@list%
\foreachitem\items\in\thelist{[{\item}]{#1},}%
}
\let\exbank@isFirstProblem\isTrue
\exb@def@makeset@cmd{\phead}{  \if\exbank@isFirstProblem\isTrue%
    \let\exbank@isFirstProblem\isFalse%
  \else%
    \Trigger\EndProblem%
  \fi%
  \Trigger\BeginProblem%
  \Trigger\VeryBeginProblem%
}
\exb@def@makeset@cmd{\pheadarg}[1]{  \if\exbank@isFirstProblem\isTrue%
    \let\exbank@isFirstProblem\isFalse%
  \else%
    \Trigger\EndProblem%
  \fi%
  \Trigger\BeginProblem%
  \bgroup\def\theproblemcounter{#1}\Trigger\VeryBeginProblem\egroup%
}
\exb@def@makeset@cmd{\pbreak}{\clearpage}
\gdef\buildex#1{  \makeset{#1}{#1}
  \buildset{#1}
}
\gdef\@countIntros{\isFalse}
\gdef\exb@setpgf#1{%
\edef\keystring{{/makeset,default,#1}}%
\ea\pgfkeys\keystring}
\newcommand\buildset[2][]{%
  \xdef\exb@currentSetID{#2}%
  \pgfkeys{/makeset/override/.cd, #1}
  \global\let\setName\exb@currentSetID%
  \gdef\exb@buildset@oarg{#1}
  \@ifundefined{setlist@#2@intro}{\gdef\@countIntros{\isFalse}}{\gdef\@countIntros{\isTrue}}%
  \@ifundefined{setlist@#2@nohead}{\gdef\nohead{\isFalse}}{\gdef\nohead{\isTrue}}%
  \ifcsname setkeys@\setName\endcsname%
  \xdef\skeys{\csname setkeys@#2\endcsname}%
  \exb@setpgf\skeys%
  \fi%
  \@ifundefined{setlist@#2}{%
    \@latex@error{Couldn't find set #2. Did you remember to do \string\makeset{#2}{}?}
    \stop\bye
}{}
  \let\exlist@protect\unexpanded%
  \edef\exbank@setlist{\csname setlist@#2\endcsname}%
  \let\exlist@protect\noexpand%
  \if\@spriteMode\isFalse%
    \if\exb@frontpage\@isFalse\else\input{\exb@frontpage}\fi
    \Trigger\StartBuildset%
  \fi%
  \gdef\@delegateFileInfo{\@ifnextchar?\@execute@makeset@command\@is@exec}%
  \def\@is@exec{\@ifnextchar:\@execute@exec\@is@file}%
  \gdef\@is@file{\@ifnextchar[\exb@setEnv@withOptargs\X@exb@setEnv}%
  \gdef\X@exb@setEnv##1{%
    \def\continueLoop{\isTrue}%
    \@dinfo{Processing normal file "\exerciseFileInfo.tex"}%
    \exbank@setEnv@normal{\exerciseFileInfo}\bgroup\nullfont%
}
  \gdef\exb@setEnv@withOptargs{%
    \def\continueLoop{\isTrue}\ea\exbank@setEnv\exerciseFileInfo\bgroup\nullfont%
}
  \gdef\@execute@makeset@command ?##1{%
    \edef\inner{\@firstofone##1}%
    \@dinfo{Executing macro \@backslashchar\@gobble##1}%
    \csname\inner\endcsname%
    #1\def\continueLoop{\isFalse}\ea\bgroup%
}
  \def\@execute@exec:{%
    \def\continueLoop{\isFalse}\@dinfo{Executing custom command}\bgroup%
}
  \readlist*\setlist\exbank@setlist%
  \foreachitem\exerciseFileInfo\in\setlist{%
    \def\continueLoop{\isTrue}%
    \gdef\ppList{\emptyList}%
    \setcounter{metacounter}{0}%
    \let\ex@protect\unexpanded%
    \edef\exerciseFileInfo{\exerciseFileInfo}%
    \ea\@delegateFileInfo\exerciseFileInfo\egroup%
    \Trigger\InputExercise%
    \if\continueLoop\isTrue%
    \let\ex@protect\noexpand%
  \Trigger\PathControl%
    \if\nohead\isFalse%
      \if\@spriteMode\isFalse%
        \Trigger\BeginProblem%
      \fi%
    \fi%
    \if\nohead\isFalse\Trigger\VeryBeginProblem\fi%
    \if\@spriteMode\isTrue\textbf{\exerciseFile.tex\\}\fi%
    \IfFileExists{\@exercisesDir/\exerciseFile}{%
      \incl{\@exercisesDir/\exerciseFile}%
      \if\@spriteMode\isTrue%
        \setcounter{partproblemcounter}{0}%
      \fi%
}{      \@latex@error{Could not find \@exercisesDir/\exerciseFile. Maybe it is because the default exercise directory is now changed to the same directory that your main file is in. To set default exercise directory to exercises, do \string\exercisebanksetup{exercise directory=exercises}}{}
      \stop\bye
}
    \if\nohead\isFalse\Trigger\EndProblem\fi%
    \fi%
}
  \if\@spriteMode\isFalse%
    \Trigger\EndBuildset%
  \fi%
  \setcounter{problemcounter}{0}%
  \setcounter{partproblemcounter}{0}%
  \clearpage%
}
\newcommand\buildsets[2][]{%
	\xdef\csvlist{#2}%
	\readlist*\items\csvlist%
	\foreachitem\set\in\items{%
		\buildset[#1]{\set}%
}
}
\newcommand\buildtags[2]{%
  \global\exb@tagbuildmodetrue
  \xdef\csvtags{#1}%
  \xdef\csvlist{#2}
	\xdef\csvsets{#2}%
	\readlist*\tagsItems\csvtags%
  \readlist*\setsItems\csvsets%
	\foreachitem\set\in\setsItems{%
    \xdef\exb@tagList{\csvtags}
		\buildset{\set}%
}
  \global\exb@tagbuildmodefalse
}
\newcommand\refcounter[1]{\edef\@currentlabel{#1}%
}
\DeclareRobustCommand{\pplabel}[1]{	\refcounter{\theproblemcounter}\label{pr:\exerciseFile:#1}
	\refcounter{\alph{partproblemcounter}}\label{pp:\exerciseFile:#1}
}
\let\pptag = \pplabel
\newcommand\pppref[1]{%
(\ea\@alph\ref{pp:\exerciseFile:#1})\relax%
}
\newcommand\ppref[1]{%
(\ref{pr:\exerciseFile:#1}\ref{pp:\exerciseFile:#1})\relax%
}
\newcommand\pref[1]{%
\ref{pr:\exerciseFile:#1}\relax%
}
\gdef\exb@currentPoints{0}
\gdef\exb@currentPointsStyle{}
\newif\ifexb@enablepoints\global\exb@enablepointstrue
\exercisebanksetup{%
current points style/.store in=\exb@currentPointsStyle,
current points style={\ifnum\exb@currentPoints=\z@\ifnum\totalpoints=\z@\else\phantom{0p}\fi\else\exb@currentPoints p\fi\ignorespaces},
disable points/.is if={exb@enablepoints}
}
\ifexb@enablepoints
\AtEndDocument{%
\immediate\write\@auxout{\string\gdef\string\totalpoints{\the\c@exb@points}}%
}
\At\PartProblemHeaderSuffix{\exb@currentPointsStyle}
\fi
\newcounter{exb@points}
\setcounter{exb@points}{0}
\providecommand\totalpoints{}
\nextproblem{points/.store in=\exb@currentPoints}
\At\BeginPartproblem{\addtocounter{exb@points}\exb@currentPoints}
\At\EndPartproblem{\gdef\exb@currentPoints{0}}
\def\exb@hidetaglist{}
\At\DecideProblemDisplay{\ifnum\pdfstrcmp{\DisplayProblem}{\T@}=\z@\relax%
\ifx\exb@hidetaglist\relax\else
\exb@intersection@any{\exb@currentTags}{\exb@hidetaglist}{\global\exb@opthidestrue}{\global\exb@opthidesfalse}%
\fi
\fi
}
\gdef\HideTags#1{\xdef\exb@hidetaglist{#1}}