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
|
% !arara: pdflatex
% !arara: biber
% arara: pdflatex
% arara: pdflatex
% arara: pdflatex
% --------------------------------------------------------------------------
% the EXSHEETS package
%
% Yet another package for the creation of exercise sheets
%
% --------------------------------------------------------------------------
% Clemens Niederberger
% Web: https://bitbucket.org/cgnieder/exsheets/
% E-Mail: contact@mychemistry.eu
% --------------------------------------------------------------------------
% Copyright 2011-2019 Clemens Niederberger
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Clemens Niederberger.
% --------------------------------------------------------------------------
% If you have any ideas, questions, suggestions or bugs to report, please
% feel free to contact me.
% --------------------------------------------------------------------------
\documentclass[load-preamble+]{cnltx-doc}
\usepackage{exsheets}
\usepackage{bookmark}
\setcnltx{
package = {exsheets} ,
authors = Clemens Niederberger ,
email = contact@mychemistry.eu ,
url = {http://www.mychemistry.eu/forums/forum/exsheets/} ,
title = the \ExSheets\ bundle ,
info = {%
the packages \ExSheets{} and \ExSheetslistings \\
\emph{or}\\
Yet another package for the creation of exercise sheets and exams.%
} ,
module-sep = {\,>>\,} ,
index-setup = { othercode=\footnotesize,level=\section} ,
abstract = {%
\ExSheets\ provides means to create exercises or questions and their
corresponding solutions. The questions can be divided into classes and
can be printed selectively. Meta-data to questions can be added and
recovered.
\par
The solutions may be printed where they are, can be collected and printed
at a later point in the document alltogether or section-wise or
selectively by \acs{id}.\par
\ExSheets\ provides a comprehensive interface for styling the headings of
questions and solutions.%
} ,
add-cmds = {
% exsheets:
addpoints,
blank,
C,
checkedchoicebox,choice,choicebox,
correct,
CurrentQuestionID,
DebugExSheets,
DeclareExSheetsHeadingContainer,
DeclareQuestionClass,DeclareQuestionProperty,
examspace,
exlabel,
ForEachQuestion,
GetQuestionClass,
GetQuestionProperty,
grade,
includequestions,iflastquestion,
IfQuestionPropertyF,IfQuestionPropertyT,IfQuestionPropertyTF,
IfQuestionSubtitleF,IfQuestionSubtitleT,IfQuestionSubtitleTF,
lastvariant,
NewQuSolPair,NewLstQuSolPair,
numberofquestions,
points,pointssum,
PrintIfIncludeActiveF,PrintIfIncludeActiveT,PrintIfIncludeActiveTF,
PrintQuestionClassF,PrintQuestionClassT,PrintQuestionClassTF,
printsolutions,
PrintSolutionsF,PrintSolutionsTF,PrintSolutionsT,
questionsincludedlast,QuestionNumber,RenewQuSolPair,
S,
SetQuestionProperties,
SetupExSheets,
SetVariations,
startnewitemline,
sumpoints,
totalpoints,
variant,vary,
% cntformats:
@cntfmts@parsed@pattern,
AddCounterPattern,
eSaveCounterPattern,
NewCounterPattern,
ReadCounterFrom,
ReadCounterPattern,ReadCounterPatternFrom,
SaveCounterPattern,
% tasks:
NewTasks,
settasks,
task
} ,
add-envs = {
question,
solution,
tasks
} ,
add-silent-cmds = {
acs,
bigstar,bottomrule,
citetitle,cs,color,
DeclareInstance,DeclareTemplateInterface,
endmdframed,endspacing,
keyis,
leftthumbsup,
mdframed,midrule,
rightarrow,rlap,
s,sample,setlength,
spacing,square,
tabcolsep,
textcite,
textcolor,
tmpa,tmpb,
toprule
}
}
\usepackage{exsheets-listings}
\microtypesetup{tracking=scshape}
\defbibheading{bibliography}[\bibname]{\section{#1}}
\usepackage[biblatex]{embrac}[2012/06/29]
\ChangeEmph{[}[,.02em]{]}[.055em,-.08em]
\ChangeEmph{(}[-.01em,.04em]{)}[.04em,-.05em]
\usepackage{booktabs,array,ragged2e}
\newpackagename\ExSheets{ExSheets}
\newpackagename\ExSheetslistings{ExSheets-listings}
\newpackagename\cntformats{cntformats}
\newpackagename\Tasks{tasks}
% ----------------------------------------------------------------------------
% other packages, bibliography, index
\usepackage{xcoffins,wasysym,enumitem,siunitx}
\usepackage[accsupp]{acro}
\DeclareAcronym{faq}{
short = faq ,
long = Frequently Asked Questions ,
format = \scshape ,
pdfstring = FAQ ,
accsupp = FAQ
}
\DeclareAcronym{id}{
short = id ,
long = Identifier ,
format = \scshape ,
pdfstring = ID ,
accsupp = ID
}
\DeclareAcronym{ctan}{
short = ctan ,
long = Comprehensive \TeX\ Archive Network ,
format = \scshape ,
pdfstring = CTAN ,
accsupp = CTAN
}
\usepackage{filecontents}
\usepackage{csquotes}
\addbibresource{biblatex-examples.bib}
\addbibresource{\jobname.bib}
\begin{filecontents*}{\jobname.bib}
@online{tex.sx:131546,
title = {Fixing lstlisting inside \ExSheets\ \code{question} and
\code{solution} environments} ,
author = {Stefano Bragaglia} ,
url = {http://tex.stackexchange.com/q/131546/5049} ,
date = {2013-09-04} ,
urldate = {2013-09-22}
}
@online{tex.sx:133907,
title = {How do I extract repeated functionality (\ExSheets\ workaround) to
make it reusable?} ,
author = {Forkrul Assail} ,
url = {http://tex.stackexchange.com/q/133907/5049} ,
date = {2013-09-18} ,
urldate = {2013-09-22}
}
\end{filecontents*}
% ----------------------------------------------------------------------------
% example definitions that have to be done in the preamble:
\DeclareQuestionClass{difficulty}{difficulties}
\DeclareQuestionProperty{notes}
\DeclareQuestionProperty{reference}
\DeclareQuestionProperty{topic}
\DeclareRelGrades{
1 = 1 ,
{1,5} = .9167 ,
2 = .8333 ,
{2,5} = .75 ,
3 = .6667 ,
{3,5} = .5833 ,
4 = .5
}
\usepackage{amssymb}
\let\checkmark\relax
\usepackage{dingbat}
\DeclareRobustCommand*\questionstar{\texorpdfstring{\bonusquestionsign}{* }}
\DeclareRobustCommand*\bonusquestionsign{\llap{$\bigstar$\space}}
\NewQuSolPair
{question*}[name=\questionstar Bonus Question]
{solution*}[name=\questionstar Solution]
\NewTasks[style=multiplechoice]{multiplechoice}[\choice](3)
\newcommand*\correct{\PrintSolutionsTF{\checkedchoicebox}{\choicebox}}
\usepackage{alphalph}
\NewPatternFormat{aa}{\alphalph}
\NewCounterPattern{testa}{ta}
% \AfterPackage!{hyperref}{%
% \pdfstringdefDisableCommands{\def\questionstar{* }}%
% }
\begin{document}
\part{Preliminaries}
\section{Licence and Requirements}
\license
\ExSheets\ loads and needs the following packages:
\needpackage{l3kernel}~\cite{bnd:l3kernel}, \pkg{xparse}, \pkg{xtemplate},
\pkg{l3keys2e}\footnote{all three \CTANurl{l3packages}}~\cite{bnd:l3packages},
\pkg{l3sort}\footnote{\CTANurl{l3experimental}}~\cite{bnd:l3experimental},
\needpackage{xcolor}~\cite{pkg:xcolor}, \needpackage{ulem}~\cite{pkg:ulem},
\needpackage{etoolbox}~\cite{pkg:etoolbox},
\needpackage{environ}~\cite{pkg:environ}, and
\pkg{pgfcore}\footnote{\CTANurl[graphics]{pgf}}~\cite{pkg:pgf}. \ExSheets\
calls \cs*{normalem} (from the \pkg{ulem} package).
\section{Motivation}
There are already quite a number of packages that allow the creation of
exercise sheets or written exams. Just to name the most common ones:
\pkg{eqexam}~\cite{pkg:eqexam}, \pkg{exam}~\cite{cls:exam},
\pkg{examdesign}~\cite{pkg:examdesign}, \pkg{exercise}~\cite{pkg:exercise},
\pkg{probsoln}~\cite{pkg:probsoln}, \pkg{answers}~\cite{pkg:answers},
\pkg{esami}~\cite{pkg:esami}, \pkg{exsol}~\cite{pkg:exsol} (and many
more \ldots).
One thing I missed in all packages that I've tried out\footnote{Well, probably
I didn't try hard enough\ldots} was a high flexibility in choosing which
questions and solutions should be printed, where which solutions should be
printed and so on, combined with the possibility to assign questions to
different classes so one could for example create two versions of an exam out
of the box. And --~I can't get enough~-- I also want to be able to use/design
different layouts for questions additional to a standard section-like format.
All these points are realized in \ExSheets.
Additionally one should be able to assign some sort of meta-data to questions
that of course should be easily reusable. How this can be done is explained
in section~\ref{sec:additional_info}.
Then there is --~at least in Germany~-- the habit of having lists of exercises
aligned in columns but counting from the left to the right instead from up to
down. That's why the \pkg{tasks} package was developed as part of \ExSheets{}
and was distributed as part of the bundle\changedversion{0.15}. Now it is a
package of its own but is loaded by \ExSheets{} automatically with the
necessary setup to make them work together nicely.
\ExSheets{} has no native support for multiple choice tests but that doesn't
mean that you can't create them with \ExSheets. It just means that they may
be a bit more work with \ExSheets{} than with other packages.
I had the idea for this package in 2008. Back then my \TeX{} skills were by
far not good enough to write it. Actually, even today I wouldn't have been
able to realize it without all the l3 packages like \pkg{l3kernel} and
\pkg{l3packages}. I actively began to develop \ExSheets\ in spring~2011 but
it wasn't until now (September~2012) that I consider it stable enough for
wider usage. At the time of writing (\today) there still are probably lots of
rough edges let alone bugs so I am very interested in all kinds of feedback.
\section{Additional Packages}
\ExSheets\ actually bundles two packages: \ExSheets, \ExSheetslistings.
\ExSheetslistings\ is an add-on to \ExSheets\ that offers some functionality
to use \pkg{listings} with \ExSheets. It is presented in
part~\ref{part:listings}.
\ExSheets\ used to bundle the \pkg{translations} package,
too\changedversion{0.9i}, but doesn't any more. You can find the
\pkg{translations} package as a package of it's own on the \ac{ctan}. It also
used to bundle the packages \pkg{tasks} and
\pkg{cntformats}\changedversion{0.15}. They're available now as packages of
their own as well.
% \section{Installation and Documentation}
% If you install \ExSheets\ manually beware to put the files
% \begin{itemize}
% \item[]\verb+exsheets_headings.def+
% \item[]\verb+exsheets_headings.cfg+
% \end{itemize}
% in the same directory as the \code{exsheets.sty} file\footnote{That is, a
% directory like \code{texmf-local/tex/latex/exsheets}, probably}.
% As with every manual package installation you need to make sure to put the
% files in a directory where \TeX\ can find them and afterwards update the
% database.
% \subsection{The \pkg*{tasks} Package}
% The \pkg{tasks} package~\cite{pkg:tasks} used to be part of the \ExSheets\
% bundle but is a package of its own now\changedversion{0.15} and released
% independently. You can find it as every other package on \ctan\ and in a full
% \TeX~Live or \hologo{MiKTeX} installation.
% \subsection{The \pkg*{cntformats} Package}
% The \pkg{cntformats} package~\cite{pkg:cntformats} used to be part of the
% \ExSheets\ bundle but is a package of its own now\changedversion{0.15} and
% released independently. You can find it as every other package on \ctan\ and
% in a full \TeX~Live or \hologo{MiKTeX} installation.
% \subsection{The \pkg*{translations} Package}
% The \pkg{translations} package~\cite{pkg:translations} used to be part of the
% \ExSheets\ bundle but is a package of its own now\changedversion{0.9i} and
% released independently. You can find it as every other package on \ctan\ and
% in a full \TeX~Live or \hologo{MiKTeX} installation.
% \section{News}
% \begin{description}
% \item[Version 0.7]
% With version~0.7 there has been a potentially breaking change: the
% \code{tasks} environment previously provided by \ExSheets\ has been
% extracted into a package of its own. This does not change any syntax
% \emph{per se}. However, if you used custom settings then you'll probably run
% into some problems. The options for the environment are no longer set with
% \cs{SetupExSheets} but with \cs{settasks}. Also the object that is used for
% the list template and its instances has been renamed from
% \code{exsheets-tasks} into \code{tasks}.
% What's probably even more of a breaking change is a syntax difference of the
% \code{tasks} environment: the optional argument for the number of columns is
% \emph{no longer set in braces but parentheses}. This is deliberate as it
% reflects the optional nature of the argument better and is consistent with
% the syntax of \cs{NewTasks}, too.
% Additionally the labels of the list got an additional offset of \code{1ex}
% from the items which will lead to slightly different output. In some cases
% this might actually lead to the most annoying changes. In this case say
% \cs{settasks}\Marg{label-offset=0pt} which should cure things again.
% I am very sorry for any inconvenience! I am trying to keep such changes as
% minimal and rare as possibly. However, it is not always avoidable when a
% package is new and still a child. It will grow up eventually.
% \ExSheets' other packages -- \href{tasks_en.pdf}{\Tasks} and
% \href{cntformats_en.pdf}{\cntformats} -- have gotten their own documentation
% which are essentially extracted from this very document you're reading now.
% This manual contains links to the respective manuals.
% \item[Version v0.9i]
% The \pkg{translations} package~\cite{pkg:translations} is no longer part of
% the \ExSheets\ bundle. From now on (July~17.\@ 2013) it is provided as a
% package of its own.
% \item[Version 0.10]
% The \ExSheets\ family has got a new member: \ExSheetslistings. This package
% proposes a solution for the problem of using verbatim material in \ExSheets'
% \env{question} and \env{solution} environments. It is presented in
% part~\ref{part:listings}.
% Question now can get subtitles that are printed if the heading instance
% supports it, see section~\ref{sec:subtitles-questions}.
% \item[Version 0.11]
% The commands \cs{GetQuestionClass} and \cs{PrintQuestionClassTF} have been
% added. They're explained in section~\ref{sec:retr-class-value}.
% \item[Version 0.12]
% The \option{auto-label} is now more flexible to allow the use together with
% packages \pkg{cleveref}.
% Question properties can now be retrieved before the question is printed (by
% writing the properties to the \code{aux} file).
% \item[Version 0.13]
% New options:
% \begin{itemize}
% \item \option{chapter-hook} allows to add code to the list of solutions
% when the solutions of a new chapter are printed, see
% section~\ref{sec:solutions-print-all}.
% \item \option{section-hook} allows to add code to the list of solutions
% when the solutions of a new section are printed, see
% section~\ref{sec:solutions-print-all}.
% \end{itemize}
% \item[Version 0.14]
% New options:
% \begin{itemize}
% \item New option \option{pre-hook} to the \env{question} environment that
% allows to add code directly before the question body, see
% section~\ref{sec:opti-ques-envir}.
% \item New option \option{post-hook} to the \env{question} environment that
% allows to add code directly after the question body, see
% section~\ref{sec:opti-ques-envir}.
% \item New command \cs{ExSheetsHeading}, see
% section~\ref{sec:using-an-exsheets}.
% \item New pre-defined question properties \code{question-body},
% \code{bonus-points} and \code{counter}, see
% section~\ref{sec:additional_info}.
% \item New option \option{save-to-aux}, see
% section~\ref{sec:additional_info}.
% \end{itemize}
% \item[Version 0.15]
% \begin{itemize}
% \item The packages \pkg{tasks} and \pkg{cntformats} have been removed from
% the bundle and are now distributed as packages of their own.
% \item The options \option*{load-headings} and \option*{load-tasks} have
% been dropped. The optional functionality they provided is now provided
% all the time.
% \item New command \cs{IfQuestionPropertyTF}, see
% section~\ref{sec:additional_info}.
% \end{itemize}
% \item[Version 0.16]
% New options/changes:
% \begin{itemize}
% \item The option \option{pre-hook} to the \env{question} environment now
% places its contents before the question heading, see
% section~\ref{sec:opti-ques-envir}.
% \item New option \option{pre-body-hook} to the \env{question} environment
% which adds its contents before the question body, see
% section~\ref{sec:opti-ques-envir}.
% \item New option \option{post-body-hook} to the \env{question} environment
% which adds its contents after the question body, see
% section~\ref{sec:opti-ques-envir}.
% \item New option \option{pre-hook} to the \env{solution} environment which
% adds code before a solution, see section~\ref{sec:opti-soli-envir}.
% \item New option \option{post-hook} to the \env{solution} environment which
% adds code after a solution, see section~\ref{sec:opti-soli-envir}.
% \item New option \option{pre-body-hook} to the \env{solution} environment
% which adds its contents before the solution body, see
% section~\ref{sec:opti-soli-envir}.
% \item New option \option{post-body-hook} to the \env{solution} environment
% which adds its contents after the solution body, see
% section~\ref{sec:opti-soli-envir}.
% \end{itemize}
% \item[Version 0.17]
% New option:
% \begin{itemize}
% \item The option \option{use-saved-counter-format} has been introduced. It
% is described in section~\ref{sec:solutions} on
% page~\pageref{option:use-saved-counter-format}.
% \end{itemize}
% \item[Version 0.18]
% The package now provides the correct Danish translations, thanks to Jonas
% Nyrup.
% The macro \cs{exsheetsprintsolution} is introduced, see
% page~\pageref{exsheetsprintsolution} for a little bit of an explanation.
% The option \option{no-skip-below} is introduced which disables the insertion
% of vertical space after the question and solution environments.
% \item[Version 0.20]
% New command \cs{DeclareExSheetsHeadingContainer}.
% \item[Version 0.21] Changes:
% \begin{itemize}
% \item \cs{includequestions} issues an error if it can't find the file to
% include.
% \item question properties are now also accessable when the corresponding
% question isn't printed.
% \item The variables \verbcode+\l_exsheets_counter_qu_int+ and \\
% \verbcode+\g_exsheets_question_identification_prop+ are now public.
% \end{itemize}
% \end{description}
\section{Thanks}
I need to thank the many users who gave me feedback so far! For one thing
this shows me that \ExSheets\ is useful to people. It also led to many
improvements like new features and countless bug fixes.
\part{The \ExSheets\ package}\label{part:exsheets}
\section{Setup}
The \ExSheets\ package has three different types of options, kind of. The
first type are the classic package options which are used when you load
\ExSheets:
\begin{sourcecode}
\usepackage[<options>]{exsheets}
\end{sourcecode}
All general options can be used this way and most of them are described in
section~\ref{sec:options}. All of those options also can be set via the setup
command:
\begin{commands}
\command{SetupExSheets}[\oarg{module}\marg{options}]
\end{commands}
The second type are options that belong to a specific environment or command.
These options are either used directly with the environment/command
\begin{sourcecode}
\begin{env}[<options>]
...
\end{env}
\end{sourcecode}
or can also be set with the setup command. In the first case they only act
upon the environment or command where they're used. In the second case they
are set for all following uses of the corresponding environment or command.
The options of the second type all belong to \module*{modules}. Let's say you
want to specify some options of the \env{question} environment. You can then
say the following:
\begin{sourcecode}
\SetupExSheets[question]{option1,option2=value2}
% or:
\SetupExSheets{question/option1,question/option2=value2}
\end{sourcecode}
The \module*{module} an option belongs to is written in the left margin next
to the when the option is described.
The third type aren't options at all, actually. However, thanks to the great
\pkg{xtemplate} package you are able to define your own instances of some of
the objects used by \ExSheets. This is explained in a little more detail in
part~\ref{part:style} on page~\pageref{part:style}\,ff. This third type,
however, brings in a possible instability: the \pkg{xtemplate} package is in
an experimental and developing state. This means that the sytax of the
package may and possibly will change sometime in the future. I cannot foresee
what any consequences of that will be for \ExSheets.
\section{General Options}\label{sec:options}
The package \ExSheets\ has some options, namely the following ones:
\begin{options}
%% counter-format
\keyval{counter-format}{counter-format}\Default{qu.}
Formatting of the counter of the questions. This option takes a special
kind of string that is described in section~\ref{ssec:counter}.
\keyval{counter-within}{counter}\Default
Resets the \code{question} counter with every step of \meta{counter}.
%% auto-label
\keybool{auto-label}\Default{false}
If set to \code{true} \ExSheets\ will automatically place a
\cs*{label}\Marg{qu:\meta{id}} for each question. See
section~\ref{sec:auto-label-opti} for ways to customize this. It will
also create the question properties \code{ref} and \code{pageref}, see
section~\ref{sec:additional_info} for more on this.
%% headings
\keyval{headings}{instance}\Default{block}
Choose the style of the questions' and solutions' headings. There are two
predefined styles: \code{block} and \code{runin}.
%% headings-format
\keyval{headings-format}{code}\Default{\cs*{normalsize}\cs*{bfseries}}
This code is placed immediately before the headings of the questions and
solutions.
\keyval{subtitle-format}{code}\Default{\cs*{normalsize}\cs*{itshape}}
This code is placed immediately before the subtitle of the questions and
solutions. It only has an effect with a title instance that uses the
subtitle coffin, see section~\ref{sec:exsheets-headings}.
% skip-below
\keyval{skip-below}{dim}\Default{.5\cs*{baselineskip}}
\sinceversion{0.18}Sets the vertical space that is inserted after the
question and solution environments.
% no-skip-below
\keybool{no-skip-below}\Default{false}
\sinceversion{0.18}Disables the insertion of vertical space after the
question and solution environments.
%% totoc
\keybool{totoc}\Default{false}
This option adds the questions and solutions with their names and numbers
to the table of contents.
%% questions-totoc
\keybool{questions-totoc}\Default{false}
This option adds the questions with their names and numbers to the table
of contents.
%% solutions-totoc
\keybool{solutions-totoc}\Default{false}
This option adds the solutions with their names and numbers to the table
of contents.
%% toc-level
\keyval{toc-level}{toc level}\Default{subsection}
This option sets the level in which questions and solutions should appear
in the table of contents.
%% questions-toc-level
\keyval{questions-toc-level}{toc level}\Default{subsection}
This option sets the level in which questions should appear in the table
of contents.
%% solutions-toc-level
\keyval{solutions-toc-level}{toc level}\Default{subsection}
This option sets the level in which solutions should appear in the table
of contents.
%% use-ref
\keybool{use-ref}\Default{false}
enable referencing to sections and chapters in a way that the references
can be used with \cs{printsolutions}, see
section~\ref{sssec:print_specific_section} for details.
\end{options}
The \code{toc} options are demonstrated with section~\ref{sec:solutions:list}
and the solutions printed there being listed in the table of contents.
\section{Create Questions/Exercises and their Solutions}
Now, let's start with the most important part: the questions and (possibly)
their respective solutions.
\subsection{The \env*{question} Environment}\label{ssec:questions}
Questions are written inside the \env{question} environment:
\begin{environments}
\environment{question}[\oarg{options}\marg{points}]
The main environment: creates a new exercise/question. Both arguments are
optional!
\end{environments}
\begin{example}
\begin{question}
This is our very first very difficult to solve question!
\end{question}
\end{example}
As you can see a heading is automatically created and the question is
numbered. You can of course change both the numbering and the naming, but
more on that later.
The \env{question} environment takes an optional argument \marg{points} that
can be used to assign points to the question (as is common in written exams):
\begin{example}
\begin{question}{3}
This is our first difficult question that is worth 3 points!
\end{question}
\end{example}
These points are saved internally (see section~\ref{sec:points} for reasons
why) and are written to the right margin next to the question heading in the
default setting.
You can also assign bonus points by inserting \code{\meta{point}+\meta{bonus
points}} as argument.
\begin{example}
\begin{question}{1+1}
This question is worth 1 point and 1 bonus point.
\end{question}
\begin{question}{+3}
This question is a bonus question. It is worth 3 bonus points.
\end{question}
\end{example}
The points are counted and added to the total sum of points, see
section~\ref{sec:points} for details on this. \sinceversion{0.12}Should you
want that the points of a specific question \emph{should not be added} to the
total sum then precede it with a bang \code{!}:
\begin{example}
\begin{question}{!3}
This question's points won't be added to the total sum.
\end{question}
\end{example}
Beware that this also prevents bonus points. The points simply will be
written where the heading instance puts them.
\sinceversion{0.3}One additional thing: you might want to define custom
commands that should behave differently if they're inside or outside of the
\env{question} environment. In this case you can use these commands:
\begin{commands}
\expandable\command{IfInsideQuestionTF}[\marg{true code}\marg{false code}]
Check if inside of a question and either leave \meta{true code} or
\meta{false code} in the input stream.
\expandable\command{IfInsideQuestionT}[\marg{true code}]
Check if inside of a question and either leave \meta{true code} in the
input stream if true.
\expandable\command{IfInsideQuestionF}[\marg{false code}]
Check if inside of a question and either leave \meta{false code} in the
input stream if not.
\end{commands}
\subsection{Options to the \env*{question} Environment}\label{sec:opti-ques-envir}
The \env{question} environment takes one or more of the following options:
\begin{options}
\keychoice{type}{exam,exercise}\Module{question}\Default{exercise}
Determines the type of question and changes the default name of a question
from ``Exercise'' to ``Question''. These default names are language
dependent.\par
If you use \cs*{usepackage}\oarg{ngerman}\marg{babel}, for example, then
the names are ``Übung'' and ``Aufgabe''.
\keyval{name}{name}\Module{question}\Default
Sets a custom name. All predefined names are discarded.
\keyval{subtitle}{subtitle}\Module{question}\Default
Adds a subtitle \meta{subtitle} for the question that is used by headings
instances that make use of the subtitle coffin, see
section~\ref{sec:exsheets-headings}.
\keyval{skip-below}{dim}\Module{question}\Default{.5\cs*{baselineskip}}
\sinceversion{0.18}Sets the vertical space that is inserted after the
question environment.
\keybool{no-skip-below}\Module{question}\Default{false}
\sinceversion{0.18}Disables the insertion of vertical space after the
question environment.
\keybool{print}\Module{question}\Default{true}
Prints or hides the question.
\keyval{ID}{id}\Module{question}\Default
Assigns a custom \acs{id} to the question. See section~\ref{ssec:ids} for
further information.
\keyval{label}{label}\Module{question}\Default
Places a \cs*{label}\marg{label} for the question. This will overwrite
any label that is placed by the \option{auto-label} option.
\keyval{class}{class}\Module{question}\Default
Assigns a class \meta{class} to the question. See
section~\ref{sec:classes} for further information.
\keyval{topic}{topic}\Module{question}\Default
Assigns a topic \meta{topic} to the question. See
section~\ref{sec:topics} for further information.
\keybool{use}\Module{question}\Default{true}
Discards the question. Or not.
\keyval{pre-hook}{code}\Module{question}\Default
\changedversion{0.16}Adds \meta{code} directly before the question title.
\keyval{post-hook}{code}\Module{question}\Default
\changedversion{0.16}Adds \meta{code} directly after the question.
\keyval{pre-body-hook}{code}\Module{question}\Default
\sinceversion{0.16}Adds \meta{code} directly before the question body.
\keyval{post-body-hook}{code}\Module{question}\Default
\sinceversion{0.16}Adds \meta{code} directly after the question body.
\end{options}
\begin{example}
\begin{question}[type=exam]
This question has the type \keyis{type}{exam}. The default name has changed
from ``Exercise'' to ``Question''.
\end{question}
\begin{question}[name=Fancy name]
This question has a custom name.
\end{question}
\begin{question}[print=false]
This question is not printed.
\end{question}
\end{example}
The difference between \option{print} and \option{use} lies behind the scenes:
with \keyis{print}{false} the question is not printed, but it still gets an
individual \ac{id}, is numbered, and a possible solution is saved. This is
for example useful when you want to print a sample solution for an exam. With
\keyis{use}{false} it is fully discarded which means it is not accessible
through an \acs{id} and a possible solution will not be saved.
\subsection{Subtitles to Questions}\label{sec:subtitles-questions}
The \option{subtitle} option mentioned in section~\ref{sec:opti-ques-envir}
can be used to add a subtitle to a question. However, unless you choose a
suitable heading (see section~\ref{sec:exsheets-headings}) it won't be
printed. Currently there is \emph{one} heading instance that uses the
subtitles but it should be easy to create a custom heading using one of the
existing ones as a starter example. When creating such a heading you may want
to distinguish between the cases when a subtitle has been given and when no
subtitle is present. This can be done with the following commands:
\begin{commands}
\expandable\command{IfQuestionSubtitleTF}[\marg{true code}\marg{false code}]
Tests if the current question has a subtitle. Leaves either \meta{true
code} or \meta{false code} in the input stream.
\expandable\command{IfQuestionSubtitleT}[\marg{true code}]
Tests if the current question has a subtitle. Leaves \meta{true code} in
the input stream if it has.
\expandable\command{IfQuestionSubtitleF}[\marg{false code}]
Tests if the current question has a subtitle. Leaves \meta{false code} in
the input stream if it hasn't.
\end{commands}
A subtitle is also a property of a question in the sense of
section~\ref{sec:additional_info}. That means if a subtitle is given it can
be retrieved with \cs{GetQuestionProperty}.
As an example you could define your own heading instance that prints the
\acs{id} of a question and (if given) the subtitle:
\begin{sourcecode}
\DeclareInstance{exsheets-heading}{QE}{default}{
join = {
title[r,B]number[l,B](.333em,0pt) ;
title[r,B]subtitle[l,B](1em,0pt)
} ,
attach = {
main[l,vc]title[l,vc](0pt,0pt) ;
main[r,vc]points[l,vc](\marginparsep,0pt)
} ,
subtitle-post-code = {ID: \CurrentQuestionID} ,
number-post-code = {\IfQuestionSubtitleF{ID: \CurrentQuestionID}}
}
\end{sourcecode}
Please see section~\ref{sec:exsheets-headings} for more details on heading
instances.
\subsection{The \env*{solution} Environment}
If you want to save/print (more on the exact usage in
section~\ref{sec:solutions}) a solution you have to use the \env{solution}
environment \emph{after} the question it belongs to and \emph{before} the next
question.
\begin{environments}
\environment{solution}[\oarg{options}]
The main environment for adding solutions to exercises/questions.
\end{environments}
\begin{example}
\begin{question}[ID=first]\label{qu:question_with_solution}
This is our first question that gets a solution!
\end{question}
\begin{solution}
This is the solution to exercise~\ref{qu:question_with_solution}!
\end{solution}
\end{example}
You can see that in the default settings the solution is \emph{not} written to
the document. It has been saved, though, for possible later usage. We will
see the solution later!
\subsection{Options to the \env*{solution} Environment}\label{sec:opti-soli-envir}
The \env{solutions} environment also has options, namely these:
\begin{options}
\keyval{name}{name}\Module{solution}\Default
Sets a custom name.
\keybool{print}\Module{solution}\Default{false}
Prints or hides the solution.
\keyval{skip-below}{dim}\Module{solution}\Default{.5\cs*{baselineskip}}
\sinceversion{0.18}Sets the vertical space that is inserted after the
solution environment.
\keybool{no-skip-below}\Module{solution}\Default{false}
\sinceversion{0.18}Disables the insertion of vertical space after the
solution environment.
\keyval{pre-hook}{code}\Module{solution}\Default
\sinceversion{0.16}Adds \meta{code} directly before the solution title.
\keyval{post-hook}{code}\Module{solution}\Default
\sinceversion{0.16}Adds \meta{code} directly after the solution.
\keyval{pre-body-hook}{code}\Module{solution}\Default
\sinceversion{0.16}Adds \meta{code} directly before the solution body.
\keyval{post-body-hook}{code}\Module{solution}\Default
\sinceversion{0.16}Adds \meta{code} directly after the solution body.
\end{options}
Their meaning is the same as those for the \code{question} environment.
\begin{example}
\begin{question}{5}
The solution to this questions gets printed where it is.
\end{question}
\begin{solution}[print]
See? This solution gets printed where you have put it in the code of
your document.
\end{solution}
\begin{question}{2.5}
The solution to this questions gets printed where it is \emph{and}
has a fancy name. Have you noticed that you can assign partial
points?
\end{question}
\begin{solution}[print,name=Fancy name]
See? This solution gets printed where you have put it and has a fancy
name!
\end{solution}
\end{example}
\subsection{Setting the Counter}\label{ssec:counter}
The package option \option{counter-format} allows you to specify how the question
counter (a counter unsurprisingly name \code{question}) is formatted.
The input is an arbitrary string which means you can have anything as counter
number. However, the letter combinations \code{ch}, \code{se}, \code{qu} and
\code{tsk} are replaced with the counters for the chapter, section, question
or tasks (see the \Tasks\ package), respectively. While the last one is not
really useful in this case the others allow for a combined numbering. Each of
these letter combinations can have an optional argument that specifies the
format of the respective counter. \code{1}: \cs*{arabic}, \code{a}:
\cs*{alph}, \code{A}: \cs*{Alph}, \code{r}: \cs*{roman} and \code{R}:
\cs*{Roman}.
\begin{example}
\SetupExSheets{counter-format=Nr~se~(qu[a])}
\begin{question}
A question with a differently formatted number.
\end{question}
\end{example}
Since the strings associated with the counters are replaced one has to hide
them if they are actually wanted in the counter format. The easiest way would
to hide them in braces.
\begin{example}
\SetupExSheets{counter-format={section}\,se~{question}\,(qu[a])}
\begin{question}
A question with a yet differently formatted number.
\end{question}
\end{example}
\subsection{Language Settings}
The names of the questions and solutions are language dependent. If you use
\pkg{babel} or \pkg{polyglossia} \ExSheets\ will adapt to the document language.
\ExSheets\ has a number of translations but surely not all! If you miss a
language please drop me a line in an
email\footnote{\href{mailto:contact@mychemistry.eu}{contact@mychemistry.eu}}
containing the \pkg{babel} language name and the correct translations for
questions (possibly distinguishing between exercises and exam questions) and
solutions.
Until I implement it you can add something like this to your preamble (example
for Danish) and try if it works:
\begin{sourcecode}
\DeclareTranslation{Danish}{exsheets-exercise-name}{\O{}velse}
\DeclareTranslation{Danish}{exsheets-question-name}{Opgave}
\DeclareTranslation{Danish}{exsheets-solution-name}{Opl\o{}sning}
\end{sourcecode}
If this isn't working it means that the language you're using is unknown to
the \pkg{translations} package. In this case please notify me, too. You then
can still use the \option{name} options.
\section{Counting Points}\label{sec:points}
\subsection{The Commands}
You have seen in section~\ref{ssec:questions} that you can assign points to a
question. If you do so these points are printed into the
margin\footnote{Well, not necessarily. It depends on the heading style you
have chosen.} and are counted internally. But there are additional commands
to assign points or bonus points and a number of commands to retrieve the sum
of points and/or bonus points.
\begin{commands}
\command{addpoints}[\sarg\marg{num}]
This command can be used to add points assigned to subquestions.
\cs{addpoints} will print the points (with ``unit'') \emph{and} add them
to the sum of all points, \cs{addpoints}\sarg\ will only add them but print
nothing.
\command{points}[\sarg\marg{num}]
This command will only print the points (with ``unit'') but won't add them
to the sum of points.
\command{addbonus}[\sarg\marg{num}]
This command can be used to add bonus points assigned to subquestions.
\cs{addbonus} will print the points (with ``unit'') \emph{and} add them
to the sum of all bonus points, \cs{addbonus}\sarg\ will only add them but
print nothing.
\command{bonus}[\sarg\marg{num}]
This command will only print the bonus points (with ``unit'') but won't
add them to the sum of bonus points.
\command{pointssum}[\sarg]
Prints the sum of all points with or without (starred version) ``unit'':
\pointssum
\command{currentpointssum}[\sarg]
Prints the current sum of points with or without (starred version)
``unit'': \currentpointssum
\command{bonussum}[\sarg]
Prints the sum of all bonus points with or without (starred version)
``unit'': \bonussum
\command{currentbonussum}[\sarg]
Prints the current sum of bonus points with or without (starred version)
``unit'': \currentbonussum
\command{totalpoints}[\sarg]
prints the sum of the points \emph{and} the sum of the bonus points with
``unit'': \totalpoints\space The starred version prints the sum of the
points without ``unit'': \totalpoints*.
\end{commands}
The commands \cs{pointssum}, \cs{bonussum} and \cs{totalpoints} need at
least \emph{two} \LaTeX\ runs to get the sum right.
Suppose you have an exercise worth \points{4} which consists of four questions
listed with an \env{enumerate} environment that are all worth \points{1}
each. You have two possibilities to display and count them:
\begin{example}
% uses package `enumitem'
\begin{question}{4}
\begin{enumerate}[label=\alph*)]
\item blah (\points{1})
\item blah (\points{1})
\item blah (\points{1})
\item blah (\points{1})
\end{enumerate}
\end{question}
\begin{question}
\begin{enumerate}[label=\alph*)]
\item blah (\addpoints{1})
\item blah (\addpoints{1})
\item blah (\addpoints{1})
\item blah (\addpoints{1})
\end{enumerate}
\end{question}
\end{example}
\subsection{Options}
\begin{options}
\keyval{name}{name}\Module{points}\Default{P.}
Choose the ``unit'' for the points. If you like to differentiate between
a single point and more than one point you can give a plural ending
separated with a slash: \keyis{name}{point/s}. This sets also the name of
the bonus points.
\keyval{name-plural}{plural form of name}\Module{points}\Default
Instead of forming the plural form with an ending to the singular form
this option allows to set an extra word for it. This sets also the plural
form for the bonus points.
\keyval{bonus-name}{name}\Module{points}\Default{P.}
Choose the ``unit'' for the bonus points. If you like to differentiate
between a single point and more than one point you can give a plural
ending separated with a slash: \key{bonus-name}{point/s}.
\keyval{bonus-plural}{plural form of name}\Module{points}\Default
Instead of forming the plural form with an ending to the singular form
this option allows to set an extra word for it.
\keybool{use-name}\Module{points}\Default{true}
Don't display the name at all. Or do.
\keyval{format}{code}\Module{points}\Default{\cs*{@firtsofone}}
\sinceversion{0.9d}Format number plus name as a whole. Ideally
\meta{code} would end with a command that takes an argument. Else
number plus name will be braced.
\keyval{number-format}{any code}\Module{points}\Default
This option allows formatting of the number, \eg, italics:
\keyis{number-format}{\cs*{textit}}.
\keyval{bonus-format}{any code}\Module{points}\Default
This option allows formatting of the number of the bonus points, \eg,
italics: \keyis{bonus-format}{\cs*{textit}}.
\keybool{parse}\Module{points}\Default{true}
If set to \code{false} the points are not counted and the
\cs{totalpoints}, \cs{pointssum} and \cs{bonussum} commands won't know
their value.
\keybool{separate-bonus}\Module{points}\Default{false}
This option determines whether points and bonus points each get their own
unit when they appear together (in the margin or with \cs{totalpoints}).
\keyval{pre-bonus}{tokens}\Module{points}\Default{\cs*{space}(+}
Code to be inserted before the bonus points when they follow normal
points.
\keyval{post-bonus}{tokens}\Module{points}\Default{)}
Code to be inserted after the bonus points when they follow normal
points.
\end{options}
\begin{example}[add-sourcecode-options={literate=}]
\SetupExSheets[points]{name=point/s,number-format=\color{red}}
\begin{question}{1}
This one's easy so only 1 point can be earned.
\end{question}
\begin{question}{7.5}
But this one's hard! 7.5 points are in there for you!
\end{question}
\end{example}
\section{Printing Solutions}\label{sec:solutions}
You have already seen that you can print solutions where they are using the
\option{print} option. But \ExSheets\ offers you quite more
possibilities.
In the next subsections the usage of the following command is discussed.
\begin{commands}
\command{printsolutions}[\oarg{setting}]
Print solutions of questions/exercises.
\end{commands}
Before we do that a hint: remember that you can set the option \option{print}
globally:
\begin{sourcecode}
% in the preamble
\SetupExSheets{solution/print=true}
\end{sourcecode}
Now if you want to typeset some text depending on the option being true or not
you can use the following commands:
\begin{commands}
\expandable\command{PrintSolutionsTF}[\marg{true code}\marg{false code}]
Either leaves \meta{true code} or \meta{false code} in the input stream
depending on wether solutions are printed or not, \ie, on the value of the
solution's option \option{print}. Inside a \env{solution} environment
this always prints \meta{true code}.
\expandable\command{PrintSolutionsT}[\marg{true code}]
Either leaves \meta{true code} or nothing in the input stream depending on
wether solutions are printed or not, \ie, on the value of the solution's
option \option{print}. Inside a \env{solution} environment this always
prints \meta{true code}.
\expandable\command{PrintSolutionsF}[\marg{false code}]
Either leaves nothing or \meta{false code} in the input stream depending
on wether solutions are printed or not, \ie, on the value of the
solution's option \option{print}. Inside a \env{solution}environment this
always prints nothing.
\end{commands}
They might come in handy if you want two versions of an exercise sheet, one
with the exercises and one with the solutions, and you want to add different
titles to these versions, for instance.
% When solutions are saved a lot of information is saved. One of them is the
% current counter format. The following option determines wether the saved
% counter format or the currently active one is used when \cs{printsolutions} is
% called:
% \begin{options}
% \keybool{use-saved-counter-format}\Default{true}
% \changedversion{0.21}When set to true the counter format of solutions
% printed by \cs{printsolutions}\label{option:use-saved-counter-format} are
% independent from the setting of \option{counter-format}. The saved format
% is used instead.
% \end{options}
\subsection{Print all}\label{sec:solutions-print-all}
The first and easiest usage of \cs{printsolutions} is the following:
\begin{sourcecode}
\printsolutions
\end{sourcecode}
There is nothing more to say, really. It prints all solutions you have
specified except those belonging to a question with option \keyis{use}{false}.
Yes, there's one more point: \cs{printsolutions} only knows the solutions
that have been set \emph{before} its usage! This is also true for every usage
explained in the next sections.
\begin{example}
\printsolutions
\end{example}
Two options allow to add code to the list of solutions when used with
\cs{printsolutions}\Oarg{all} (which is the same as using it without option):
\begin{options}
\keyval{chapter-hook}{code}
\sinceversion{0.13}Adds \meta{code} to the list of solutions every time
solutions from a new chapter are printed (before the solutions of the
corresponding chapter are printed).
\keyval{section-hook}{code}
\sinceversion{0.13}Adds \meta{code} to the list of solutions every time
solutions from a new section are printed (before the solutions of the
corresponding section are printed).
\end{options}
\subsection{Print per chapter/section}
\minisec{Current chapter/section}
If you are not creating an exercise sheet or an exam but are writing a
textbook you maybe want a section at the end of each chapter showing the
solution to the exercises presented in that chapter. In this case use the
command as follows:
\begin{sourcecode}
\printsolutions[section]
% or
\printsolutions[chapter]
\end{sourcecode}
Again, this is pretty much self-explaining. The solutions to the questions of
the current chapter\footnote{Only if the document class you're using
\emph{has} chapters, of course!} or section are printed.
\begin{example}
\begin{question}
This is the first and only question in this section.
\end{question}
\begin{solution}
This will be one of a few solutions printed by the following call of
\cs{printsolutions}.
\end{solution}
And now:
\printsolutions[section]
\end{example}
\minisec{Specific chapter/section}\label{sssec:print_specific_section}
You can also print only the solutions from chapters or sections other than the
current ones. The syntax is fairly easy:
\begin{example}
\printsolutions[section={1-7,10}]
% the same for chapters:
% \printsolutions[chapter={1-7,10}]
\end{example}
Don't forget that \cs{printsolutions} cannot know the solutions from
section~10 yet. It is just used to demonstrate the syntax. You can also use
an open range, \eg, something like
\begin{sourcecode}
\printsolutions[section={-4,10-}]
\end{sourcecode}
This would print the solutions from sections~1--4 and from all sections with
number 10\footnote{Or rather where \cs*{value}\Marg{section} is 10 or greater --
the actual counter formatting is irrelevant.} and greater.
There is an obvious disadvantage: you have to know the section numbers! But
there is a solution: use the package option \keyis{use-ref}{true}. Then you
can do something like
\begin{sourcecode}
% in the preamble:
\usepackage[use-ref]{exsheets}
% somewhere in your code after \section{A really cool section title}:
\label{sec:ReallyCool}
% somewhere later in your code:
\printsolutions[section={-\S{sec:ReallyCool}}]
% which will print all solutions from questions up to and
% including the really cool section
\end{sourcecode}
With the package option \keyis{use-ref}{true} each usage of \cs*{label} will
create additional labels (one preceded with \code{exse:} and another one with
\code{exch:}) which store the section number and the chapter number,
respectively. These are used internally by two commands \cs{S} and \cs{C}
which refer to the section number and the chapter number the label was created
in. \emph{These commands are only available as arguments of}
\cs{printsolutions}.
Since some packages like the well known \pkg{hyperref} for example redefine
\cs*{label} \option{use-ref} won't work in together with it. In this case
don't use \option{use-ref} and set \cs{exlabel}\marg{label} instead to
remember the section/the chapter number. Its usage is just like \cs*{label}.
So the safest way is as follows:
\begin{sourcecode}
% in the preamble:
\usepackage{exsheets}
% somewhere in your code after \section{A really cool section title}:
\exlabel{sec:ReallyCool}
% somewhere later in your code:
\printsolutions[section={-\S{sec:ReallyCool}}]
% which will print all solutions from questions up to and
% including the really cool section
\end{sourcecode}
Please be aware that the labels must be processed in a previous \LaTeX\ run
before \cs{S} and \cs{C} can pass them on to \cs{printsolutions}.
\subsection{Print by \acs{id}}\label{ssec:ids}
Now comes the best part: you can also print selected solutions! Every
question has an \acs{id}. To see which \acs{id} a question has you can call
the following command:
\begin{commands}
% \command{DebugExSheets}[\Marg{\choices{true,false}}]
% Enable or disable visual \ExSheets' debugging.
\expandable\command{CurrentQuestionID}
\sinceversion{0.4a}Expands to the current question \acs{id}.
\end{commands}
\begin{options}
\keybool{debug}
Enable or disable visual \ExSheets' debugging.
\end{options}
Let's create some more questions and take a look what this command does:
\begin{example}
\SetupExSheets{debug=true}
\begin{question}[ID=nice!]
A question with a nice \acs{id}!
\end{question}
\begin{solution}
The solution to the question with the nice \acs{id}.
\end{solution}
\begin{question}{3.75}
Yet another question. But this time with quarter points!
\end{question}
\begin{solution}
Yet another solution.
\end{solution}
\end{example}
So now we can call some specific solutions:
\begin{example}
\printsolutions[byID={first,nice!,10,14}]
\end{example}
This makes use of the \pkg{l3sort} package which at the time of writing is
still considered experimental. In case you wonder where solution~14 is:
question~14 has no solution given.
If you don't want that the solutions are sorted automatically but appear in
the order given you can use the option
\begin{options}
\keybool{sorted}\Module{solution}\Default{true}
Sort solutions given by \acs{id} or don't.
\end{options}
\section{Conditional Printing of Questions}\label{sec:cond-print-quest}
\subsection{Using Classes}\label{sec:classes}
For creating different variants of a written exam or different difficulty
levels of an exercise sheet it comes in handy if one can assign certain
classes to questions and then tell \ExSheets\ only to use one ore more
specific classes.
\begin{options}
\keyval{use-classes}{list of classes}\Default
When this option is used only the questions belonging to the specified
classes are printed and have their solutions saved.
\end{options}
\begin{example}
\SetupExSheets{use-classes={A,C}}
\begin{question}[class=A]
Belonging to class A.
\end{question}
\begin{question}[class=B]
Belonging to class B.
\end{question}
\begin{question}[class=C]
Belonging to class C!
\end{question}
\end{example}
Questions of classes that are not used are fully discarded. \emph{This also
means that questions that don't have a class assigned are discarded.}
\ExplSyntaxOn
\bool_set_false:N \g__exsheets_use_classes_bool
\ExplSyntaxOff
\subsection{Using Topics}\label{sec:topics}
Similarly to classes one can assign topics to questions. The usage is
practically identical, the semantic meaning is different.
\begin{options}
\keyval{use-topics}{list of topics}\Default
When this option is used only the questions belonging to the specified
topics are printed and have their solutions saved.
\end{options}
\begin{example}
\SetupExSheets{use-topics={trigonometry}}
\begin{question}[topic=trigonometry]
A trigonometry question.
\end{question}
\begin{question}[topic=arithmetics]
A arithmetics question
\end{question}
\end{example}
Questions of topics that are not used are fully discarded. \emph{This also
means that questions that don't have a topic assigned are discarded.}
If you set both \option{use-classes} and \option{use-topics} then only
questions will be used that \emph{match both categories}.
Ideally one could assign more than one topic to a question but this is
\emph{not} supported yet.
\ExplSyntaxOn
\bool_set_false:N \g__exsheets_use_topics_bool
\ExplSyntaxOff
\subsection{Own Dividing Concepts}
Actually\sinceversion{0.8} both classes and topics are introduced into
\ExSheets\ internally this way:
\begin{sourcecode}
\DeclareQuestionClass{class}{classes}
\DeclareQuestionClass{topic}{topics}
\end{sourcecode}
which means you can do the same introducing your own dividing concepts.
\begin{commands}
\command{DeclareQuestionClass}[\marg{singular name}\marg{plural name}]
Introduces a new dividing concept and defines both new options for the
\env{question} environment and new global options.
\end{commands}
For example you could decide you want to group your questions according to
their difficulty. You could place the following line in your preamble:
\begin{sourcecode}
\DeclareQuestionClass{difficulty}{difficulties}
\end{sourcecode}
This would define an option \option*{use-difficulties} analogous to
\option{use-classes} and \option{use-topics}. It would also define an option
\option{difficulty} for the \env{question} environment. This means you could
now do something like the following:
\begin{example}
\SetupExSheets{use-difficulties={easy,hard}}
\begin{question}[difficulty=easy]
An easy question.
\end{question}
\begin{question}[difficulty=medium]
This one's a bit harder.
\end{question}
\begin{question}[difficulty=hard]
Now let's see if you can solve this one.
\end{question}
\end{example}
\subsection{Retrieving the Class Value in a Question}\label{sec:retr-class-value}
Sometimes it may be desirable to retrieve the value of a class defined by
\cs{DeclareQuestionClass} that a question has in order to be able to print,
say. This is possible with the following commands:
\begin{commands}
\expandable\command{GetQuestionClass}[\marg{class}]
Prints the value of \meta{class} a question has. The command is
expandable. If the class does not exist or the value is empty the command
expands to nothing.
\command{PrintQuestionClassTF}[\marg{class}\marg{true}\marg{false}]
Test if a question has a non-empty value for class \meta{class} and either
leaves \meta{true} or \meta{false} in the input stream. In the
\meta{true} argument you can refer to the value with \code{\#1} where you
want it printed.
\command{PrintQuestionClassT}[\marg{class}\marg{true}]
Like \cs{PrintQuestionClassTF} but only has the \meta{true} branch.
\command{PrintQuestionClassF}[\marg{class}\marg{false}]
Like \cs{PrintQuestionClassTF} but only has the \meta{false} branch.
\end{commands}
\begin{example}
\begin{question}[difficulty=hard]
This question has the difficulty level
``\PrintQuestionClassTF{difficulty}{#1}{??}''.
\end{question}
\end{example}
\ExplSyntaxOn
\bool_set_false:N \g__exsheets_use_difficulties_bool
\ExplSyntaxOff
\subsection{Tagging Questions}
There\sinceversion{0.20} is another way of dividing questions: you can assign
tags to questions:
\begin{sourcecode}
\begin{question}[tags={foo,bar,baz}]
...
\end{question}
\end{sourcecode}
You can then decide to print only questions with certain tags by using the
following option:
\begin{options}
\keyval{use-tags}{csv list of tags to include}
Select tags. When used only questions being tagged with at least one of
the tags in \meta{csv list of tags to include} are printed.
\end{options}
\section{Adding and Using Additional Information to
Questions}\label{sec:additional_info}
\subsection{Question Properties -- the Basics}
For managing lots of questions and corresponding solutions it can be very
useful to be able to save and recover additional information to the questions.
This is possible with the following commands. First the ones for saving:
\begin{commands}
\command{DeclareQuestionProperty}[\marg{name}]
This command defines a question property \meta{name}. It can only be
used in the document preamble.
\command{SetQuestionProperties}[\Marg{\meta{name}=\meta{value},...}]
Set the properties for a specific question. this command can only be used
inside the \env{question} environment.
\end{commands}
Now the commands for recovering the properties:
\begin{commands}
\command{QuestionNumber}[\marg{id}]
Recover the number of the question with the \acs{id} \meta{id}. The
number is displayed according to the format set with
\option{counter-format}.
\expandable\command{GetQuestionProperty}[\marg{name}\marg{id}]
Recover the property \meta{name} of the question with the \acs{id}
\meta{id}. Of course the property must have been declared before. The
command is expandable. Since\changedversion{0.12} the properties of a
question are written to the \code{aux} file it is possible to retrieve
them before the corresponding \env{question} environment has been used.
\expandable\command{IfQuestionPropertyTF}[\marg{name}\marg{id}\marg{true}\marg{false}]
A command\sinceversion{0.15} that returns \meta{true} if the question with
the \acs{id} \meta{id} has the property \meta{name} and \meta{false}
otherwise. The variants \cs{IfQuestionPropertyT} and
\cs{IfQuestionPropertyF} also exist which only have the \meta{true} or the
\meta{false} branch.
\end{commands}
Let's say we have declared the properties \code{notes}, \code{reference} and
\code{topic}. By default the property \code{points} is available and gets the
value of the optional argument of the \code{question} environment.
We can now do the following:
\begin{example}
% uses `biblatex'
\begin{question}[ID=center,topic=LaTeX]{3}
Explain how you could center text in a \LaTeX\ document.
\SetQuestionProperties{
topic = \TeX/\LaTeX ,
notes = {How to center text.},
reference = {\textcite{companion}}}
\end{question}
\begin{solution}
To center a short part of the text body one can use the \env*{center}
environment (\points{1}). Inside an environment like \env*{table} one
should use \cs*{centering} (\points{1}). For single lines there is also
the \cs*{centerline} command (\points{1}).
\end{solution}
\begin{question}[ID=knuthbooks,topic=LaTeX]{2}
Name two books by D.\,E.\,Knuth.
\SetQuestionProperties{
topic = \TeX/\LaTeX ,
notes = {Books by Knuth.},
reference = {\textcite{knuth:ct:a,knuth:ct:b,knuth:ct:c,knuth:ct:d,knuth:ct:e}}}
\end{question}
\begin{solution}
For example two volumes from \citetitle{knuth:ct}:
\citetitle{knuth:ct:a,knuth:ct:b,knuth:ct:c,knuth:ct:d,knuth:ct:e}. Each
valid answer is worth \points{1}
\end{solution}
\end{example}
It is now possible to recover these values later:
\begin{example}
% uses `booktabs'
\begin{center}
\begin{tabular}{lll}
\toprule
Question & Property & \\
\midrule
\QuestionNumber{center}
& Points & \GetQuestionProperty{points}{center} \\
& Topic & \GetQuestionProperty{topic}{center} \\
& References & \GetQuestionProperty{reference}{center} \\
& Note & \GetQuestionProperty{notes}{center} \\
\midrule
\QuestionNumber{knuthbooks}
& Points & \GetQuestionProperty{points}{knuthbooks} \\
& Topic & \GetQuestionProperty{topic}{knuthbooks} \\
& References & \GetQuestionProperty{reference}{knuthbooks} \\
& Note & \GetQuestionProperty{notes}{knuthbooks} \\
\bottomrule
\end{tabular}
\end{center}
\end{example}
Please note that properties \emph{are not the same} as the dividing concepts
explained in section~\ref{sec:cond-print-quest} although they may seem
similar in meaning or even have the same name.
When properties are set they are also written to the \code{aux} file which
means they can be retrieved \emph{before} the corresponding question. Of
course this means that two compilation runs are necessary.
\subsection{Pre-defined Properties}
A few properties are already defined by \ExSheets:
\begin{itemize}
\item \code{counter}:\sinceversion{0.14} this property holds the actual
question number formatted according to the formatting set with option
\option{counter-format}.
\item \code{subtitle}:\sinceversion{0.12} this property holds the subtitle
of the question if given.
\item \code{question-body}:\sinceversion{0.14} this property holds the body
of the corresponding \env{question} environment. Unlike the other
properties it is per default \emph{not} written to the \code{aux} file.
\item \code{points}: this property holds the sum of points given to a
question.
\item \code{bonus-points}:\sinceversion{0.14} this property holds the sum of
bonus points given to a question.
\item \code{ref}:\sinceversion{0.7f} when the option \option{auto-label} is
used this property is defined and expands to the corresponding \cs*{ref}.
Also see section~\ref{sec:auto-label-opti}.
\item \code{page-ref}:\sinceversion{0.7f} when the option
\option{auto-label} is used this property is defined and expands to the
corresponding \cs*{pageref}. Also see section~\ref{sec:auto-label-opti}.
\end{itemize}
There is one option affecting the property \code{question-body}:
\begin{options}
\keybool{save-to-aux}\Module{question}\Default{false}
When set to \code{true} the property \code{question-body} is also written
to the \code{aux} file.
\end{options}
\subsection{Advanced Usage}
There are additional commands\sinceversion{0.3} that might prove useful. They
allow advanced usage of defined properties. Below an example is shown how
they can be used to generate a grading table.
\begin{commands}
\command{ForEachQuestion}[\marg{code to be executed for each used question}]
\changedversion{0.14}Inside the argument one can refer to the \ac{id} of a
question with \code{\#1}. You can also refer to the number of the
question with \code{\#2}. \emph{Number} means that if you \emph{use}
seven questions then those questions have numbers~1 to~7.
\expandable\command{numberofquestions}
\changedversion{0.14} returns the complete number of used questions.
\expandable\command{iflastquestion}[\marg{true code}\marg{false code}]
Although this command is available in the whole document it is only useful
inside \cs{ForEachQuestion}. It tells you if the end of the loop is
reached or not.
\end{commands}
One could use these commands to create a grading table, for instance:
\begin{sourcecode}
\begin{tabular}{|l|*{\numberofquestions}{c|}c|}\hline
Question &
\ForEachQuestion{\QuestionNumber{#1}\iflastquestion{}{&}} &
Total \\ \hline
Points &
\ForEachQuestion{\GetQuestionProperty{points}{#1}\iflastquestion{}{&}} &
\pointssum* \\ \hline
Reached &
\ForEachQuestion{\iflastquestion{}{&}} & \\ \hline
\end{tabular}
\end{sourcecode}
For four questions the table now would look similar to
figure~\ref{fig:grading-table}.
\begin{figure}[ht]
\centering
\begin{tabular}{|l|*{4}{c|}c|}\hline
Question & 1. & 2. & 3. & 4. & Total \\ \hline
Points & 3 & 5 & 10 & 8 & 26 \\ \hline
Reached & & & & & \\ \hline
\end{tabular}
\caption{An example for a grading table. (Actually this is a fake. See the
\code{grading-table.tex} file shipped with exsheets for the real use case.)}
\label{fig:grading-table}
\end{figure}
\section{Variations of an Exam}
It is a quite common task\sinceversion{0.6} to design an exam in two different
variants. This is of course possible with \ExSheets' classes (see
section~\ref{sec:classes}). However, often not the whole question is to be
different but only small details, the numbers in a maths exam, say. For this
purpose \ExSheets\ provides the following commands:
\begin{commands}
\command{SetVariations}[\marg{num}]
Set the number of different variants. This will determine how many
arguments the command \cs{vary} will get. \meta{num} must at least be
\code{2} and is initially set to \code{2}.
\command{variant}[\marg{num}]
Choose the active variant. The argument must be a number between \code{1}
and the number set with \cs{SetVariations}. Initially set to \code{1}.
\command{vary}[\marg{variant 1}\marg{variant 2}]
This command is the one actually used in the document. It has a number of
required arguments equal to the number set with \cs{SetVariations}. All
of its arguments are discarded except the one specified with
\cs{variant}.
\command{lastvariant}
\sinceversion{0.7b}Each time \cs{vary} is called it stores the value it
chose in \cs{lastversion}. This might be convenient to use if one
otherwise would have to repeatedly write the same \cs{vary}.
\end{commands}
\begin{example}
\SetVariations{6}%
\variant{6}\vary{A}{B}{C}{D}{E}{F}
(last variant: \lastvariant)
\variant{1}\vary{A}{B}{C}{D}{E}{F}
(last variant: \lastvariant)
\variant{5}\vary{A}{B}{C}{D}{E}{F}
(last variant: \lastvariant)
\variant{2}\vary{A}{B}{C}{D}{E}{F}
(last variant: \lastvariant)
\variant{4}\vary{A}{B}{C}{D}{E}{F}
(last variant: \lastvariant)
\variant{3}\vary{A}{B}{C}{D}{E}{F}
(last variant: \lastvariant)
\end{example}
\section{A Grade Distribution}
Probably this is a rather esoteric feature but it could proof useful in some
cases. Suppose you are a German math teacher and want to grade exactly
corresponding to the number of points relative to the sum of total points,
regardless of how big that might be. You could do something like this to
present your grading decisions for the exam:
\begin{example}
% preamble:
% \DeclareRelGrades{
% 1 = 1 ,
% {1,5} = .9167 ,
% 2 = .8333 ,
% {2,5} = .75 ,
% 3 = .6667 ,
% {3,5} = .5833 ,
% 4 = .5
% }
\small\setlength\tabcolsep{2pt}
\begin{tabular}{r|*8c}
Punkte
& $\grade*{1}$ & $\le\grade*{1}$ & $\le\grade*{1,5}$ & $\le\grade*{2}$
& $\le\grade*{2,5}$ & $\le\grade*{3}$ & $\le\grade*{3,5}$ & $<\grade*{4}$ \\
Note
& 1 & 1--2 & 2 & 2--3 & 3 & 3--4 & 4 & 5
\end{tabular}
\end{example}
These are the available commands and options:
\begin{commands}
\command{DeclareRelGrades}[\Marg{\meta{grade}=\meta{num},...}]
This command is used to define grades and assign the percentage of total
points to them.
\command{grade}[\sarg\marg{grade}]
Gives the number of points corresponding to a grade depending on the value
of \cs{pointssum} with or without (starred version) ``unit''.
\end{commands}
\begin{options}
\keyval{round}{num}\Module{grades}\Default{0}
The number of decimals the points of a grade are rounded to. This doesn't
apply to the maximum number of points if the rounded number would be
bigger than the actual sum.
\keybool{half}\Module{grades}\Default{false}
If set to \code{true} points are rounded either to full or to half
points.
\end{options}
\section{Selectively Include Questions from External Files}\label{sec:include}
\subsection{Caveat}
I need to say some words of caution: the \cs{includequestions} that will be
presented shortly is probably \ExSheets' most experimental one at the time of
writing (\today). Thanks to feedback of users it is constantly improved and
bugs are fixed. It is not a very efficient way to insert question regarding
performance and you shouldn't wonder if compilation slows down when you use
it. It probably needs to be re-written all over but on the one hand that
would introduce new bugs and on the other hand for the time being I don't have
the capacities, anyway, so you'll have to live it, I'm afraid.
\subsection{How it works}
Suppose you have one or more files with questions prepared to use them as a
kind of database. One for class A, say, one for class B, one for class C and
so one, something like this:
\begin{sourcecode}
% this is file classA.tex
\begin{question}[class=A,ID=A1,topic=X]
First question of class A, topic X.
\end{question}
\begin{solution}
First solution of class A.
\end{solution}
\begin{question}[class=A,ID=A2,topic=Y]
Second question of class A, topic Y.
\end{question}
\begin{solution}
Second solution of class A.
\end{solution}
...
% end of file classA.tex
\endinput
\end{sourcecode}
You can of course just \cs*{input} or \cs*{include} it but that would of
course include the whole file into your document. But would't it be nice to
just include selected questions? Or maybe a five random questions from the
file? That is possible with the following command:
\begin{commands}
\command{includequestions}[\oarg{options}\marg{list of filenames}]
Include questions from external files.
\end{commands}
If you use it without options it will have the same effect as \cs*{input}.
There are however the following options:
\begin{options}
\keybool{all}\Module{include}
\keyval{IDs}{list of IDs}\Module{include}\Default
Includes only the specified questions.
\keyval{random}{num}\Module{include}\Default
Includes \meta{num} randomly selected questions. This option uses the
\pkg{pgfcore} package to create the pseudo-random numbers.
\keyval{exclude}{list of IDs}\Module{include}\Default
Questions who's \acp{id} are specified here are \emph{not} included. This
option can be combined with the \option{random} option.
\end{options}
The usage should be self-explainable:
\begin{sourcecode}
% include questions A1, A3 and A4:
\includequestions[IDs={A1,A3,A4}]{classA.tex}
% or include 3 random questions:
\includequestions[random=3]{classA}
\end{sourcecode}
In order to be able to select the questions \ExSheets\ needs to \cs*{input}
the file twice. The first time the available questions are determined, the
second time the selected questions are used. This unfortunately means that
anything that is \emph{not} part of a question or solution is also input
twice. Either don't put anything else into the file or use one of the
following commands for control:
\begin{commands}
\command{PrintIfIncludeActiveTF}[\marg{true code}\marg{false code}]
Checks if the questions are actively included or not and puts \meta{true
code} or \meta{false code} in the input stream depending on the answer.
\command{PrintIfIncludeActiveT}[\marg{true code}]
Checks if the questions are actively included or not and puts \meta{true
code} in the input stream if the answer is yes.
\command{PrintIfIncludeActiveF}[\marg{false code}]
Checks if the questions are actively included or not and puts \meta{false
code} in the input stream if the answer is no.
\end{commands}
The selection can be refined further by selecting questions belonging to a
specific class of questions (see section~\ref{sec:cond-print-quest}) before
using \cs{includequestions}.
\sinceversion{0.8}After you've used \cs{includequestions} the \acp{id} of the
included questions is available as an unordered comma separated list in the
following macro:
\begin{commands}
\command{questionsincludedlast}
Unordered comma separated list of question \acp{id} included with the last
usage of \cs{includequestions}.
\end{commands}
\section{The \option*{auto-label} Option}\label{sec:auto-label-opti}
The\sinceversion{0.12} package option \option{auto-label} sets a
\cs*{label}\Marg{qu:\meta{id}} every time the question environment is used.
Both the used command and the automated label can be customized using the
following options:
\begin{options}
\keyval{label-format}{code}\Default{qu:\#1}
The pattern for generating the automatic label. \code{\#1} gets replaced
by the \ac{id} of the corresponding question.
\keyval{label-cmd}{macro}\Default{\cs*{label}}
The command used for generating the label. A command that should take one
mandatory argument.
\keyval{ref-cmd}{macro}\Default{\cs*{ref}}
The command used in the \code{ref} property created by the
\option{auto-label} option, also see section \ref{sec:additional_info}.
The command should take one mandatory argument.
\keyval{pageref-cmd}{macro}\Default{\cs*{pageref}}
The command used in the \code{pageref} property created by the
\option{auto-label} option, also see section \ref{sec:additional_info}.
The command should take one mandatory argument.
\end{options}
\section{Own Question/Solution Pairs}
\ExSheets\changedversion{0.9} provides the possibility to create new
environments that behave like the \env{question} and \env{solution}
environments. This would allow, for example, to define a
\env*{question*}/\env*{solution*} environment pair for bonus questions. The
following commands may be used in the document preamble:
\begin{commands}
\command{NewQuSolPair}[\marg{question}\oarg{question options}\oarg{general
options}\marg{solution}\oarg{solution options}\oarg{general options}]
Define a new pair of question and solution environments.
\command{RenewQuSolPair}[\marg{question}\oarg{question options}\oarg{general
options}\marg{solution}\oarg{solution options}\oarg{general options}]
Redefine an existing pair of question and solution environments.
\end{commands}
The standard environments are defined as follows:
\begin{sourcecode}
\NewQuSolPair{question}{solution}
\end{sourcecode}
Let's say we want the possibility to add bonus questions. A simple way would
be to define starred variants that add a star in the margin left to the title:
\begin{example}
% preamble:
% - \texorpdfstring is provided by `hyperref'
% - \bigstar is provided by `amssymb'
% \DeclareRobustCommand*\questionstar{\texorpdfstring{\bonusquestionsign}{* }}
% \DeclareRobustCommand*\bonusquestionsign{\llap{$\bigstar$\space}}
%
% \NewQuSolPair
% {question*}[name=\questionstar Bonus Question]
% {solution*}[name=\questionstar Solution]
\begin{question*}
This is a bonus question.
\end{question*}
\begin{solution*}[print]
This is what the solution looks like.
\end{solution*}
\end{example}
As you can see the environments take the same options as are described for the
standard \env{question} and \env{solution} environments.
\section{Filling in the Blanks}
\subsection{Cloze}
Both\changedversion{0.4} in exercise sheets and in exams it is sometimes
desirable to be able to create \blank{blanks} that have to be filled in. Or
maybe some more lines: \blank[width=5\linewidth]{}
\begin{commands}
\command{blank}[\sarg\oarg{options}\marg{text to be filled in}]
creates a blank in normal text or in a question but fills the text of its
argument if inside a solution. If used at the \emph{begin of a paragraph}
\cs{blank} will do two things: it will set the linespread according to an
option explained below and will insert \cs*{par} after the lines. If you
don't want that use the starred version.
\end{commands}
The options are these:
\begin{options}
\keychoice{style}{line,wave,dline,dotted,dashed}\Module{blank}\Default{line}
The style of the line. This uses the corresponding command from the
\pkg{ulem} package and is the whole reason why \ExSheets\ loads it in the
first place.
\keyval{scale}{num}\Module{blank}\Default{1}
Scales the width of the blank by factor \meta{num} unless the width is
explicitly set.
\keyval{width}{dim}\Module{blank}\Default
The width of the line. If it is not used the width of the filled in text
is used.
\keyval{linespread}{num}\Module{blank}\Default{1}
Set the linespread for the blank lines. This only has an effect if
\cs{blank} is used at the begin of a paragraph.
\keyval{line-increment}{dim}\Module{blank}\Default{1pt}
\sinceversion{0.21h}When the blank line ist built it is built in multiples
of this value. If the value is too large you may end up with uneven
lines. If the value is too small you may end up with a non-ending
compilation.
\keyval{line-minimum-length}{dim}\Module{blank}\Default{2em}
\sinceversion{0.21h}The minimal length a line must have before it is built
step by step.
\end{options}
\begin{example}
\begin{question}
Try to fill in \blank[width=4cm]{these} blanks. All of them
\blank[style=dotted]{are created} by using the \cs{blank}
\blank[style=dashed]{command}.
\end{question}
\begin{solution}[print]
Try to fill in \blank[width=4cm]{these} blanks. All of them
\blank[style=dotted]{are created} by using the \cs{blank}
\blank[style=dashed]{command}.
\end{solution}
\end{example}
A number of empty lines are easily created by setting the width option:
\begin{example}
\blank[width=4.8\linewidth,linespread=1.5]{}
\end{example}
\subsection{Vertical Space for answers}
When\sinceversion{0.3} you're creating an exam you might want to add some
vertical space where the students can write down their answers. While you can
always use \cs*{vspace} this is not always handy when the space left on the
page is less than you want. In this case it would be nice if a) there would
be no warning and b) the rest of the space would be added at the top of the
next page. This is what the following command is for:
\begin{commands}
\command{examspace}[\sarg\marg{dim}]
Add space as specified in \meta{dim}. If the space available on the
current page is not enough the rest of the space will be added at the top
of the next page. The starred version will silently drop any leftover
space instead of adding it to the next page.
\end{commands}
\begin{example}[side-by-side]
\begin{question}
What do you think of this feature?
\examspace{3cm}
\end{question}
This line comes after the space.
\end{example}
\section{Styling your Exercise/Exam Sheets}\label{part:style}
\subsection{Background}
The \ExSheets\ package makes extensive use of \LaTeX3's coffins\footnote{See
the documentation to the \pkg{xcoffins} package for more information on
that.} as well as its templates concept\footnote{Have a look into the
documentation to the \pkg{xtemplate} package.}. The latter allows a
rather easy extension and customization of some of \ExSheets' environments.
To be more precise: you can define your own instances for the headings used
for questions and solutions.
What this package doesn't provide is changing the background of questions or
framing them. But this is easily possible using the \pkg{mdframed} package
and its \cs*{surroundwithmdframed} command.
\ExSheets{} also provides the options \option{pre-hook}, \option{post-hook},
\option{pre-body-hook} and \option{post-body-hook} to both the question and
the solution environment. With them it is rather straightforward to add a
\pkg{mdframed} frame for instance:
\begin{sourcecode}
\SetupExSheets{
solution/pre-hook = \mdframed ,
solution/post-hook = \endmdframed
}
\end{sourcecode}
Then\sinceversion{0.18} there is the macro
\cs{exsheetsprintsolution}\marg{heading}\marg{body}\label{exsheetsprintsolution}
which may be redefined to suit your needs. The default definition is
equivalent to
\begin{sourcecode}
\newcommand\exsheetsprintsolution[2]{#1#2}
\end{sourcecode}
\subsection{The \code{exsheets-headings} Object}\label{sec:exsheets-headings}
\ExSheets\ defines the object \code{exsheets-headings} and one template for it,
the `default' template. The package also defines two instances of this
template, the `block' instance and the `runin' instance.
\begin{example}
\SetupExSheets{headings=block}
\begin{question}{1}
a `block' heading
\end{question}
\SetupExSheets{headings=runin}
\begin{question}{1}
a `runin' heading
\end{question}
\end{example}
\subsubsection{Available Options}
This section only lists the options that can be used when defining an instance
of the `default' template. The following subsections will give loads of
examples of their usage. The options are listed in the definition for the
template interface:
\begin{sourcecode}
\DeclareTemplateInterface{exsheets-heading}{default}{3}{
% option : type = default
inline : boolean = false ,
runin : boolean = false ,
indent-first : boolean = false ,
toc-reversed : boolean = false ,
vscale : real = 1 ,
above : length = 2pt ,
below : length = 2pt ,
main : tokenlist = ,
pre-code : tokenlist = ,
post-code : tokenlist = ,
title-format : tokenlist = ,
title-pre-code : tokenlist = ,
title-post-code : tokenlist = ,
number-format : tokenlist = ,
number-pre-code : tokenlist = ,
number-post-code : tokenlist = ,
subtitle-format : tokenlist = ,
subtitle-pre-code : tokenlist = ,
subtitle-post-code : tokenlist = ,
points-format : tokenlist = ,
points-pre-code : tokenlist = ,
points-post-code : tokenlist = ,
join : tokenlist = ,
attach : tokenlist =
}
\end{sourcecode}
Each heading is built with at most five coffins available with the names
`main', `title', `subtitle', `number' and `points'. Those coffins place
possibly the whole heading, the title, the subtitle, the question number and
the assigned points. The only coffin that's always typeset is the `main'
coffin, which is empty per default.
Coffins can be joined (two become one, the first extends its bounding box to
contain the second) using the following syntax:
\begin{sourcecode}
join = coffin1[handle11,handle12]coffin2[handle21,handle22](x-offset,y-offset)
\end{sourcecode}
The syntax for attaching (two become one, the first does \emph{not} extend its
bounding box around the second) is the same.
More on coffin handles is described in the documentation for the
\pkg{xcoffins}. Figure~\ref{fig:handles} briefly demonstrates the available
handle pairs.
\begin{figure}[ht]
\centering
\parbox{4.5cm}{%
\NewCoffin\ExampleCoffin
\SetHorizontalCoffin\ExampleCoffin{\color{gray!30}\rule{4cm}{4cm}}%
\DisplayCoffinHandles\ExampleCoffin{blue}%
}
\caption{Available handles for a horizontal coffin.}\label{fig:handles}
\end{figure}
It is possible\sinceversion{0.20} to add own static coffins:
\begin{commands}
\command{DeclareExSheetsHeadingContainer}[\marg{name}\marg{code}]
Defines a new coffin \meta{name} containing \meta{code}. You can refer to
the current question's \ac{id} with \cs{CurrentQuestionID}.
\end{commands}
The following subsections will show all definitions of the instances available
and how they look. This will hopefully give you enough ideas to create your
own instance if you want to have another heading style than the ones
available. Each of the following instances is available through the option
\key{headings}{instance}.
The following examples use a sample text defined as follows:
\begin{sourcecode}
\def\s{This is some sample text we will use to create a somewhat
longer text spanning a few lines.}
\def\sample{\s\ \s\par\s}
\end{sourcecode}
\def\s{This is some sample text we will use to create a somewhat longer text
spanning a few lines.}
\def\sample{\s\ \s\par\s}
All of the following examples use the same question call:
\begin{sourcecode}
\SetupExSheets{headings=<name>}
\begin{question}[subtitle=The subtitle of the question]{1}
A `<name>' heading. \sample
\end{question}
\end{sourcecode}
\subsubsection{The `block' Instance}
\begin{sourcecode}
\DeclareInstance{exsheets-heading}{block}{default}{
join = { title[r,B]number[l,B](.333em,0pt) } ,
attach =
{
main[l,vc]title[l,vc](0pt,0pt) ;
main[r,vc]points[l,vc](\marginparsep,0pt)
}
}
\end{sourcecode}
\SetupExSheets{headings=block}
\begin{question}[subtitle=The subtitle of the question]{1}
A `block' heading. \sample
\end{question}
\subsubsection{The `runin' Instance}
\begin{sourcecode}
\DeclareInstance{exsheets-heading}{runin}{default}{
runin = true ,
number-post-code = \space ,
attach =
{ main[l,vc]points[l,vc](\linewidth+\marginparsep,0pt) } ,
join =
{
main[r,vc]title[r,vc](0pt,0pt) ;
main[r,vc]number[l,vc](.333em,0pt)
}
}
\end{sourcecode}
\SetupExSheets{headings=runin}
\begin{question}[subtitle=The subtitle of the question]{1}
A `runin' heading. \sample
\end{question}
\subsubsection{The `simple' Instance}
\begin{sourcecode}
\DeclareInstance{exsheets-heading}{simple}{default}{
title-format = \normalsize ,
points-pre-code = ( ,
points-post-code = ) ,
attach = { main[l,t]number[l,t](0pt,0pt) } ,
join =
{
number[r,b]title[l,b](.333em,0pt) ;
main[l,b]points[l,t](1em,0pt)
}
}
\end{sourcecode}
\SetupExSheets{headings=simple}
\begin{question}[subtitle=The subtitle of the question]{1}
A `simple' heading. \sample
\end{question}
\subsubsection{The `empty' Instance}
\sinceversion{0.9a}
\begin{sourcecode}
\DeclareInstance{exsheets-heading}{empty}{default}{
runin = true ,
above = \parskip ,
below = \parskip ,
attach = { main[l,vc]points[l,vc](\linewidth+\marginparsep,0pt) }
}
\end{sourcecode}
\SetupExSheets{headings=empty}
\begin{question}[subtitle=The subtitle of the question]{1}
An `empty' heading. \sample
\end{question}
\subsubsection{The `block-rev' Instance}
\begin{sourcecode}
\DeclareInstance{exsheets-heading}{block-rev}{default}{
toc-reversed = true ,
join = { number[r,B]title[l,B](.333em,0pt) } ,
attach =
{
main[l,vc]number[l,vc](0pt,0pt) ;
main[r,vc]points[l,vc](\marginparsep,0pt)
}
}
\end{sourcecode}
\SetupExSheets{headings=block-rev}
\begin{question}[subtitle=The subtitle of the question]{1}
A `block-rev' heading. \sample
\end{question}
\subsubsection{The `block-subtitle' Instance}
\sinceversion{0.10}
\begin{sourcecode}
\DeclareInstance{exsheets-heading}{block-subtitle}{default}{
join = {
title[r,B]number[l,B](.333em,0pt) ;
title[r,B]subtitle[l,B](1em,0pt)
} ,
attach = {
main[l,vc]title[l,vc](0pt,0pt) ;
main[r,vc]points[l,vc](\marginparsep,0pt)
}
}
\end{sourcecode}
\SetupExSheets{headings=block-subtitle}
\begin{question}[subtitle=The subtitle of the question]{1}
A `block-subtitle' heading. \sample
\end{question}
\subsubsection{The `block-wp' Instance}
\begin{sourcecode}
\DeclareInstance{exsheets-heading}{block-wp}{default}{
points-pre-code = ( ,
points-post-code = ) ,
join =
{
title[r,B]number[l,B](.333em,0pt) ;
title[r,B]points[l,B](.333em,0pt)
} ,
attach = { main[l,vc]title[l,vc](0pt,0pt) }
}
\end{sourcecode}
\SetupExSheets{headings=block-wp}
\begin{question}[subtitle=The subtitle of the question]{1}
A `block-wp' heading. \sample
\end{question}
\subsubsection{The `block-wp-rev' Instance}
\begin{sourcecode}
\DeclareInstance{exsheets-heading}{block-wp-rev}{default}{
toc-reversed = true ,
points-pre-code = ( ,
points-post-code = ) ,
join =
{
number[r,B]title[l,B](.333em,0pt) ;
number[r,B]points[l,B](.333em,0pt)
} ,
attach = { main[l,vc]number[l,vc](0pt,0pt) }
}
\end{sourcecode}
\SetupExSheets{headings=block-wp-rev}
\begin{question}[subtitle=The subtitle of the question]{1}
A `block-wp-rev' heading. \sample
\end{question}
\subsubsection{The `block-nr' Instance}
\begin{sourcecode}
\DeclareInstance{exsheets-heading}{block-nr}{default}{
attach =
{
main[l,vc]number[l,vc](0pt,0pt) ;
main[r,vc]points[l,vc](\marginparsep,0pt)
}
}
\end{sourcecode}
\SetupExSheets{headings=block-nr}
\begin{question}[subtitle=The subtitle of the question]{1}
A `block-nr' heading. \sample
\end{question}
\subsubsection{The `block-nr-wp' Instance}
\begin{sourcecode}
\DeclareInstance{exsheets-heading}{block-nr-wp}{default}{
points-pre-code = ( ,
points-post-code = ) ,
join = { number[r,vc]points[l,vc](.333em,0pt) } ,
attach = { main[l,vc]number[l,vc](0pt,0pt) }
}
\end{sourcecode}
\SetupExSheets{headings=block-nr-wp}
\begin{question}[subtitle=The subtitle of the question]{1}
A `block-nr-wp' heading. \sample
\end{question}
\subsubsection{The `runin-rev' Instance}
\begin{sourcecode}
\DeclareInstance{exsheets-heading}{runin-rev}{default}{
toc-reversed = true ,
runin = true ,
title-post-code = \space ,
attach =
{ main[l,vc]points[l,vc](\linewidth+\marginparsep,0pt) } ,
join =
{
main[r,vc]number[r,vc](0pt,0pt) ;
main[r,vc]title[l,vc](.333em,0pt)
}
}
\end{sourcecode}
\SetupExSheets{headings=runin-rev}
\begin{question}[subtitle=The subtitle of the question]{1}
A `runin-rev' heading. \sample
\end{question}
\subsubsection{The `runin-wp' Instance}
\begin{sourcecode}
\DeclareInstance{exsheets-heading}{runin-wp}{default}{
runin = true ,
points-pre-code = ( ,
points-post-code = )\space ,
join =
{
main[r,vc]title[r,vc](0pt,0pt) ;
main[r,vc]number[l,vc](.333em,0pt) ;
main[r,vc]points[l,vc](.333em,0pt)
}
}
\end{sourcecode}
\SetupExSheets{headings=runin-wp}
\begin{question}[subtitle=The subtitle of the question]{1}
A `runin-wp' heading. \sample
\end{question}
\subsubsection{The `runin-wp-rev' Instance}
\begin{sourcecode}
\DeclareInstance{exsheets-heading}{runin-wp-rev}{default}{
toc-reversed = true ,
runin = true ,
points-pre-code = ( ,
points-post-code = )\space ,
join =
{
main[r,vc]number[r,vc](0pt,0pt) ;
main[r,vc]title[l,vc](.333em,0pt) ;
main[r,vc]points[l,vc](.333em,0pt)
}
}
\end{sourcecode}
\SetupExSheets{headings=runin-wp-rev}
\begin{question}[subtitle=The subtitle of the question]{1}
A `runin-wp-rev' heading. \sample
\end{question}
\subsubsection{The `runin-nr' Instance}
\begin{sourcecode}
\DeclareInstance{exsheets-heading}{runin-nr}{default}{
runin = true ,
number-post-code = \space ,
attach =
{ main[l,vc]points[l,vc](\linewidth+\marginparsep,0pt) } ,
join = { main[r,vc]number[l,vc](0pt,0pt) }
}
\end{sourcecode}
\SetupExSheets{headings=runin-nr}
\begin{question}[subtitle=The subtitle of the question]{1}
A `runin-nr' heading. \sample
\end{question}
\subsubsection{The `runin-fixed-nr' Instance}
\begin{sourcecode}
\DeclareInstance{exsheets-heading}{runin-fixed-nr}{default}{
runin = true ,
number-pre-code = \hbox to 2em \bgroup ,
number-post-code = \hfil\egroup ,
attach =
{ main[l,vc]points[l,vc](\linewidth+\marginparsep,0pt) } ,
join = { main[r,vc]number[l,vc](0pt,0pt) }
}
\end{sourcecode}
\SetupExSheets{headings=runin-fixed-nr}
\begin{question}[subtitle=The subtitle of the question]{1}
A `runin-fixed-nr' heading. \sample
\end{question}
\subsubsection{The `runin-nr-wp' Instance}
\begin{sourcecode}
\DeclareInstance{exsheets-heading}{runin-nr-wp}{default}{
runin = true ,
points-pre-code = ( ,
points-post-code = )\space ,
join =
{
main[r,vc]number[l,vc](0pt,0pt) ;
main[r,vc]points[l,vc](.333em,0pt)
}
}
\end{sourcecode}
\SetupExSheets{headings=runin-nr-wp}
\begin{question}[subtitle=The subtitle of the question]{1}
A `runin-nr-wp' heading. \sample
\end{question}
\subsubsection{The `inline' Instance}
\sinceversion{0.5}
\begin{sourcecode}
\DeclareInstance{exsheets-heading}{inline}{default}{
inline = true ,
number-pre-code = \space ,
number-post-code = \space ,
join =
{
main[r,vc]title[r,vc](0pt,0pt) ;
main[r,vc]number[l,vc](0pt,0pt)
}
}
\end{sourcecode}
\SetupExSheets{headings=inline}
Text before
\begin{question}[subtitle=The subtitle of the question]{1}
An `inline' heading. \sample
\end{question}
Text after
\subsubsection{The `inline-wp' Instance}
\sinceversion{0.5}
\begin{sourcecode}
\DeclareInstance{exsheets-heading}{inline-wp}{default}{
inline = true ,
number-pre-code = \space ,
number-post-code = \space ,
points-pre-code = ( ,
points-post-code = )\space ,
join =
{
main[r,vc]title[r,vc](0pt,0pt) ;
main[r,vc]number[l,vc](0pt,0pt) ;
main[r,vc]points[l,vc](0pt,0pt)
}
}
\end{sourcecode}
\SetupExSheets{headings=inline-wp}
Text before
\begin{question}[subtitle=The subtitle of the question]{1}
An `inline-wp' heading. \sample
\end{question}
Text after
\subsubsection{The `inline-nr' Instance}
\sinceversion{0.5}
\begin{sourcecode}
\DeclareInstance{exsheets-heading}{inline-nr}{default}{
inline = true ,
number-post-code = \space ,
join = { main[r,vc]number[l,vc](0pt,0pt) }
}
\end{sourcecode}
\SetupExSheets{headings=inline-nr}
Text before
\begin{question}[subtitle=The subtitle of the question]{1}
An `inline-nr' heading. \sample
\end{question}
Text after
\subsubsection{The `centered' Instance}
\begin{sourcecode}
\DeclareInstance{exsheets-heading}{centered}{default}{
join = { title[r,B]number[l,B](.333em,0pt) } ,
attach =
{
main[hc,vc]title[hc,vc](0pt,0pt) ;
main[r,vc]points[l,vc](\marginparsep,0pt)
}
}
\end{sourcecode}
\SetupExSheets{headings=centered}
\begin{question}[subtitle=The subtitle of the question]{1}
A `centered' heading. \sample
\end{question}
\subsubsection{The `centered-wp' Instance}
\begin{sourcecode}
\DeclareInstance{exsheets-heading}{centered-wp}{default}{
points-pre-code = ( ,
points-post-code = ) ,
join =
{
title[r,B]number[l,B](.333em,0pt) ;
title[r,B]points[l,B](.333em,0pt)
} ,
attach = { main[hc,vc]title[hc,vc](0pt,0pt) }
}
\end{sourcecode}
\SetupExSheets{headings=centered-wp}
\begin{question}[subtitle=The subtitle of the question]{1}
A `centered-wp' heading. \sample
\end{question}
\subsubsection{The `margin' Instance}
\begin{sourcecode}
\DeclareInstance{exsheets-heading}{margin}{default}{
runin = true ,
number-post-code = \space ,
points-pre-code = ( ,
points-post-code = )\space ,
join = { title[r,b]number[l,b](.333em,0pt) } ,
attach =
{
main[l,vc]title[r,vc](0pt,0pt) ;
main[l,b]points[r,t](0pt,0pt)
}
}
\end{sourcecode}
\SetupExSheets{headings=margin}
\begin{question}[subtitle=The subtitle of the question]{1}
A `margin' heading. \sample
\end{question}
\subsubsection{The `margin-nr' Instance}
\begin{sourcecode}
\DeclareInstance{exsheets-heading}{margin-nr}{default}{
runin = true ,
attach =
{
main[l,vc]number[r,vc](-.333em,0pt) ;
main[r,vc]points[l,vc](\linewidth+\marginparsep,0pt)
}
}
\end{sourcecode}
\SetupExSheets{headings=margin-nr}
\begin{question}[subtitle=The subtitle of the question]{1}
A `margin-nr' heading. \sample
\end{question}
\subsubsection{The `raggedleft' Instance}
\begin{sourcecode}
\DeclareInstance{exsheets-heading}{raggedleft}{default}{
join = { title[r,B]number[l,B](.333em,0pt) } ,
attach =
{
main[r,vc]title[r,vc](0pt,0pt) ;
main[r,vc]points[l,vc](\marginparsep,0pt)
}
}
\end{sourcecode}
\SetupExSheets{headings=raggedleft}
\begin{question}[subtitle=The subtitle of the question]{1}
A `raggedleft' heading. \sample
\end{question}
\subsubsection{The `fancy' Instance}
\begin{sourcecode}
\DeclareInstance{exsheets-heading}{fancy}{default}{
toc-reversed = true ,
indent-first = true ,
vscale = 2 ,
pre-code = \rule{\linewidth}{1pt} ,
post-code = \rule{\linewidth}{1pt} ,
title-format = \large\scshape\color{rgb:red,0.65;green,0.04;blue,0.07} ,
number-format = \large\bfseries\color{rgb:red,0.02;green,0.04;blue,0.48} ,
points-format = \itshape ,
join = { number[r,B]title[l,B](.333em,0pt) } ,
attach =
{
main[hc,vc]number[hc,vc](0pt,0pt) ;
main[l,vc]points[r,vc](-\marginparsep,0pt)
}
}
\end{sourcecode}
\SetupExSheets{headings=fancy}
\begin{question}[subtitle=The subtitle of the question]{1}
A `fancy' heading. \sample
\end{question}
\subsubsection{The `fancy-wp' Instance}
\begin{sourcecode}
\DeclareInstance{exsheets-heading}{fancy-wp}{default}{
toc-reversed = true ,
indent-first = true ,
vscale = 2 ,
pre-code = \rule{\linewidth}{1pt} ,
post-code = \rule{\linewidth}{1pt} ,
title-format = \large\scshape\color{rgb:red,0.65;green,0.04;blue,0.07} ,
number-format = \large\bfseries\color{rgb:red,0.02;green,0.04;blue,0.48} ,
points-format = \itshape ,
points-pre-code = ( ,
points-post-code = ) ,
join =
{
number[r,B]title[l,B](.333em,0pt) ;
number[r,B]points[l,B](.333em,0pt)
} ,
attach = { main[hc,vc]number[hc,vc](0pt,0pt) }
}
\end{sourcecode}
\SetupExSheets{headings=fancy-wp}
\begin{question}[subtitle=The subtitle of the question]{1}
A `fancy-wp' heading. \sample
\end{question}
\subsection{Using an \ExSheets{} Heading in Custom Code}\label{sec:using-an-exsheets}
It can be useful to have access to \ExSheets{} headings in custom code. This
is possible with the following command\sinceversion{0.14}:
\begin{commands}
\command{ExSheetsHeading}[\marg{instance}\marg{title}\marg{number}%
\marg{points}\marg{bonus}\marg{id}]
The meaning of the arguments is as follows:
\begin{itemize}
\item \meta{instance}: the name of the headings instance to be used.
\item \meta{title}: the contents of the \code{title} coffin.
\item \meta{number}: the contents of the \code{number} coffin.
\item \meta{points}: The number of points given to the question. If
non-zero this will cause the points to be printed in the \code{points}
coffin.
\item \meta{bonus}: the same as \meta{points} but for bonus points.
\item \meta{id}: the \acs{id} of the question this heading belongs to.
\end{itemize}
\end{commands}
In combination with \cs{ForEachQuestion} the command can be used to build a
custom list of questions. An example of its usage can be seen at the German
Q\&A~site \TeX welt: \url{http://texwelt.de/wissen/fragen/6698#6738}.
\subsection{Load Custom Configurations}
If you have custom configurations you want to be loaded automatically then save
them in a file \code{exsheets\_configurations.cfg}. If this file is present it
will be loaded \cs*{AtBeginDocument}.
\SetupExSheets{headings=block}
\part{The \ExSheetslistings\ Package}\label{part:listings}
\section{The Problem}
I knew the day would come when people would ask how to include verbatim
material in the \env{question} and \env{solution} environments. Since they're
defined with the \pkg{environ} package they're reading their environment
bodies like macros read their arguments. This makes it impossible to use
verbatim material inside them\footnote{See the \TeX\ \acs{faq}
\url{http://www.tex.ac.uk/cgi-bin/texfaq2html?label=verbwithin} for reasons
why.}. Now the day has come~\cite{tex.sx:131546}. Soon after the first
question appeared I wrote the first draft for \ExSheetslistings\ for a question
on \TeX.sx~\cite{tex.sx:133907}.
\section{The Proposed Solution}
The \ExSheetslistings\ package defines \pkg{listings} environments that place
their contents inside \env{question} and \env{solution} environments. They do
this by writing the listing to a unique auxiliary file --
questions to \code{\cs*{jobname}-ex\meta{num}.lst} and solutions to
\code{\cs*{jobname}-sol\meta{num}.lst} where \meta{num} is an increasing
integer that ensures that each listing gets a unique file name. Those files
are then included with \cs{lstinputlisting} if and when the question or
solution is printed.
\begin{environments}
\environment{lstquestion}[\oarg{options}]
A \pkg{listings} environment placed in a \env{question}.
\environment{lstsolution}[\oarg{options}]
A \pkg{listings} environment placed in a \env{solution}.
\end{environments}
All you have to do to use the package is loading it the usual way:
\begin{sourcecode}
\usepackage{exsheets-listings}
\end{sourcecode}
This will also load the packages \ExSheets\ and \pkg{listings} if they're not
loaded already.
\begin{example}
% this uses my listings style used in this documentation for all pieces of
% code:
\begin{lstquestion}[%
pre=Explain what this piece of \TeX\ code does:,
listings={style=cnltx}]
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname foo\endcsname\relax
...
\else
...
\fi
\end{lstquestion}
\end{example}
The example already shows two options of these environments. Here is the
complete list:
\begin{options}
\keyval{pre}{text}
\meta{text} is placed before the code in the \env{question} or
\env{solution} environment.
\keyval{post}{text}
\meta{text} is placed after the code in the \env{question} or
\env{solution} environment.
\keyval{options}{options}
Options passed to underlying the \env{question} or \env{solution}
environment.
\keyval{points}{points}
The points assigned to the underlying \env{question} environment.
\keyval{listings}{options}
Options passed to the underlying \pkg{listings} environment.
\end{options}
There are also two new options for \ExSheets\ that can be set with
\cs{SetupExSheets}:
\begin{options}
\keyval{listings}{options}\Module{question}
Options passed to the underlying \pkg{listings} environment of
\env{lstquestion}.
\keyval{listings}{options}\Module{solution}
Options passed to the underlying \pkg{listings} environment of
\env{lstsolution}.
\end{options}
\section{Own Environments}
\begin{commands}
\command{NewLstQuSolPair}[\oarg{options for both environments}\marg{lst question
env}\marg{question env}\oarg{options for lst question env}\marg{lst
solution env}\marg{solution env}\oarg{options for lst solution env}]
Defines two new \pkg{listings} environments that place the listing in a
question environment \meta{question env} or a solution environment
\meta{solution env}. Those underlying environments should be
environments as defined by \cs{NewQuSolPair}. The different options
allow to preset options for the newly defined environments.
\end{commands}
The existing environments have been defined like this:
\begin{sourcecode}
\NewLstQuSolPair{lstquestion}{question}{lstsolution}{solution}
\end{sourcecode}
\appendix
\part{Appendix}
\section{A List of all Solutions used in this Manual}\label{sec:solutions:list}
\SetupExSheets{headings=block-wp,solutions-totoc}
\printsolutions
\end{document}
|