summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/exframe/exframe.dtx
blob: 726a6afd8b5e16cb35c59d585b0d590a809757d5 (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
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
% \iffalse
%
% exframe.dtx Copyright (C) 2011-2020 Niklas Beisert
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Niklas Beisert.
%
% This work consists of the files exframe.dtx and exframe.ins
% and the derived files exframe.sty and exfsamp.tex, exfserm.tex,
% exfser01.tex, exfser02.tex, exfser03.tex, exfseraa.tex,
% exfserpe.tex, exfserpf.tex, exfsermk.sh, exfsermk.mak.
%
%<package|samplesingle|samplemultimain>\NeedsTeXFormat{LaTeX2e}[1996/12/01]
%<package>\ProvidesPackage{exframe}[2020/02/24 v3.4 Framework for Exercise Problems]
%<samplesingle>\ProvidesFile{exfsamp.tex}[2020/02/24 v3.4 standalone sample for exframe]
%<samplemultimain>\ProvidesFile{exfserm.tex}[2020/02/24 v3.4 multipart sample for exframe]
%<*driver>
\def\thedate#1{2020/02/24}\def\theversion#1{v3.4}
\ProvidesFile{exframe.dtx}[\thedate{} \theversion{} exframe reference manual file]
\PassOptionsToClass{10pt,a4paper}{article}
\documentclass{ltxdoc}

\usepackage[margin=35mm]{geometry}
\usepackage{hyperref}
\usepackage{hyperxmp}
\usepackage[usenames]{color}

\hypersetup{colorlinks=true}
\hypersetup{pdfstartview=FitH}
\hypersetup{pdfpagemode=UseNone}
\hypersetup{keeppdfinfo=true}
\hypersetup{pdfsource={}}
\hypersetup{pdflang={en-UK}}
\hypersetup{pdfcopyright={Copyright 2010-2020 Niklas Beisert.
  This work may be distributed and/or modified under the
  conditions of the LaTeX Project Public License, either version 1.3
  of this license or (at your option) any later version.}}
\hypersetup{pdflicenseurl={http://www.latex-project.org/lppl.txt}}
\hypersetup{pdfcontactaddress={ETH Zurich, ITP, HIT K,
  Wolfgang-Pauli-Strasse 27}}
\hypersetup{pdfcontactpostcode={8093}}
\hypersetup{pdfcontactcity={Zurich}}
\hypersetup{pdfcontactcountry={Switzerland}}
\hypersetup{pdfcontactemail={nbeisert@itp.phys.ethz.ch}}
\hypersetup{pdfcontacturl={http://people.phys.ethz.ch/\xmptilde nbeisert/}}

\newcommand{\secref}[1]{\hyperref[#1]{section \ref*{#1}}}

\parskip1ex
\parindent0pt
\let\olditemize\itemize
\def\itemize{\olditemize\parskip0pt}

\begin{document}

\title{The \textsf{exframe} Package}
\hypersetup{pdftitle={The exframe Package}}
\author{Niklas Beisert\\[2ex]
  Institut f\"ur Theoretische Physik\\
  Eidgen\"ossische Technische Hochschule Z\"urich\\
  Wolfgang-Pauli-Strasse 27, 8093 Z\"urich, Switzerland\\[1ex]
  \href{mailto:nbeisert@itp.phys.ethz.ch}
  {\texttt{nbeisert@itp.phys.ethz.ch}}}
\hypersetup{pdfauthor={Niklas Beisert}}
\hypersetup{pdfsubject={Manual for the LaTeX2e Package exframe}}
\date{\thedate{}, \theversion{}}
\maketitle

\begin{abstract}\noindent
\textsf{exframe} is a \LaTeXe{} package
which provides a general purpose framework to describe and typeset
exercises and exam questions along with their solutions.
The package features mechanisms
to hide or postpone solutions,
to assign and handle points,
to collect problems on exercise sheets,
to store and use metadata
and to implement a consistent numbering.
It also provides a very flexible interface for configuring and customising
the formatting, layout and representation of the exercise content.
\end{abstract}

\begingroup
\parskip0ex
\tableofcontents
\endgroup

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Introduction}

This package provides a framework to describe and typeset
exercises (homework problems, classroom exercises, quizzes, exam questions,
exercise questions in books and lecture notes, \ldots)
and their solutions or answers.
The aim of this package is to set up a few \LaTeX{} environments
into which questions and corresponding answers can be filled conveniently.
The main task of the package is to manage the text and data
that are provided in the source document,
perform some common operations on them,
and then output the content appropriately.
The package has the following goals, tasks and features:
%
\begin{itemize}
\item
The package is designed with generality in mind.
It is meant to be usable in many different situations.
The primary target is science and education, but it may well
be useful in other areas.

\item
The package defines a basic functional layout for the output
and provides many options to reshape the layout and formatting
according to the author's needs and wishes.

\item
The package can handle two layers of exercises:
main problems and subproblems.
The use of subproblems is optional.

\item
The display of solutions can be configured:
Solutions can be hidden for a hand-out version of exercise sheets.
When displayed, they may appear immediately,
collectively after the problem,
at the end of each sheet or at some manually defined location.

\item
The package can handle exercise sheets which combine several exercise problems:
A \LaTeX{} document can consist of an individual sheet
or of a collection of sheets (e.g.\ spanning a lecture course).
In the latter case, the document files can be set up
such that single sheets as well as a collection of all sheets
can be compiled; the package \textsf{childdoc} may be of assistance.

\item
The package can handle points to be credited:
Points will be displayed according to the layout.
Overall points for a problem or a sheet can be added automatically.
Points can also be stored and used elsewhere.

\item
The package provides an interface to specify exercise metadata
(author, source, \ldots):
Some basic types of metadata are predefined and more specific metadata
categories can be added.

\item
The package can use alternative counters for equations
within solutions (and problems). This is to ensure a consistent
numbering independently of whether solutions are output or not.

\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Usage}
\label{sec:usage}

To use the package \textsf{exframe} add the command
%
\begin{center}
|\usepackage{exframe}|
\end{center}
%
to the preamble of the \LaTeX{} document.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Exercise Environments}
\label{sec:environments}

The package provides four environments
to describe the main entities of exercise problems.
Additional information on the exercises can be provided
in the optional arguments to these environments
which will be discussed in the following sections.
Furthermore, a limited set of commands
is provided for control and extra features,
see the sections below for details.

\DescribeEnv{problem}
The |problem| environment describes
an exercise problem:
%
\begin{center}
\begin{tabular}{l}
|\begin{problem}[|\textit{opts}|]|\\
|  |\textit{problem text and subproblems}\\
|\end{problem}|
\end{tabular}
\end{center}
%
As one of the many available options \textit{opts},
one can provide a title for the exercise by
specifying |title={|\textit{title}|}|.
If no title is given, the problem number will be displayed instead.
See \secref{sec:metadata} and \secref{sec:points}
for a description of the available options.

\DescribeEnv{subproblem}
The |subproblem| environment describes
a subproblem, part or an individual question of an exercise problem:
%
\begin{center}
\begin{tabular}{l}
|\begin{subproblem}[|\textit{opts}|]|\\
|  |\textit{subproblem text}\\
|\end{subproblem}|
\end{tabular}
\end{center}
%
A |subproblem| environment must be contained within a |problem| environment
(however, a |problem| block need not contain |subproblem| blocks).

\DescribeEnv{solution}
The |solution| environment describes
the solution to a problem or a subproblem:
\begin{center}
\begin{tabular}{l}
|\begin{solution}[|\textit{opts}|]|\\
|  |\textit{solution text}\\
|\end{solution}|
\end{tabular}
\end{center}
%
A |solution| environment should be
at the end of a |subproblem| or |problem| environment
(it is not mandatory to provide a |solution|).
It can be contained within the corresponding environment or it can follow it.
Depending on the choice of solution display, see \secref{sec:solutions},
the output may have a slightly different layout.
In terms of logic, it is preferred
to define a solution \emph{within} the corresponding environment;
this may also have some technical advantages and produce
a slightly better result in terms of layout.

\DescribeEnv{sheet}
The |sheet| environment describes an exercise sheet:
%
\begin{center}
\begin{tabular}{l}
|\begin{sheet}[|\textit{opts}|]|\\
|  |\textit{sheet text and problems}\\
|\end{sheet}|
\end{tabular}
\end{center}
%
A sheet typically contains one or several problems
(it is not mandatory to group problems into a |sheet|).
There may or may not be additional auxiliary text introducing the problems.
A header will be added to the sheet according to the specified layout.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Solution and Problem Display}
\label{sec:solutions}

There are several options to control the output of solutions
and of problems.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{solutions}
Most importantly, the display of solutions
can be disabled or enabled altogether:
%
\begin{center}
|\exercisesetup{solutions|[|=true|\textbar|false|]|}|
\end{center}
%
Solutions are hidden by default,
and their display needs to be activated explicitly
(it suffices to specify the option |solutions| without the value |true|).
It is also possible to control the display
by an analogous package option |solutions|,
see \secref{sec:options} for further information.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{\ifsolutions}
\DescribeMacro{onlysolutions}
The display of solutions is reflected by the conditional |\ifsolutions|.
As the hiding of solutions is performed automatically,
the conditional would typically be used to change some details,
e.g.\ for adjusting titles:
%
\begin{center}
|\ifsolutions Solutions\||else Exercises\||fi|
\end{center}
%
Alternatively, content to be processed only in solutions mode
can be enclosed in an |onlysolutions| block:
%
\begin{center}
\begin{tabular}{l}
|\begin{onlysolutions}|\\
|...|\\
|\end{onlysolutions}|
\end{tabular}
\end{center}
%
This structure can be useful to hide auxiliary text or material
if all solution content is to be stripped from a source file,
e.g.\ by an automated \textsf{sed} filter rule
(doubling of backslashes required for \textsf{sed}
as well as for shell script strings):
%
\begin{center}
\begin{tabular}{l}
|sed "/\\\\begin{solution}/,/\\\\end{solution}/d;"\|\\
|"/\\\\begin{onlysolutions}/,/\\\\end{onlysolutions}/d"|
\end{tabular}
\end{center}
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{solutionequation}
As solutions can contain numbered equations
while the display of solutions can be switched on and off,
it is important to assign a different counter for equations within solutions
in order for the equation numbers to be stable.
A separate counter for equations within solutions is enabled by default.
It can be disabled by:
%
\begin{center}
|\exercisestyle{solutionequation=false}|
\end{center}
%
This option prepends the letter `S' to equation
numbers within solutions which are counted separately;
the display can be configured differently, see \secref{sec:layout}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{solutionbelow}
\DescribeMacro{\insertsolutions}
The package allows to collect solutions
and defer their display to particular locations:
%
\begin{center}
|\exercisestyle{solutionbelow=|\textit{pos}|}|
\end{center}
%
The available choices for \textit{pos} are
to display solutions where they are defined (|here|),
defer them to the end of the current subproblem (|subproblem|),
problem (|problem|) or sheet (|sheet|)
or display them at a manually chosen location (|manual|).
Note that typically solutions are defined at the end of a (sub)problem
and therefore the choice |here| is similar to (|sub|)|problem|.
The latter form, however, makes sure that a solution
does not inherit the margin of the parent environment.
The alternate modes |problem*| and |subproblem*|
positions the solution \emph{after} the (sub)problem environment
such that it does not inherit any layout,
but also no definitions made in the parent environment.
In |manual| mode, all solutions are collected (with appropriate headers)
until they are output by the directive |\insertsolutions|.
If no solutions are stored in the buffer
(or if the mode is not |manual|), |\insertsolutions| has no effect.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{\writesolutions}
Another option to handle solutions is to write them to a file
for later use.
Writing to a file is initiated by:
%
\begin{center}
|\writesolutions[|\textit{filename}|]|
\end{center}
%
The optional argument describes the filename as \textit{filename}|.sol|;
no argument defaults to the main tex filename as |\jobname.sol|;
the extension |.sol| can be customised by the configuration |extsolutions|.
This mode overrides the |solutionbelow| behaviour described above;
all subsequent solutions are written to the file.
The file is closed by |\closesolutions| and the display of solutions
returns to manual mode.
It is not necessary to close a file as it will be closed
automatically by reading from a file, writing to another file
or by the end of the document.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{\readsolutions}
Solutions are read from a file by:
%
\begin{center}
|\readsolutions[|\textit{filename}|]|
\end{center}
%
This command outputs a sectional title
and reads the file via |\input{|\textit{filename}|.sol}|.

\medskip

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{solutionbuf}
\DescribeMacro{problembuf}
The package offers similar functionality to control the display of problems.
In order to have any control over the content of |problem| environments,
the latter needs to be read into an internal buffer.
Reading of solutions and problems to internal buffers is activated
or deactivated by:
%
\begin{center}
\begin{tabular}{l}
|\exercisesetup{solutionbuf|[|=true|\textbar|false|]|}|\\
|\exercisesetup{problembuf|[|=true|\textbar|false|]|}|
\end{tabular}
\end{center}
%
By default, |solution| environments are read to an internal buffer,
while the content of |problem| environments is processed directly
by the \TeX\ engine.
Therefore, the following options to control the display
of |problem| environments require the statement |\exercisesetup{problembuf}|.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{problemmanual}
\DescribeMacro{\insertproblems}
The immediate display of |problem| environments is controlled by:
%
\begin{center}
|\exercisestyle{problemmanual|[|=true|\textbar|false|]|}|
\end{center}
%
In the default automatic mode, problems are displayed directly
where they are declared.
In manual mode, problems are collected to an internal buffer,
and only displayed by issuing |\insertproblems|.

Note that |solution| environments should be
declared within the corresponding |problem| environment in order to
preserve their appropriate association.
The |solution| environment is then processed at the place
where the |problem| environment is displayed,
and it may (or may not) be deferred further.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{\writeproblems}
\DescribeMacro{\readproblems}
Problems can be written out to an external file for later usage.
The functionality is analogous to solutions
and uses the macros:
%
\begin{center}
\begin{tabular}{l}
|\writeproblems[|\textit{filename}|]|\\
|\readproblems[|\textit{filename}|]|
\end{tabular}
\end{center}
%
The optional argument describes the filename as \textit{filename}|.prb|;
no argument defaults to the main tex filename as |\jobname.prb|;
the extension |.prb| can be customised by the configuration |extproblems|.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{disable}
\DescribeMacro{insertproblemselect}
The display of a particular |problem|
can be suppressed altogether by an optional argument:
%
\begin{center}
|\begin{problem}[disable]|
\end{center}
%

This option can be exploited to automatically
suppress certain classes of problems as follows:
A hook function |insertproblemselect| declared by:
%
\begin{center}
|\exerciseconfig{insertproblemselect}[1]{|\textit{code}|}|
\end{center}
%
can call
|\setproblemdata{disable}| whenever a problem is to be suppressed.
In order to decide, the optional argument of the |problem| environment
is passed on to the hook function as the single argument.
Note that the argument needs to be processed manually.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Metadata}
\label{sec:metadata}

In a collection of exercise problems
it makes sense to keep track of metadata
for the overall collection as well as for individual problems
and potentially display some of them.
The framework defines a standard set of metadata fields
and offers functionality to add more specialised metadata fields.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{\exercisedata}
Global metadata is specified by the command:
%
\begin{center}
|\exercisedata{|\textit{data}|}|
\end{center}
%
The argument \textit{data}
is a comma-separated list of metadata specifications
in the form \textit{key}|={|\textit{value}|}|.
The standard set of global metadata keys consists of:
%
\begin{itemize}
\item |author|:
principal author(s) of the exercise collection;
also invokes the \LaTeX{} command |\author|;
will be written to pdf documents.
\item |title|:
title of the exercise collection;
also invokes the \LaTeX{} command |\title|;
will be written to pdf documents.
\item |date|:
date of the exercise collection;
also invokes the \LaTeX{} command |\date|;
will be written to pdf documents.
\item |subject|:
subject area of the exercise collection;
will be written to pdf documents.
\item |keyword|:
keyword(s) for the exercise collection;
will be written to pdf documents.
\item |course|:
title of the course (class, lecture, module, \ldots)
for the exercise collection.
\item |institution|:
institution (school, department, institute, university, \ldots)
offering the course or exercise collection.
\item |instructor|:
instructor(s) for the course or exercise;
this field refers to person(s) who organise
the corresponding course or exercises
whereas |author| refers to the principal creator of the material.
\item |period|:
period (year, season, date, term identifier, \ldots)
of the corresponding course.
\item |material|:
type of material
(exercises, homework assignments, exam, quizzes, solutions, \ldots).
\end{itemize}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{\defexercisedata}
Additional custom fields for global metadata can be created with:
%
\begin{center}
|\defexercisedata{|\textit{key}|}|
\end{center}
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{\getexercisedata}
\DescribeMacro{\exercisedataempty}
Global metadata should typically be specified
somewhere at the top of the main document,
and it can be inserted wherever needed.
There are two commands to read and process metadata.
To insert the value of metadata field \textit{key} use:
%
\begin{center}
|\getexercisedata{|\textit{key}|}|
\end{center}
%
In some situations the output should depend on whether
a metadata has been filled
(e.g.\ to fill a default value or to display something else instead).
This can be checked with the conditional:
%
\begin{center}
|\exercisedataempty{|\textit{key}|}|%
  |{|\textit{empty code}|}{|\textit{filled code}|}|
\end{center}
%
The \textit{empty code} is executed if no value
or an empty value has been specified;
otherwise the \textit{filled code} is executed.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{sheet}
\DescribeMacro{problem}
The package offers a similar mechanism to describe and use metadata
for sheets and problems:
%
\begin{center}
\begin{tabular}{l}
|\begin{sheet}[|\textit{opts}|]|\\
|\begin{problem}[|\textit{opts}|]|
\end{tabular}
\end{center}
%
The argument \textit{opt}
is a comma-separated list which can contain metadata specifications
in the form \textit{key}|={|\textit{value}|}|.
The standard set of metadata keys for sheets consists of:
%
\begin{itemize}
\item |due|:
indication of the due date for the exercise sheet.
\item |handout|:
indication of the handout date for the exercise sheet.
\item |title|:
specifies a title for the sheet;
when reading value (see below), returns composed title;
untitled sheets will be displayed by their number;
title will be written to pdf documents.
\item |rawtitle| (for reading only):
contains the raw title as specified by |title|.
\item |author|:
author(s) of the sheet;
will be written to pdf documents.
\item |editor|:
editor(s) of the sheet; this field refers to a person
who makes adjustments to the sheet
whereas |author| refers to the creator of the sheet.
\item |editdate|:
indication of the date when the sheet was last edited.
\end{itemize}
%
The standard set of metadata keys for problems consists of:
%
\begin{itemize}
\item |title|:
specifies a title for the problem;
when reading value (see below), returns composed title;
untitled problems will be displayed by their number.
\item |rawtitle| (for reading only):
contains the raw title as specified by |title|.
\end{itemize}
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{\defsheetdata}
\DescribeMacro{\setsheetdata}
\DescribeMacro{\getsheetdata}
\DescribeMacro{\sheetdataempty}
\DescribeMacro{\defproblemdata}
\DescribeMacro{\setproblemdata}
\DescribeMacro{\getproblemdata}
\DescribeMacro{\problemdataempty}
Metadata for sheets can be used in the same way as the global metadata.
The following directives are analogous to |\defexercisedata|,
|\exercisedata|, |\getexercisedata| and |\exercisedataempty|:
%
\begin{center}
\begin{tabular}{l}
|\defsheetdata{|\textit{key}|}|\\
|\setsheetdata{|\textit{data}|}|\\
|\getsheetdata{|\textit{key}|}|\\
|\sheetdataempty{|\textit{key}|}|%
  |{|\textit{empty code}|}{|\textit{filled code}|}|\\[1ex]
|\defproblemdata{|\textit{key}|}|\\
|\setproblemdata{|\textit{data}|}|\\
|\getproblemdata{|\textit{key}|}|\\
|\problemdataempty{|\textit{key}|}|%
  |{|\textit{empty code}|}{|\textit{filled code}|}|
\end{tabular}
\end{center}
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{pdfdata}
\DescribeMacro{\writeexercisedata}
The most relevant metadata can be written to
the metadata section of pdf files
(using pdf\LaTeX{} and the package \textsf{hyperref}
whenever loaded).
This feature is configured by:
%
\begin{center}
|\exercisesetup{pdfdata|[|=auto|\textbar|manual|%
  \textbar|sheet|\textbar|off|]|}|
\end{center}
%
The option |auto| writes the global metadata
|title|, |author|, |subject| and |keyword|
to the corresponding fields in the pdf file.
To make this work, these must be defined before the
|\begin{document}| directive.
The option |manual| allows to manually write these metadata
by the command |\writeexercisedata|.
It should be issued after the metadata have been set,
but before any content is written to the pdf file.
In other words, it can be anywhere in the document preamble
directly after |\begin{document}|,
or following a couple of content-free definitions at the beginning
of the document body (in case the metadata should be set
within the document body for some reason).
The option |sheet| writes out the metadata
at the beginning of the first |sheet| environment
(which should follow |\begin{document}| without any content in between).
This option is primarily for filling the
|author| and |title| fields with metadata
of a sheet rather than a collection of exercises.
Note that if no |author| is defined for the sheet,
the global metadata |author| is used.
The option |off| disables all writing of metadata.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{problem}
\DescribeMacro{subproblem}
\DescribeMacro{solution}
There is an additional mechanism to keep track of metadata
for problems, subproblems and solutions
which can be displayed in the opening line of these entities.
Displayed metadata serve two purposes:
they are used to describe the quality of a problem
or they are intended for internal documentation purposes.
Their output can be controlled individually,
e.g.\ only in development versions of a document.
Note that specifying a key more than once
will display the content multiple times
in the order in which they are encountered.
Displayed metadata are specified
at the top of the corresponding environment:
%
\begin{center}
\begin{tabular}{l}
|\begin{problem}[|\textit{opts}|]|\\
|\begin{subproblem}[|\textit{opts}|]|\\
|\begin{solution}[|\textit{opts}|]|
\end{tabular}
\end{center}
%

The standard set of displayed metadata keys consists of:
%
\begin{itemize}
\item |author|:
author(s) of the problem (or subproblem, solution).
\item |editor|:
editor(s) of the problem; this field refers to a person
who has made adjustments to the problem
whereas |author| refers to the creator of the problem.
\item |source|:
source of the problem;
in case the problem has been taken from elsewhere
(conceptually or literally).
\item |difficulty|:
indication of the level of difficulty of the problem.
\item |keyword|:
keyword(s) for the problem;
\item |comment|:
some comment on the problem.
\item |optional|
(display enabled by default):
whether addressing the problem is mandatory or optional;
by default the text will be displayed after the title
in italic shape.
\end{itemize}
%
By default, only the |optional| items are displayed,
all other types of items are hidden;
controlling the display for each type of item is described below.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{extdata}
Further displayed metadata keys
are defined by the package option |extdata|, see \secref{sec:options}:
%
\begin{itemize}
\item |review|:
field to review the aspects of the problem
(quality, length, appropriateness, difficulty, \ldots).
\item |recycle|:
indication of previous instances where this problem was used.
\item |timesolve|:
indication of the time needed to solve this problem (or subproblem).
\item |timepresent|:
indication of the time needed to present this problem
(or subproblem, solution).
\end{itemize}
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{\showprobleminfo}
The display of the above metadata fields for a problem
(or subproblem, solution) is controlled by:
%
\begin{center}
|\showprobleminfo{|\textit{keys}|}|
\end{center}
%
Here \textit{keys} is a comma-separated list of keys to
be activated (\textit{key} or \textit{key}|=true|)
or deactivated (\textit{key}|=false|).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{\defprobleminfo}
Displayable metadata can be defined or adjusted by:
%
\begin{center}
|\defprobleminfo{|\textit{key}|}{|\textit{code}|}|
\end{center}
%
Here \textit{key} specifies the metadata field and
\textit{code} the code to display this type of metadata
where the argument |#1| represents the data to be displayed.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{insertprobleminfo}
\DescribeMacro{insertsubprobleminfo}
\DescribeMacro{insertsolutioninfo}
\DescribeMacro{\addprobleminfo}
\DescribeMacro{\addprobleminfo*}
Additional information can be injected into the opening line
of problems and solutions by the definitions:
%
\begin{center}
\begin{tabular}{l}
|\exerciseconfig{insertprobleminfo}{|\textit{code}|}|\\
|\exerciseconfig{insertsubprobleminfo}{|\textit{code}|}|\\
|\exerciseconfig{insertsolutioninfo}{|\textit{code}|}|
\end{tabular}
\end{center}
%
The hook code \textit{code} will be called after processing
the environment arguments. Information can be added to the opening line by:
%
\begin{center}
\begin{tabular}{l}
|\addprobleminfo{|\textit{info}|}|\\
|\addprobleminfo*{|\textit{info}|}|
\end{tabular}
\end{center}
%
The unstarred command adds information at the end of the opening line,
the starred version at the beginning (but after the title or identifier).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Points}
\label{sec:points}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{points}
Exercise problems or certain parts of them
can be credited with points (credits, awards, \ldots).
The package provides an interface to specify and manage such points.
Points are declared by the option |points=|\textit{points}
for the environments |sheet|, |problem| and |subproblem|.
These numbers will be printed to the opening line of
problems and subproblems.

Note that the points should normally be integer numbers.
Fractional points are permissible as well,
but the internal storage by the \TeX{} engine is somewhat limited,
so that only fractions with powers of two as denominators
(.5, multiples of .25, .125, .0625, \ldots) are reliable.
More general fractional decimal numbers such as multiples of 0.2
will be subject to rounding errors and will not display nicely.

Bonus points can be specified in the format
|points=|[\textit{regular}][|+|\textit{bonus}].
By default, such points will be printed as
[\textit{regular}][|+|\textit{bonus}] where 0 components are omitted.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{problempointsat}
\DescribeMacro{subproblempointsat}
\DescribeMacro{solutionpointsat}
The location where points of problems and subproblems
shall be displayed can be adjusted individually by:
%
\begin{center}
\begin{tabular}{l}
|\exercisestyle{problempointsat=start|\textbar|start*|\textbar|margin|%
  \textbar|end|\textbar|manual|\textbar|off}|\\
|\exercisestyle{subproblempointsat=start|\textbar|start*|\textbar|margin|%
  \textbar|end|\textbar|manual|\textbar|off}|\\
|\exercisestyle{solutionpointsat=start|\textbar|start*|\textbar|margin|%
  \textbar|end|\textbar|manual|\textbar|off}|
\end{tabular}
\end{center}
%
The default values are |start| and |end| for problems and subproblems,
respectively.
The option |start| displays points at
the very end of the opening line;
the option |start*| displays them at the start of it.
The option |end| displays points at the end of the
problem or subproblem text.
The option |margin| displays points in the margin.
The option |manual| displays points at a manually chosen location
specified by the directive |\showpoints|.
Note that |\showpoints| can also be used for the option |end|
to display the points prematurely
(e.g.\ if the text ends with a displayed equation,
it may make sense to display the points just before the equation).
The option |off| disables the display of points.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{\getsheetdata}
Points for sheets are only stored by the package;
they must displayed manually.
Within the corresponding |sheet| environment
the points can be accessed by:
%
\begin{center}
|\getsheetdata{points}|
\end{center}
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{\getsheetpoints}
\DescribeMacro{\getproblempoints}
\DescribeMacro{\getsubproblempoints}
\DescribeMacro{\getsolutionpoints}
\DescribeMacro{\extractpoints}
\DescribeMacro{\switchpoints}
The package allows to read the point totals
for other sheets and problems:
%
\begin{center}
\begin{tabular}{l}
|\getsheetpoints{|[\textit{tag}]|}|\\
|\getproblempoints{|[\textit{tag}]|}|\\
|\getsubproblempoints{|[\textit{tag}]|}|\\
|\getsolutionpoints{}|
\end{tabular}
\end{center}
%
Here \textit{tag} is the tag assigned to the corresponding sheet or problem,
see \secref{sec:labels}.
An empty argument \textit{tag} refers to the current
sheet, (sub)problem or solution.
If bonus points are used, the points will be returned
in the format [\textit{regular}][|+|\textit{bonus}];
the components \textit{regular} and \textit{bonus}
can be extracted from the returned expression
by |\extractpoints| and |\extractpoints*|, respectively.
A convenient case switch of the returned value can be performed by:
%
\begin{center}
|\switchpoints{|\textit{reg}|}{|\textit{bonus}|}{|\textit{both}|}{|%
\textit{none}|}{|\textit{val}|}|
\end{center}
%
Here \textit{val} is the value returned from the points register,
\textit{reg} is displayed for purely regular points,
\textit{bonus} is displayed for purely bonus points,
\textit{both} is displayed for mixed points,
\textit{none} is displayed for no points.
In each of the four expressions,
|#1| will be replaced by the regular points
and |#2| by the bonus points.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{\awardpoints}
Grading instructions with points to be awarded
can be specified in the solution text by:
%
\begin{center}
\begin{tabular}{l}
|\awardpoints[|\textit{details}|]{|\textit{points}|}|\\
|\awardpoints*[|\textit{details}|]{|\textit{points}|}|
\end{tabular}
\end{center}
%
Here \textit{details} is an optional text with further details,
e.g.\ to explain under which conditions
these points are to be awarded.
The starred form is used to specify optional points or alternative paths
with alternative grading instructions.
These points will be marked and not be used for the computation of a total.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{warntext}
The package attempts to add up
the points of subproblems to the problem total
and likewise the points of problems to the sheet total.
The package also performs some sanity checks on the provided numbers:
If points are specified for both subproblems and problems
or for both problems and sheets, they will be compared.
Also the points within solutions (excluding optional or alternative points)
are added up and compared to the corresponding problem or subproblem.
Furthermore the package checks whether points
are defined for all subproblems within a problem
or all problems within a sheet.
Mismatches are reported as package warnings.
As point mismatches can be rather severe,
there is an option to write such warnings directly into
the output document (to be removed before distribution):
%
\begin{center}
|\exercisesetup{warntext|[|=true|\textbar|false|]|}|
\end{center}
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{fracpoints}
The package offers pretty display of fractional points
with denominators 2, 4 and 8 by writing the decimal part
as a fraction, e.g.\ 1.75 $\to$ 1$^3\mskip-4mu/\mskip-2mu_4$.
This feature is enabled by:
%
\begin{center}
|\exercisestyle{fracpoints}|
\end{center}
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Labels and Tags}
\label{sec:labels}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{label}
\LaTeX{} provides labels to make references to remote parts of the text.
Labels can be set as usual by |\label{|\textit{label}|}| within the
|problem|, |subproblems| and |sheet| environments.
Alternatively, they can be specified
as the environment option:
%
\begin{center}
|label={|\textit{label}|}|
\end{center}
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{tag}
\DescribeMacro{\sheettag}
\DescribeMacro{\problemtag}
\DescribeMacro{\subproblemtag}
The package provides an additional mechanism to tag sheets and problems.
Each |sheet|, |problem| and |subproblem|
can be assigned a unique tag \textit{tag} by
the environment option:
%
\begin{center}
|tag={|\textit{tag}|}|
\end{center}
%
This tag is used for reading point totals
as described in \secref{sec:points}.
Furthermore, the macro |\sheettag|, |\problemtag| or |\subproblemtag|
is set to the tag \textit{tag} within the current environment.
If no tag is specified it defaults to the number
of the current sheet or (sub)problem;
note that this number can change by reordering sheets and problems
and therefore it should not be used to identify the entity from
other parts of the document.

A useful application for tags is to encapsulate labels
within individual sheets and problems
which are part of a collection of exercises.
Labels which are composed as
|\sheettag-|\textit{label} or
|\problemtag-|\textit{label}
can be considered local and will not clash with labels
defined within a different environment.
Within the same sheet or problem, local labels can be accessed
by the same construction.
They can also be accessed from remote parts of the document by fully
expanding |\sheettag| or |\problemtag| for the desired target environment.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{autolabelsheet}
\DescribeMacro{autolabelproblem}
If unique tags are specified, the package can automatically create labels
for sheets (|sheet:|\textit{tag}) and problems (|prob:|\textit{tag}) by:
%
\begin{center}
\begin{tabular}{l}
|\exercisesetup{autolabelsheet|[|=true|\textbar|false|]|}|\\
|\exercisesetup{autolabelproblem|[|=true|\textbar|false|]|}|
\end{tabular}
\end{center}
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{\getsheetlist}
\DescribeMacro{\getproblemlist}
\DescribeMacro{\getsubproblemlist}
Tags can also be used to process a list of sheets, problems and subproblems:
%
\begin{center}
\begin{tabular}{l}
|\getsheetlist{}|\\
|\getproblemlist{|[\textit{sheet-tag}]\textbar|*}|\\
|\getsubproblemlist{|[\textit{problem-tag}]|}|\\
\end{tabular}
\end{center}
%
These commands return a list of sheets, problems and subproblems tags,
where each item is encapsulated in braces.
The commands |\get|[|sub|]|problemlist| return the (sub)problems
within the specified sheet or problem. If no argument is given,
the current sheet or problem is assumed.
|\getproblemlist*| returns the list of all problems.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{\exerciseloop}
\DescribeMacro{\exerciseloopstr}
\DescribeMacro{\exerciseloopret}
\DescribeMacro{exerciseloop}
The package defines two commands to walk through such a list:
%
\begin{center}
\begin{tabular}{l}
|\exerciseloop{|\textit{items}|}{|\textit{cmd}|}|\\
|\exerciseloopstr[|\textit{ret}|]{|\textit{items}|}{|\textit{str}|}|
\end{tabular}
\end{center}
%
Here, \textit{items} is a list of items in braces,
and |\exerciseloop| evaluates \textit{cmd}
for each item of the list where `|#1|' is replaced by the item.
The command |\exerciseloopstr| concatenates
the evaluations of \textit{str}
and returns the resulting string in the macro \textit{ret}
(which defaults to |\exerciseloopret|).
Both commands maintain a counter of items |exerciseloop|
which can be accessed within \textit{cmd}/\textit{str} or
after |\exerciseloop|[|str|] to obtain the total number of items
in the list.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Layout}
\label{sec:layout}

The package provides a large number of parameters to adjust the
display of exercises to a desired layout.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{\exerciseconfig}
Configuration settings are declared and modified by the command:
%
\begin{center}
|\exerciseconfig{|\textit{key}|}[|\textit{narg}|]{|\textit{value}|}|
\end{center}
%
Here \textit{key} is a key and \textit{value} is its assigned value.
Configuration options can also be macros with arguments in which case
\textit{narg} is the number of arguments and \textit{value}
is the macro definition using arguments |#|\textit{n}.
The command |\exerciseconfig| therefore is analogous to
|\|(|re|)|newcommand| except that the definitions are
encapsulated by the package and any previous definition
is overwritten without checking.

\DescribeMacro{\exerciseconfigappend}
\DescribeMacro{\exerciseconfigprepend}
In some cases it may be useful to be able to
append or prepend to a (parameterless) definition by:
%
\begin{center}
\begin{tabular}{l}
|\exerciseconfigappend{|\textit{key}|}{|\textit{value}|}|\\
|\exerciseconfigprepend{|\textit{key}|}{|\textit{value}|}|
\end{tabular}
\end{center}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{\getexerciseconfig}
\DescribeMacro{\exerciseconfigempty}
Configuration definitions can be read by:
%
\begin{center}
|\getexerciseconfig{|\textit{key}|}|[\textit{arguments}]
\end{center}
%
The number of arguments after |{|\textit{key}|}|
must match the optional argument \textit{nargs} of the definition.
Furthermore, it can be checked whether a configuration definition
is empty:
%
\begin{center}
|\exerciseconfigempty{|\textit{key}|}|%
  |{|\textit{empty code}|}{|\textit{filled code}|}|
\end{center}
%
The \textit{empty code} is executed if no value
or an empty value has been specified.
Otherwise the \textit{filled code} is executed.

The package defines numerous layout configuration options.
They are listed along with their original definition
and a brief description in \secref{sec:imp-config}.
They include options to:
%
\begin{itemize}
\item
adjust the language for the principal entities of this package
like `sheet(s)', `problem(s)', `solution(s)', `points(s)';
\item
adjust the fonts styles of various parts of the text;
\item
adjust the spacing above, below, between various elements;
\item
define code to process data and insert text at various locations;
\item
compose text to be used in various situations;
\item
adjust the appearance of counters;
\item
adjust some other behaviour of the package.
\end{itemize}
%
The following will highlight only few examples.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{insertsheettitle}
An important setting is:
%
\begin{center}
|\exerciseconfig{insertsheettitle}{|\textit{code}|}|
\end{center}
%
The code \textit{code} is meant to print the title
or header of an exercise sheet.
The minimalistic default code |\centerline{\getsheetdata{title}}|
merely prints the sheet title ``Sheet \#'' at the centre of a line.
Commonly, one would replace this by a more elaborate header
(potentially with some more information,
appealing layout, logos, \ldots).
In order to design a header template,
it makes sense to retrieve data
via |\getexercisedata| and |\getsheetdata|
described in \secref{sec:metadata}.
Likewise |\exercisedataempty| and |\sheetdataempty|
can be used to display default values or alternative data
if some particular data is not provided.
An example is given by the |plainheader| extended style option
defined in \secref{sec:imp-styles}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{composetitleproblem}
Another noteworthy example is |composetitleproblem|
to compose the title for a problem. It takes two parameters,
the number and the title.
The (somewhat simplified) default declaration is:
%
\begin{center}
\begin{tabular}{l}
|\exerciseconfig{composetitleproblem}[2]{\exerciseifempty{#2}|\\
|  {\getexerciseconfig{termproblem}|\\
|   \getexerciseconfig{composeitemproblem}{#1}}|\\
|  {\getexerciseconfig{composeitemproblem}{#1} #2}}|
\end{tabular}
\end{center}
%
This checks whether the title is empty.
If no title is given use ``Problem \#.'',
otherwise use ``\#. \textit{title}''.
Here the term ``Problem'' is made abstract
by the configuration |termproblem|
(e.g.\ to support internationalisation)
and the problem number is further composed obtained by
the configuration |composeitemproblem|
which takes the bare number as argument
and returns it followed by a dot.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{\exerciseifempty}
\DescribeMacro{\exerciseifnotempty}
Handy conditionals command to check
whether an expression \textit{expr} is empty are:
%
\begin{center}
\begin{tabular}{l}
|\exerciseifempty{|\textit{expr}|}|%
  |{|\textit{empty code}|}{|\textit{filled code}|}|\\
|\exerciseifnotempty{|\textit{expr}|}|%
  |{|\textit{filled code}|}|
\end{tabular}
\end{center}
%
Their main purpose is to test
whether some provided expression \textit{expt} is empty.
They expand to the common \TeX{} constructs
|\if&#1&#2\else#3\fi| and |\if&#1&\else#2\fi|
which work assuming that \textit{expr} is not too exotic
(e.g.\ it should not start with the character `|&|'
and other special \TeX{} characters or macros are potentially dangerous;
also using this within tables can be troublesome;
the character `|&|' can be reconfigured by the package option |emptytestchar|).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Exercise Styles}
\label{sec:styles}

The package provides a mechanism to define exercise styles
which customise the display of exercises in some coordinated fashion.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{\exercisestyle}
Style(s) are activated by the command:
%
\begin{center}
|\exercisestyle{|\textit{styles}|}|
\end{center}
%
Here \textit{styles} is a comma-separated list of styles,
where each style is given by a pair \textit{style}[|={|\textit{argument}|}|].
The package defines a couple of standard styles:
%
\begin{itemize}
\item |solutionbelow=|\textit{pos}
(can take values |here|, |subproblem|, |subproblem*|,
|problem|, |problem*|, |sheet| and |manual|;
initially set to |subproblem|) --
positions the solutions below the indicated environments;
see \secref{sec:solutions} for details.

\item |problempointsat=|\textit{pos}
(can take values |start|, |start*|, |margin|, |end| and |manual|;
initially set to |start|) --
displays points in problems at the indicated location;
see \secref{sec:points} for details.

\item |subproblempointsat=|\textit{pos}
(can take values |start|, |start*|, |margin|, |end| and |manual|;
initially set to |end|) --
displays points in subproblems at the indicated location;
see \secref{sec:points} for details.

\item |solutionpointsat=|\textit{pos}
(can take values |start|, |start*|, |margin|, |end| and |manual|;
initially set to |end|) --
displays points in solutions at the indicated location;
see \secref{sec:points} for details.

\item |problemby={|\textit{counter}|}| --
number problems with the prefix \textit{counter},
i.e.\ reset the problem counter whenever \textit{counter} increases
and use a composite label \textit{counter}|.|\textit{problem}
to identify problems.

\item |equationby={|\textit{counter}|}| --
number the dedicated equation counters for sheets, problems and solutions
with the prefix \textit{counter}.

\item |problembysheet| --
number problems by sheet.

\item |equationbysheet| --
number dedicated equations for sheets, problems and solutions by sheet;
note that the main equation counter is unaffected by this setting,
it therefore makes sense to also activate the style |sheetequation|
or use |\counterwithin{equation}{sheet}|.

\item |pagebysheet| --
number pages by sheet and denote pages by \textit{sheet}|.|\textit{page};
this style is useful to generate stable page numbers for
a collection of sheets.

\item |sheetequation|[|=true|\textbar|false|]
(no value implies |true|, initially set to |false|) --
use a dedicated equation counter within sheets.

\item |problemequation|[|=true|\textbar|false|]
(no value implies |true|, initially set to |false|) --
use a dedicated equation counter within problems.

\item |solutionequation|[|=true|\textbar|false|]
(no value implies |true|, initially set to |true|) --
use a dedicated equation counter within solutions.

\item |fracpoints|[|=true|\textbar|false|]
(no value implies |true|, initially set to |false|) --
display fractional points for denominators 2, 4, 8;
see \secref{sec:points} for details.

\item |twoside|[|=true|\textbar|false|]
(no value implies |true|, initially set to |false|) --
enable/disable two-sided layout;
in two-sided layout, sheets will start on odd pages
and empty pages are added at the end of sheets
to produce an even number of pages.

\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{extstyle}
Further exercise styles
are defined by the package option |extstyle|, see \secref{sec:options}:
%
\begin{itemize}
\item |plainheader| --
define a plain sheet header to display
some essential exercise and sheet data:
|course|, |institution|, |instructor|, |period| (optional), sheet |title|,
see \secref{sec:metadata};
the line below the header, font styles and spaces can be adjusted,
see the definition in \secref{sec:imp-styles}.

\item |contents| --
display sheets and problems in the table of contents
(as sections and subsections).

\item |solutionsf| --
display solutions in sans serif font family.

\item |solutiondimproblem| --
dim the problem text whenever solutions are displayed.

\item |solutionsep| --
separate the solutions from the remaining text by horizontal lines.

\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{\defexercisestyle}
Custom styles can be defined by:
%
\begin{center}
\begin{tabular}{l}
|\defexercisestyle{|\textit{style}|}{|\textit{init}|}|\\
|\defexercisestylearg[|\textit{default}|]{|\textit{style}|}{|\textit{init}|}|
\end{tabular}
\end{center}
%
This feature can be used to predefine certain aspects of
the exercises layout.
For example, different default page layouts could be declared in this way.
The first version declares a style which is
initialised by the code \textit{item} upon activation by
|\exercisestyle{|\textit{style}[|=true|]|}|.
Note that |\exercisestyle{|\textit{style}|=false}| does nothing.
The second version declares a style which is activated by
|\exercisestyle{|\textit{style}[|={|\textit{arg}|}|]|}|
and which calls \textit{item} with the argument |#1| referring to \textit{arg}
(or \textit{default} if no argument is given).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Package Options}
\label{sec:options}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DescribeMacro{\exercisesetup}
Features and options of general nature can be selected by the commands:
%
\begin{center}
\begin{tabular}{rl}
&|\usepackage[|\textit{opts}|]{exframe}|
\\
or&|\PassOptionsToPackage{|\textit{opts}|}{exframe}|
\\
or&|\exercisesetup{|\textit{opts}|}|
\end{tabular}
\end{center}
%
|\PassOptionsToPackage| must be used before |\usepackage|;
|\exercisesetup| must be used afterwards.
\textit{opts} is a comma-separated list of options.

The following options are available only when
loading the package, i.e.\ they will not work
within |\exercisesetup|:
%
\begin{itemize}
\item |extdata|[|=true|\textbar|false|]
(no value implies |true|, initially set to |false|) --
define some more advanced metadata entries.

\item |extstyle|[|=true|\textbar|false|]
(no value implies |true|, initially set to |false|) --
define some more advanced styles.

\item |metastr|[|=true|\textbar|false|]
(no value implies |true|, initially set to |false|) --
load \textsf{metastr} package and use to handle PDF metadata
and basic internationalisation,
see \secref{sec:imp-metastr} for details.

\item |problemenv=|\textit{name} --
redefine environment name |problem|.
This and the following alike options may be useful in
quickly adjusting existing sources to
the \textsf{exframe} framework
if the original framework works similarly
and no special features are used.
Otherwise, it is highly advisable to leave the
names of environments and counters
defined by the package untouched.

\item |subproblemenv=|\textit{name} --
redefine environment name |subproblem|.

\item |solutionenv=|\textit{name} --
redefine environment name |solution|.

\item |sheetenv=|\textit{name} --
redefine environment name |sheet|.

\item |problemcounter=|\textit{name} --
redefine counter name |problem|.

\item |subproblemcounter=|\textit{name} --
redefine counter name |subproblem|.

\item |solutioncounter=|\textit{name} --
redefine counter name |solution|.

\item |sheetcounter=|\textit{name} --
redefine counter name |sheet|.

\end{itemize}
%

The following options can be specified by all three methods described above:
%
\begin{itemize}
\item |solutions|[|=true|\textbar|false|]
(no value implies |true|, initially set to |false|) --
Enable/disable display of solutions.
Sets the conditional |\ifsolutions| accordingly.

\item |pdfdata|[|=auto|\textbar|manual|\textbar|sheet|\textbar|off|]
(no value implies |auto|, initially set to |auto|) --
control writing most relevant metadata to pdf files;
has no effect without package \textsf{hyperref}.

\item |lineno|[|=true|\textbar|false|]
(no value implies |true|, initially set to |false|) --
enable/disable writing of line numbers as comments
into solution files.

\item |twoside|[|=true|\textbar|false|]
(no value implies |true|, initially set to |false|) --
enable/disable two-sided layout;
see \secref{sec:styles} for details.

\item |solutionhref|[|=true|\textbar|true|]
(no value implies |true|, initially set to |false|) --
enable/disable use of hyper-references from solutions
to the corresponding problems;
has no effect without package \textsf{hyperref}.

\item |warntext|[|=true|\textbar|false|]
(no value implies |true|, initially set to |false|) --
enable/disable writing of relevant warning messages
(points mismatch, point sums require update)
into the document output for easier detection.

\item |autolabelsheet|[|=true|\textbar|false|]
(no value implies |true|, initially set to |false|) --
enable/disable automatically assigning labels
(|sheet:\sheettag|; can be adjusted)
to sheets according to their tag |\sheettag|.

\item |autolabelproblem|[|=true|\textbar|false|]
(no value implies |true|, initially set to |false|) --
enable/disable automatically assigning labels
(|prob:\problemtag|; can be adjusted)
to problems according to their tag |\problemtag|.

\item |solutionbuf|[|=true|\textbar|false|]
(no value implies |true|, initially set to |true|) --
enable/disable buffering for |solution| environments
in order to control their display;
disabling buffering can be helpful
in debugging faulty |solution| environments;
it might also resolve some tokenisation issues in special circumstances;
note that the display of solutions cannot be suppressed
with |\exercisesetup{solutions=false}| when buffering if disabled.

\item |problembuf|[|=true|\textbar|false|]
(no value implies |true|, initially set to |false|) --
enable/disable buffering for |problem| environments
in order to control their display.

\item |emptytestchar=|\textit{char}
(initially set to `|&|') --
character to use for testing whether an argument |#1|
is empty via |\if&#1&...\fi|;
if `|&|' causes trouble within tables, could try `|@|' instead.

\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Information}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Copyright}

Copyright \copyright{} 2011--2020 Niklas Beisert

This work may be distributed and/or modified under the
conditions of the \LaTeX{} Project Public License, either version 1.3
of this license or (at your option) any later version.
The latest version of this license is in
  \url{http://www.latex-project.org/lppl.txt}
and version 1.3 or later is part of all distributions of \LaTeX{}
version 2005/12/01 or later.

This work has the LPPL maintenance status `maintained'.

The Current Maintainer of this work is Niklas Beisert.

This work consists of the files |README.txt|, |exframe.ins| and |exframe.dtx|
as well as the derived files |exframe.sty|, |exfsamp.tex|, |exfserm.tex|,
|exfser|\textit{nn}|.tex| (\textit{nn}=|01|, |02|, |03|, |aa|),
|exfserpe.tex|, |exfserpf.tex|, |exfsermk.sh|, |exfsermk.mak|
and |exframe.pdf|.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Files and Installation}

The package consists of the files:
%
\begin{center}
\begin{tabular}{ll}
    |README.txt|   & readme file \\
    |exframe.ins|  & installation file \\
    |exframe.dtx|  & source file \\
    |exframe.sty|  & package file \\
    |exfsamp.tex|  & sample file \\
    |exfserm.tex|  & multipart sample main file \\
    |exfser01.tex| & multipart sample sheet 1 \\
    |exfser02.tex| & multipart sample sheet 2 \\
    |exfser03.tex| & multipart sample sheet 3 \\
    |exfseraa.tex| & multipart sample unused problems \\
    |exfserpe.tex| & multipart sample problem E \\
    |exfserpf.tex| & multipart sample problem F \\
    |exfsermk.sh|  & multipart sample compile script \\
    |exfsermk.mak| & multipart sample makefile \\
    |exframe.pdf|  & manual
\end{tabular}
\end{center}
%
The distribution consists of the files
|README.txt|, |exframe.ins| and |exframe.dtx|.
%
\begin{itemize}
\item
Run (pdf)\LaTeX{} on |exframe.dtx|
to compile the manual |exframe.pdf| (this file).
\item
Run \LaTeX{} on |exframe.ins| to create the package |exframe.sty|
and the samples consisting of |exfsamp.tex|, |exfserm.tex|,
|exfser01.tex|, |exfser02.tex|, |exfser03.tex|, |exfseraa.tex|,
|exfserpe.tex|, |exfserpf.tex|, |exfsermk.sh|, |exfsermk.mak|.
Copy the file |exframe.sty| to an appropriate directory of your \LaTeX{}
distribution, e.g.\ \textit{texmf-root}|/tex/latex/exframe|.
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Related Packages}

The package makes use of other packages available at CTAN:
\begin{itemize}
\item
This package relies on some functionality of the package \textsf{verbatim}
to read verbatim code from the \LaTeX{} source without expansion of macros.
Compatibility with the \textsf{verbatim} package
has been tested with v1.5q (2014/10/28).
\item
This package uses the package
\href{http://ctan.org/pkg/xkeyval}{\textsf{xkeyval}}
to process the options for the package, environments and macros.
Compatibility with the \textsf{xkeyval} package
has been tested with v2.7a (2014/12/03).
\item
This package can use the package
\href{http://ctan.org/pkg/hyperref}{\textsf{hyperref}}
to include hyperlinks between problems and solutions.
Compatibility with the \textsf{hyperref} package
has been tested with v6.88e (2018/11/30).
\item
This package can use the package
\href{http://ctan.org/pkg/amstext}{\textsf{amstext}}
(which is automatically loaded by \textsf{amsmath})
to display text within equations.
Compatibility with the \textsf{amstext} package
has been tested with v2.01 (2000/06/29).
\item
This package uses the command |\currfilename|
provided by the package \textsf{currfile} (if available and loaded)
to indicate the \LaTeX{} source file in the generated metapost file.
Compatibility with the \textsf{currfile} package
has been tested with v0.7c (2015/04/23).
\item
This package can use the package
\href{http://ctan.org/pkg/metastr}{\textsf{metastr}}
to write PDF metadata and to handle basic translations.
Compatibility with the \textsf{metastr} package
has been tested with v1.0 (2020/02/06).
\end{itemize}

There are several other \LaTeX{} packages
which offer a similar functionality
varying largely in scope and sophistication:
%
\begin{itemize}
\item
The package \href{http://ctan.org/pkg/exsheets}{\textsf{exsheets}}
and its successor \href{http://ctan.org/pkg/xsim}{\textsf{xsim}}
provide a \LaTeX{} 3 style for typesetting exercises with solutions.
They offer options to
hide or delay solutions,
print only specific problems,
deal with points,
specify metadata,
handle exercise collections,
as well as some more specific options.
They allow to adjust the layout and choose among predefined ones.
\item
The package \href{http://ctan.org/pkg/exercise}{\textsf{exercise}}
provides a style for typesetting exercises with solutions.
It offers many options to
hide or delay solutions,
print only specific problems,
specify some metadata
as well as some more specific options.
It allows to customise the layout.
\item
The package \href{http://ctan.org/pkg/exercises}{\textsf{exercises}}
provides a style for typesetting exercises with solutions.
It offers options to hide solutions and deal with points.
It allows basic customisation of the layout.
\item
The package \href{http://ctan.org/pkg/exam}{\textsf{exam}}
provides a document class for typesetting exams conveniently.
It offers many options to hide solutions, deal with points
and deal with other exam-specific tasks.
It allows to adjust the layout and choose among predefined ones.
\item
The package \href{http://ctan.org/pkg/probsoln}{\textsf{probsoln}}
provides a style for typesetting exercises with solutions
which are stored in a collection.
It offers options to
hide solutions
and to assemble problems from an external collection.
\item
The packages
\href{http://ctan.org/pkg/uebungsblatt}{\textsf{uebungsblatt}},
\href{http://ctan.org/pkg/uassign}{\textsf{uassign}},
\href{http://ctan.org/pkg/mathexam}{\textsf{mathexam}},
\href{http://ctan.org/pkg/exsol}{\textsf{exsol}},
\href{https://github.com/mbauman/homework}{\textsf{homework}},
\href{https://gist.github.com/jhwilson/1278588}{\textsf{jhwhw}}
provide basic functionality for somewhat more particular situations.
\end{itemize}
%
See CTAN categories
\href{http://ctan.org/topic/exercise}{\textsf{exercise}}
and \href{http://ctan.org/topic/exam}{\textsf{exam}}
for further up-to-date packages.

The philosophy of the present package is to
define a low-level framework to describe exercises with solutions
to be used in various situations.
The aim is to provide the means to describe the content
(problems, solutions, sheets) in a simple fashion
and separate it from the various layout definitions and choices
which will define the appearance of the content.
The interface was designed to reduce potential conflict
with other packages and definitions.
The package itself does not define an elaborate layout,
but it provides means to adjust it in many ways and
to predefine custom layout schemes.
The package offers most of the functionality of the above packages,
but (presently) misses out on some more advanced features,
see \secref{sec:suggestions}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\iffalse
\subsection{Suggested Customisations}
\label{sec:customisations}

\textbf{philosophy:}
this is fundamental, relies on few other basic packages.
can improve by combining with other packages which provide solutions
for particular applications. some suggestions:

\textbf{Optional Starred}

\textbf{Till's Boxen}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Realize background color for solutions with tcolorbox:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\RequirePackage{tcolorbox}
%\tcbuselibrary{breakable}
%\exercisestyle{solutionsep}
%\exerciseconfig{insertsolutionsbefore}{%
%  \begin{tcolorbox}[breakable,boxrule=0.2pt,sharp corners=all]}
%\exerciseconfig{insertsolutionsafter}{%
%  \end{tcolorbox}}
%% cannot use marginpar inside tcolorbox (nested floats), use marginnote instead:
%\exercisestyle{solutionpointsat=margin}
%\RequirePackage{marginnote}
%\exerciseconfig{insertpointsmargin}[1]{\marginnote{\footnotesize #1}}
%% Don't indent solutions:
%\exerciseconfig{skipsolutionitemsub}{0ex}
%% remove initial "Solution:" because the colorbox is highlight enough:
%\exerciseconfig{composetitlesolutionsingle}[2]{}

\textbf{Collections}

\textbf{keep list of tags per sheet. code to loop through list. Manuel Benz}

\fi

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Feature Suggestions}
\label{sec:suggestions}

The following is a list of features which may be useful for future
versions of this package:
%
\begin{itemize}
\item
Add a section on useful combinations of customisation settings
to achieve specific goals. Please send suggestions.
\item
Option to hide problem text while maintaining access to embedded solutions
(for a version containing only solutions):
this is difficult to implement because the problem environment
cannot simply be discarded, but would have to be scanned very carefully
for the embedded solution;
instead process problems to some document and save solutions to file,
then read solutions from different document.
\item
Define structures for multiple-choice questions.
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Revision History}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\iffalse
\paragraph{v3.4+:} 2020/02/25

\begin{itemize}
\item
section on extensions
\item
\ldots
\end{itemize}
\fi

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{v3.4:} 2020/02/24

\begin{itemize}
\item
lists of sheets, problems and subproblems;
list iterators
\item
tags for subproblems, tag customisation
\item
interaction with package \textsf{metastr}
\item
minor fixes
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{v3.31:} 2020/01/11

\begin{itemize}
\item
|onlysolutions| environment for solution mode content
\item
sample multipart setup streamlined
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{v3.3:} 2019/06/15

\begin{itemize}
\item
control display of |problem| environments via
package option |problembuf|:
manual display, write to file, disable individual problems
\item
|solutionbelow| mode |here*| superseded by
package option |solutionbuf|
\item
display total points within solution: |solutionpointsat|
(thanks to Till Bargheer for suggestion)
\item
read points for current sheet, (sub)problem and solution
(thanks to Johannes Hahn for suggestion)
\item
case switch for bonus points
(thanks to Johannes Hahn for suggestion)
\item
option to |disable| particular problems,
control by hook function
(thanks to Manuel Benz for suggestion)
\item
provided interface |\showfracpoints| and |\exerciseconfig{frac}|
for fractional points display
\item
filename extensions configurable
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{v3.2:} 2019/05/01

\begin{itemize}
\item
bonus points can be specified as
|points=|[\textit{regular}][|+|\textit{bonus}]
\item
|solutionbelow| mode |here*| added
for direct processing of the solution environment
\item
multipart sample added
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{v3.11:} 2019/04/15

\begin{itemize}
\item
fix interaction with
package \href{http://ctan.org/pkg/calc}{\textsf{calc}}
(thanks to Johannes Hahn for bug report)
\item
fix style |fracpoints| in combination
with some [|sub|]|problempointsat| choices
(thanks to Johannes Hahn for bug report)
\item
fix spacing for [|sub|]|problempointsat=margin|
(thanks to Johannes Hahn for bug report)
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{v3.1:} 2019/01/21

\begin{itemize}
\item
alternate placement modes for solutions
\item
fixed expansion of problem title
\item
reset font size for problem text
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{v3.0:} 2019/01/16

\begin{itemize}
\item
renamed to |exframe.sty|
\item
first version published on CTAN
\item
overhaul and streamline interface
\item
solution processing remodelled
\item
changed metadata handling
\item
changed and generalised points handling
\item
generalised sectioning layout
\item
changed layout specification model
\item
insert hyperlinks using \textsf{hyperref}
\item
manual, example and installation package added
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{v2.0 -- v2.6:} 2014/10/03 -- 2018/11/05

\begin{itemize}
\item
changed metadata interface
\item
broadened scope
\item
added more layout options
\item
added more metadata
\item
added sheet and problem tags
\item
add and remember points
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{v1.1 -- v1.6:} 2014/08/07 -- 2014/09/14

\begin{itemize}
\item
renamed to |nbprob.sty|
\item
added metadata
\item
added points
\item
added layout configuration
\item
removed specific macros
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{v1.0 -- v1.02:} 2011/09/23 -- 2013/03/17

\begin{itemize}
\item
first version as |problems.cls|
\item
dedicated layout and macros for author's exercise sheets
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\appendix

\settowidth\MacroIndent{\rmfamily\scriptsize 0000\ }

 \DocInput{exframe.dtx}

\end{document}
%</driver>
% \fi
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \section{Standalone Sample}
% \label{sec:samplesingle}
%\iffalse
%<*samplesingle>
%\fi
%
% This section provides an example of how to use
% some of the \textsf{exframe} features.
% The resulting layout will be somewhat messy
% due to a random selection of features.
%
% This example file describes a single exercise sheet.
% The other sheet of the series would be declared
% analogously in independent documents.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Preamble.}
%
% Standard document class:
%    \begin{macrocode}
\documentclass[12pt]{article}
%    \end{macrocode}

% Use package \textsf{geometry} to set the page layout;
% adjust the paragraph shape:
%    \begin{macrocode}
\usepackage{geometry}
\geometry{layout=a4paper}
\geometry{paper=a4paper}
\geometry{margin=2.5cm}
\parindent0pt
\parskip0.5ex
%    \end{macrocode}

% Include \textsf{amsmath}, \textsf{hyperref} packages:
%    \begin{macrocode}
\usepackage{amsmath}
\usepackage{hyperref}
%    \end{macrocode}

% May include \textsf{metastr} package;
% below code adjusts to whether or not present:
%    \begin{macrocode}
\PassOptionsToPackage{loadlang=en|de}{metastr}
\PassOptionsToPackage{course=true}{metastr}
%%\usepackage{metastr}
%%\metasetlang{de}
%    \end{macrocode}

% Include \textsf{exframe} package:
%    \begin{macrocode}
\usepackage[extstyle]{exframe}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Solutions Switch.}
%
% It will be useful to have the switch to turn on/off
% the display of solutions near the top
% of the source file, potentially with the opposite setting commented out:
%    \begin{macrocode}
%%\exercisesetup{solutions=true}
\exercisesetup{solutions=false}
%    \end{macrocode}

% Automatically put labels for (sub)problems:
%    \begin{macrocode}
\exercisesetup{autolabelproblem=true}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Layout Declarations.}
%
% The following layout declarations adjust the general layout
% of exercise sheets. They may as well be moved into an include file.
%
% Declare a header for exercise sheets
% to display several relevant pieces of data;
% display points total:
%    \begin{macrocode}
\exercisestyle{plainheader}
\exerciseconfig{composeheaderbelowright}{\getsheetdata{points}}%
%    \end{macrocode}

% Redefine the appearance of some counters;
% sheets should be labelled by capital roman numerals,
% subproblems by lowercase roman numerals;
% declare the widest subproblem item to be expected:
%    \begin{macrocode}
\exerciseconfig{countersheet}{\Roman{sheet}}
\exerciseconfig{countersubproblem}{\roman{subproblem})}
\exerciseconfig{countersubproblemmax}{vii)}
%    \end{macrocode}

% Automatically display an asterisk for all
% subproblems with bonus points only;
% remove space to separate items:
%    \begin{macrocode}
\exerciseconfig{insertsubprobleminfo}{%
 \switchpoints{}{\addprobleminfo*{%
   \hspace{-\getexerciseconfig{skipsubprobleminfo}}*}}%
  {}{}{\getsubproblempoints{}}}
%    \end{macrocode}

% Redefine the terms to be used for sheet(s);
% here, a German version:
%    \begin{macrocode}
\ifdefined\metaset
\metasetterm[en]{sheet}{Exercise Sheet}
\metasetterm[en]{sheets}{Exercise Sheets}
\metasetterm[de]{sheet}{\"Ubungsblatt}
\metasetterm[de]{sheets}{\"Ubungsbl\"atter}
\else
\exerciseconfig{termsheet}{\"Ubungsblatt}
\exerciseconfig{termsheets}{\"Ubungsbl\"atter}
\fi
%    \end{macrocode}

% Display points for problems in the margin;
% change margin display to use the left margin;
% use the abbreviated form `$n$p.':
%    \begin{macrocode}
\exercisestyle{problempointsat=margin}
\reversemarginpar
\exerciseconfig{composepointsmargin}[1]{#1p.}
\exerciseconfig{composepointspairmargin}[2]{%
  \ifdim#2pt=0pt#1p.%
  \else\ifdim#1pt=0pt+#2p.%
  \else#1+#2p.%
  \fi\fi}
%    \end{macrocode}

% Change the basic font style for all titles to be bold sans-serif:
%    \begin{macrocode}
\exerciseconfig{styletitle}{\sffamily\bfseries}
%    \end{macrocode}

% Add a significant amount of space below problems:
%    \begin{macrocode}
\exerciseconfig{skipproblembelow}{1.5cm}
%    \end{macrocode}

% Display half points as fractions:
%    \begin{macrocode}
\exercisestyle{fracpoints}
%    \end{macrocode}
% Show solutions below each problem
% (may try alternatives |subproblem| or |sheet|):
%    \begin{macrocode}
\exercisestyle{solutionbelow=problem}
%    \end{macrocode}
% Separate solutions by horizontal lines (extended style):
%    \begin{macrocode}
\exercisestyle{solutionsep}
%    \end{macrocode}

% Write metadata for sheet:
%    \begin{macrocode}
\exercisesetup{pdfdata=sheet}
%    \end{macrocode}

% Set title and author for pdf metadata;
% |title| is |course| plus |material| or sheet title;
% |author| is |instructor| or sheet author plus |institution|:
%    \begin{macrocode}
\ifdefined\metaset
\metaset[sep]{subtitle}{, }
\metaset{subtitle}{\ifsolutions\metatranslate[#1]{solutions} \fi%
  \metaif[use]{sheettitle}
   {\metapick[#1]{sheettitle}}
   {\metapick[#1]{material}}}
\metaset{author}{\exerciseifempty{\getsheetdata{author}}%
  {\metapick[#1]{instructor}}{\metapick[#1]{sheetauthor}},
  \metapick[#1]{institution}}
\else
\exerciseconfig{composemetasheet}[2]{\getexercisedata{course},
  \ifsolutions\getexerciseconfig{termsolutions} \fi%
  \exerciseifempty{#2}{\getexerciseconfig{termsheet} #1}{#2}}
\exercisedata{title=%
  {\getexercisedata{course},
  \ifsolutions\getexercisedata{solutions} \fi%
  \getexercisedata{material}}}
\exercisedata{author=%
  {\getexercisedata{instructor}, \getexercisedata{institution}}}
\fi
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Exercise Series Data.}
%
% Set some data on the current series:
%    \begin{macrocode}
\ifdefined\metaset
\metaset{institution}{Katharinen-Volksschule}
\metaset[de]{course}{Mathematik}
\metaset[en]{course}{Mathematics}
\metaset{instructor}{J.\ G.\ B\"uttner}
\metaset{period}{ca.\ 1786}
\metaset[de]{material}{\"Ubungsaufgaben}
\metaset[en]{material}{Exercise Problems}
\else
\exercisedata{institution={Katharinen-Volksschule}}
\exercisedata{course={Mathematik}}
\exercisedata{instructor={J.\ G.\ B\"uttner}}
\exercisedata{period={ca.\ 1786}}
\exercisedata{material={\"Ubungsaufgaben}}
\fi
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Body.}
%
%    \begin{macrocode}
\begin{document}
%    \end{macrocode}

% Start sheet number 5:
%    \begin{macrocode}
\begin{sheet}[number=5,label={sheet5}]
%    \end{macrocode}

% Start a problem with a title:
%    \begin{macrocode}
\begin{problem}[title={Sums},points=99+4]
%    \end{macrocode}

% Summary of points:
%    \begin{macrocode}
\exerciseloopstr{\getsubproblemlist{}}{c}%
\hfill\begin{tabular}{c|\exerciseloopret|c}
\exerciseloop{\getsubproblemlist{}}
 {&\ref{\getexerciseconfig{labelsubproblem}{#1}}}
&\ref{prob:\problemtag}\\\hline
\getexerciseconfig{termpoints}
\exerciseloop{\getsubproblemlist{}}{&\extractpoints{\getsubproblempoints{#1}}}
&\extractpoints{\getproblempoints{}}
\\
extra
\exerciseloop{\getsubproblemlist{}}{&\extractpoints*{\getsubproblempoints{#1}}}
&\extractpoints*{\getproblempoints{}}
\end{tabular}
%    \end{macrocode}

% Some introduction to the problem:
%    \begin{macrocode}
This problem deals with sums and series.
%    \end{macrocode}

% A subproblem with a local label:
%    \begin{macrocode}
\begin{subproblem}[points=2,difficulty=simple,label={\problemtag-simplesum}]
Compute the sum
\showpoints
\begin{equation}
1+2+3.
\end{equation}
%    \end{macrocode}

% Provide a solution for the subproblem (within the subproblem environment):
%    \begin{macrocode}
\begin{solution}
The result is
\begin{equation}
1+2+3=6.
\end{equation}
\end{solution}
%    \end{macrocode}

% End subproblem:
%    \begin{macrocode}
\end{subproblem}
%    \end{macrocode}

% Another subproblem:
%    \begin{macrocode}
\begin{subproblem}[points=97+0.5,difficulty=lengthy]
Compute the sum
\begin{equation}
1+2+3+\ldots+98+99+100.
\end{equation}
Keep calm and calculate!
%%That ought to keep him occupied for a while
\end{subproblem}
%    \end{macrocode}

% Provide a solution for the previous subproblem
% (layout may differ slightly from declaration within);
% declare author:
%    \begin{macrocode}
\begin{solution}[author={C.\ F.\ Gau\ss}]
We use the result $1+2+3=6$ from part \ref{\problemtag-simplesum}
to jumpstart the calculation. The remaining sums yield
\awardpoints*[1 for each remaining sum]{97}
\begin{equation}
6+4+5+\ldots+99+100=5050.
\end{equation}
Alternatively the summands can be grouped into pairs as follows:
\begin{align}
1+100&=101,\\
2+99&=101,\\
3+98&=101,\\
\ldots &\nonumber\\
50+51&=101.
\end{align}
These amount to 50 times the same number 101.
Therefore the sum equals
\begin{equation}
1+2+\ldots+99+100=50\cdot 101=5050.
\end{equation}
\textit{Ligget se!} \awardpoints{97+0.5}
\end{solution}
%    \end{macrocode}

% Some text between subproblems:
%    \begin{macrocode}
You may give the final part a try:
%    \end{macrocode}

% Final subproblem; this one is optional:
%    \begin{macrocode}
\begin{subproblem}[optional={optional},
  difficulty={requires inspiration},points={+3.5}]
Compute the series
\showpoints
\begin{equation}
1+2+3+\ldots
\end{equation}
%    \end{macrocode}

% Provide a solution:
%    \begin{macrocode}
\begin{solution}
The series is divergent, so the result is $\infty$ \awardpoints{+1}.
\par
However, after subtracting the divergent part,
the result clearly is
\begin{equation}
\zeta(-1)=-\frac{1}{12}\,,
\end{equation}
where the zeta-function $\zeta(s)$ is defined by
\begin{equation}
\zeta(s):=\sum_{k=1}^\infty \frac{1}{k^s}\,.
\end{equation}
This definition holds only for $s>1$ where the sum is convergent,
but one can continue the complex analytic function to $s<0$
\awardpoints{+1.5}.
\par
Another way of understanding the result
is to use the indefinite summation formula
for arbitrary exponent $s$ in the summand
(which also follows from the Euler--MacLaurin formula)
\begin{equation}
\sum_n n^s
= \frac{n^{s+1}}{s+1}
 -\sum_{j=0}^s  \frac{\zeta(j-s)\,s!}{(s-j)!\,j!}\,n^j
= \ldots - \zeta(-s)\,n^0.
\end{equation}
Curiously, the constant term with $j=0$ is just the desired result
but with the wrong sign
(in fact, the constant term of an indefinite sum is ambiguous;
for the claim we merely set $j=0$
in the expression which holds for others values of $j$)
\awardpoints{+0.5}.
In order to understand the sign,
we propose that the above formula describes the regularised result
for the sum with limits $+\infty$ and $n$
\begin{equation}
\sum_{k=+\infty}^n k^s
\simeq \frac{n^{s+1}}{s+1}
 -\sum_{j=0}^s  \frac{\zeta(j-s)\,s!}{(s-j)!\,j!}\,n^j.
\end{equation}
Then we flip the summation limits of the desired sum
to bring it into the above form
\awardpoints{+0.5}
\begin{equation}
\sum_{k=1}^\infty k^s
= -\sum_{k=\infty}^0 k^s
\simeq \zeta(-s).
\end{equation}
\end{solution}
%    \end{macrocode}

% End subproblem:
%    \begin{macrocode}
\end{subproblem}
%    \end{macrocode}

% End problem:
%    \begin{macrocode}
\end{problem}
%    \end{macrocode}

% Another problem; this one is untitled:
%    \begin{macrocode}
\begin{problem}[points=1, difficulty=insane]
Show that the equation
\begin{equation}
a^3+b^3=c^3
\end{equation}
has no positive integer solutions.
\end{problem}
%    \end{macrocode}

% A solution can also follow a problem
% (but the layout may be slightly different,
% e.g.\ here the space below the problem will
% appear before the solution):
%    \begin{macrocode}
\begin{solution}
\normalmarginpar
This is beyond the scope of this example.
\marginpar{\footnotesize\raggedright does not fit here.\par}
\end{solution}
%    \end{macrocode}

% Summary of points per problem and per subproblem for grading:
%    \begin{macrocode}
\ifsolutions\else
\textbf{Grading:}\par
\exerciseloopstr{\getproblemlist{}}{|c}
\begin{tabular}{|c|\exerciseloopret||c|}\hline
\getexerciseconfig{termsheet} \ref{sheet5}
\exerciseloop{\getproblemlist{*}}
 {&\ref{\getexerciseconfig{labelproblem}{#1}}}
&total
\\\hline
value
\exerciseloop{\getproblemlist{*}}
 {&\extractpoints{\getproblempoints{#1}}}%
&\extractpoints{\getsheetpoints{}}
\\\hline
\exerciseloop{\getproblemlist{*}}{&}
&\\\hline
\end{tabular}\qquad
\exerciseloop{\getproblemlist{*}}{
 \exerciseloopstr{\getsubproblemlist{#1}}{|c}
 \ifnum\value{exerciseloop}>0\relax
  \begin{tabular}{|c|\exerciseloopret||c|}\hline
  \getexerciseconfig{termproblem} \ref{\getexerciseconfig{labelproblem}{#1}}
  \exerciseloop{\getsubproblemlist{#1}}
   {&\ref{\getexerciseconfig{labelsubproblem}{##1}}}
  &total
  \\\hline
  value
  \exerciseloop{\getsubproblemlist{#1}}
   {&\extractpoints{\getsubproblempoints{##1}}}%
  &\extractpoints{\getproblempoints{#1}}
  \\\hline
  \exerciseloop{\getsubproblemlist{#1}}{&}
  &\\\hline
  \end{tabular}\quad
 \fi
}
\fi
%    \end{macrocode}

% End sheet:
%    \begin{macrocode}
\end{sheet}
%    \end{macrocode}

% End of document body:
%    \begin{macrocode}
\end{document}
%    \end{macrocode}
%\iffalse
%</samplesingle>
%\fi
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \section{Multipart Sample}
% \label{sec:samplemulti}
%
% The second example describes a series of exercise sheets
% which can be compiled as a collection or as individual sheets.
% This example describes a versatile setup
% with several convenient features;
% most of these features can be adjusted or removed easily as they
% mostly enhance the setup and do not interact with each other strongly.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Main File}
% \label{sec:samplemultimain}
%\iffalse
%<*samplemultimain>
%\fi
%
% The main source file is called |exfserm.tex|.
% It is referenced at several places within the setup,
% and when changing the name they need to be adjusted accordingly.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{childdoc Mechanism.}
%
% The setup uses the package \textsf{childdoc} to allow compilation
% of the series as a whole or in parts and with various sets of options:
%    \begin{macrocode}
\input{childdoc.def}
\childdocmain{exfserm}
%    \end{macrocode}
% The parameter of |\childdocmain| must match the main file name |exfserm|.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Compilation Switches.}
%
% Define compilation switches and declare their default settings.
% |\printsol| controls whether solutions should be printed or not;
% by default solutions are activated for compilation of a part,
% but not for the complete document.
% |\draftver| controls whether the final version of
% the document is to be compiled;
% concretely this affects the compilations of metapost figures, see below:
%    \begin{macrocode}
\ifchilddoc
\providecommand{\printsol}{y}
\else
\providecommand{\printsol}{n}
\fi
\providecommand{\draftver}{y}
\newif\ifdraft\if\draftver y\drafttrue\else\draftfalse\fi
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Preamble.}
%
% Standard document class:
%    \begin{macrocode}
\documentclass[12pt]{article}
%    \end{macrocode}

%    \begin{macrocode}
% \textsf{graphicx} package to display license logo:
\RequirePackage{graphicx}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{hyperref Package.}
%
% Use the \textsf{hyperref} package.
% Declare some options, e.g.\ use bookmarks only for complete document:
%    \begin{macrocode}
\PassOptionsToPackage{bookmarks=\ifchilddoc false\else true\fi}{hyperref}
\PassOptionsToPackage{bookmarksopen=true}{hyperref}
\RequirePackage{hyperref}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{metastr Package.}
%
% Use the \textsf{metastr} package to handle
% metadata and copyright information;
% disable usage of \textsf{hyperxmp} package if not installed;
% write auxiliary PDF metadata and rights information:
%    \begin{macrocode}
\ifdraft
\PassOptionsToPackage{draft}{metastr}
\fi
\IfFileExists{hyperxmp.sty}{}{\PassOptionsToPackage{hyperxmp=false}{metastr}}
\RequirePackage[course]{metastr}
\metaset[aux]{writepdf}{}
\metaset[rights]{writepdf}{}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{exframe Package.}
%
% Invoke \textsf{exframe} with extended data and styles:
%    \begin{macrocode}
\RequirePackage[extdata,extstyle]{exframe}
%    \end{macrocode}

% Set solutions switch and declare two-sided layout only
% if no solutions are printed;
% do not use solution buffer in draft mode
% for easier identification of potential compile errors:
%    \begin{macrocode}
\if\printsol n
\exercisesetup{solutions=false}
\exercisesetup{twoside=true}
\else
\exercisesetup{solutions=true}
\exercisesetup{twoside=false}
\ifdraft
\exercisesetup{solutionbuf=false}
\fi
\fi
%    \end{macrocode}

% Might want to display some metadata (only for partial compile):
%    \begin{macrocode}
%%\if\printsol n\else\showprobleminfo{author,source,recycle}\fi
%    \end{macrocode}

% Set some options. Automatically assign labels to problems.
% Include sheets and problems in table of contents.
% Separate solutions by horizontal rules.
% Count problems, equations and pages by sheet
% (unless compiling single problem).
% Collect solutions below each problem.
% Write pdf metadata for sheet when compiling single sheet:
%    \begin{macrocode}
\exercisesetup{autolabelproblem}
\exercisestyle{contents,solutionsep}
\ifchilddocmanual\else
\exercisestyle{pagebysheet,problembysheet,equationbysheet,sheetequation}
\fi
\exercisestyle{solutionbelow={problem}}
\ifchilddoc\ifchilddocmanual\else\exercisesetup{pdfdata=sheet}\fi\fi
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Language.}
%
% Redefine some terms:
%    \begin{macrocode}
\metasetlang{en-GB}

\metasetterm[en]{sheet}{sheet}
\metasetterm[en]{sheets}{sample sheets}
\metasetterm[en]{solution}{Solution}
\metasetterm[en]{solutions}{solutions}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Layout Definitions.}
%
% Set page dimensions and layout:
%    \begin{macrocode}
\RequirePackage[a4paper,margin=2.5cm]{geometry}
\pagestyle{plain}
%    \end{macrocode}
% Remove paragraph indentation:
%    \begin{macrocode}
\setlength\parindent{0pt}
\setlength\parskip{\smallskipamount}
%    \end{macrocode}
% Show overfull lines:
%    \begin{macrocode}
\setlength\overfullrule{5pt}
%    \end{macrocode}
% Define turn page over mark; hide when printing solutions:
%    \begin{macrocode}
\newcommand{\turnover}{\ifsolutions\else\vfill%
  \hfill{\mathversion{bold}$\longrightarrow$}\newpage\fi}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Sheet Banner.}
%
% Use standard sheet banner;
% show sheet |editdate| below banner (if declared);
% when compiling single sheet, display sheet due date instead:
%    \begin{macrocode}
\exercisestyle{plainheader}
\exerciseconfig{composeheaderbelowright}
 {\sheetdataempty{editdate}{}{version: \getsheetdata{editdate}}}
\ifchilddoc\ifsolutions\else
 \exerciseconfig{composeheaderbelowright}
  {\sheetdataempty{due}{}{due: \getsheetdata{due}}}
\fi\fi
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Lorem.}
%
% Define a macro |\lorem| to write out some paragraph of text
% for the example:
%    \begin{macrocode}
\def\lorem{Lorem ipsum dolor sit amet, consectetur adipisici elit,
  sed eiusmod tempor incidunt ut labore et dolore magna aliqua.
  Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
  nisi ut aliquid ex ea commodi consequat.
  Quis aute iure reprehenderit in voluptate velit esse
  cillum dolore eu fugiat nulla pariatur.
  Excepteur sint obcaecat cupiditat non proident,
  sunt in culpa qui officia deserunt mollit anim id est laborum.\par}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{metapost Setup.}
%
% Use package \textsf{mpostinl} (if available)
% to include some metapost figures within the source of the problems:
%    \begin{macrocode}
\IfFileExists{mpostinl.sty}{\RequirePackage{mpostinl}}{}
\ifdefined\mpostsetup
%    \end{macrocode}

% Setup \textsf{mpostinl}.
% Use checksums to invoke metapost only when figures change.
% Process all figures individually and immediately when in
% draft mode for child documents (avoids a second compilation pass).
% Number figures within sheet to provide a stable numbering
% upon insertion/deletion of new figures or partial compilation:
%    \begin{macrocode}
\mpostsetup{checksum}
\ifchilddoc\ifdraft\mpostsetup{now,nowall}\fi\fi
\ifchilddocmanual\else\mpostsetup{numberwithin={sheet}}\fi
%    \end{macrocode}

% Global metapost definitions.
% Define some latex macro to demonstrate
% usage of latex for typesetting labels.
% Define some global metapost variables,
% |paths| is an array of path variables,
% |xu| serves as a length unit to
% scale individual figures
% (use |interim xu:=...;| to set scale for local figure only),
% |pensize| changes the size of the pen,
% |fillshape| fills and outlines a shape:
%    \begin{macrocode}
\mpostsetup{globaldef=true}
\begin{mposttex}
\def\figure{figure}
\end{mposttex}
\begin{mpostdef}
path paths[];
newinternal numeric xu;
xu:=1cm;
def pensize(expr s)=withpen pencircle scaled s enddef;
def fillshape(expr p,c)=
  fill p withcolor c;
  draw p
enddef;
\end{mpostdef}
\mpostsetup{globaldef=false}
%    \end{macrocode}

% Close optional \textsf{mpostinl} processing:
%    \begin{macrocode}
\fi
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Document Data.}
%
% Set document data for series of problem sheets:
%    \begin{macrocode}
\metaset{course}{exframe package samples}
\metaset{instructor}{N.\ Beisert}
\metaset{author}{Niklas Beisert, \metapick[#1]{institution}}
\metaset{institution}{exframe academy}
\metaset{period}{spring 2019}
\metaset{copyrightdate}{2019--2020}
%    \end{macrocode}

% Assemble some entries from given data:
%    \begin{macrocode}
\metaset{material}{\metatranslate[#1]{sheets}}
\exerciseconfig{composetitlesheet}[2]{\exerciseifempty{#2}%
  {\ifsolutions\metaterm{solutions}\else%
   \metaterm{sheet}\fi\ #1}%
  {\ifsolutions\metaterm{solutions} \fi #2}}
%    \end{macrocode}

% For child documents declare part of:
%    \begin{macrocode}
\ifchilddoc
\metaset{partof}{\metatranslate[#1]{sheets} \metapick[#1]{course}}
\fi
%    \end{macrocode}

% Set general purpose metadata:
%    \begin{macrocode}
\metaset[sep]{draft}{ -- }
\metaset[sep]{subtitle}{, }
\metaset{subtitle}{\ifsolutions\metatranslate[#1]{solutions} \fi%
  \metaif[use]{sheettitle}{\metapick[#1]{sheettitle}}{\metapick[#1]{material}}}
\metaset{subject}{Lecture Series,
  \metapick[#1]{institution}, \metapick[#1]{period}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{License.}
%
% It is good practice to specify a copyright line
% and a license for the document:
%    \begin{macrocode}
\metaset{copyrightowner}{\metapick[#1]{author}}
\ifchilddoc
\metacopyright{doc}
\else
\metacopyright{doc-parts}
\fi
\metaset{licenseprovider}{of \metapick[#1]{institution}}
\metalicense{consent}
%    \end{macrocode}

% Apply Creative Commons BY-SA license
% under certain conditions (no solutions, final version):
%    \begin{macrocode}
\ifsolutions\else\ifdraft\else
\metalicensecc{by-sa}
\fi\fi
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Body.}
%
% Start document body:
%    \begin{macrocode}
\begin{document}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Single Problem Display.}
%
% The following code handles the compilation
% of individual problems from their own source file.
% Make sure to leave the conditional before issuing |\end{document}|:
%    \begin{macrocode}
\def\tmp{}
\ifchilddocmanual
\def\tmp{\end{document}}
\input{\childdocname}
\fi\tmp
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Frontmatter.}
%
% Do not print frontmatter for individual sheets.
% Define a plain page counter for frontmatter:
%    \begin{macrocode}
\setcounter{section}{-1}
\begingroup\ifchilddoc\else
\renewcommand{\thepage}{\arabic{page}}
%    \end{macrocode}

% Prepare a title page to display some relevant data:
%    \begin{macrocode}
\pdfbookmark[1]{\metaterm{title}}{title}
\thispagestyle{empty}
\vspace*{\fill}
\begin{center}
\metapick[course]{titletext}
\end{center}
\vspace*{\fill}\vspace*{\fill}
\newpage
%    \end{macrocode}

% Prepare a copyright and license page using data specified above:
%    \begin{macrocode}
\phantomsection\pdfbookmark[1]{\metaterm{copyright}}{copyright}
\thispagestyle{empty}
\vspace*{\fill}\vspace*{\fill}
\begin{center}\begin{minipage}{11cm}\raggedright
\metapick[print]{rightstext}
\end{minipage}\end{center}
\vspace*{\fill}\vspace*{\fill}\vspace*{\fill}
\newpage
%    \end{macrocode}

% Print table of contents:
%    \begin{macrocode}
\makeatletter\renewcommand\@pnumwidth{2.4em}\makeatother
\setcounter{tocdepth}{2}
\phantomsection\pdfbookmark[1]{\metaterm{contents}}{contents}
{\parskip0pt\tableofcontents}
\exercisecleardoublepage\setcounter{page}{1}
%    \end{macrocode}

% End of frontmatter:
%    \begin{macrocode}
\fi\endgroup
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Include Sheets.}
%
% Include problem sheets:
%    \begin{macrocode}
\include{exfser01}
\include{exfser02}
\include{exfser03}
%    \end{macrocode}

% Include sheet to collect unused problems
% (only process for individual sheets, i.e.\ itself):
%    \begin{macrocode}
\def\jobnameunused{exfseraa}
\ifx\childdocname\jobnameunused\include{\jobnameunused}\fi
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{End.}
%
% End of document body:
%    \begin{macrocode}
\end{document}
%    \end{macrocode}
%
%\iffalse
%</samplemultimain>
%\fi
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Sheet File}
% \label{sec:samplemultisheets}
%\iffalse
%<*samplemultisheet1|samplemultisheet2|samplemultisheet3|samplemultisheeta>
%\fi
%
% Provide some source files
% |exfser01.tex|, |exfser02.tex|, |exfser03.tex|, |exfseraa.tex|
% for problem sheets.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{childdoc Mechanism.}
%
% Instruct the package \textsf{childdoc} to compile
% only the present sheet if source is compiled by latex:
%    \begin{macrocode}
%%\providecommand{\printsol}{n}
\input{childdoc.def}
\childdocof{exfserm}
%    \end{macrocode}
%\iffalse
%</samplemultisheet1|samplemultisheet2|samplemultisheet3|samplemultisheeta>
%<samplemultiprobleme|samplemultiproblemf>%%\providecommand{\printsol}{n}
%<samplemultiprobleme|samplemultiproblemf>\input{childdoc.def}
%<samplemultiprobleme|samplemultiproblemf>\childdocby{exfserm}
%<*samplemultisheet1>
%\fi
% The parameter of |\childdocof| must match the main file name |exfserm|.
% Uncommenting the commented line suppressed printing of the solution.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Sheet Environment.}
%
% Declare a sheet with intended due date:
%    \begin{macrocode}
\begin{sheet}[due={2019-04-29}]
%    \end{macrocode}
% Adjust due date for each sheet.
% For sheet containing unused problems |exfseraa.tex|,
% declare a sheet |title={unused problems}| instead of due date.
%\iffalse
%</samplemultisheet1>
%<samplemultisheet2>\begin{sheet}[due={2019-05-06}]
%<samplemultisheet3>\begin{sheet}[due={2019-05-13}]
%<samplemultisheeta>\begin{sheet}[title={unused problems}]
%<*samplemultisheet1>
%\fi

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Problems.}
%
% Start a problem:
%    \begin{macrocode}
\begin{problem}[title={Sample A}]
%    \end{macrocode}
%
%\iffalse
%</samplemultisheet1>
%<samplemultisheet2>\begin{problem}[title={Sample C}]
%<samplemultisheet3>\input{exfserpe}
%<samplemultisheeta>\begin{problem}[title={Sample X}]
%<samplemultiprobleme>\begin{problem}[title={Sample E}]
%<*samplemultisheet1|samplemultisheet2|samplemultisheeta|samplemultiprobleme>
%\fi

% Let us declare a figure using \textsf{mpostinl} (if available).
% Denote it by the label \textit{tag}|-fig|,
% where \textit{tag} is the tag of the problem
% (in order to avoid potential conflicts with other problems;
% \textit{tag} is assigned automatically or by specifying
% the option |tag| for the |problem| environment).
% Also declare a figure \textit{tag}|-solfig| for use within the solution:
%    \begin{macrocode}
\ifdefined\mpostuse
\begin{mpostfig}[label={\problemtag-fig}]
interim xu:=1.5cm;
paths[1]:=fullcircle scaled 1xu;
fillshape(paths[1], 0.7white) pensize(1pt);
label(btex \figure etex, center(paths[1]));
\end{mpostfig}
\begin{onlysolutions}
\begin{mpostfig}[label={\problemtag-solfig}]
interim xu:=1.5cm;
paths[1]:=fullcircle scaled 1xu;
paths[2]:=((subpath (-2,2) of paths[1])--cycle) shifted (+0.5xu,0);
paths[3]:=((subpath (2,6) of paths[1])--cycle) shifted (-0.5xu,0);
fillshape(paths[2], 0.7white) pensize(1pt);
fillshape(paths[3], 0.7white) pensize(1pt);
\end{mpostfig}
\end{onlysolutions}
\fi
%    \end{macrocode}

% Write a problem body with figure, some subproblems and a solution:
%    \begin{macrocode}
\lorem

\begin{subproblem}
\lorem
\begin{center}
\ifdefined\mpostuse\mpostuse{\problemtag-fig}\else figure\fi
\end{center}
\lorem
\end{subproblem}

\begin{solution}
\lorem
\begin{center}
\ifdefined\mpostuse\mpostuse{\problemtag-solfig}\else figure\fi
\end{center}
\lorem
\end{solution}

\begin{subproblem}
\lorem
\end{subproblem}

\begin{solution}
\lorem
\end{solution}

\lorem

\begin{subproblem}
\lorem
\end{subproblem}

\begin{solution}
\lorem
\end{solution}
%    \end{macrocode}

% End the problem:
%    \begin{macrocode}
\end{problem}
%    \end{macrocode}
%\iffalse
%</samplemultisheet1|samplemultisheet2|samplemultisheeta|samplemultiprobleme>
%<*samplemultisheet1|samplemultisheet2|samplemultisheet3|samplemultisheeta>
%\fi

% Start new page:
%    \begin{macrocode}
\turnover
%    \end{macrocode}

%\iffalse
%</samplemultisheet1|samplemultisheet2|samplemultisheet3|samplemultisheeta>
%<*samplemultisheet1>
%\fi
% Write a second problem to accompany the first one:
%    \begin{macrocode}
\begin{problem}[title={Sample B}]
%    \end{macrocode}
%
%\iffalse
%</samplemultisheet1>
%<samplemultisheet2>\begin{problem}[title={Sample D}]
%<samplemultisheet3>\input{exfserpf}
%<samplemultisheeta>\begin{problem}[title={Sample Y}]
%<samplemultiproblemf>\begin{problem}[title={Sample F}]
%<*samplemultisheet1|samplemultisheet2|samplemultisheeta|samplemultiproblemf>
%\fi

% Problem body without a figure;
% this time the |solution| environments are
% included in the |subproblem| environments:
%    \begin{macrocode}
\lorem

\begin{subproblem}
\lorem
\begin{solution}
\lorem
\end{solution}
\end{subproblem}

\begin{subproblem}
\lorem
\begin{solution}
\lorem
\end{solution}
\end{subproblem}
%    \end{macrocode}

% End the problem:
%    \begin{macrocode}
\end{problem}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{End Sheet.}
%\iffalse
%</samplemultisheet1|samplemultisheet2|samplemultisheeta|samplemultiproblemf>
%<*samplemultisheet1|samplemultisheet2|samplemultisheet3|samplemultisheeta>
%\fi
% End the sheet:
%    \begin{macrocode}
\end{sheet}
%    \end{macrocode}

%\iffalse
%</samplemultisheet1|samplemultisheet2|samplemultisheet3|samplemultisheeta>
%\fi
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Individual Problem Files}
% \label{sec:samplemultisheet3}
%\iffalse
%<*discard>
%\fi
%
% It may be more convenient to define each problem in an individual file,
% so that a sheet can be composed by including the appropriate
% problem files.
% In such a setup, the \textsf{childdoc} mechanism
% allows to compile each problem individually.
%
% To that end, prepare a file |exfserp|\textit{nn}|.tex|
% containing the |problem| environment.
% This file should start with:
%    \begin{macrocode}
%%\providecommand{\printsol}{n}
\input{childdoc.def}
\childdocby{exfserm}
%    \end{macrocode}
% and end with |\endinput|.
% Then compose the problem sheet
% by including the appropriate set of problem files
% via |\input{exfserp|\textit{nn}|}|.
%
% In the example, a sheet file |exfser03.tex|
% includes two problem files |exfserpe.tex| and |exfserpf.tex|.
%
%\iffalse
%</discard>
%\fi
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Make Scripts}
% \label{sec:samplemultimake}
%\iffalse
%<*samplemultiscript>
%\fi
%
% The setup allows the compilation in various modes for editing purposes.
% In order to generate and update a complete set of documents for distribution
% (all individual sheets and a collection of sheets;
% with and without solutions),
% it makes sense to use the software development utility |make|.
% The compilation of individual components is simplified
% by a |bash| shell script.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Compile Script.}
%
% The |bash| shell script |exfsermk.sh| compiles one part of
% the collection of problem sheets in a given mode.
%
% Shebang for |bash| script:
%    \begin{macrocode}
#!/bin/bash
%    \end{macrocode}

% Configure and declare variables with default values.
% |srcmain| defines the name of the main source file;
% |srcsec|\textit{nn} defines the name of the sheet source file;
% |trglist| defines the target file names;
% |trgsol| defines the target modes;
% |sheets| is a list of allowable sheet identifiers \textit{nn}:
%    \begin{macrocode}
srcmain="exfserm"
srcsec="exfser"
trglist=(Problems Solutions)
trgsol=(n y)
secnum="01 02 03 aa"
%    \end{macrocode}

% Display usage:
%    \begin{macrocode}
if [ -z $1 ]
then
  echo "Usage:
  $0 number [version]
    number: number of sheet, 0 for combined document
    version: 0 for problems, 1 for solutions
  $0 filename
    filename: target file to be compiled"
  exit 1
fi
%    \end{macrocode}
%\iffalse$\fi

% Configure and declare variables with default values.
% |num| takes the sheet number;
% |ver| takes the compile mode;
%    \begin{macrocode}
num="$1"
ver="$2"
nl=$'\n'
secokay=""
make=".pdf"
%    \end{macrocode}
%\iffalse$\fi

% Check if the parameter matches any of the acceptable output file names:
%    \begin{macrocode}
for v in "${trglist[@]}"
do
  if [[ $num =~ ^$v ]]
  then
    ver=$v
    num=${num#$v}
    if [[ $num =~ ^.*\.tex$ ]]; then make=".tex"; fi
    num=${num%%.*}
  fi
done
%    \end{macrocode}
%\iffalse$\fi

% Ensure that |num| is a two-digit number, prepend `0' otherwise:
%    \begin{macrocode}
if [[ $num =~ ^[0-9]$ ]]; then num="0$num"; fi
if [[ $num == "00" ]]; then num=""; fi
%    \end{macrocode}

% Check whether |num| is acceptable:
%    \begin{macrocode}
if [[ -z $num ]]; then secokay="okay"; fi
for v in $secnum
do
  if [[ "$num" == "$v" ]]; then secokay="okay"; fi
done
%    \end{macrocode}

% Otherwise display error message and exit:
%    \begin{macrocode}
if [[ -z $secokay ]]
then
  echo "error: unknown sheet"
  exit 1
fi
%    \end{macrocode}
%\iffalse$\fi

% Disable newline character for command line tex code:
%    \begin{macrocode}
if [[ "$make" == ".pdf" ]]; then nl=""; fi
%    \end{macrocode}
%\iffalse$\fi

% Function to compile a component.
% Set up \textsf{childdoc} mechanism according to desired component.
% Compile two passes, first in |-draftmode|.
% Suppress messages by |mpost|.
% Display warning messages in log file:
%    \begin{macrocode}
function docompile
{
  if [[ -z $num ]]
  then
    job="$srcmain"
    fwd="\\childdocforward{$srcmain}"
  else
    job="$srcsec$num"
    fwd="\\childdocforward[$srcmain]{$srcsec$num}"
  fi
  body="\\def\\jobname{$job}$optdef\\input{childdoc.def}$fwd"
  for pass in first main extra
  do
    par="";
    if [[ "$pass" == "first" ]]; then par="-draftmode"; fi
    drop="This is|entering extended mode|\\write18"
    drop="$drop|Preloading the plain mem file|mpost\.mp|plain\.mp"
    pdflatex -shell-escape -interaction=batchmode $par \
      -jobname "$trg" "$body" | grep -vE "$drop"
    if [[ "$pass" != "main" ]]; then continue; fi
    if ! (grep -E -q "may have changed|rerunfilecheck Warning" "$trg.log")
      then break; fi
  done
  grep -E "^! |Warning|Error|Undefined|Overfull|Underfull" "$trg.log"
}
%    \end{macrocode}
%\iffalse$\fi

% Function to generate a \textsf{childdoc} compile file with specific options:
%    \begin{macrocode}
function writesource
{
  if [[ -z $num ]]
  then
    fwd="\\childdocforward{$srcmain}"
  else
    fwd="\\childdocforwardprefix[$srcmain]{$target}{$srcsec}"
  fi
  body="$optdef\\input{childdoc.def}$nl$fwd"
  echo "$body" > $trg.tex
}
%    \end{macrocode}
%\iffalse$\fi

% Translate versions to parameter values,
% configure variables and select appropriate function for intended task:
%    \begin{macrocode}
for i in "${!trglist[@]}"
do
  if [[ -z $ver || "$ver" == "${trglist[$i]}" || $ver = $i ]]
  then
    target="${trglist[$i]}"
    sol="${trgsol[$i]}"
    trg="$target$num"
    optdef="\\def\\draftver{n}$nl\\def\\printsol{$sol}$nl"
    if [[ "$make" == ".pdf" ]]; then docompile; else writesource; fi
  fi
done
%    \end{macrocode}
%\iffalse$\fi

% Finish with blank line:
%    \begin{macrocode}
echo
%    \end{macrocode}
%
%\iffalse
%</samplemultiscript>
%\fi
%
%\iffalse
%<*samplemultimake>
%\fi
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Makefile.}
%
% \catcode9=13\def^^I{~~~~~~~~}
%
% Define a make file |exfsermk.mak| for the project.
% The compilation is then started by
% |make -f exfsermk.mak| \ldots.
% More conveniently, in a single-project setup within the directory,
% this file would be called |Makefile| in which case it suffices
% to just run |make| \ldots.
%
% Configuration definitions:
%    \begin{macrocode}
SRCMAIN = exfserm
SRCSEC = exfser
SRCPRB = exfserp
SCRIPT = exfsermk.sh
MAKEFILE = exfsermk.mak
TRGLIST = Problems Solutions
SECNUM = 01 02 03 aa
PREREQS = $(SRCMAIN).tex

SRCSECFILES = $(SECNUM:%=$(SRCSEC)%.tex)
TRGMAINFILES = $(foreach trg,$(TRGLIST),$(trg).pdf)
TRGSECFILES = $(foreach trg,$(TRGLIST),$(trg).pdf $(SECNUM:%=$(trg)%.pdf))
GENFILES = $(foreach trg,$(TRGLIST),$(trg).tex $(SECNUM:%=$(trg)%.tex))
BAKFILES = $(PREREQS) $(SRCSECFILES) $(GENFILES)\
           $(MAKEFILE) $(SCRIPT) $(SRCPRB)*
%    \end{macrocode}
%\iffalse$\fi

% Define some abstract targets;
% |default| is the default target when no parameters are given:
%    \begin{macrocode}
default: sheets ;
main: $(TRGMAINFILES) ;
sheets: $(TRGSECFILES) ;
sheet%: $(foreach trg,$(TRGLIST),$(trg)%.pdf) ;
all: main sheets ;
sources: $(GENFILES) ;
%    \end{macrocode}
%\iffalse$\fi

% Compile particular files via |exfsermk.sh| bash script.
% Note that command lines have to start with a tab character
% (represented by 8 spaces here):
%    \begin{macrocode}
$(TRGMAINFILES): $(SRCSECFILES) $(PREREQS)
	bash ./$(SCRIPT) $@
$(word 1,$(TRGLIST))%.pdf: $(SRCSEC)%.tex $(PREREQS)
	bash ./$(SCRIPT) $@
$(word 2,$(TRGLIST))%.pdf: $(SRCSEC)%.tex $(PREREQS)
	bash ./$(SCRIPT) $@
$(GENFILES):
	bash ./$(SCRIPT) $@
%    \end{macrocode}
%\iffalse$\fi

% Touch main file for recompile:
%    \begin{macrocode}
touch:
	touch $(SRCMAIN).tex
%    \end{macrocode}
%\iffalse$\fi
% Define |clean| target to remove all intermediate compilation files:
%    \begin{macrocode}
clean:
	rm -f $(foreach ext,.aux .log,$(SECNUM:%=$(SRCSEC)%$(ext)))
	rm -f $(foreach trg,$(TRGLIST),$(SECNUM:%=$(trg)%.log) $(trg).log)
	rm -f $(foreach ext,.aux .log .out .toc,$(SRCMAIN)$(ext))
	rm -f $(foreach ext,.mp .mpx -*.mps,$(SRCMAIN)$(ext))
	rm -f $(foreach ext,-tmp.log -tmp.mp -tmp.mpx,$(SRCMAIN)$(ext))
	rm -f mpxerr.tex mpxerr.log mpxerr.dvi texput.log
	rm -f $(patsubst %,$(SRCPRB)*%,.aux .log .mp .mpx -*.mps)
	rm -f $(patsubst %,$(SRCPRB)*%,-tmp.log -tmp.mp -tmp.mpx)
%    \end{macrocode}
% Define |clean-bak| target to remove all backup files
% ending in `|~|' or `|.bak|':
%    \begin{macrocode}
clean-bak:
	rm -f $(BAKFILES:%=%~) $(BAKFILES:%=%.bak)
%    \end{macrocode}
% Define |clean-all| target to remove all generated files
% for a clean source directory:
%    \begin{macrocode}
clean-all:  clean
	rm -f $(TRGSECFILES) $(TRGMAINFILES) $(GENFILES)
	rm -f $(SECNUM:%=$(SRCSEC)%.pdf) $(SRCMAIN).pdf
	rm -f $(SRCPRB)*.pdf
%    \end{macrocode}
%\iffalse$\fi
% \catcode9=9
%
%\iffalse
%</samplemultimake>
%\fi
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \section{Implementation}
% \label{sec:implementation}
%\iffalse
%<*package>
%\fi
%
% This section describes the package |exframe.sty|.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{General Definitions}
% \label{sec:imp-def}
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Required Packages.}
%
% The package loads the package
% \textsf{verbatim} and \textsf{xkeyval}
% if not yet present.
% \textsf{verbatim} is used for solution environment reading
% and \textsf{xkeyval} is used for extended options processing:
%    \begin{macrocode}
\RequirePackage{verbatim}
\RequirePackage{xkeyval}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{General Definitions.}
%
% \macro{\exf@empty}
% Define an empty macro for comparison by |\ifx|:
%    \begin{macrocode}
\def\exf@empty{}
%    \end{macrocode}

% \macro{\exf@tmpdim}
% Define a length for temporary storage:
%    \begin{macrocode}
\newlength\exf@tmpdim
%    \end{macrocode}

% \macro{\exf@exptwo}
% A macro to conveniently expand the third token in line:
%    \begin{macrocode}
\def\exf@exptwo#1{\expandafter#1\expandafter}
%    \end{macrocode}
% \macro{\exf@exparg}
% A macro to conveniently expand the first token
% of an argument following arbitrary code:
%    \begin{macrocode}
\long\def\exf@expswitch#1#2{#2{#1}}
\long\def\exf@exparg#1#2{\exf@exptwo\exf@expswitch{#2}{#1}}
%    \end{macrocode}
% \macro{\exf@csdo}
% \macro{\exf@csdotwo}
% Some macros to conveniently expand |\csname| arguments
% before expanding the macro:
%    \begin{macrocode}
\def\exf@csdo#1#2{\expandafter#1\csname#2\endcsname}
\def\exf@csdotwo#1#2#3{\exf@exptwo#1#2\csname#3\endcsname}
%    \end{macrocode}
% \macro{\exf@csor}
% A macro to return |\csname| or default if not exists:
%    \begin{macrocode}
\def\exf@csor#1#2{\ifcsname#1\endcsname\csname#1\endcsname\else#2\fi}
%    \end{macrocode}

% \macro{\exf@append@def}
% \macro{\exf@prepend@def}
% Add definitions to macros (after or before original content):
%    \begin{macrocode}
\long\def\exf@append@def#1#2{\exf@exptwo\def#1\expandafter{#1#2}}
\long\def\exf@prepend@switch#1#2#3{#2{#3#1}}
\long\def\exf@prepend@def#1#2{\exf@exptwo\exf@prepend@switch{#1}{\def#1}{#2}}
%    \end{macrocode}

% \macro{\exf@expsetkeys}
% A version of |\setkeys| from \textsf{xkeyval} which expands first:
%    \begin{macrocode}
\newcommand{\exf@expsetkeys}[2]{\edef\exf@tmp{#2}%
  \exf@exparg{\setkeys{#1}}{\exf@tmp}}
%    \end{macrocode}

% \macro{\exf@isif}
% Execute |#3| if content of macro |#1| equals |#2|:
%    \begin{macrocode}
\newcommand{\exf@ifis}[3]%
  {\def\exf@tmp{#2}\ifx#1\exf@tmp#3\fi}
%    \end{macrocode}

% \macro{\exf@href}
% Display text with hyperreference passed by macro |#1|
% (in case \textsf{hyperref} is loaded
% and the reference is defined and not empty):
%    \begin{macrocode}
\newcommand{\exf@href}[2]{%
  \ifdefined#1\ifx#1\exf@empty#2\else%
   \ifdefined\hyperlink\protect\hyperlink{#1}{#2}\else#2\fi\fi\else#2\fi}
%    \end{macrocode}

% \macro{\exf@text}
% \macro{\exf@ensuretext}
% Two macros to display text in math mode.
% |exf@text| is a wrapper for |\text| of \textsf{amstext}
% in case the latter package is loaded.
% |exf@ensuretext| makes sure the text is set in text mode
% or within an |\mbox| in math math:
%    \begin{macrocode}
\newcommand{\exf@text}[1]{\ifdefined\text\text{#1}\else#1\fi}
\newcommand{\exf@ensuretext}[1]{\ifmmode\mbox{#1}\else#1\fi}
%    \end{macrocode}

% \macro{\exf@addcontentsline}
% Add a line to the table of contents unless macro in argument |#1| is empty:
%    \begin{macrocode}
\newcommand{\exf@addcontentsline}[2]{%
  \ifx#1\exf@empty\else\addcontentsline{toc}{#1}{#2}\fi}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Auxiliary File Data Storage.}
%
% \macro{\exf@notedata}
% Process stored data by handler:
%    \begin{macrocode}
\newcommand{\exf@notedata}[3]{\csname exf@notedata@#1\endcsname{#2}{#3}}
%    \end{macrocode}
% Make sure the macros in code written to the |.aux| file exist:
%    \begin{macrocode}
\AtBeginDocument{\immediate\write\@auxout{%
  \string\providecommand{\string\exf@notedata}[3]{}}}
%    \end{macrocode}
% \macro{\exf@writedata}
% Write data to the |.aux| file:
%    \begin{macrocode}
\newcommand{\exf@writedata}[3]%
  {\immediate\write\@auxout{\string\exf@notedata{#1}{#2}{#3}}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Package Setup}
% \label{sec:imp-setup}
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Initialisation Options.}
%
% \macro{exframe.sty}
% Some setup options are available while loading the package only.
%
% Configure names of main environments and counters:
%    \begin{macrocode}
\def\exf@problemname{problem}
\def\exf@subproblemname{sub\exf@problemname}
\def\exf@solutionname{solution}
\def\exf@sheetname{sheet}
\def\exf@problemcounter{problem}
\def\exf@subproblemcounter{sub\exf@problemcounter}
\def\exf@solutioncounter{solution}
\def\exf@sheetcounter{sheet}
\define@key{exframe.sty}{problemenv}{\def\exf@problemname{#1}}
\define@key{exframe.sty}{subproblemenv}{\def\exf@subproblemname{#1}}
\define@key{exframe.sty}{solutionenv}{\def\exf@solutionname{#1}}
\define@key{exframe.sty}{sheetenv}{\def\exf@sheetname{#1}}
\define@key{exframe.sty}{problemcounter}{\def\exf@problemcounter{#1}}
\define@key{exframe.sty}{subproblemcounter}{\def\exf@subproblemcounter{#1}}
\define@key{exframe.sty}{solutioncounter}{\def\exf@solutioncounter{#1}}
\define@key{exframe.sty}{sheetcounter}{\def\exf@sheetcounter{#1}}
%    \end{macrocode}

% Whether to provide some extended configuration options
% (available while loading only):
%    \begin{macrocode}
\define@boolkey{exframe.sty}[exf@]{extdata}[true]{}
\define@boolkey{exframe.sty}[exf@]{extstyle}[true]{}
%    \end{macrocode}

% Whether to load package \textsf{metastr}
% (available while loading only):
%    \begin{macrocode}
\define@boolkey{exframe.sty}[exf@]{metastr}[true]{}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Setup Options.}
%
% \macro{exf@setup}
% All remaining setup options are available
% also when the package is already loaded.
%
% Main switch for solutions:
%    \begin{macrocode}
\define@boolkey{exf@setup}[]{solutions}[true]{}
%    \end{macrocode}
% Switch for writing pdf metadata:
%    \begin{macrocode}
\define@choicekey{exf@setup}{pdfdata}%
  {auto,manual,sheet,off}[auto]{\def\exf@metadata{#1}}
\def\exf@metadata{auto}
%    \end{macrocode}
% Write line number indicators to output file:
%    \begin{macrocode}
\define@boolkey{exf@setup}[exf@]{lineno}[true]{}
%    \end{macrocode}
% Prepare two-sided sheets:
%    \begin{macrocode}
\define@boolkey{exf@setup}[exf@]{twoside}[true]{}
%    \end{macrocode}
% Generate hyperreferences from solutions to corresponding problems:
%    \begin{macrocode}
\define@boolkey{exf@setup}[exf@]{solutionhref}[true]{}
\exf@solutionhreftrue
%    \end{macrocode}
% Automatically generate labels for sheets and problems:
%    \begin{macrocode}
\define@boolkey{exf@setup}[exf@]{autolabelsheet}[true]{}
\define@boolkey{exf@setup}[exf@]{autolabelproblem}[true]{}
%    \end{macrocode}
% Write warning message to document for better detection of inconsistencies:
%    \begin{macrocode}
\define@boolkey{exf@setup}[exf@]{warntext}[true]{}
%    \end{macrocode}
% Activate buffering of solutions:
%    \begin{macrocode}
\define@boolkey{exf@setup}[exf@]{solutionbuf}[true]{}
\exf@solutionbuftrue
%    \end{macrocode}
% Activate buffering of problems:
%    \begin{macrocode}
\define@boolkey{exf@setup}[exf@]{problembuf}[true]{}
%    \end{macrocode}
% \macro{\exf@emptytestchar}
% Redefine character for testing emptyness:
%    \begin{macrocode}
\def\exf@emptytestchar{&}
\define@key{exf@setup}{emptytestchar}{\def\exf@emptytestchar{#1}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Processing.}
%
% Process global options while loading package:
%    \begin{macrocode}
\ProcessOptionsX<exframe.sty,exf@setup>
%    \end{macrocode}

% \macro{\exercisesetup}
% Configure package when package is already loaded:
%    \begin{macrocode}
\newcommand{\exercisesetup}[1]{\exf@expsetkeys{exf@setup}{#1}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Additional Packages.}
%
% Load \textsf{metastr} package if desired:
%    \begin{macrocode}
\ifexf@metastr
\PassOptionsToPackage{course=true}{metastr}
\RequirePackage{metastr}
\fi
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Solutions Only Processing.}
%
% \macro{onlysolutions}
% Process block only in solutions mode:
%    \begin{macrocode}
\newenvironment{onlysolutions}%
 {\ifsolutions\else%
   \let\endonlysolutions\endcomment%
   \expandafter\comment\fi}%
 {}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Configuration}
% \label{sec:imp-config}
%
% This section defines and describes the various configuration options
% provided by the package. It also serves as a manual,
% and most code can be recycled and adjusted for individual configurations:
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Definitions.}
%
% \macro{\exerciseconfig}
% Set a configuration macro;
% store definition in |exf@config@#2|;
% use |\newcommand| for macros with arguments,
% but (non-long) |\def| for plain definitions:
%    \begin{macrocode}
\newcommand{\exerciseconfig}[1]{%
  \@ifnextchar[{\exf@configopt{#1}}{\exf@confignoopt{#1}}}
\long\def\exf@configopt#1[#2]#3{%
  \exf@csdo\def{exf@config@#1}{}%
  \exf@csdo\renewcommand{exf@config@#1}[#2]{#3}}%
\long\def\exf@confignoopt#1#2{\exf@csdo\def{exf@config@#1}{#2}}
%    \end{macrocode}
% \macro{\exerciseconfigappend}
% \macro{\exerciseconfigprepend}
% Append to a (parameterless) configuration macro:
%    \begin{macrocode}
\newcommand{\exerciseconfigappend}[2]{%
  \exf@csdo\exf@append@def{exf@config@#1}{#2}}
\newcommand{\exerciseconfigprepend}[2]{%
  \exf@csdo\exf@prepend@def{exf@config@#1}{#2}}
%    \end{macrocode}
% \macro{\getexerciseconfig}
% Get configuration macro:
%    \begin{macrocode}
\newcommand{\getexerciseconfig}[1]{\csname exf@config@#1\endcsname}
%    \end{macrocode}
% \macro{\exerciseconfigempty}
% Test whether configuration macro |#1| is empty;
% execute |#2| if empty, otherwise execute |#3|:
%    \begin{macrocode}
\newcommand{\exerciseconfigempty}[3]{\exf@csdo\ifx{exf@config@#1}\exf@empty%
  #2\else#3\fi}
%    \end{macrocode}

% \macro{\exerciseifemtpy}
% \macro{\exerciseifnotempty}
% Code to test whether |#1| (expanded) is empty;
% execute |#2| if empty, otherwise execute |#3|:
%    \begin{macrocode}
\long\def\exerciseifempty#1#2#3{%
  \if\exf@emptytestchar#1\exf@emptytestchar#2\else#3\fi}
\long\def\exerciseifnotempty#1#2{%
  \if\exf@emptytestchar#1\exf@emptytestchar\else#2\fi}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Terms.}
%
% \macro{term...}
% Terms for sheet, problem, solution and points
% (for adjustment or internationalisation):
%    \begin{macrocode}
\exerciseconfig{termsheet}{Sheet}
\exerciseconfig{termsheets}{Sheets}
\exerciseconfig{termproblem}{Problem}
\exerciseconfig{termproblems}{Problems}
\exerciseconfig{termsolution}{Solution}
\exerciseconfig{termsolutions}{Solutions}
\exerciseconfig{termpoint}{point}
\exerciseconfig{termpoints}{points}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Formatting Styles.}
%
% \macro{style...}
% Formatting styles to be applied for various parts of text.
% Different styles will be applied in sequence from more general
% to more specific.
%
% Basic style for all exercise text:
%    \begin{macrocode}
\exerciseconfig{styletext}{\normalsize\normalfont}
%    \end{macrocode}
% Style for problems:
%    \begin{macrocode}
\exerciseconfig{styletextproblem}{}
%    \end{macrocode}
% Style for solutions:
%    \begin{macrocode}
\exerciseconfig{styletextsolution}{\footnotesize}
%    \end{macrocode}
% Basic style for titles:
%    \begin{macrocode}
\exerciseconfig{styletitle}{\bfseries}
%    \end{macrocode}
% Style for problem titles:
%    \begin{macrocode}
\exerciseconfig{styletitleproblem}{\large}
%    \end{macrocode}
% Style for subproblem titles:
%    \begin{macrocode}
\exerciseconfig{styletitlesubproblem}{}
%    \end{macrocode}
% Style for solution titles:
%    \begin{macrocode}
\exerciseconfig{styletitlesolution}{}
%    \end{macrocode}
% Style for problem section title in solution block:
%    \begin{macrocode}
\exerciseconfig{styletitlesolutionsproblem}{\small}
%    \end{macrocode}
% Style for solution block title:
%    \begin{macrocode}
\exerciseconfig{styletitlesolutions}{\normalsize}
%    \end{macrocode}
% Style for problem block title:
%    \begin{macrocode}
\exerciseconfig{styletitleproblems}{\Large}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Spacing.}
%
% \macro{skip...}
% Spaces related to various elements.
% Vertical space is typically combined with space declared elsewhere
% using |\addvspace|.
%
% Space above problem environment:
%    \begin{macrocode}
\exerciseconfig{skipproblemabove}{3.25ex plus 1ex minus 1.5ex}
%    \end{macrocode}
% Space below problem environment:
%    \begin{macrocode}
\exerciseconfig{skipproblembelow}{3pt plus 1pt minus 1pt}
%    \end{macrocode}
% Space below or after problem title;
% positive numbers generate vertical space
% (problem body is started in new paragraph),
% negative numbers generate horizontal space
% (problem body continues on opening line):
%    \begin{macrocode}
\exerciseconfig{skipproblemtitle}{3pt plus 1pt minus 1pt}
%    \end{macrocode}
% Horizontal space between items in the problem opening line:
%    \begin{macrocode}
\exerciseconfig{skipprobleminfo}{0.5em}
%    \end{macrocode}
% Space for problem item and indentation;
% |0pt| means no indentation and direct display of title;
% positive numbers define an absolute amount;
% |-1pt| (or any negative number) computes the amount of indentation
% from the width of (standard) item plus separator:
%    \begin{macrocode}
\exerciseconfig{skipproblemitem}{0pt}
%    \end{macrocode}

% Spaces related to subproblem environment;
% analogous to spaces related to problem environment,
% see above:
%    \begin{macrocode}
\exerciseconfig{skipsubproblemabove}{1.5ex plus 0.5ex minus 1ex}
\exerciseconfig{skipsubproblembelow}{1.5ex plus 0.5ex minus 1ex}
\exerciseconfig{skipsubproblemtitle}{-1em}
\exerciseconfig{skipsubprobleminfo}{0.25em}
\exerciseconfig{skipsubproblemitem}{-1pt}
%    \end{macrocode}

% Spaces related to solution environment;
% analogous to spaces related to problem environment,
%    \begin{macrocode}
\exerciseconfig{skipsolutionabove}{0ex}
\exerciseconfig{skipsolutionbelow}{1.5ex plus 0.5ex minus 1ex}
\exerciseconfig{skipsolutiontitle}{-0.5em}
\exerciseconfig{skipsolutioninfo}{0.25em}
%    \end{macrocode}
% |skipsolutionitem| and |skipsolutionitemsub|
% are analogous to |skipproblemitem| described above;
% they apply to solutions corresponding to problems and subproblems,
% respectively:
%    \begin{macrocode}
\exerciseconfig{skipsolutionitem}{0pt}
\exerciseconfig{skipsolutionitemsub}{0pt}
%    \end{macrocode}

% Spaces related to solution blocks;
% space above and below a solution block:
%    \begin{macrocode}
\exerciseconfig{skipsolutionsabove}{1.5ex plus 0.5ex minus 1ex}
\exerciseconfig{skipsolutionsbelow}{1.5ex plus 0.5ex minus 1ex}
%    \end{macrocode}
% Space above problem titles in a solution block:
%    \begin{macrocode}
\exerciseconfig{skipsolutionsproblemabove}{1.0ex plus 0ex minus 0.5ex}
%    \end{macrocode}
% Space following problem titles in a solution block
% (with legacy definition):
%    \begin{macrocode}
\exerciseconfig{skipsolutionsproblemtitle}{1.0ex plus 0ex minus 0.5ex}
\exerciseconfig{skipsolutionsproblem}{\exf@config@skipsolutionsproblemtitle}
%    \end{macrocode}
% Space following title of a solution block:
%    \begin{macrocode}
\exerciseconfig{skipsolutionstitle}{1.0ex plus 0ex minus 0.5ex}
%    \end{macrocode}

% Spaces related to problem blocks;
% space above and below a problem block:
%    \begin{macrocode}
\exerciseconfig{skipproblemsabove}{1.5ex plus 0.5ex minus 1ex}
\exerciseconfig{skipproblemsbelow}{1.5ex plus 0.5ex minus 1ex}
%    \end{macrocode}
% Space following title of a problem block:
%    \begin{macrocode}
\exerciseconfig{skipproblemstitle}{1.0ex plus 0ex minus 0.5ex}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Hook Code.}
%
% \macro{insert...}
% Code to process data and to insert text at various points of processing.
%
% Code to generate the title for a sheet;
% minimalistic default to display the sheet title:
%    \begin{macrocode}
\exerciseconfig{insertsheettitle}{\centerline{\getsheetdata{title}}}
%    \end{macrocode}
% Code to clear the page at the start and at the end of a new sheet:
%    \begin{macrocode}
\exerciseconfig{insertsheetclearpage}{\exercisecleardoublepage}
%    \end{macrocode}
% Code to insert before a sheet is displayed:
%    \begin{macrocode}
\exerciseconfig{insertsheetbefore}{}
%    \end{macrocode}
% Code to insert after a sheet is displayed:
%    \begin{macrocode}
\exerciseconfig{insertsheetafter}{}
%    \end{macrocode}
% Code to insert before a solution block is displayed:
%    \begin{macrocode}
\exerciseconfig{insertsolutionsbefore}{}
%    \end{macrocode}
% Code to insert after a solution block is displayed:
%    \begin{macrocode}
\exerciseconfig{insertsolutionsafter}{}
%    \end{macrocode}
% Code to insert before a problem block is displayed:
%    \begin{macrocode}
\exerciseconfig{insertproblemsbefore}{}
%    \end{macrocode}
% Code to insert after a problem block is displayed:
%    \begin{macrocode}
\exerciseconfig{insertproblemsafter}{}
%    \end{macrocode}
% Code to insert before a problem is displayed:
%    \begin{macrocode}
\exerciseconfig{insertproblembefore}{}
%    \end{macrocode}
% Code to insert after a problem is displayed:
%    \begin{macrocode}
\exerciseconfig{insertproblemafter}{}
%    \end{macrocode}
% Code to insert between a problem and its solution
% (if style |solutionbelow| is |problem|):
%    \begin{macrocode}
\exerciseconfig{insertproblemsolution}{}
%    \end{macrocode}
% Code to insert text into the problem opening line
% by means of |\addprobleminfo|:
%    \begin{macrocode}
\exerciseconfig{insertprobleminfo}{}
%    \end{macrocode}
% Code to determine the display of problems:
%    \begin{macrocode}
\exerciseconfig{insertproblemselect}[1]{}
%    \end{macrocode}
% Analogous definitions for subproblems:
%    \begin{macrocode}
\exerciseconfig{insertsubproblembefore}{}
\exerciseconfig{insertsubproblemafter}{}
\exerciseconfig{insertsubprobleminfo}{}
\exerciseconfig{insertsubproblemsolution}{}
%    \end{macrocode}
% Analogous definitions for solutions:
%    \begin{macrocode}
\exerciseconfig{insertsolutionbefore}{}
\exerciseconfig{insertsolutionafter}{}
\exerciseconfig{insertsolutioninfo}{}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Text Composition for Environments.}
%
% \macro{compose...}
% Macros to generate text for various situations.
% Preferably the output is plain text without formatting,
% but in some situations it may be required to
% address formatting in these macros.
%
% Default separator for items:
%    \begin{macrocode}
\exerciseconfig{composeitemsep}{\ }
%    \end{macrocode}
% Compose sheet title;
% arguments are sheet number and raw title (empty if not specified);
% default is ``Sheet |#1|'' or given title ``|#2|'':
%    \begin{macrocode}
\exerciseconfig{composetitlesheet}[2]%
  {\exerciseifempty{#2}{\getexerciseconfig{termsheet} #1}{#2}}
%    \end{macrocode}
% Compose sheet title for pdf metadata;
% arguments are sheet number and raw title:
%    \begin{macrocode}
\exerciseconfig{composemetasheet}[2]%
  {\getexerciseconfig{composetitlesheet}{#1}{#2}}
%    \end{macrocode}
% Compose sheet title for table of contents;
% arguments are sheet number and raw title:
%    \begin{macrocode}
\exerciseconfig{composetocsheet}[2]%
  {\exerciseifempty{#2}{\getexerciseconfig{termsheet} #1}{#1. #2}}
%    \end{macrocode}
% Compose problem item; argument is problem number:
%    \begin{macrocode}
\exerciseconfig{composeitemproblem}[1]{#1.}
%    \end{macrocode}
% Problem item separator:
%    \begin{macrocode}
\exerciseconfig{composeitemproblemsep}%
  {\getexerciseconfig{composeitemsep}}
%    \end{macrocode}
% Compose problem title;
% arguments are problem number (empty if item is split off)
% and raw title (empty if not specified);
% default is ``Problem |#1|.'' or ``|#1|. |#2|'':
%    \begin{macrocode}
\exerciseconfig{composetitleproblem}[2]{\exerciseifempty{#1}%
   {\exerciseifempty{#2}{}{#2}}%
   {\exerciseifempty{#2}{\getexerciseconfig{termproblem}\ %
     \getexerciseconfig{composeitemproblem}{#1}}%
    {\getexerciseconfig{composeitemproblem}{#1} #2}}}
%    \end{macrocode}
% Compose problem title for table of contents;
% arguments are problem number and raw title:
%    \begin{macrocode}
\exerciseconfig{composetocproblem}[2]%
  {\exerciseifempty{#2}{\getexerciseconfig{termproblem} #1}{#1. #2}}
%    \end{macrocode}
% Compose subproblem item; argument is subproblem number:
%    \begin{macrocode}
\exerciseconfig{composeitemsubproblem}[1]{#1}
%    \end{macrocode}
% Subproblem item separator:
%    \begin{macrocode}
\exerciseconfig{composeitemsubproblemsep}%
  {\getexerciseconfig{composeitemsep}}
%    \end{macrocode}
% Compose subproblem title;
% argument is subproblem number:
%    \begin{macrocode}
\exerciseconfig{composetitlesubproblem}[1]{#1}
%    \end{macrocode}
% Compose solution item; arguments are problem and subproblem number:
%    \begin{macrocode}
\exerciseconfig{composeitemsolution}[2]{#1.}
\exerciseconfig{composeitemsolutionsub}[2]{#2}
%    \end{macrocode}
% Solution item separator:
%    \begin{macrocode}
\exerciseconfig{composeitemsolutionsep}%
  {\getexerciseconfig{composeitemsep}}
%    \end{macrocode}
% Compose title for single solution;
% arguments are corresponding problem and subproblem number:
%    \begin{macrocode}
\exerciseconfig{composetitlesolutionsingle}[2]%
  {\getexerciseconfig{termsolution}:}
%    \end{macrocode}
% Compose title for one out of several solutions;
% arguments are corresponding problem and subproblem number:
%    \begin{macrocode}
\exerciseconfig{composetitlesolutionmulti}[2]{#2}
%    \end{macrocode}
% Compose table of contents line for solution;
% arguments are problem number and raw title:
%    \begin{macrocode}
\exerciseconfig{composetocsolution}[2]%
  {\getexerciseconfig{composetocproblem}{#1}{#2}}
%    \end{macrocode}
% Compose title for solution block:
%    \begin{macrocode}
\exerciseconfig{composetitlesolutions}%
  {\getexerciseconfig{termsolutions}}
%    \end{macrocode}
% Compose title for problem block:
%    \begin{macrocode}
\exerciseconfig{composetitleproblems}%
  {\getexerciseconfig{termproblems}}
%    \end{macrocode}
% Compose table of contents line for solution block:
%    \begin{macrocode}
\exerciseconfig{composetocsolutions}%
  {\getexerciseconfig{composetitlesolutions}}
%    \end{macrocode}
% Compose table of contents line for problem block:
%    \begin{macrocode}
\exerciseconfig{composetocproblems}%
  {\getexerciseconfig{composetitleproblems}}
%    \end{macrocode}
% Compose sectional title for solution following a single problem;
% arguments are problem number and raw title:
%    \begin{macrocode}
\exerciseconfig{composetitlesolutionsproblemsingle}[2]%
  {\getexerciseconfig{termsolution}}
%    \end{macrocode}
% Compose sectional title for solution of one problem within a solution block;
% arguments are problem number and raw title:
%    \begin{macrocode}
\exerciseconfig{composetitlesolutionsproblemmulti}[2]%
  {\exerciseifempty{#2}{\getexerciseconfig{termproblem} #1}{#1. #2}}
%    \end{macrocode}
% Compose label:
%    \begin{macrocode}
\exerciseconfig{composeitemsolutionlabel}[2]{#1#2}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Points.}
%
% Compose number of points:
%    \begin{macrocode}
\exerciseconfig{composepointsnum}[1]{#1}
%    \end{macrocode}
% Compose number of points followed by `points';
% use singular `point' for $1$:
%    \begin{macrocode}
\exerciseconfig{composepoints}[1]{\getexerciseconfig{composepointsnum}{#1}~%
  \ifdim #1pt=1pt\getexerciseconfig{termpoint}%
  \else\getexerciseconfig{termpoints}\fi}
%    \end{macrocode}
% Compose points declaration for use in opening line:
%    \begin{macrocode}
\exerciseconfig{composepointsstart}[1]{(\getexerciseconfig{composepoints}{#1})}
%    \end{macrocode}
% Compose points declaration for use in margin:
%    \begin{macrocode}
\exerciseconfig{composepointsmargin}[1]{\getexerciseconfig{composepoints}{#1}}
%    \end{macrocode}
% Compose points declaration for use in text:
%    \begin{macrocode}
\exerciseconfig{composepointsbody}[1]{(\getexerciseconfig{composepoints}{#1})}
%    \end{macrocode}
% Compose points declaration for use in sheet data:
%    \begin{macrocode}
\exerciseconfig{composepointssheet}[1]{%
  \exerciseifnotempty{#1}{\getexerciseconfig{composepoints}{#1}}}
%    \end{macrocode}
% Compose points declaration for solution with comment:
%    \begin{macrocode}
\exerciseconfig{composepointsaward}[2]%
  {(\getexerciseconfig{composepoints}{#1}\exerciseifnotempty{#2}{; #2})}
%    \end{macrocode}
% Compose alternative points for solution declaration with comment:
%    \begin{macrocode}
\exerciseconfig{composepointsawardalt}[2]%
  {(\getexerciseconfig{composepoints}{#1}*\exerciseifnotempty{#2}{; #2})}
%    \end{macrocode}

% Compose pairs of points; omit 0 components:
%    \begin{macrocode}
\exerciseconfig{composepointspair}[2]{%
  \ifdim#2pt=0pt%
   \getexerciseconfig{composepoints}{#1}%
  \else\ifdim#1pt=0pt%
   +\getexerciseconfig{composepoints}{#2}%
  \else%
   \getexerciseconfig{composepointsnum}{#1}+%
   \getexerciseconfig{composepointsnum}{#2}~%
   \getexerciseconfig{termpoints}%
  \fi\fi}
%    \end{macrocode}
% Compose pairs of points for designated use;
% recycle plain definition if no bonus points given:
%    \begin{macrocode}
\exerciseconfig{composepointspairbody}[2]{%
  \ifdim#2pt=0pt\getexerciseconfig{composepointsbody}{#1}\else%
  (\getexerciseconfig{composepointspair}{#1}{#2})\fi}
\exerciseconfig{composepointspairstart}[2]{%
  \ifdim#2pt=0pt\getexerciseconfig{composepointsstart}{#1}\else%
  (\getexerciseconfig{composepointspair}{#1}{#2})\fi}
\exerciseconfig{composepointspairmargin}[2]{%
  \ifdim#2pt=0pt\getexerciseconfig{composepointsmargin}{#1}\else%
  \getexerciseconfig{composepointspair}{#1}{#2}\fi}
\exerciseconfig{composepointspairsheet}[2]{%
  \ifdim#2pt=0pt\getexerciseconfig{composepointssheet}{#1}\else%
  \getexerciseconfig{composepointspair}{#1}{#2}\fi}
\exerciseconfig{composepointspairaward}[3]{%
  \ifdim#2pt=0pt\getexerciseconfig{composepointsaward}{#1}{#3}\else%
  (\getexerciseconfig{composepointspair}{#1}{#2}%
   \exerciseifnotempty{#3}{; #3})\fi}
\exerciseconfig{composepointspairawardalt}[3]{%
  \ifdim#2pt=0pt\getexerciseconfig{composepointsawardalt}{#1}{#3}\else%
  (\getexerciseconfig{composepointspair}{#1}{#2}*%
   \exerciseifnotempty{#3}{; #3})\fi}
%    \end{macrocode}
% Compose pairs of points for designated situations:
%    \begin{macrocode}
\exerciseconfig{composepointspairbodyproblem}[2]{%
  \getexerciseconfig{composepointspairbody}{#1}{#2}}
\exerciseconfig{composepointspairbodysubproblem}[2]{%
  \getexerciseconfig{composepointspairbody}{#1}{#2}}
\exerciseconfig{composepointspairbodysolution}[2]{%
  \getexerciseconfig{composepointspairbody}{#1}{#2}}
\exerciseconfig{composepointspairstartproblem}[2]{%
  \getexerciseconfig{composepointspairstart}{#1}{#2}}
\exerciseconfig{composepointspairstartsubproblem}[2]{%
  \getexerciseconfig{composepointspairstart}{#1}{#2}}
\exerciseconfig{composepointspairstartsolution}[2]{%
  \getexerciseconfig{composepointspairstart}{#1}{#2}}
%    \end{macrocode}

% Display points in the margin:
%    \begin{macrocode}
\exerciseconfig{insertpointsmargin}[1]{\marginpar{\footnotesize #1}}
%    \end{macrocode}

% Display warning about points mismatch:
%    \begin{macrocode}
\exerciseconfig{insertwarnpoints}[3]
  {\textbf{points mismatch for #1 (#2 determined vs.\ #3 given)}}
%    \end{macrocode}
% Display warning about points changed:
%    \begin{macrocode}
\exerciseconfig{insertwarnpointsrerun}[1]
  {\textbf{points changed for #1 (please recompile)}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Counters.}
%
% Define counter display via configuration interface:
%    \begin{macrocode}
\exerciseconfig{countersheet}{\arabic{\exf@sheetcounter}}
\exerciseconfig{counterproblem}{\arabic{\exf@problemcounter}}
\exerciseconfig{counterproblemmax}{10}
\exerciseconfig{countersubproblem}{\alph{\exf@subproblemcounter})}
\exerciseconfig{countersubproblemmax}{m)}
\exerciseconfig{countersheetequation}{\arabic{equation}}
\exerciseconfig{counterproblemequation}{P\arabic{equation}}
\exerciseconfig{countersolutionequation}{S\arabic{equation}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Further Definitions.}
%
% \macro{tagsheet}
% \macro{tagproblem}
% \macro{tagsubproblem}
% Templates for automatic generation of tags:
%    \begin{macrocode}
\exerciseconfig{tagsheet}{\arabic{\exf@sheetcounter}}
\exerciseconfig{tagproblem}{\csname the\exf@problemcounter\endcsname}
\exerciseconfig{tagsubproblem}{\problemtag-\arabic{\exf@subproblemcounter}}
%    \end{macrocode}

% \macro{labelsheet}
% \macro{labelproblem}
% \macro{labelsubproblem}
% Templates for automatic generation of labels from tags:
%    \begin{macrocode}
\exerciseconfig{labelsheet}[1]{sheet:#1}
\exerciseconfig{labelproblem}[1]{prob:#1}
\exerciseconfig{labelsubproblem}[1]{\getexerciseconfig{labelproblem}{#1}}
%    \end{macrocode}

% \macro{toclevel...}
% Table of contents levels for sheets, problems,
% solutions of problems and solution blocks;
% empty means no writing to table of contents:
%    \begin{macrocode}
\exerciseconfig{toclevelsheet}{}
\exerciseconfig{toclevelproblem}{}
\exerciseconfig{toclevelproblems}{}
\exerciseconfig{toclevelsolution}{}
\exerciseconfig{toclevelsolutions}{}
%    \end{macrocode}

% \macro{extsolutions}
% \macro{extproblems}
% Filename extension for solution and problem blocks:
%    \begin{macrocode}
\exerciseconfig{extsolutions}{.sol}
\exerciseconfig{extproblems}{.prb}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Styles}
% \label{sec:imp-styles}
%
% Styles are meant as a way to adjust
% several configuration options at the same time
% to achieve a consistent layout in some regard.
% Useful examples can be found among the
% extended exercise styles.
% They can serve a starting point for further
% custom styles.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Exercise Styles Code.}
%
% \macro{\defexercisestylearg}
% Define a style with an argument:
%    \begin{macrocode}
\newcommand{\defexercisestylearg}[3][]{%
  \def\exf@tmp{#1}\ifx\exf@tmp\exf@empty%
   \define@key{exf@style}{#2}{#3}\else%
   \define@key{exf@style}{#2}[#1]{#3}\fi}
%    \end{macrocode}
% \macro{\defexercisestyle}
% Define a style with a boolean argument;
% execute code onlf if true:
%    \begin{macrocode}
\newcommand{\defexercisestyle}[2]{%
  \exf@csdotwo\long\def{exf@style@code@#1}{#2}%
  \exf@exparg{\define@boolkey{exf@style}[exf@style@]{#1}[true]}%
   {\csname ifexf@style@#1\endcsname\csname exf@style@code@#1\endcsname\fi}}
%    \end{macrocode}
% \macro{\exercisestyle}
% Process styles:
%    \begin{macrocode}
\newcommand{\exercisestyle}[1]{\exf@expsetkeys{exf@style}{#1}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Default Exercise Styles.}
%
% \macro{problemmanual}
% Delay display of problems:
%    \begin{macrocode}
\define@boolkey{exf@style}[exf@]{problemmanual}[true]{}
\exf@problemmanualfalse
%    \end{macrocode}
%
% \macro{solutionbelow}
% Choose location for solutions:
%    \begin{macrocode}
\def\exf@solutionbelow{subproblem}
\define@choicekey{exf@style}{solutionbelow}%
  {here,subproblem,subproblem*,problem,problem*,sheet,manual}%
  {\ifexf@solfile@open\else\gdef\exf@solutionbelow{#1}\fi}
%    \end{macrocode}
%
% \macro{sheetequation}
% \macro{problemequation}
% \macro{solutionequation}
% Use separate equation counters for sheets, problems and solutions:
%    \begin{macrocode}
\defexercisestyle{sheetequation}{}
\defexercisestyle{problemequation}{}
\defexercisestyle{solutionequation}{}
\exf@style@solutionequationtrue
%    \end{macrocode}
%
% \macro{problempointsat}
% \macro{subproblempointsat}
% \macro{solutionpointsat}
% Choose where points of (sub)problems and solutions are displayed:
%    \begin{macrocode}
\def\exf@pointsat{start}
\define@choicekey{exf@style}{problempointsat}%
  {start,start*,margin,end,manual,off}{\def\exf@pointsat{#1}}
\define@choicekey{exf@style}{pointsat}%
  {start,start*,margin,end,manual,off}{\def\exf@pointsat{#1}}
\def\exf@subpointsat{end}
\define@choicekey{exf@style}{subproblempointsat}%
  {start,start*,margin,end,manual,off}{\def\exf@subpointsat{#1}}
\define@choicekey{exf@style}{subpointsat}%
  {start,start*,margin,end,manual,off}{\def\exf@subpointsat{#1}}
\def\exf@solpointsat{off}
\define@choicekey{exf@style}{solutionpointsat}%
  {start,start*,margin,end,manual,off}{\def\exf@solpointsat{#1}}
\define@choicekey{exf@style}{solpointsat}%
  {start,start*,margin,end,manual,off}{\def\exf@solpointsat{#1}}
%    \end{macrocode}
%
% \macro{problemby}
% \macro{equationby}
% Declare problems or equations as subcounter of other counter:
%    \begin{macrocode}
\defexercisestylearg{problemby}{\exf@numberproblemwithin{#1}}
\defexercisestylearg{equationby}{\exf@numberequationwithin{#1}}
%    \end{macrocode}
%
% \macro{pagebysheet}
% \macro{problembysheet}
% \macro{equationbysheet}
% Number pages, problems or equations by sheet:
%    \begin{macrocode}
\defexercisestyle{pagebysheet}{%
  \def\thepage{\csname the\exf@sheetcounter\endcsname.\arabic{page}}%
  \def\theHpage{\csname theH\exf@sheetcounter\endcsname.\arabic{page}}%
  \exerciseconfigappend{insertsheetbefore}{\setcounter{page}{1}}}
\defexercisestyle{problembysheet}%
  {\exf@numberproblemwithin{\exf@sheetcounter}}
\defexercisestyle{equationbysheet}%
  {\exf@numberequationwithin{\exf@sheetcounter}}
%    \end{macrocode}
%
% \macro{fracpoints}
% Use vulgar fractions to display binary fractional points:
%    \begin{macrocode}
\defexercisestyle{fracpoints}%
  {\exerciseconfig{composepointsnum}[1]{\protect\showfracpoints{##1}}}
%    \end{macrocode}
%
% \macro{twoside}
% Use two-sided layout for sheets:
%    \begin{macrocode}
\defexercisestylearg[true]{twoside}{\exercisesetup{twoside={#1}}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Extended Exercise Styles.}
%
% Declare more specific styles:
%    \begin{macrocode}
\ifexf@extstyle
%    \end{macrocode}
%
% \macro{contents}
% Add sheets and problems to table of contents:
%    \begin{macrocode}
\defexercisestyle{contents}{%
  \exerciseconfig{toclevelsheet}{section}%
  \exerciseconfig{toclevelproblem}{subsection}}
%    \end{macrocode}
% \macro{solutionsf}
% Use sans serif font for solutions:
%    \begin{macrocode}
\defexercisestyle{solutionsf}{%
  \exerciseconfigappend{styletextsolution}{\sffamily\let\itshape\slshape}}
%    \end{macrocode}
% \macro{solutiondimproblem}
% Dim problem text if solutions are displayed:
%    \begin{macrocode}
\defexercisestyle{solutiondimproblem}{%
  \RequirePackage{color}%
  \exerciseconfigappend{styletextsolution}{\color[gray]{0}}%
  \exerciseconfigappend{styletextproblem}{\color[gray]{0.2}}}
%    \end{macrocode}
% \macro{solutionsep}
% Separate solutions by horizontal lines:
%    \begin{macrocode}
\defexercisestyle{solutionsep}{%
  \exerciseconfig{insertsolutionsbefore}{\hrule\nopagebreak[3]\vspace{0.5ex}}%
  \exerciseconfig{insertsolutionsafter}%
   {\removelastskip\nopagebreak[3]\vspace{1.0ex}\hrule}}
%    \end{macrocode}
% \macro{plainheader}
% Declare a simple sheet header with some configurable options;
% the configuration options |styleheader...| define font styles,
% |skipheaderbelow| the space below the header and
% |composeheaderbelow...| some auxiliary text to be displayed
% on the line below the header:
%    \begin{macrocode}
\defexercisestyle{plainheader}{%
  \exerciseconfig{styleheadertitle}{\Large\bfseries}%
  \exerciseconfig{styleheadercourse}{\sffamily}%
  \exerciseconfig{styleheaderbelow}{\footnotesize}%
  \exerciseconfig{skipheaderbelow}{3ex}%
  \exerciseconfig{composeheaderbelowleft}{}%
  \exerciseconfig{composeheaderbelowright}{}%
  \exerciseconfig{composeheaderbelowcenter}{}%
  \exerciseconfig{insertsheettitle}{\noindent%
   \begin{minipage}{\textwidth}%
   {\getexerciseconfig{styleheadertitle}%
    \makebox[0pt][l]{\getexercisedata{course}}%
    \hfill\makebox[0pt][r]{\getsheetdata{title}}\par}%
   {\getexerciseconfig{styleheadercourse}%
    \makebox[0pt][l]{\getexercisedata{institution}%
     \exercisedataempty{period}{}{, \getexercisedata{period}}}%
    \hfill\makebox[0pt][r]{\getexercisedata{instructor}}%
    \vphantom{g}\par}%
   \hrule%
   {\def\tmp{}%
    \exerciseconfigempty{composeheaderbelowleft}{}{\def\tmp{.}}%
    \exerciseconfigempty{composeheaderbelowcenter}{}{\def\tmp{.}}%
    \exerciseconfigempty{composeheaderbelowright}{}{\def\tmp{.}}%
    \exerciseifnotempty{\tmp}%
     {\getexerciseconfig{styleheaderbelow}\vphantom{\^A}%
      \makebox[0pt][l]{\getexerciseconfig{composeheaderbelowleft}}%
      \hfill\makebox[0pt][c]{\getexerciseconfig{composeheaderbelowcenter}}%
      \hfill\makebox[0pt][r]{\getexerciseconfig{composeheaderbelowright}}%
      \vspace*{-\baselineskip}\vspace*{-\parskip}\par}}%
   \end{minipage}%
   \par\addvspace{\getexerciseconfig{skipheaderbelow}}}}
%    \end{macrocode}
%
% Done with extended styles:
%    \begin{macrocode}
\fi
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Metadata}
% \label{sec:imp-metadata}
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Global Metadata Code.}
%
% \macro{\defexercisedata}
% Declare global metadata field
% by defining a key \textit{key} in category |exf@data|
% that stores the chosen value in |\exf@data@|\textit{key}:
%    \begin{macrocode}
\newcommand{\defexercisedata}[1]{%
  \exf@csdo\def{exf@data@#1}{}%
  \define@key{exf@data}{#1}%
   {\exf@csdo\gdef{exf@data@#1}{##1}}}
%    \end{macrocode}
% \macro{\exercisedata}
% Process key-value pairs:
%    \begin{macrocode}
\newcommand{\exercisedata}[1]{\setkeys{exf@data}{#1}}
%    \end{macrocode}
% \macro{\getexercisedata}
% Read global metadata:
%    \begin{macrocode}
\newcommand{\getexercisedata}[1]{\csname exf@data@#1\endcsname}
%    \end{macrocode}
% \macro{\exercisedataempty}
% Check whether the field is empty:
%    \begin{macrocode}
\newcommand{\exercisedataempty}[3]{\exf@csdo\ifx{exf@data@#1}\exf@empty%
  #2\else#3\fi}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Global Metadata Declarations.}
%
% Declare fields corresponding to standard pdf metadata:
%    \begin{macrocode}
\defexercisedata{author}
\defexercisedata{title}
\defexercisedata{subject}
\defexercisedata{keyword}
%    \end{macrocode}
% Declare additional general purpose fields:
%    \begin{macrocode}
\defexercisedata{date}
%    \end{macrocode}
% Declare metadata related to courses:
%    \begin{macrocode}
\defexercisedata{instructor}
\defexercisedata{course}
\defexercisedata{institution}
\defexercisedata{period}
\defexercisedata{material}
%    \end{macrocode}
% Overwrite standard definitions for |author|, |title|, |date|
% to also fill ordinary \LaTeX{} structures:
%    \begin{macrocode}
\define@key{exf@data}{author}{\gdef\exf@data@author{#1}\author{#1}}
\define@key{exf@data}{title}{\gdef\exf@data@title{#1}\title{#1}}
\define@key{exf@data}{date}{\gdef\exf@data@date{#1}\date{#1}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Sheet Metadata.}
%
% \macro{\defsheetdata}
% Declare sheet metadata field
% by defining a key \textit{key} in category |exf@sheet|
% that stores the chosen value in |\exf@data@sheet@|\textit{key}:
%    \begin{macrocode}
\newcommand{\defsheetdata}[1]{%
  \exf@csdo\def{exf@data@sheet@#1}{}%
  \define@key{exf@sheet}{#1}%
   {\exf@csdo\def{exf@data@sheet@#1}{##1}}}
%    \end{macrocode}
% \macro{\setsheetdata}
% Set sheet metadata:
%    \begin{macrocode}
\newcommand{\setsheetdata}[1]{\setkeys{exf@sheet}{#1}}
%    \end{macrocode}
% \macro{\getsheetdata}
% Read sheet metadata:
%    \begin{macrocode}
\newcommand{\getsheetdata}[1]{\csname exf@data@sheet@#1\endcsname}
%    \end{macrocode}
% \macro{\sheetdataempty}
% Check whether the field is empty:
%    \begin{macrocode}
\newcommand{\sheetdataempty}[3]{\exf@csdo\ifx{exf@data@sheet@#1}\exf@empty%
  #2\else#3\fi}
%    \end{macrocode}

% Declare general purpose fields:
%    \begin{macrocode}
\defsheetdata{due}
\defsheetdata{handout}
\defsheetdata{editdate}
\defsheetdata{author}
\defsheetdata{editor}
%    \end{macrocode}

% Special title processing:
%    \begin{macrocode}
\def\exf@data@sheet@rawtitle{}
\define@key{exf@sheet}{title}{\def\exf@data@sheet@rawtitle{#1}}
\def\exf@data@sheet@title{\exf@config@composetitlesheet%
  {\csname the\exf@sheetcounter\endcsname}{\exf@data@sheet@rawtitle}}%
%    \end{macrocode}
% Special points processing:
%    \begin{macrocode}
\def\exf@data@sheet@points{\ifdefined\exf@sheet@points%
   \expandafter\exf@config@composepointspairsheet\exf@sheet@points\fi}%
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Problem Metadata.}
%
% \macro{\defproblemdata}
% Declare problem metadata field
% by defining a key \textit{key} in category |exf@problem|
% that stores the chosen value in |\exf@data@problem@|\textit{key}:
%    \begin{macrocode}
\newcommand{\defproblemdata}[1]{%
  \exf@csdo\def{exf@data@problem@#1}{}%
  \define@key{exf@problem}{#1}%
   {\exf@csdo\def{exf@data@problem@#1}{##1}}}
%    \end{macrocode}
% \macro{\setproblemdata}
% Set problem metadata:
%    \begin{macrocode}
\newcommand{\setproblemdata}[1]{\setkeys{exf@problem,exf@scanproblem}{#1}}
%    \end{macrocode}
% \macro{\getproblemdata}
% Read problem metadata:
%    \begin{macrocode}
\newcommand{\getproblemdata}[1]{\csname exf@data@problem@#1\endcsname}
%    \end{macrocode}
% \macro{\problemdataempty}
% Check whether the field is empty:
%    \begin{macrocode}
\newcommand{\problemdataempty}[3]{\exf@csdo\ifx{exf@data@problem@#1}\exf@empty%
  #2\else#3\fi}
%    \end{macrocode}

% Special title processing:
%    \begin{macrocode}
\def\exf@data@problem@rawtitle{}
\define@key{exf@problem}{title}{\def\exf@data@problem@rawtitle{#1}}
\def\exf@data@problem@title{\exf@config@composetitleproblem{%
 \csname the\exf@problemcounter\endcsname}{\exf@data@problem@rawtitle}}%
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Problem Environment Code.}
%
% \macro{\exf@addmargin}
% Define a length for environment margin:
%    \begin{macrocode}
\newlength\exf@addmargin
%    \end{macrocode}

% \macro{\exf@section}
% Write out problem opening line followed by some amount of skip
% (positive dimensions add vertical space,
% negative dimensions add horizontal space);
% protected expand argument if in horizontal mode
% (because it will be held until text is output
% and some definitions may become invalid):
%    \begin{macrocode}
\newcommand{\exf@section}[2]{\setlength\exf@tmpdim{#1}%
  \ifdim\exf@tmpdim<0pt%
   \protected@edef\exf@tmp{#2}%
  \else%
   \def\exf@tmp{#2}%
  \fi%
  \exf@exparg{\@startsection{}{}{0pt}{0pt}{#1}{}*}{\exf@tmp}}
%    \end{macrocode}

% \macro{\exf@init@block}
% Clean info buffer, define amount of skip between items:
%    \begin{macrocode}
\newcommand{\exf@init@block}[1]{%
  \def\exf@intro{}\def\exf@intro@skip{#1}%
  \exf@addmargin0pt\def\exf@introitem{}}
%    \end{macrocode}
% \macro{\exf@append@intro}
% Append to info buffer:
%    \begin{macrocode}
\newcommand{\exf@append@intro}[1]%
  {\exf@append@def\exf@intro{#1\hspace{\exf@intro@skip}}}
%    \end{macrocode}
% \macro{\exf@prepend@intro}
% Prepend to info buffer:
%    \begin{macrocode}
\newcommand{\exf@prepend@intro}[1]%
  {\exf@prepend@def\exf@intro{#1\hspace{\exf@intro@skip}}}
%    \end{macrocode}
% \macro{\exf@open@block}
% Open environment, set margin, compose opening line:
%    \begin{macrocode}
\newcommand{\exf@open@block}[1]{%
  \advance\leftskip\exf@addmargin%
  \advance\linewidth-\exf@addmargin%
  \advance\@totalleftmargin\exf@addmargin%
  \ifx\exf@intro\exf@empty%
   \exf@section{0pt}{\exf@introitem}%
  \else%
   \exf@section{#1}{\exf@introitem\exf@intro\unskip}%
  \fi}%
%    \end{macrocode}
% \macro{\exf@close@block}
% Close environment, undo margin:
%    \begin{macrocode}
\newcommand{\exf@close@block}{%
  \advance\leftskip-\exf@addmargin%
  \advance\linewidth\exf@addmargin%
  \advance\@totalleftmargin-\exf@addmargin}%
%    \end{macrocode}

% \macro{\addprobleminfo}
% Interface to append or prepend to info buffer:
%    \begin{macrocode}
\newcommand{\addprobleminfo}{\@ifstar\exf@prepend@intro\exf@append@intro}
%    \end{macrocode}

% \macro{\exf@addinfoswitch}
% Add a switch for displaying problem info:
%    \begin{macrocode}
\newcommand{\exf@addinfoswitch}[1]%
  {\define@boolkey{exf@infoswitch}[exf@showdata@]{#1}[true]{}}
%    \end{macrocode}
% \macro{\defprobleminfo}
% Declare a problem info field,
% add corresponding info switch,
% process key-value pair if switch activated:
%    \begin{macrocode}
\newcommand{\defprobleminfo}[2]{%
  \exf@addinfoswitch{#1}%
  \exerciseconfig{compose@probleminfo@#1}[1]{#2}%
  \exf@exparg{\define@key{exf@probleminfo}{#1}}%
   {\csname ifexf@showdata@#1\endcsname\exf@append@intro{%
    \csname exf@config@compose@probleminfo@#1\endcsname{##1}}\fi}}
%    \end{macrocode}
% \macro{\showprobleminfo}
% Process info switches, expand argument first:
%    \begin{macrocode}
\newcommand{\showprobleminfo}[1]{\exf@expsetkeys{exf@infoswitch}{#1}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Problem Info Declarations.}
%
% Declare general purpose fields:
%    \begin{macrocode}
\defprobleminfo{optional}{\emph{#1:}}
\showprobleminfo{optional}
\defprobleminfo{difficulty}{(#1)}
%    \end{macrocode}

% Declare fields for internal information (mostly):
%    \begin{macrocode}
\defprobleminfo{comment}{#1}
\defprobleminfo{author}{$\langle$#1$\rangle$}
\defprobleminfo{editor}{$\{$#1$\}$}
\defprobleminfo{source}{[#1]}
\defprobleminfo{keyword}{\#(#1)}
%    \end{macrocode}

% Declare more specific fields:
%    \begin{macrocode}
\ifexf@extdata
\defprobleminfo{review}{#1}
\defprobleminfo{recycle}{[[#1]]}
\defprobleminfo{timesolve}{\{#1\}}
\defprobleminfo{timepresent}{\{\!\{#1\}\!\}}
\fi
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Write Metadata to PDF Files.}
%
% \macro{\exf@writemetadata}
% Write Metadata to PDF Files in case \textsf{hyperref} is available:
%    \begin{macrocode}
\newcommand{\exf@writemetadata}{%
  \ifdefined\hypersetup%
%    \end{macrocode}
% Write author, title, subject and keywords:
%    \begin{macrocode}
   \ifx\exf@data@author\exf@empty\else%
    \hypersetup{pdfauthor={\exf@data@author}}\fi%
   \ifx\exf@data@title\exf@empty\else%
    \hypersetup{pdftitle={\exf@data@title}}\fi%
   \ifx\exf@data@subject\exf@empty\else%
    \hypersetup{pdfsubject={\exf@data@subject}}\fi%
   \ifx\exf@data@keyword\exf@empty\else%
    \hypersetup{pdfkeywords={\exf@data@keyword}}\fi%
  \fi}
%    \end{macrocode}

% Automatic writing at |\begin{document}|:
%    \begin{macrocode}
\AtBeginDocument{\exf@ifis\exf@metadata{auto}%
  {\exf@writemetadata\gdef\exf@metadata{off}}}
%    \end{macrocode}

% \macro{\writeexercisedata}
% Write metadata manually:
%    \begin{macrocode}
\newcommand{\writeexercisedata}{\exf@ifis\exf@metadata{manual}%
  {\exf@writemetadata\gdef\exf@metadata{off}}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Counters}
% \label{sec:imp-counter}
%
% \macro{sheet}
% \macro{problem}
% \macro{subproblem}
% \macro{solution}
% Define main counters (with customised names if necessary)
% and equation counters:
%    \begin{macrocode}
\newcounter{\exf@sheetcounter}
\newcounter{\exf@problemcounter}
\newcounter{\exf@subproblemcounter}[\exf@problemcounter]
\newcounter{\exf@solutioncounter}[\exf@problemcounter]
\newcount\exf@eqsav
\newcounter{exf@sheetequation}
\newcounter{exf@problemequation}
\newcounter{exf@solutionequation}
%    \end{macrocode}

% Implement counter display;
% take care of corresponding \textsf{hyperref} labels:
%    \begin{macrocode}
\exf@csdo\def{the\exf@sheetcounter}{\exf@config@countersheet}
\exf@csdo\def{the\exf@problemcounter}{\exf@config@counterproblem}
\exf@csdo\def{the\exf@subproblemcounter}{\exf@config@countersubproblem}
\def\theexf@sheetequation{\exf@config@countersheetequation}
\def\theHexf@sheetequation{sheet.\arabic{equation}}
\def\theexf@problemequation{\exf@config@counterproblemequation}
\def\theHexf@problemequation{prob.\arabic{equation}}
\def\theexf@solutionequation{\exf@config@countersolutionequation}
\def\theHexf@solutionequation{sol.\arabic{equation}}
%    \end{macrocode}

% \macro{\exf@numberproblemwithin}
% Declare problem counter as subcounter of |#1|:
%    \begin{macrocode}
\newcommand{\exf@numberproblemwithin}[1]{%
  \@addtoreset{\exf@problemcounter}{#1}%
  \exf@csdo\def{the\exf@problemcounter}%
   {\csname the#1\endcsname.\exf@config@counterproblem}%
  \edef\exf@tmp{#1}%
  \ifx\exf@tmp\exf@sheetcounter%
   \exerciseconfig{tagproblem}{\ifdefined\sheettag\sheettag-\fi%
    \arabic{\exf@problemcounter}}%
  \else%
   \exerciseconfig{tagproblem}{\csname the#1\endcsname-%
    \arabic{\exf@problemcounter}}%
  \fi}
%    \end{macrocode}

% \macro{\exf@numberequationwithin}
% Declare various new equation counters as subcounter of |#1|;
% take care of corresponding \textsf{hyperref} labels:
%    \begin{macrocode}
\newcommand{\exf@numberequationwithin}[1]{%
  \@addtoreset{exf@sheetequation}{#1}%
  \def\theexf@sheetequation%
   {\csname the#1\endcsname.\exf@config@countersheetequation}%
  \def\theHexf@sheetequation%
   {\csname theH#1\endcsname.sheet.\arabic{equation}}%
  \@addtoreset{exf@problemequation}{#1}%
  \def\theexf@problemequation%
   {\csname the#1\endcsname.\exf@config@counterproblemequation}%
  \def\theHexf@problemequation%
   {\csname theH#1\endcsname.prob.\arabic{equation}}%
  \@addtoreset{exf@solutionequation}{#1}%
  \def\theexf@solutionequation%
   {\csname the#1\endcsname.\exf@config@countersolutionequation}%
  \def\theHexf@solutionequation%
   {\csname theH#1\endcsname.sol.\arabic{equation}}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Buffers}
% \label{sec:imp-buffer}
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{File Output.}
%
% \macro{\ifexf@solfile@open}
% Conditional whether output files are presently in use:
%    \begin{macrocode}
\newif\ifexf@solfile@open\exf@solfile@openfalse
\newif\ifexf@probfile@open\exf@probfile@openfalse
%    \end{macrocode}
% \macro{\exf@solfile}
% Reserve file handles:
%    \begin{macrocode}
\newwrite\exf@solfile
\newwrite\exf@probfile
%    \end{macrocode}

% \macro{\exf@writeline}
% Write a line to the file:
%    \begin{macrocode}
\newcommand{\exf@writeline}[2]{\immediate\write#1{#2}}
%    \end{macrocode}

% \macro{\exf@linesep}
% Return a separator line:
%    \begin{macrocode}
\newcommand{\exf@linesep}%
  {\@percentchar---------------------------------------}
%    \end{macrocode}
% \macro{\exf@lineno}
% Return current position in source file;
% display line number and source file name
% (if available via package \textsf{currfile}):
%    \begin{macrocode}
\newcommand{\exf@lineno}{\@percentchar%
  \ifdefined\currfilename\currfilename\space\fi%
  l.\the\inputlineno}
%    \end{macrocode}

% \macro{\exf@start@solfile}
% Open a new solution file |#1.sol| (do nothing if already open);
% indicate source, switch to manual solution display mode:
%    \begin{macrocode}
\newcommand{\exf@start@solfile}[1]{%
  \ifexf@solfile@open\else%
   \exercisestyle{solutionbelow=manual}%
   \global\exf@solfile@opentrue%
   \edef\exf@tmp{#1}%
   \immediate\openout\exf@solfile\exf@tmp\exf@config@extsolutions\relax%
   \exf@writeline\exf@solfile{\@percentchar%
    generated from file `\jobname' by exframe.sty}%
   \ifexf@lineno\exf@writeline\exf@solfile{\exf@lineno}\fi%
   \exf@writeline\exf@solfile{}%
  \fi}
%    \end{macrocode}

% \macro{\exf@close@solfile}
% Close solution file (if open);
% indicate position, close and reset variables:
%    \begin{macrocode}
\newcommand{\exf@close@solfile}{%
  \ifexf@solfile@open%
   \ifexf@lineno\exf@writeline\exf@solfile{\exf@linesep}%
    \exf@writeline\exf@solfile{\exf@lineno}\fi%
   \exf@writeline\exf@solfile{\@backslashchar endinput}%
   \immediate\closeout\exf@solfile%
   \global\exf@solfile@openfalse%
  \fi}
%    \end{macrocode}

% \macro{\exf@start@probfile}
% Open a new problem file |#1.prb| (do nothing if already open);
% indicate source, switch to manual problem display mode:
%    \begin{macrocode}
\newcommand{\exf@start@probfile}[1]{%
  \ifexf@probfile@open\else%
   \global\exf@probfile@opentrue%
   \edef\exf@tmp{#1}%
   \immediate\openout\exf@probfile\exf@tmp\exf@config@extproblems\relax%
   \exf@writeline\exf@probfile{\@percentchar%
    generated from file `\jobname' by exframe.sty}%
   \ifexf@lineno\exf@writeline\exf@probfile{\exf@lineno}\fi%
   \exf@writeline\exf@probfile{}%
  \fi}
%    \end{macrocode}

% \macro{\exf@close@probfile}
% Close problem file (if open);
% indicate position, close and reset variables:
%    \begin{macrocode}
\newcommand{\exf@close@probfile}{%
  \ifexf@probfile@open%
   \ifexf@lineno\exf@writeline\exf@probfile{\exf@linesep}%
    \exf@writeline\exf@probfile{\exf@lineno}\fi%
   \exf@writeline\exf@probfile{\@backslashchar endinput}%
   \immediate\closeout\exf@probfile%
   \global\exf@probfile@openfalse%
  \fi}
%    \end{macrocode}

% Make sure to properly close files at the end:
%    \begin{macrocode}
\AtEndDocument{\exf@close@solfile\exf@close@probfile}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Buffers.}
%
% \macro{\exf@solbuf}
% \macro{\exf@probbuf}
% \macro{\ifexf@solbuf@clean}
% \macro{\ifexf@probbuf@clean}
% Declare token buffers for storing problems and solutions
% and conditionals indicating whether the buffers have been used:
%    \begin{macrocode}
\newtoks\exf@solbuf
\newtoks\exf@probbuf
\newif\ifexf@solbuf@clean\exf@solbuf@cleantrue
\newif\ifexf@probbuf@clean\exf@probbuf@cleantrue
%    \end{macrocode}
% \macro{\exf@clear@solbuf}
% \macro{\exf@clear@probbuf}
% Clear a buffer and mark clean:
%    \begin{macrocode}
\def\exf@clear@solbuf{\global\exf@solbuf@cleantrue\global\exf@solbuf={}}
\def\exf@clear@probbuf{\global\exf@probbuf@cleantrue\global\exf@probbuf={}}
%    \end{macrocode}

% \macro{\exf@append@buf}
% Append tokens to buffer:
%    \begin{macrocode}
\def\exf@append@buf#1#2{\global#1=\expandafter{\the#1#2}}
%    \end{macrocode}
% \macro{\exf@addline}
% Add a protected expanded line to the buffer:
%    \begin{macrocode}
\def\exf@addline#1#2{{\protected@edef\exf@tmp{#2}%
  \exf@exparg{\exf@append@buf#1}{\exf@tmp^^J}}}
%    \end{macrocode}
% \macro{\exf@source@buf}
% Source a buffer into the document:
%    \begin{macrocode}
\def\exf@source@buf#1{\exf@exptwo\scantokens{\the#1}}
%    \end{macrocode}
% \macro{\exf@write@buf}
% Write the buffer into the solution file:
%    \begin{macrocode}
\def\exf@write@buf#1#2{\exf@writeline#1{\the#2}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Verbatim Processing.}
%
% \macro{\exf@verbatim}
% Start reading the buffer from the environment body:
%    \begin{macrocode}
\newcommand{\exf@verbatim}{%
  \begingroup%
  \@bsphack%
  \let\do\@makeother\dospecials%
  \catcode`\^^M\active%
  \def\verbatim@processline{\exf@exptwo\exf@verbatim@process%
   {\the\verbatim@line^^J}}%
  \verbatim@start}
%    \end{macrocode}

% \macro{\exf@endverbatim}
% Stop reading the buffer:
%    \begin{macrocode}
\newcommand{\exf@endverbatim}{\@esphack\endgroup}
%    \end{macrocode}

% \macro{\exf@scanblock}
% Scan an optional argument from a verbatim environment;
% allow for an empty environment and an empty first line;
% argument |#1| is macro to be called eventually:
%    \begin{macrocode}
\def\exf@scanblock#1{%
%    \end{macrocode}
% Check for empty first line:
%    \begin{macrocode}
  \@ifnextchar\par{\exf@scanblock@par{#1}}{\exf@scanblock@sel{#1}}}
%    \end{macrocode}
% Handle empty first line, implies no optional argument:
%    \begin{macrocode}
\long\def\exf@scanblock@par#1\par{\exf@scanblock@sel{#1}[]}
%    \end{macrocode}
% Check for optional argument (|[|) and for environment ending (|\end|):
%    \begin{macrocode}
\def\exf@scanblock@sel#1{\@ifnextchar[{\exf@scanblock@opt{#1}}%
  {\@ifnextchar\end{\exf@scanblock@end{#1}}{\exf@scanblock@noopt{#1}}}}
%    \end{macrocode}
% Handle empty environment, hopefully environment matches (otherwise?!):
%    \begin{macrocode}
\def\exf@scanblock@end#1\end#2{%
  \def\exf@tmp{#2}\ifx\exf@tmp\@currenvir%
    \def\exf@verbatim{}\def\exf@endverbatim{}%
  \fi%
  #1{}{\scantokens{\end{#2}}}}
%    \end{macrocode}
% Pass on without and with optional argument;
% pass on optional argument and any token scanned prematurely:
%    \begin{macrocode}
\def\exf@scanblock@noopt#1#2{#1{}{\scantokens#2}}
\def\exf@scanblock@opt#1[#2]{#1{#2}{}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Points}
% \label{sec:imp-points}
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Points Arithmetic.}
%
% \macro{\exf@addtopoints}
% Add points |#2|+|#3| to macro |#1| using metric register:
%    \begin{macrocode}
\newcommand{\exf@addtopoints}[3]{%
  \ifdefined#1\else\def#1{{0}{0}}\fi%
  \setlength\exf@tmpdim{\expandafter\@firstoftwo#1pt}%
  \addtolength\exf@tmpdim{#2pt}%
  \edef\exf@tmp{\strip@pt\exf@tmpdim}%
  \setlength\exf@tmpdim{\expandafter\@secondoftwo#1pt}%
  \addtolength\exf@tmpdim{#3pt}%
  \xdef#1{{\exf@tmp}{\strip@pt\exf@tmpdim}}}
%    \end{macrocode}
%
% \macro{\exf@pointsmismatch}
% Execute |#3| if points disagree:
%    \begin{macrocode}
\newcommand{\exf@pointsmismatch}[3]{%
  \let\exf@tmp\@undefined%
  \ifdim\expandafter\@firstoftwo#1pt=\expandafter\@firstoftwo#2pt\else%
   \def\exf@tmp{}\fi%
  \ifdim\expandafter\@secondoftwo#1pt=\expandafter\@secondoftwo#2pt\else%
   \def\exf@tmp{}\fi%
  \ifdefined\exf@tmp#3\fi}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Points Expansion.}
%
% \macro{\exf@outpoints}
% If points macro |#3| is set,
% expand |#3|, pass on as |#1{\protect#2}#3| and clear |#3| globally:
%    \begin{macrocode}
\def\exf@outpoints#1#2#3{\ifdefined#3%
   \exf@exptwo\exf@outpoints@switch{#3}{#1}{#2}%
   \global\let#3\@undefined\fi}
\def\exf@outpoints@switch#1#2#3{#2{\protect#3#1}}
%    \end{macrocode}

% \macro{\exf@scanpoints}
% Call as |\exf@scanpoints#1|[\textit{regular}][|+|\textit{bonus}]|++@| to
% write |{|\textit{regular}|}{|\textit{bonus}|}| into |#1|;
% fill with 0 if empty:
%    \begin{macrocode}
\def\exf@scanpoints#1#2+#3+#4@{%
  \edef#1{\if @#2@0\else#2\fi}%
  \edef#1{{#1}{\if @#3@0\else#3\fi}}}
%    \end{macrocode}
% \macro{\exf@formatpoints}
% Format as [|#1|][|+#2|]; remove 0 components:
%    \begin{macrocode}
\def\exf@formatpoints#1#2{\ifdim#2pt=0pt#1\else%
  \ifdim#1pt=0pt+#2\else#1+#2\fi\fi}
%    \end{macrocode}

% \macro{\extractpoints}
% Extract main (plain) or bonus (starred) part from saved points register:
%    \begin{macrocode}
\newcommand{\extractpoints}{\@ifstar{\exf@extractpoints\@secondoftwo}%
  {\exf@extractpoints\@firstoftwo}}
\newcommand{\exf@extractpoints}[2]{\edef\exf@tmp{#2}%
  \exf@exptwo\exf@scanpoints\exf@tmp\exf@tmp++@%
  \expandafter#1\exf@tmp}
%    \end{macrocode}

% \macro{\switchpoints}
% Extract main (plain) and bonus (starred) part from points,
% and execute one of three:
%    \begin{macrocode}
\newcommand{\switchpoints}[5]{\edef\exf@tmp{#5}%
  \exf@exptwo\exf@scanpoints\exf@tmp\exf@tmp++@%
  \expandafter\exf@switchpoints\exf@tmp{#1}{#2}{#3}{#4}}
\newcommand{\exf@switchpoints}[6]{%
  \ifdim#2pt=0pt\ifdim#1pt=0pt\def\exf@tmp##1##2{#6}%
   \else\def\exf@tmp##1##2{#3}\fi%
  \else\ifdim#1pt=0pt\def\exf@tmp##1##2{#4}%
   \else\def\exf@tmp##1##2{#5}\fi\fi\exf@tmp{#1}{#2}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Tools.}
%
% \macro{\exf@makepointsmargin}
% Combination to typeset points in margin:
%    \begin{macrocode}
\newcommand{\exf@makepointsmargin}[2]{%
  \exf@config@insertpointsmargin{\exf@config@composepointspairmargin{#1}{#2}}}
%    \end{macrocode}

% \macro{\exf@warnmismatch}
% If points |#3| and |#4| are defined and disagree,
% issue a warning message:
%    \begin{macrocode}
\newcommand{\exf@warnmismatch}[4]{%
  \ifdefined#4\ifdefined#3\exf@pointsmismatch#3#4{%
   \let\exf@tmp\PackageWarning%
   \ifx#1\exf@solutionname\let\exf@tmp\PackageWarningNoLine\fi%
   \exf@tmp{exframe}{points mismatch %
    (\expandafter\exf@formatpoints#3 determined %
    vs. \expandafter\exf@formatpoints#4 given) %
    for #1 \csname the#2\endcsname}%
   \ifexf@warntext\edef\exf@tmp{%
    {\expandafter\exf@formatpoints#3}{\expandafter\exf@formatpoints#4}}%
    \exf@exptwo\exf@config@insertwarnpoints#1\exf@tmp\fi}%
  \fi\fi}
%    \end{macrocode}
%
% \macro{\exf@warnrerun}
% If points |#3| and |#4| are defined and disagree,
% issue advice to recompile:
%    \begin{macrocode}
\newcommand{\exf@warnrerun}[4]{%
  \ifdefined#4\ifdefined#3\exf@pointsmismatch#3#4{%
   \PackageWarning{exframe}{points changed %
    for #1 \csname the#2\endcsname; rerun to fix}%
   \ifexf@warntext\exf@config@insertwarnpointsrerun#1\fi}%
  \fi\fi}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Binary Rational Numbers.}
%
% \macro{\exf@splitsign}
% \macro{\exf@splitdecimal}
% Split a decimal float number into sign, integer and fractional part:
%    \begin{macrocode}
\def\exf@splitsign#1-#2-#3&{\def\exf@splitnum{#1#2}\def\exf@splitminus{#3}}
\def\exf@splitdecimal#1.#2.#3&{\def\exf@splitint{#1}\def\exf@splitdec{#2}}
%    \end{macrocode}

% \macro{\showfracpoints}
% Display a float number as a fraction
% with denominators 2, 4 or 8 when possible;
% first split number, complete missing zeros and handle cases:
%    \begin{macrocode}
\newcommand{\showfracpoints}[1]{%
  \edef\exf@tmp{#1}%
  \expandafter\exf@splitsign\exf@tmp--&%
  \expandafter\exf@splitdecimal\exf@splitnum..&%
  \if @\exf@splitint @\def\exf@splitint{0}\fi%
  \if @\exf@splitdec @\def\exf@splitdec{0}\fi%
  \def\exf@tmp{\exf@splitint.\exf@splitdec}%
  \ifnum\exf@splitdec=0\def\exf@tmp{\exf@splitint}\fi%
  \ifnum\exf@splitdec=5\def\exf@tmp{\exf@config@frac{\exf@splitint}{1}{2}}\fi%
  \ifnum\exf@splitdec=25\def\exf@tmp{\exf@config@frac{\exf@splitint}{1}{4}}\fi%
  \ifnum\exf@splitdec=75\def\exf@tmp{\exf@config@frac{\exf@splitint}{3}{4}}\fi%
  \ifnum\exf@splitdec=125\def\exf@tmp{\exf@config@frac{\exf@splitint}{1}{8}}\fi%
  \ifnum\exf@splitdec=375\def\exf@tmp{\exf@config@frac{\exf@splitint}{3}{8}}\fi%
  \ifnum\exf@splitdec=625\def\exf@tmp{\exf@config@frac{\exf@splitint}{5}{8}}\fi%
  \ifnum\exf@splitdec=875\def\exf@tmp{\exf@config@frac{\exf@splitint}{7}{8}}\fi%
  \ifx\exf@splitminus\exf@empty\else$\exf@splitminus$\fi\exf@tmp%
}
%    \end{macrocode}

% \macro{\exf@config@frac}
% Display a vulgar fraction
% such as 12$^3\mskip-4mu/\mskip-2mu_4$:
%    \begin{macrocode}
\newcommand{\exf@config@frac}[3]{%
  \ifnum#1=0\relax\else#1\fi%
  \ifnum#2=0\relax\else$%
   ^{\exf@text{#2}}%
   \mskip-4mu/\mskip-2mu%
   _{\exf@text{#3}}$\fi}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Sheet Points Code.}
%
% \macro{\exf@notedata@sheetpoints}
% Store a sheet point number in a macro:
%    \begin{macrocode}
\newcommand{\exf@notedata@sheetpoints}[2]{%
  \exf@csdo\gdef{exf@sheetpoints@#1}{#2}}
%    \end{macrocode}
% \macro{\exf@writesheetpoints}
% Write sheet points to the |.aux| file:
%    \begin{macrocode}
\newcommand{\exf@writesheetpoints}[2]%
  {\exf@writedata{sheetpoints}{\sheettag}{\exf@formatpoints{#1}{#2}}}
%    \end{macrocode}
% \macro{\getsheetpoints}
% Read points for current sheet or from |.aux| file:
%    \begin{macrocode}
\newcommand{\getsheetpoints}[1]{\if @#1@%
   \ifdefined\exf@sheet@points%
    \expandafter\exf@formatpoints\exf@sheet@points\else 0\fi%
  \else\exf@csor{exf@sheetpoints@#1}{0}\fi}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Problem Points Code.}
%
% \macro{\exf@notedata@problempoints}
% Store a problem point number in a macro:
%    \begin{macrocode}
\newcommand{\exf@notedata@problempoints}[2]{%
  \exf@csdo\gdef{exf@problempoints@#1}{#2}}
%    \end{macrocode}
% \macro{\exf@writeproblempoints}
% Write problem points to the |.aux| file:
%    \begin{macrocode}
\newcommand{\exf@writeproblempoints}[2]%
  {\exf@writedata{problempoints}{\problemtag}{\exf@formatpoints{#1}{#2}}}
%    \end{macrocode}
% \macro{\getproblempoints}
% Read points for current problem or from |.aux| file:
%    \begin{macrocode}
\newcommand{\getproblempoints}[1]{\if @#1@%
   \ifdefined\exf@problem@points%
    \expandafter\exf@formatpoints\exf@problem@points\else 0\fi%
  \else\exf@csor{exf@problempoints@#1}{0}\fi}
%    \end{macrocode}

% \macro{\showpoints}
% Show points within a problem or subproblem:
%    \begin{macrocode}
\newcommand{\showpoints}{%
  \ifdefined\exf@in@solution\exf@outpoints{\exf@ensuretext}%
   {\exf@config@composepointspairbodysolution}{\exf@solution@points@show}%
  \else\ifdefined\exf@in@subproblem\exf@outpoints{\exf@ensuretext}%
   {\exf@config@composepointspairbodysubproblem}{\exf@subproblem@points@show}%
  \else\ifdefined\exf@in@problem\exf@outpoints{\exf@ensuretext}%
   {\exf@config@composepointspairbodyproblem}{\exf@problem@points@show}%
  \fi\fi\fi}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Subproblem Points Code.}
%
% \macro{\exf@notedata@subproblempoints}
% Store a subproblem point number in a macro:
%    \begin{macrocode}
\newcommand{\exf@notedata@subproblempoints}[2]{%
  \exf@csdo\gdef{exf@subproblempoints@#1}{#2}}
%    \end{macrocode}
% \macro{\exf@writesubproblempoints}
% Write subproblem points to the |.aux| file:
%    \begin{macrocode}
\newcommand{\exf@writesubproblempoints}[2]%
  {\exf@writedata{subproblempoints}%
   {\subproblemtag}{\exf@formatpoints{#1}{#2}}}
%    \end{macrocode}
% \macro{\getsubproblempoints}
% Read points for current subproblem:
%    \begin{macrocode}
\newcommand{\getsubproblempoints}[1]{\if @#1@%
   \ifdefined\exf@subproblem@points%
    \expandafter\exf@formatpoints\exf@subproblem@points\else 0\fi%
  \else\exf@csor{exf@subproblempoints@#1}{0}\fi}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Solution Points Code.}
%
% \macro{\exf@awardpointsalt}
% Award points for alternative or optional solution;
% does not count towards solution total:
%    \begin{macrocode}
\newcommand{\exf@awardpointsalt}[2][]{\exf@scanpoints\exf@tmp#2++@%
  \exf@exptwo\exf@ensuretext{%
   \expandafter\exf@config@composepointspairawardalt\exf@tmp{#1}}}
%    \end{macrocode}
% \macro{\exf@awardpointsreg}
% Award points for regular solution;
% counts towards solution total:
%    \begin{macrocode}
\newcommand{\exf@awardpointsreg}[2][]{\exf@scanpoints\exf@tmp#2++@%
  \exf@exptwo\exf@addtopoints\exf@solution@points@total\exf@tmp%
  \exf@scanpoints\exf@tmp#2++@%
  \exf@exptwo\exf@ensuretext{%
   \expandafter\exf@config@composepointspairaward\exf@tmp{#1}}}
%    \end{macrocode}
% \macro{\awardpoints}
% Award points within solution with optional starred form:
%    \begin{macrocode}
\newcommand{\awardpoints}{\@ifstar\exf@awardpointsalt\exf@awardpointsreg}
%    \end{macrocode}

% \macro{\getsolutionpoints}
% Read points for current solution:
%    \begin{macrocode}
\newcommand{\getsolutionpoints}[1]{\if @#1@%
   \ifdefined\exf@solution@points%
    \expandafter\exf@formatpoints\exf@solution@points\else 0\fi%
  \else 0\fi}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Tag Lists}
% \label{sec:imp-taglist}
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Loop Lists.}
%
% \macro{exerciseloop}
% \macro{exf@loopdepth}
% Counters for item number within list and depth of loop nesting:
%    \begin{macrocode}
\newcounter{exerciseloop}
\newcounter{exf@loopdepth}
%    \end{macrocode}

% \macro{exf@listwalk}
% Step through a list;
% call the callback function |#1| with current item |#2|:
%    \begin{macrocode}
\def\exf@listwalk#1#2{\if @#2@\def\exf@tmp{}\else%
  \def\exf@tmp{#1{#2}\exf@listwalk#1}\fi\exf@tmp}
%    \end{macrocode}

% \macro{\exerciseloop}
% Loop through a list of items in braces |#1|
% which is expanded first;
% store code |#2| to be executed in a callback function
% (need to use different callback function for each loop depth,
% callback function must be global to work within table cells);
% initialise item counter:
%    \begin{macrocode}
\newcommand{\exerciseloop}[2]{\addtocounter{exf@loopdepth}{1}%
  \setcounter{exerciseloop}{0}%
  \exf@csdo\gdef{exf@listcallback@\roman{exf@loopdepth}}##1%
   {\stepcounter{exerciseloop}#2}%
  \edef\exf@tmp{#1}%
  \exf@csdotwo\exf@exptwo\exf@listwalk%
   {exf@listcallback@\roman{exf@loopdepth}}\exf@tmp{}%
  \addtocounter{exf@loopdepth}{-1}}
%    \end{macrocode}
% \macro{\exerciseloopstr}
% Loop through list and save result to |\exerciseloopret|
% (or optional argument |#1|):
%    \begin{macrocode}
\newcommand{\exerciseloopstr}[3][\exerciseloopret]{%
  \def#1{}\exerciseloop{#2}{\protected@edef#1{#1#3}}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Lists Management.}
%
% \macro{\exf@notedata@sheet}
% Store a sheet tag:
%    \begin{macrocode}
\def\exf@sheetlist{}
\newcommand{\exf@notedata@sheet}[2]{%
  \xdef\exf@sheetlist{\exf@sheetlist{#1}}}
%    \end{macrocode}
% \macro{\exf@notedata@problem}
% Store a problem tag:
%    \begin{macrocode}
\def\exf@problemlist{}
\newcommand{\exf@notedata@problem}[2]{%
  \xdef\exf@problemlist{\exf@problemlist{#1}}%
  \if @#2@\else%
   \ifcsname exf@problemlist@#2\endcsname\else%
    \exf@csdo\gdef{exf@problemlist@#2}{}\fi%
   \exf@csdo\xdef{exf@problemlist@#2}%
    {\csname exf@problemlist@#2\endcsname{#1}}%
  \fi}
%    \end{macrocode}
% \macro{\exf@notedata@subproblem}
% Store a subproblem tag:
%    \begin{macrocode}
\newcommand{\exf@notedata@subproblem}[2]{%
  \ifcsname exf@subproblemlist@#2\endcsname\else%
   \exf@csdo\gdef{exf@subproblemlist@#2}{}\fi%
  \exf@csdo\xdef{exf@subproblemlist@#2}%
   {\csname exf@subproblemlist@#2\endcsname{#1}}}
%    \end{macrocode}

% \macro{\getsheetlist}
% \macro{\getproblemlist}
% \macro{\getsubproblemlist}
% Get list of sheet tags,
% problem tags (all, within current or particular sheet),
% subproblem tags (within current or particular problem):
%    \begin{macrocode}
\newcommand{\getsheetlist}[1]{\exf@sheetlist}
\newcommand{\getproblemlist}[1]{\if @#1@%
  \ifdefined\sheettag\exf@csor{exf@problemlist@\sheettag}{}%
  \else\exf@problemlist\fi%
 \else%
  \if *#1\exf@problemlist\else\exf@csor{exf@problemlist@#1}{}\fi%
 \fi}
\newcommand{\getsubproblemlist}[1]{\if @#1@%
  \exf@csor{exf@subproblemlist@\problemtag}{}\else%
  \exf@csor{exf@subproblemlist@#1}{}\fi}
%    \end{macrocode}


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Sheet Environment}
% \label{sec:imp-sheet}
%
% \macro{exf@sheet}
% Define options for |sheet| environment:
%    \begin{macrocode}
\define@key{exf@sheet}{points}{\exf@scanpoints\exf@sheet@points#1++@}
\define@key{exf@sheet}{number}{\setcounter{\exf@sheetcounter}{#1}%
  \addtocounter{\exf@sheetcounter}{-1}\refstepcounter{\exf@sheetcounter}}
\define@key{exf@sheet}{label}{\def\exf@label{#1}}
\define@key{exf@sheet}{tag}{\def\sheettag{#1}}
%    \end{macrocode}

% \macro{sheet}
% Define |sheet| environment (potentially using custom name):
%    \begin{macrocode}
\newenvironment{\exf@sheetname}[1][]{%
%    \end{macrocode}
% Insert hook code to clear page, step counter:
%    \begin{macrocode}
  \exf@config@insertsheetclearpage%
  \refstepcounter{\exf@sheetcounter}%
%    \end{macrocode}
% Use equation counter for sheets:
%    \begin{macrocode}
  \ifexf@style@sheetequation%
   \exf@eqsav\value{equation}\relax%
   \setcounter{equation}{\value{exf@sheetequation}}%
   \let\theequation\theexf@sheetequation%
   \let\theHequation\theHexf@sheetequation%
  \fi%
%    \end{macrocode}
% Reset optional arguments, process arguments:
%    \begin{macrocode}
  \let\exf@sheet@points\@undefined%
  \def\sheettag{\getexerciseconfig{tagsheet}}%
  \let\exf@sheet@points@total\@undefined%
  \let\exf@label\@undefined%
  \setkeys{exf@sheet}{#1}%
%    \end{macrocode}
% Process automatic and manual labels:
%    \begin{macrocode}
  \ifexf@autolabelsheet\label{\exf@config@labelsheet{\sheettag}}\fi%
  \ifdefined\exf@label\label{\exf@label}\fi%
  \exf@writedata{sheet}{\sheettag}{}%
%    \end{macrocode}
% Set points from explicit input or from |.aux| storage:
%    \begin{macrocode}
  \ifdefined\exf@sheet@points%
   \let\exf@sheet@points@given\exf@empty%
  \else%
   \let\exf@sheet@points@given\@undefined%
   \ifcsname exf@sheetpoints@\sheettag\endcsname%
    \exf@csdotwo\let\exf@tmp{exf@sheetpoints@\sheettag}%
    \exf@exptwo\exf@scanpoints\exf@sheet@points\exf@tmp++@%
  \fi\fi%
%    \end{macrocode}
% Process metadata:
%    \begin{macrocode}
  \exf@ifis\exf@metadata{sheet}{{%
   \ifx\exf@data@sheet@author\exf@empty\else%
    \let\exf@data@author\exf@data@sheet@author\fi%
   \def\exf@data@title{\exf@config@composemetasheet%
    {\csname the\exf@sheetcounter\endcsname}{\exf@data@sheet@rawtitle}}%
   \exf@writemetadata}\gdef\exf@metadata{off}}%
%    \end{macrocode}
% Insert hook code:
%    \begin{macrocode}
  \exf@config@insertsheetbefore%
%    \end{macrocode}
% Add table of contents line:
%    \begin{macrocode}
  \ifx\exf@config@toclevelsheet\exf@empty\else%
   \ifdefined\phantomsection\phantomsection\fi\fi%
  \exf@addcontentsline{\exf@config@toclevelsheet}%
   {\exf@config@composetocsheet{\csname the\exf@sheetcounter\endcsname}%
    {\exf@data@sheet@rawtitle}}%
%    \end{macrocode}
% Write sheet title:
%    \begin{macrocode}
  \exf@config@insertsheettitle}%
%    \end{macrocode}
% End of environment;
% perform sanity check on total points if given explicitly:
%    \begin{macrocode}
 {\ifdefined\exf@sheet@points@given%
   \exf@warnmismatch{\exf@sheetname}{\exf@sheetcounter}%
    {\exf@sheet@points@total}{\exf@sheet@points}%
%    \end{macrocode}
% Test whether points have changed since last compile:
%    \begin{macrocode}
  \else%
   \exf@warnrerun{\exf@sheetname}{\exf@sheetcounter}%
    {\exf@sheet@points@total}{\exf@sheet@points}%
%    \end{macrocode}
% Store points:
%    \begin{macrocode}
   \let\exf@sheet@points\exf@sheet@points@total%
  \fi%
%    \end{macrocode}
% Write sheet points to |.aux| file:
%    \begin{macrocode}
  \ifdefined\exf@sheet@points%
   \expandafter\exf@writesheetpoints\exf@sheet@points%
  \fi%
%    \end{macrocode}
% Insert solutions:
%    \begin{macrocode}
  \exf@ifis\exf@solutionbelow{sheet}{\insertsolutions}%
%    \end{macrocode}
% Insert hook code:
%    \begin{macrocode}
  \exf@config@insertsheetafter%
  \exf@config@insertsheetclearpage%
%    \end{macrocode}
% Restore original equation counter:
%    \begin{macrocode}
  \ifexf@style@sheetequation%
   \setcounter{exf@sheetequation}{\value{equation}}%
   \setcounter{equation}{\exf@eqsav}%
  \fi%
%    \end{macrocode}
% Done:
%    \begin{macrocode}
  \ignorespacesafterend}
%    \end{macrocode}

% \macro{\exercisecleardoublepage}
% Clear the current page, clear even page with a totally empty page:
%    \begin{macrocode}
\newcommand{\exercisecleardoublepage}{%
  \clearpage\ifexf@twoside\ifodd\value{page}\else%
  \thispagestyle{empty}\hbox{}\newpage\fi\fi}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Problem Environment}
% \label{sec:imp-problem}
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Print Problems.}
%
% \macro{exf@problem}
% Define options for |problem| environment:
%    \begin{macrocode}
\define@key{exf@problem}{points}{\exf@scanpoints\exf@problem@points#1++@}
\define@key{exf@problem}{label}{\def\exf@label{#1}}
\define@key{exf@problem}{tag}{\def\problemtag{#1}}
\define@key{exf@problem}{sollabel}{\xdef\exf@sollabel{#1}}
%    \end{macrocode}

% \macro{printproblem}
% Define |printproblem| environment:
%    \begin{macrocode}
\newenvironment{printproblem}[1]{%
%    \end{macrocode}
% Start with new paragraph, set text style, add vspace:
%    \begin{macrocode}
  \par\exf@config@styletext\addvspace{\exf@config@skipproblemabove}%
%    \end{macrocode}
% Step problem counter:
%    \begin{macrocode}
  \refstepcounter{\exf@problemcounter}%
%    \end{macrocode}
% Insert hook code:
%    \begin{macrocode}
  \exf@config@insertproblembefore%
%    \end{macrocode}
% Begin inner group, mark in problem:
%    \begin{macrocode}
  \begingroup%
  \def\exf@in@problem{}%
%    \end{macrocode}
% Use equation counter for problems:
%    \begin{macrocode}
  \ifexf@style@problemequation%
   \exf@eqsav\value{equation}\relax%
   \setcounter{equation}{\value{exf@problemequation}}%
   \let\theequation\theexf@problemequation%
   \let\theHequation\theHexf@problemequation%
  \fi%
%    \end{macrocode}
% Initialise variables, process arguments:
%    \begin{macrocode}
  \exf@init@block{\exf@config@skipprobleminfo}%
  \def\problemtag{\getexerciseconfig{tagproblem}}%
  \let\exf@problem@points\@undefined%
  \let\exf@label\@undefined%
  \global\let\exf@sollabel\@undefined%
  \let\exf@problem@points@total\@undefined%
  \setkeys{exf@problem,exf@probleminfo,exf@scanproblem}{#1}%
%    \end{macrocode}
% Process automatic and manual labels:
%    \begin{macrocode}
  \ifexf@autolabelproblem\label{\exf@config@labelproblem{\problemtag}}\fi%
  \ifdefined\exf@label\label{\exf@label}\fi%
  \exf@writedata{problem}{\problemtag}{\ifdefined\sheettag\sheettag\fi}%
%    \end{macrocode}
% Mark for new solution section; remember problem counter, title:
%    \begin{macrocode}
  \gdef\exf@problem@solnewsec{}%
  \xdef\exf@prevprob{\csname the\exf@problemcounter\endcsname}%
  \ifcsname theH\exf@problemcounter\endcsname%
   \xdef\exf@prevprobhref{\exf@problemcounter.%
    \csname theH\exf@problemcounter\endcsname}%
  \fi%
  \ifx\exf@data@problem@rawtitle\exf@empty%
   \global\let\exf@prevprobtitle\@undefined%
  \else%
   \protected@xdef\exf@prevprobtitle{\exf@data@problem@rawtitle}%
  \fi%
  \global\let\exf@prevsubprob\@undefined%
  \global\let\exf@prevsubprobhref\@undefined%
%    \end{macrocode}
% Set points from explicit input or from |.aux| storage:
%    \begin{macrocode}
  \ifdefined\exf@problem@points%
   \let\exf@problem@points@given\exf@empty%
  \else%
   \let\exf@problem@points@given\@undefined%
   \ifcsname exf@problempoints@\problemtag\endcsname%
    \exf@csdotwo\let\exf@tmp{exf@problempoints@\problemtag}%
    \exf@exptwo\exf@scanpoints\exf@problem@points\exf@tmp++@%
  \fi\fi%
  \global\let\exf@prevpoints\exf@problem@points%
  \let\exf@problem@points@show\@undefined%
  \ifdefined\exf@problem@points%
   \let\exf@problem@points@show\exf@problem@points%
  \fi%
%    \end{macrocode}
% Disable points display if desired:
%    \begin{macrocode}
  \exf@ifis\exf@pointsat{off}{\let\exf@problem@points@show\@undefined}%
%    \end{macrocode}
% Display points in opening line if desired;
% expand points into argument and remove points:
%    \begin{macrocode}
  \exf@ifis\exf@pointsat{start}{\exf@outpoints{\exf@append@intro}%
   {\exf@config@composepointspairstartproblem}{\exf@problem@points@show}}%
  \exf@ifis\exf@pointsat{start*}{\exf@outpoints{\exf@prepend@intro}%
   {\exf@config@composepointspairstartproblem}{\exf@problem@points@show}}%
%    \end{macrocode}
% Insert hook code, set problem body style:
%    \begin{macrocode}
  \exf@config@insertprobleminfo%
  \exf@config@styletextproblem%
%    \end{macrocode}
% Write title without item:
%    \begin{macrocode}
  \ifdim\exf@config@skipproblemitem=0pt%
   \exf@prepend@intro{{%
    \exf@config@styletitle\exf@config@styletitleproblem%
    \exf@config@composetitleproblem{\csname the\exf@problemcounter\endcsname}%
     {\exf@data@problem@rawtitle}}}%
%    \end{macrocode}
% Write item with fixed total width or item width plus space:
%    \begin{macrocode}
  \else%
   \ifdim\exf@config@skipproblemitem>0pt%
    \setlength\exf@addmargin{\exf@config@skipproblemitem}%
   \else%
    \settowidth\exf@addmargin{%
     \exf@config@styletitle\exf@config@styletitleproblem%
     \exf@config@composeitemproblem{\exf@config@counterproblemmax}%
     \exf@config@composeitemproblemsep}%
   \fi%
%    \end{macrocode}
% Define item label:
%    \begin{macrocode}
   \def\exf@introitem{\makebox[0cm][r]{%
    \exf@config@styletitle\exf@config@styletitleproblem%
    \exf@config@composeitemproblem{\csname the\exf@problemcounter\endcsname}%
     \exf@config@composeitemproblemsep}}%
%    \end{macrocode}
% Compose title:
%    \begin{macrocode}
   \ifx\exf@data@problem@rawtitle\exf@empty\else%
    \exf@prepend@intro{{%
     \exf@config@styletitle\exf@config@styletitleproblem%
     \exf@config@composetitleproblem{\exf@empty}{\exf@data@problem@rawtitle}}}%
   \fi%
  \fi%
%    \end{macrocode}
% Write points into margin if desired;
% expand points into argument and remove points:
%    \begin{macrocode}
  \exf@ifis\exf@pointsat{margin}{%
   \exf@outpoints{\exf@prepend@def\exf@introitem}%
   {\exf@makepointsmargin}{\exf@problem@points@show}}%
%    \end{macrocode}
% Write out opening line:
%    \begin{macrocode}
  \exf@open@block{\exf@config@skipproblemtitle}%
%    \end{macrocode}
% Add table of contents line:
%    \begin{macrocode}
  \exf@addcontentsline{\exf@config@toclevelproblem}%
   {\exf@config@composetocproblem{\csname the\exf@problemcounter\endcsname}%
    {\exf@data@problem@rawtitle}}%
%    \end{macrocode}
% Done:
%    \begin{macrocode}
  \@afterindentfalse}%
%    \end{macrocode}
% End environment, show points if desired:
%    \begin{macrocode}
 {\exf@ifis\exf@pointsat{end}{\showpoints}%
%    \end{macrocode}
% Perform sanity checks on total points if given explicitly:
%    \begin{macrocode}
  \ifdefined\exf@problem@points@given%
   \exf@warnmismatch{\exf@problemname}{\exf@problemcounter}%
    {\exf@problem@points@total}{\exf@problem@points}%
%    \end{macrocode}
% Warn if calculated total points have changed:
%    \begin{macrocode}
  \else%
   \exf@warnrerun{\exf@problemname}{\exf@problemcounter}%
    {\exf@problem@points@total}{\exf@problem@points}%
%    \end{macrocode}
% Read computed total points:
%    \begin{macrocode}
   \let\exf@problem@points\exf@problem@points@total%
  \fi%
%    \end{macrocode}
% Write points to |.aux| file; add to sheet total:
%    \begin{macrocode}
  \ifdefined\exf@problem@points%
   \expandafter\exf@writeproblempoints\exf@problem@points%
   \exf@exptwo\exf@addtopoints\exf@sheet@points@total\exf@problem@points%
%    \end{macrocode}
% Warn if no points given for present problem but previously:
%    \begin{macrocode}
  \else\ifdefined\exf@sheet@points@total%
   \PackageWarning{exframe}{no points defined for \exf@problemname}%
  \fi\fi%
%    \end{macrocode}
% Solutions to subproblems must be declared within problem environment:
%    \begin{macrocode}
  \global\let\exf@prevsubprob\@undefined%
  \global\let\exf@prevsubprobhref\@undefined%
%    \end{macrocode}
% End paragraph and environment:
%    \begin{macrocode}
  \par\exf@close@block%
%    \end{macrocode}
% Display solution if desired:
%    \begin{macrocode}
  \exf@ifis\exf@solutionbelow{problem}{%
   \exf@config@insertproblemsolution%
   \exf@showsolutions{\exf@config@composetitlesolutionmulti}{}}%
%    \end{macrocode}
% Restore original equation counter:
%    \begin{macrocode}
  \ifexf@style@problemequation%
   \setcounter{exf@problemequation}{\value{equation}}%
   \setcounter{equation}{\exf@eqsav}%
  \fi%
%    \end{macrocode}
% End inner group:
%    \begin{macrocode}
  \endgroup%
%    \end{macrocode}
% Insert hook code, vertical skip:
%    \begin{macrocode}
  \exf@config@insertproblemafter%
  \addvspace{\exf@config@skipproblembelow}%
%    \end{macrocode}
% Display solution if desired:
%    \begin{macrocode}
  \exf@ifis\exf@solutionbelow{problem*}{%
   \exf@showsolutions{\exf@config@composetitlesolutionmulti}{}}%
%    \end{macrocode}
% Done:
%    \begin{macrocode}
  \ignorespacesafterend}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Read Problem Environment.}
%
% \macro{exf@scanproblem}
% Define options for |problem| environment:
%    \begin{macrocode}
\define@boolkey{exf@scanproblem}[exf@scanproblem@]{disable}[true]{}
%    \end{macrocode}

% \macro{exf@problem@direct}
% Define direct output version of |problem| environment;
% pass on to |printproblem| environment:
%    \begin{macrocode}
\newenvironment{exf@problem@direct}[1][]%
 {\printproblem{#1}}{\endprintproblem\ignorespacesafterend}
%    \end{macrocode}

% \macro{exf@problem@scan}
% \macro{exf@scanproblem}
% Define scan version of |problem| environment;
% use |\exf@scanblock| to properly parse optional argument
% and pass on to |exf@scanproblem|:
%    \begin{macrocode}
\newenvironment{exf@problem@scan}%
 {\exf@scanblock{\exf@scanproblem}}{\endexf@scanproblem}%
\newenvironment{exf@scanproblem}[2]{%
%    \end{macrocode}
% Determine problem display:
%    \begin{macrocode}
  \exf@scanproblem@disablefalse%
  \setkeys*{exf@scanproblem}{#1}%
  \exf@config@insertproblemselect{#1}%
%    \end{macrocode}
% Write separator and |printproblem| environment to buffer:
%    \begin{macrocode}
  \ifexf@scanproblem@disable%
   \def\exf@verbatim@process{\@gobble}%
  \else%
   \ifexf@lineno\exf@addline\exf@probbuf{\exf@linesep}%
    \exf@addline\exf@probbuf{\exf@lineno}\fi%
   \exf@addline\exf@probbuf%
    {\@backslashchar begin{printproblem}{#1}}%
   \def\exf@verbatim@process{\exf@append@buf\exf@probbuf}%
  \fi%
%    \end{macrocode}
% Start verbatim processing:
%    \begin{macrocode}
  \exf@verbatim#2}%
%    \end{macrocode}
% End verbatim processing; close |printproblem| environment:
%    \begin{macrocode}
 {\exf@endverbatim%
  \ifexf@scanproblem@disable\else%
   \exf@addline\exf@probbuf{\@backslashchar end{printproblem}}%
   \global\exf@probbuf@cleanfalse%
  \fi%
%    \end{macrocode}
% Write buffer to file if output file open:
%    \begin{macrocode}
  \ifexf@probfile@open%
   \exf@write@buf\exf@probfile\exf@probbuf%
   \exf@clear@probbuf%
  \fi%
%    \end{macrocode}
% Output buffer immediately:
%    \begin{macrocode}
  \ifexf@problemmanual\else%
   \exf@source@buf\exf@probbuf%
   \exf@clear@probbuf%
  \fi%
%    \end{macrocode}
% Done:
%    \begin{macrocode}
  \ignorespacesafterend}
%    \end{macrocode}

% \macro{problem}
% Define |problem| environment
% (potentially using custom name)
% to choose between direct and buffered version:
%    \begin{macrocode}
\newenvironment{\exf@problemname}%
 {\ifexf@problembuf\let\exf@tmp\exf@problem@scan%
  \else\let\exf@tmp\exf@problem@direct\fi%
  \exf@tmp}%
 {\ifexf@problembuf\let\exf@tmp\endexf@problem@scan%
  \else\let\exf@tmp\endexf@problem@direct\fi%
  \exf@tmp}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Problem Blocks}
% \label{sec:imp-problems}
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Problem Block Handling.}
%
% \macro{\exf@problemstitle}
% Compose the title for a problem block section:
%    \begin{macrocode}
\newcommand{\exf@problemstitle}{%
%    \end{macrocode}
% Check whether title is empty:
%    \begin{macrocode}
  \protected@edef\exf@problemstitleexp{\exf@config@composetitleproblems}%
  \ifx\exf@problemstitleexp\exf@empty\else%
%    \end{macrocode}
% Output section line:
%    \begin{macrocode}
   \exf@section{\exf@config@skipproblemstitle}%
    {\exf@config@styletitle\exf@config@styletitleproblems%
     \exf@problemstitleexp}%
   \exf@addcontentsline{\exf@config@toclevelproblems}%
    {\exf@config@composetocproblems}%
  \fi}
%    \end{macrocode}

% \macro{\exf@showproblemsin}
% Output problem block intro:
%    \begin{macrocode}
\newcommand{\exf@showproblemsin}{%
%    \end{macrocode}
% Set problem body style; add vertical space; insert hook code:
%    \begin{macrocode}
  \par\exf@config@styletext\addvspace{\exf@config@skipproblemsabove}%
  \exf@config@insertproblemsbefore}
%    \end{macrocode}

% \macro{\exf@showproblemsout}
% Output problem block outro:
%    \begin{macrocode}
\newcommand{\exf@showproblemsout}{%
%    \end{macrocode}
% Insert hook code; close paragraph; add vertical space:
%    \begin{macrocode}
  \exf@config@insertproblemsafter%
  \par\exf@config@styletext\addvspace{\exf@config@skipproblemsbelow}}
%    \end{macrocode}

% \macro{\exf@showproblems}
% Output problem block in buffer:
%    \begin{macrocode}
\newcommand{\exf@showproblems}{%
%    \end{macrocode}
% Do nothing if buffer is empty (avoid titles):
%    \begin{macrocode}
  \ifexf@probbuf@clean\else\begingroup%
%    \end{macrocode}
% Execute output problem block intro:
%    \begin{macrocode}
   \exf@showproblemsin%
   \exf@problemstitle%
%    \end{macrocode}
% Source and clear buffer:
%    \begin{macrocode}
   \exf@source@buf\exf@probbuf%
   \exf@clear@probbuf%
%    \end{macrocode}
% Execute output problem block outro:
%    \begin{macrocode}
   \exf@showproblemsout%
  \endgroup\fi}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Problems Buffer Interface.}
%
% \macro{\writeproblems}
% Open a file |#1.prb| for writing problems;
% default is present main file name:
%    \begin{macrocode}
\newcommand{\writeproblems}[1][\jobname]{%
  \exf@close@probfile\exf@start@probfile{#1}}
%    \end{macrocode}

% \macro{\closeproblems}
% Close problems output file (if open):
%    \begin{macrocode}
\newcommand{\closeproblems}{\exf@close@probfile}
%    \end{macrocode}

% \macro{\readproblems}
% Read problems from file |#1.prb|;
% default is present main file name;
% switch layout and add heading:
%    \begin{macrocode}
\newcommand{\readproblems}[1][\jobname]{\exf@close@probfile%
  \begingroup%
   \exf@config@styletext\exf@config@styletextproblem%
   \exf@problemstitle%
   \input{#1\exf@config@extproblems}%
  \endgroup}
%    \end{macrocode}

% \macro{\insertproblems}
% Show problems buffer:
%    \begin{macrocode}
\newcommand{\insertproblems}{\exf@showproblems}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Subproblem Environment}
% \label{sec:imp-subproblem}
%
% \macro{exf@subproblem}
% Define options for |subproblem| environment:
%    \begin{macrocode}
\define@key{exf@subproblem}{points}{\exf@scanpoints\exf@subproblem@points#1++@}
\define@key{exf@subproblem}{label}{\def\exf@label{#1}}
\define@key{exf@subproblem}{tag}{\def\subproblemtag{#1}}
%    \end{macrocode}

% \macro{subproblem}
% Define |subproblem| environment (potentially using custom name):
%    \begin{macrocode}
\newenvironment{\exf@subproblemname}[1][]{%
%    \end{macrocode}
% Start with new paragraph, set text style, add vspace and step counter:
%    \begin{macrocode}
  \par{\exf@config@styletext\addvspace{\exf@config@skipsubproblemabove}}%
  \refstepcounter{\exf@subproblemcounter}%
%    \end{macrocode}
% Insert hook code:
%    \begin{macrocode}
  \exf@config@insertsubproblembefore%
%    \end{macrocode}
% Start inner group, mark in subproblem:
%    \begin{macrocode}
  \begingroup%
  \def\exf@in@subproblem{}%
%    \end{macrocode}
% Initialise variables, process arguments:
%    \begin{macrocode}
  \exf@init@block{\exf@config@skipsubprobleminfo}%
  \def\subproblemtag{\getexerciseconfig{tagsubproblem}}%
  \let\exf@subproblem@points\@undefined%
  \let\exf@label\@undefined%
  \setkeys{exf@subproblem,exf@probleminfo}{#1}%
%    \end{macrocode}
% Process automatic and manual labels:
%    \begin{macrocode}
  \ifexf@autolabelproblem\label{\exf@config@labelsubproblem%
   {\subproblemtag}}\fi%
  \ifdefined\exf@label\label{\exf@label}\fi%
  \exf@writedata{subproblem}{\subproblemtag}{\problemtag}%
%    \end{macrocode}
% Remember subproblem counter for solution:
%    \begin{macrocode}
  \xdef\exf@prevsubprob{\csname the\exf@subproblemcounter\endcsname}%
  \ifcsname theH\exf@subproblemcounter\endcsname%
   \xdef\exf@prevsubprobhref{\exf@subproblemcounter.%
    \csname theH\exf@subproblemcounter\endcsname}%
  \fi%
%    \end{macrocode}
% Remember points for display;
% disable points display if desired:
%    \begin{macrocode}
  \let\exf@subproblem@points@show\@undefined%
  \ifdefined\exf@subproblem@points%
   \let\exf@subproblem@points@show\exf@subproblem@points\fi%
  \exf@ifis\exf@subpointsat{off}{\let\exf@subproblem@points@show\@undefined}%
%    \end{macrocode}
% Write points to |.aux| file; add to problem total:
%    \begin{macrocode}
  \ifdefined\exf@subproblem@points%
   \global\let\exf@prevpoints\exf@subproblem@points%
   \expandafter\exf@writesubproblempoints\exf@subproblem@points%
   \exf@exptwo\exf@addtopoints\exf@problem@points@total\exf@subproblem@points%
%    \end{macrocode}
% Warn if no points given for present subproblem but previously:
%    \begin{macrocode}
  \else\ifdefined\exf@problem@points@total%
   \PackageWarning{exframe}{no points defined for \exf@subproblemname}%
  \fi\fi%
%    \end{macrocode}
% Display points in opening line if desired;
% expand points into argument and remove points:
%    \begin{macrocode}
  \exf@ifis\exf@subpointsat{start}{\exf@outpoints{\exf@append@intro}%
   {\exf@config@composepointspairstartsubproblem}{\exf@subproblem@points@show}}%
  \exf@ifis\exf@subpointsat{start*}{\exf@outpoints{\exf@prepend@intro}%
   {\exf@config@composepointspairstartsubproblem}{\exf@subproblem@points@show}}%
%    \end{macrocode}
% Insert hook code:
%    \begin{macrocode}
  \exf@config@insertsubprobleminfo%
%    \end{macrocode}
% Write opening line without item:
%    \begin{macrocode}
  \ifdim\exf@config@skipsubproblemitem=0pt%
   \exf@prepend@intro{{%
    \exf@config@styletitle\exf@config@styletitlesubproblem%
    \exf@config@composetitlesubproblem{%
     \csname the\exf@subproblemcounter\endcsname}}}%
%    \end{macrocode}
% Write item with fixed total width or item width plus space:
%    \begin{macrocode}
  \else%
   \ifdim\exf@config@skipsubproblemitem>0pt%
    \setlength\exf@addmargin{\exf@config@skipsubproblemitem}%
   \else%
    \settowidth\exf@addmargin{%
     \exf@config@styletitle\exf@config@styletitlesubproblem%
     \exf@config@composeitemsubproblem{\exf@config@countersubproblemmax}%
     \exf@config@composeitemsubproblemsep}%
   \fi%
%    \end{macrocode}
% Define item label:
%    \begin{macrocode}
   \def\exf@introitem{\makebox[0cm][r]{%
    \exf@config@styletitle\exf@config@styletitlesubproblem%
    \exf@config@composeitemsubproblem%
     {\csname the\exf@subproblemcounter\endcsname}%
    \exf@config@composeitemsubproblemsep}}%
  \fi%
%    \end{macrocode}
% Write points into margin if desired;
% expand points into argument and remove points:
%    \begin{macrocode}
  \exf@ifis\exf@subpointsat{margin}{%
   \exf@outpoints{\exf@prepend@def\exf@introitem}%
   {\exf@makepointsmargin}{\exf@subproblem@points@show}}%
%    \end{macrocode}
% Write out opening line:
%    \begin{macrocode}
  \exf@open@block{\exf@config@skipsubproblemtitle}%
%    \end{macrocode}
% Done:
%    \begin{macrocode}
  \@afterindentfalse}%
%    \end{macrocode}
% End environment, show points if desired:
%    \begin{macrocode}
 {\exf@ifis\exf@subpointsat{end}{\showpoints}%
%    \end{macrocode}
% End paragraph and environment:
%    \begin{macrocode}
  \par\exf@close@block%
%    \end{macrocode}
% Display solution if desired:
%    \begin{macrocode}
  \exf@ifis\exf@solutionbelow{subproblem*}{%
   \exf@config@insertsubproblemsolution%
   \exf@showsolutions{\exf@config@composetitlesolutionsingle}{}}%
%    \end{macrocode}
% End inner group:
%    \begin{macrocode}
  \endgroup%
%    \end{macrocode}
% Insert hook code, vertical skip:
%    \begin{macrocode}
  \exf@config@insertsubproblemafter%
  {\exf@config@styletext\addvspace{\exf@config@skipsubproblembelow}}%
%    \end{macrocode}
% Display solution if desired:
%    \begin{macrocode}
  \exf@ifis\exf@solutionbelow{subproblem}{%
   \exf@showsolutions{\exf@config@composetitlesolutionsingle}{}}%
%    \end{macrocode}
% Done:
%    \begin{macrocode}
  \ignorespacesafterend}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Solution Environment}
% \label{sec:imp-solution}
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Print Solutions.}
%
% \macro{exf@solution}
% Define options for |solution| environment:
%    \begin{macrocode}
\define@key{exf@solution}{prob}{\def\exf@solprob{#1}}
\define@key{exf@solution}{subprob}{\def\exf@solsubprob{#1}}
\define@key{exf@solution}{problemtag}{\def\problemtag{#1}}
\define@key{exf@solution}{sheettag}{\def\sheettag{#1}}
\define@key{exf@solution}{href}{\def\exf@solhref{#1}}
\define@key{exf@solution}{label}{\def\exf@label{#1}}
\define@key{exf@solution}{points}{\exf@scanpoints\exf@solution@points#1++@}
\define@key{exf@solution}{probtitle}{\def\exf@solprobtitle{#1}}
%    \end{macrocode}

% \macro{printsolution}
% Define |printsolution| environment
% to display a previously read |solution| environment;
% this works analogously to |problem| and |subproblem|:
%    \begin{macrocode}
\newenvironment{printsolution}[1]{%
%    \end{macrocode}
% Start new paragraph, add vertical space:
%    \begin{macrocode}
  \par{\exf@config@styletext\addvspace{\exf@config@skipsolutionabove}}%
%    \end{macrocode}
% Insert hook code:
%    \begin{macrocode}
  \exf@config@insertsolutionbefore%
%    \end{macrocode}
% Use equation counter for solutions:
%    \begin{macrocode}
  \ifexf@style@solutionequation%
   \exf@eqsav\value{equation}\relax%
   \setcounter{equation}{\value{exf@solutionequation}}%
   \let\theequation\theexf@solutionequation%
   \let\theHequation\theHexf@solutionequation%
  \fi%
%    \end{macrocode}
% Start a group, initialise variables, process arguments:
%    \begin{macrocode}
  \begingroup%
  \def\exf@in@solution{}%
  \def\exf@solprob{}%
  \def\exf@solsubprob{}%
  \let\exf@label\@undefined%
  \let\exf@solution@points\@undefined%
  \let\exf@solution@points@total\@undefined%
  \def\exf@solhref{}%
  \exf@init@block{\exf@config@skipsolutioninfo}%
  \setkeys{exf@solution,exf@probleminfo}{#1}%
%    \end{macrocode}
% Set solution counter to reflect associated problem:
%    \begin{macrocode}
  \exf@csdo\def{the\exf@solutioncounter}%
   {\exf@config@composeitemsolutionlabel{\exf@solprob}{\exf@solsubprob}}%
  \refstepcounter{\exf@solutioncounter}%
%    \end{macrocode}
% Set label:
%    \begin{macrocode}
  \ifdefined\exf@label\label{\exf@label}\fi%
%    \end{macrocode}
% Remember points for display;
% disable points display if desired:
%    \begin{macrocode}
  \let\exf@solution@points@show\@undefined%
  \ifdefined\exf@solution@points%
   \let\exf@solution@points@show\exf@solution@points\fi%
  \exf@ifis\exf@solpointsat{off}{\let\exf@solution@points@show\@undefined}%
%    \end{macrocode}
% Display points in opening line if desired;
% expand points into argument and remove points:
%    \begin{macrocode}
  \exf@ifis\exf@solpointsat{start}{\exf@outpoints{\exf@append@intro}%
   {\exf@config@composepointspairstartsolution}{\exf@solution@points@show}}%
  \exf@ifis\exf@solpointsat{start*}{\exf@outpoints{\exf@prepend@intro}%
   {\exf@config@composepointspairstartsolution}{\exf@solution@points@show}}%
%    \end{macrocode}
% Insert hook code, set solution body style:
%    \begin{macrocode}
  \exf@config@insertsolutioninfo%
  \exf@config@styletext\exf@config@styletextsolution%
%    \end{macrocode}
% Determine solution for problem or subproblem:
%    \begin{macrocode}
  \ifx\exf@solsubprob\exf@empty%
   \let\exf@tmp\exf@config@skipsolutionitem%
  \else%
   \let\exf@tmp\exf@config@skipsolutionitemsub%
  \fi%
%    \end{macrocode}
% Write title without item:
%    \begin{macrocode}
  \ifdim\exf@tmp=0pt%
   \protected@edef\exf@solution@title{%
    \exf@composetitle{\exf@solprob}{\exf@solsubprob}}%
   \ifx\exf@solution@title\exf@empty\else%
    \exf@prepend@intro{{%
     \exf@config@styletitle\exf@config@styletitlesolution%
     \ifexf@solutionhref\exf@href{\exf@solhref}%
      {\exf@solution@title}\else\exf@solution@title\fi}}%
   \fi%
%    \end{macrocode}
% Write item with fixed total width or item width plus space:
%    \begin{macrocode}
  \else%
   \ifdim\exf@tmp>0pt%
    \setlength\exf@addmargin{\exf@tmp}%
   \else%
    \settowidth\exf@addmargin{%
     \exf@config@styletitle\exf@config@styletitlesolution%
     \ifx\exf@solsubprob\exf@empty%
      \exf@config@composeitemsolution{\exf@config@counterproblemmax}%
       {\exf@config@countersubproblemmax}%
     \else%
      \exf@config@composeitemsolutionsub{\exf@config@counterproblemmax}%
       {\exf@config@countersubproblemmax}%
     \fi\exf@config@composeitemsolutionsep}%
   \fi%
%    \end{macrocode}
% Set item label depending on problem or subproblem:
%    \begin{macrocode}
   \ifx\exf@solsubprob\exf@empty%
    \protected@edef\exf@solution@item%
     {\exf@config@composeitemsolution{\exf@solprob}{\exf@empty}}%
   \else%
    \protected@edef\exf@solution@item%
     {\exf@config@composeitemsolutionsub{\exf@solprob}{\exf@solsubprob}}%
   \fi%
%    \end{macrocode}
% Define item label:
%    \begin{macrocode}
   \def\exf@introitem{\makebox[0cm][r]{%
    \exf@config@styletitle\exf@config@styletitlesubproblem%
    \ifexf@solutionhref\exf@href{\exf@solhref}{\exf@solution@item}%
    \else\exf@solution@item\fi%
    \exf@config@composeitemproblemsep}}%
  \fi%
%    \end{macrocode}
% Write points into margin if desired;
% expand points into argument and remove points:
%    \begin{macrocode}
  \exf@ifis\exf@solpointsat{margin}{%
   \exf@outpoints{\exf@prepend@def\exf@introitem}%
   {\exf@makepointsmargin}{\exf@solution@points@show}}%
%    \end{macrocode}
% Write out opening line:
%    \begin{macrocode}
  \exf@open@block{\exf@config@skipsolutiontitle}%
%    \end{macrocode}
% Done:
%    \begin{macrocode}
  \@afterindentfalse}%
%    \end{macrocode}
% End environment, show points if desired, perform sanity check:
%    \begin{macrocode}
 {\exf@ifis\exf@solpointsat{end}{\showpoints}%
  \exf@warnmismatch{\exf@solutionname}{\exf@solutioncounter}%
   {\exf@solution@points@total}{\exf@solution@points}%
%    \end{macrocode}
% End paragraph and envionment:
%    \begin{macrocode}
  \par\exf@close@block%
%    \end{macrocode}
% Restore original equation counter:
%    \begin{macrocode}
  \ifexf@style@solutionequation%
   \setcounter{exf@solutionequation}{\value{equation}}%
   \setcounter{equation}{\exf@eqsav}%
  \fi%
%    \end{macrocode}
% End inner group:
%    \begin{macrocode}
  \endgroup%
%    \end{macrocode}
% Vertical skip, insert hook code:
%    \begin{macrocode}
  {\exf@config@styletext\addvspace{\exf@config@skipsolutionbelow}}%
  \exf@config@insertsolutionafter%
%    \end{macrocode}
% Done:
%    \begin{macrocode}
  \ignorespacesafterend}
%    \end{macrocode}

% \macro{\solutionssection}
% Define a section for a problem within a solution block:
%    \begin{macrocode}
\newcommand{\solutionssection}[1]{\begingroup%
%    \end{macrocode}
% Initialise variables, process arguments:
%    \begin{macrocode}
  \def\exf@solprob{}%
  \def\exf@solsubprob{}%
  \def\exf@solprobtitle{}%
  \let\exf@label\@undefined%
  \let\exf@solhref\@undefined%
  \setkeys{exf@solution}{#1}%
%    \end{macrocode}
% Select title (and table of contents entry)
% corresponding to multiple problems vs.\ single problem:
%    \begin{macrocode}
  \let\exf@composetitle\exf@config@composetitlesolutionsproblemmulti%
  \exf@ifis\exf@solutionbelow{problem}{\let\exf@composetitle%
    \exf@config@composetitlesolutionsproblemsingle}%
  \exf@ifis\exf@solutionbelow{problem*}{\let\exf@composetitle%
    \exf@config@composetitlesolutionsproblemsingle}%
  \def\exf@solutionstoc{\exf@addcontentsline{\exf@config@toclevelsolution}%
    {\exf@config@composetocsolution{\exf@solprob}{\exf@solprobtitle}}}%
%    \end{macrocode}
% Write section line:
%    \begin{macrocode}
  \addvspace{\exf@config@skipsolutionsproblemabove}%
  \exf@solutionssection{\exf@config@styletitlesolutionsproblem}%
   {\exf@composetitle{\exf@solprob}{\exf@solprobtitle}}%
   {\exf@config@skipsolutionsproblemtitle}%
   {\exf@solutionstoc}{\exf@label}{\exf@solhref}%
  \endgroup}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Read Solution Environment.}
%
% \macro{\exf@process@solnewsec}
% If this is the first solution within a new section,
% write section heading to buffer:
%    \begin{macrocode}
\newcommand{\exf@process@solnewsec}{%
  \ifdefined\exf@problem@solnewsec%
   \def\exf@probarg{\ifdefined\exf@prevprob prob={\exf@prevprob}\fi%
    \ifdefined\exf@prevprobtitle,probtitle={\exf@prevprobtitle}\fi%
    \ifdefined\exf@prevprobhref,href={\exf@prevprobhref}\fi%
    \ifdefined\exf@sollabel,label={\exf@sollabel}\fi}%
   \exf@ifis\exf@solutionbelow{here}{\let\exf@probarg\@undefined}%
   \exf@ifis\exf@solutionbelow{subproblem}{\let\exf@probarg\@undefined}%
   \exf@ifis\exf@solutionbelow{subproblem*}{\let\exf@probarg\@undefined}%
   \ifdefined\exf@probarg%
    \ifexf@lineno\exf@addline\exf@solbuf{\exf@linesep}%
     \exf@addline\exf@solbuf{\exf@lineno}\fi%
    \exf@addline\exf@solbuf{\@backslashchar solutionssection{\exf@probarg}}%
    \exf@addline\exf@solbuf{}%
   \fi%
   \global\let\exf@problem@solnewsec\@undefined%
  \fi}%
%    \end{macrocode}

% \macro{\exf@process@solnewsec}
% Declare additional arguments to |printsolution|
% to describe corresponding problem and tags:
%    \begin{macrocode}
\newcommand{\exf@generate@solprobarg}{%
  \edef\exf@solprobarg{%
    \ifdefined\exf@prevprob prob={\exf@prevprob},\fi%
    \ifdefined\exf@prevsubprob subprob={\exf@prevsubprob},%
     \ifdefined\exf@prevsubprobhref href={\exf@prevsubprobhref},\fi%
    \else%
     \ifdefined\exf@prevprobhref href={\exf@prevprobhref},\fi%
    \fi%
    \ifdefined\exf@prevpoints points=%
     {\expandafter\exf@formatpoints\exf@prevpoints},\fi%
    \ifdefined\sheettag sheettag={\sheettag},\fi%
    \ifdefined\problemtag problemtag={\problemtag},\fi}%
%    \end{macrocode}
% Clean up:
%    \begin{macrocode}
  \global\let\exf@prevsubprob\@undefined%
  \global\let\exf@prevsubprobhref\@undefined%
  \global\let\exf@prevpoints\@undefined}%
%    \end{macrocode}

% \macro{exf@solution@direct}
% Define direct output version of |solution| environment;
% pass on to |printsolution| environment:
%    \begin{macrocode}
\newenvironment{exf@solution@direct}[1][]%
 {\showpoints%
  \global\let\exf@problem@solnewsec\@undefined%
  \exf@generate@solprobarg%
  \exf@showsolutionsin%
  \let\exf@composetitle\exf@config@composetitlesolutionsingle%
  \exf@exptwo\printsolution{\exf@solprobarg#1}}%
 {\endprintsolution%
  \exf@showsolutionsout%
  \ignorespacesafterend}%
%    \end{macrocode}

% \macro{exf@solution@scan}
% \macro{exf@scansolution}
% Define scan version of |solution| environment;
% use |\exf@scanblock| to properly parse optional argument
% and pass on to |exf@scansolution|:
%    \begin{macrocode}
\newenvironment{exf@solution@scan}%
 {\exf@scanblock{\exf@scansolution}}{\endexf@scansolution}%
\newenvironment{exf@scansolution}[2]{%
%    \end{macrocode}
% If solution is to be displayed immediately,
% make sure to display points first;
% insert solution section heading in buffer;
% compose additional arguments to |printsolution|:
%    \begin{macrocode}
  \exf@ifis\exf@solutionbelow{here}{\showpoints}%
  \exf@process@solnewsec%
  \exf@generate@solprobarg%
%    \end{macrocode}
% Write separator and |printsolution| environment to buffer:
%    \begin{macrocode}
  \ifexf@lineno\exf@addline\exf@solbuf{\exf@linesep}%
   \exf@addline\exf@solbuf{\exf@lineno}\fi%
  \exf@addline\exf@solbuf%
   {\@backslashchar begin{printsolution}{\exf@solprobarg#1}}%
%    \end{macrocode}
% Start verbatim processing:
%    \begin{macrocode}
  \def\exf@verbatim@process{\exf@append@buf\exf@solbuf}%
  \exf@verbatim#2}%
%    \end{macrocode}
% End verbatim processing; close |printsolution| environment:
%    \begin{macrocode}
 {\exf@endverbatim%
  \exf@addline\exf@solbuf{\@backslashchar end{printsolution}}%
  \global\exf@solbuf@cleanfalse%
%    \end{macrocode}
% Write buffer to file if output file open:
%    \begin{macrocode}
  \ifexf@solfile@open%
   \exf@write@buf\exf@solfile\exf@solbuf%
   \exf@clear@solbuf%
  \fi%
%    \end{macrocode}
% Drop buffer if solutions not to be displayed:
%    \begin{macrocode}
  \ifsolutions\else\exf@clear@solbuf\fi%
%    \end{macrocode}
% Display solution immediately in various cases:
%    \begin{macrocode}
  \exf@ifis\exf@solutionbelow{here}{\exf@showsolutions%
   {\exf@config@composetitlesolutionsingle}{}}%
  \ifdefined\exf@in@subproblem\else%
   \exf@ifis\exf@solutionbelow{subproblem}{%
    \exf@showsolutions{\exf@config@composetitlesolutionsingle}{}}%
   \exf@ifis\exf@solutionbelow{subproblem*}{%
    \exf@showsolutions{\exf@config@composetitlesolutionsingle}{}}\fi%
  \ifdefined\exf@in@problem\else%
   \exf@ifis\exf@solutionbelow{problem}{%
    \exf@showsolutions{\exf@config@composetitlesolutionmulti}{}}%
   \exf@ifis\exf@solutionbelow{problem*}{%
    \exf@showsolutions{\exf@config@composetitlesolutionmulti}{}}\fi%
%    \end{macrocode}
% Done:
%    \begin{macrocode}
  \ignorespacesafterend}
%    \end{macrocode}

% \macro{solution}
% Define |solution| environment
% (potentially using custom name)
% to choose between direct and buffered version:
%    \begin{macrocode}
\newenvironment{\exf@solutionname}%
 {\ifexf@solutionbuf\let\exf@tmp\exf@solution@scan%
  \else\let\exf@tmp\exf@solution@direct\fi%
  \exf@tmp}%
 {\ifexf@solutionbuf\let\exf@tmp\endexf@solution@scan%
  \else\let\exf@tmp\endexf@solution@direct\fi%
  \exf@tmp}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Solution Blocks}
% \label{sec:imp-solutions}
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Solution Block Handling.}
%
% \macro{\exf@solutionssection}
% Output solution block section:
%    \begin{macrocode}
\newcommand{\exf@solutionssection}[6]{%
%    \end{macrocode}
% Check whether title is empty:
%    \begin{macrocode}
  \protected@edef\exf@solutionstitleexp{#2}%
  \ifx\exf@solutionstitleexp\exf@empty\else%
%    \end{macrocode}
% Define a label:
%    \begin{macrocode}
   \ifdefined#5%
    \exf@csdo\def{the\exf@solutioncounter}%
     {\exf@config@composeitemsolutionlabel{\exf@solprob}{\exf@solsubprob}}%
    \refstepcounter{\exf@solutioncounter}\label{#5}%
   \fi%
%    \end{macrocode}
% Output section line:
%    \begin{macrocode}
   \exf@section{#3}{\exf@config@styletitle\exf@config@styletitlesolution#1%
    \ifexf@solutionhref\exf@href{#6}{\exf@solutionstitleexp}%
    \else\exf@solutionstitleexp\fi}#4%
  \fi}
%    \end{macrocode}

% \macro{\exf@solutionstitle}
% Compose the title for a solution block:
%    \begin{macrocode}
\newcommand{\exf@solutionstitle}{\exf@solutionssection%
  {\exf@config@styletitlesolutions}{%
   \exf@config@composetitlesolutions}{\exf@config@skipsolutionstitle}%
   {\exf@addcontentsline{\exf@config@toclevelsolutions}%
    {\exf@config@composetocsolutions}}{\@undefined}{\@undefined}}
%    \end{macrocode}

% \macro{\exf@showsolutionsin}
% Output solution block intro:
%    \begin{macrocode}
\newcommand{\exf@showsolutionsin}{%
%    \end{macrocode}
% Set solution body style; add vertical space; insert hook code:
%    \begin{macrocode}
  \par\exf@config@styletext\addvspace{\exf@config@skipsolutionsabove}%
  \exf@config@styletextsolution%
  \exf@config@insertsolutionsbefore}
%    \end{macrocode}

% \macro{\exf@showsolutionsout}
% Output solution block outro:
%    \begin{macrocode}
\newcommand{\exf@showsolutionsout}{%
%    \end{macrocode}
% Insert hook code; close paragraph; add vertical space:
%    \begin{macrocode}
  \exf@config@insertsolutionsafter%
  \par\exf@config@styletext\addvspace{\exf@config@skipsolutionsbelow}}
%    \end{macrocode}

% \macro{\exf@showsolutions}
% Output solution block in buffer:
%    \begin{macrocode}
\newcommand{\exf@showsolutions}[2]{%
%    \end{macrocode}
% Do nothing if buffer is empty (avoid titles):
%    \begin{macrocode}
  \ifexf@solbuf@clean\else\begingroup%
%    \end{macrocode}
% Execute output solution block intro:
%    \begin{macrocode}
   \exf@showsolutionsin%
   \let\exf@composetitle#1%
   #2%
%    \end{macrocode}
% Source and clear buffer:
%    \begin{macrocode}
   \exf@source@buf\exf@solbuf%
   \exf@clear@solbuf%
%    \end{macrocode}
% Execute output solution block outro:
%    \begin{macrocode}
   \exf@showsolutionsout%
  \endgroup\fi}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Solutions Buffer Interface.}
%
% \macro{\writesolutions}
% Open a file |#1.sol| for writing solutions;
% default is present main file name:
%    \begin{macrocode}
\newcommand{\writesolutions}[1][\jobname]{%
  \exf@close@solfile\exf@start@solfile{#1}}
%    \end{macrocode}

% \macro{\closesolutions}
% Close solutions output file (if open):
%    \begin{macrocode}
\newcommand{\closesolutions}{\exf@close@solfile}
%    \end{macrocode}

% \macro{\readsolutions}
% Read solutions from file |#1.sol|;
% default is present main file name;
% switch layout and add heading:
%    \begin{macrocode}
\newcommand{\readsolutions}[1][\jobname]{\exf@close@solfile%
  \ifsolutions\begingroup%
   \exf@config@styletext\exf@config@styletextsolution%
   \let\exf@composetitle\exf@config@composetitlesolutionmulti%
   \exf@solutionstitle%
   \input{#1\exf@config@extsolutions}%
  \endgroup\fi}
%    \end{macrocode}

% \macro{\insertsolutions}
% Show solutions buffer:
%    \begin{macrocode}
\newcommand{\insertsolutions}{\exf@showsolutions%
  {\exf@config@composetitlesolutionmulti}{\exf@solutionstitle}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Interaction with metastr}
% \label{sec:imp-metastr}
%
% This package transfers some functionality
% to the package \textsf{metastr} when loaded
% previously (preferably with package option |course|)
% by the package option |metastr|.
% The following changes apply:
% \begin{itemize}
% \item
% The terms specified by the configuration options |term...|,
% see \secref{sec:imp-config},
% are transferred to the corresponding term registers
% |\metaterm{...}| in \textsf{metastr}.
% This can facilitate internationalisation,
% and suitable words for English, German, French and Spanish are provided.
% \item
% Metadata as described in \secref{sec:metadata}
% should be filled via |\metaset| rather than |\exercisedata|.
% The present package will read it from the \textsf{metastr} registers.
% \item
% Basic PDF metadata is written automatically or manually
% as described in \secref{sec:metadata}.
% This is done via |\metawritepdfinfo|,
% consequently, automatic writing of these basic metadata
% is disabled in \textsf{metastr}.
% \item
% Sheet-specific metadata (package option |pdfdata=sheet|)
% is handled via the \textsf{metastr} registers |sheettitle| and |sheetdata|
% rather than |composemetasheet|.
% \end{itemize}
%
% Apply modifications only when package \textsf{metastr} is loaded:
%    \begin{macrocode}
\ifdefined\metaset
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Transfer Metadata.}
%
% Import basic data from \textsf{metastr}:
%    \begin{macrocode}
\exercisedata{author={\metapick[]{author}}}
\exercisedata{title={\metapick[]{title}}}
\exercisedata{subject={\metapick[]{subject}}}
\exercisedata{keyword={\metapick[]{keyword}}}
\exercisedata{date={\metapick[]{date}}}
%    \end{macrocode}
% Import course data from \textsf{metastr}:
%    \begin{macrocode}
\ifdefined\mstr@def@course
\exercisedata{course={\metapick[]{course}}}
\exercisedata{instructor={\metapick[]{instructor}}}
\exercisedata{institution={\metapick[]{institution}}}
\exercisedata{period={\metapick[]{period}}}
\exercisedata{material={\metapick[]{material}}}
\fi
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Sheet Data.}
%
% \macro{sheettitle}
% \macro{sheetauthor}
% Registers for sheet title and author:
%    \begin{macrocode}
\metadef{sheettitle}
\metadef{sheetauthor}
%    \end{macrocode}

% \macro{\exf@writemetadata}
% Write PDF metadata via \textsf{metastr} package,
% let \textsf{exframe} initiate process (especially for sheet):
%    \begin{macrocode}
\metaunset[info]{writepdf}
\def\exf@writemetadata{%
  \exf@ifis\exf@metadata{sheet}{\metaset[use]{sheettitle}{}}%
  \metawritepdfinfo%
  \exf@ifis\exf@metadata{sheet}{\metaunset[use]{sheettitle}}}
%    \end{macrocode}

% Fill registers:
%    \begin{macrocode}
\metaset{sheetauthor}{\exerciseifempty{\getsheetdata{author}}%
  {\metapick[#1]{instructor}}{\getsheetdata{author}}}
\metaset{sheettitle}{\exerciseifempty{\getsheetdata{rawtitle}}%
  {\metatranslate[#1]{sheet} \thesheet}%
  {\getsheetdata{rawtitle}}}
\metaset{author}{\exerciseifempty{\getsheetdata{author}}%
  {\metapick[#1]{instructor}}{\metapick[#1]{sheetauthor}}}
\metaset{subtitle}{%
  \metaif[use]{sheettitle}
   {\metapick[#1]{sheettitle}}
   {\metapick[#1]{material}}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Terms.}
%
% \macro{term...}
% Transfer term definitions to \textsf{metastr}:
%    \begin{macrocode}
\exerciseconfig{termsheet}{\metaterm{sheet}}
\exerciseconfig{termsheets}{\metaterm{sheets}}
\exerciseconfig{termproblem}{\metaterm{problem}}
\exerciseconfig{termproblems}{\metaterm{problems}}
\exerciseconfig{termsolution}{\metaterm{solution}}
\exerciseconfig{termsolutions}{\metaterm{solutions}}
\exerciseconfig{termpoint}{\metaterm{point}}
\exerciseconfig{termpoints}{\metaterm{points}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Translations.}
%
% English:
%    \begin{macrocode}
\ifdefined\mstr@lang@en
\metasetterm[en]{sheet}{Sheet}
\metasetterm[en]{sheets}{Sheets}
\metasetterm[en]{problem}{Problem}
\metasetterm[en]{problems}{Problems}
\metasetterm[en]{solution}{Solution}
\metasetterm[en]{solutions}{Solutions}
\metasetterm[en]{point}{point}
\metasetterm[en]{points}{points}
\fi
%    \end{macrocode}

% German:
%    \begin{macrocode}
\ifdefined\mstr@lang@de
\metasetterm[de]{sheet}{Blatt}
\metasetterm[de]{sheets}{Blätter}
\metasetterm[de]{problem}{Aufgabe}
\metasetterm[de]{problems}{Aufgaben}
\metasetterm[de]{solution}{L\"osung}
\metasetterm[de]{solutions}{L\"osungen}
\metasetterm[de]{point}{Punkt}
\metasetterm[de]{points}{Punkte}
\fi
%    \end{macrocode}

% French:
%    \begin{macrocode}
\ifdefined\mstr@lang@fr
\metasetterm[fr]{sheet}{Feuille}
\metasetterm[fr]{sheets}{Feuilles}
\metasetterm[fr]{problem}{Probl\`eme}
\metasetterm[fr]{problems}{Probl\`emes}
\metasetterm[fr]{solution}{Solution}
\metasetterm[fr]{solutions}{Solutions}
\metasetterm[fr]{point}{point}
\metasetterm[fr]{points}{points}
\fi
%    \end{macrocode}

% Spanish:
%    \begin{macrocode}
\ifdefined\mstr@lang@es
\metasetterm[es]{sheet}{Hoja}
\metasetterm[es]{sheets}{Hojas}
\metasetterm[es]{problem}{Problema}
\metasetterm[es]{problems}{Problemas}
\metasetterm[es]{solution}{Solucion}
\metasetterm[es]{solutions}{Soluciones}
\metasetterm[es]{point}{punto}
\metasetterm[es]{points}{puntos}
\fi
%    \end{macrocode}

% Close \textsf{metastr} conditional:
%    \begin{macrocode}
\fi
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\iffalse
%</package>
%\fi
%
\endinput