summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/keyfloat/keyfloat.dtx
blob: a729c86a4b59e8de3a93d5fda1d347a1e9e020ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
%
% \iffalse meta-comment
%
% Copyright 2016--2021 Brian Dunn
%
% 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.
%
% \fi

%
% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{keyfloat}
%<package>    [2021/06/29 v2.06 Key/value interface for floats and subfloats.]
%
%<*driver>
\documentclass{ltxdoc}

\newcommand*{\mypackagename}{keyfloat}
\newcommand{\quicksummary}{Provides a key/value interface for generating floats.}


% \usepackage{lmodern}
\usepackage{erewhon}
\usepackage{roboto}
% \usepackage{sourcesanspro}
\usepackage{inconsolata}
% \usepackage{libertine}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}	% provides \degree, \textquotesingle, \textmu


\newcommand*{\TakeFourierOrnament}[1]{{%
\fontencoding{U}\fontfamily{futs}\selectfont\char#1}}

\newcommand*{\textwarning}{\TakeFourierOrnament{66}}

% copy/paste special unicode symbols:
\input{glyphtounicode}
\pdfglyphtounicode{prime}{2032}% hex
\pdfglyphtounicode{diameter}{2300}% diameter
\pdfglyphtounicode{warningsign}{26A0}% warning sign
\pdfgentounicode=1

\usepackage{newunicodechar}
\newunicodechar{ff}{ff}
\newunicodechar{fi}{fi}
\newunicodechar{fl}{fl}
\newunicodechar{ffi}{ffi}
\newunicodechar{ffl}{ffl}
% \newunicodechar{°}{\degree}
\newunicodechar{ρ}{\ensuremath{\rho}}
\newunicodechar{⨯}{\texttimes}
\newunicodechar{⁄}{\textfractionsolidus}
% \newunicodechar{®}{\textregistered}
% \newunicodechar{©}{\textcopyright}
\newunicodechar{—}{---}
\newunicodechar{–}{--}
% \newunicodechar{”}{''}
% \newunicodechar{“}{``}
% \newunicodechar{§}{\S}
% \newunicodechar{¶}{\P}
% \newunicodechar{†}{\dag}
\newunicodechar{‡}{\ddag}
\newunicodechar{⚠}{\textwarning}



\usepackage{metalogo}
\makeatletter
\@ifpackageloaded{erewhon}{
\setlogokern{Te}{-.08em}
\setlogokern{eX}{-0.04em}
\setlogokern{La}{-.25em}
\setlogokern{aT}{-.08em}
\setlogokern{Xe}{-.04em}
\setlogokern{eL}{-.06em}
\setlogodrop{0.27ex}
}{}
\makeatother

\usepackage{microtype}

\usepackage{etoolbox}

\usepackage[log-declarations=false]{xparse}



\usepackage[svgnames]{xcolor}
\definecolor{myurlcolor}{rgb}{0,0,.7}
\definecolor{mylinkcolor}{rgb}{.7,0,0}
\definecolor{codecolor}{rgb}{0,.4,.2}
\definecolor{overviewcolor}{rgb}{0,.2,.4}


\usepackage{graphicx}
\graphicspath{{images/}}

\usepackage{enumitem}

\usepackage{needspace}

\usepackage{array}
\usepackage{booktabs}
\usepackage{threeparttable}

\usepackage{fancybox}% must be loaded before fancyvrb
\usepackage{fancyvrb}


\usepackage{caption}
\usepackage{newfloat}

\DeclareFloatingEnvironment[
fileext=lox,
listname={List of Examples},
name=Example,
placement=hbp
]{example}

\captionsetup*[example]{
format=hang,
font=bf,
justification=raggedright,
singlelinecheck=false,
skip=0pt,
position=top,
}

\captionsetup{labelfont={small,bf},textfont={small,bf}}

\captionsetup*[figure]{
	style=default, justification=centering,
	margin=0pt, parskip=0pt, skip=2ex,
	labelfont={small,bf},textfont={small,bf}
}

\captionsetup*[table]{
	style=default, justification=centering,
	margin=0pt, parskip=0pt, skip=1ex,
	labelfont={small,bf},textfont={small,bf},
    position=top
}

\captionsetup*[subfigure]{
	style=default, justification=centering,
	margin=0pt, parskip=0pt, skip=2ex,
	labelfont={small},textfont={small}
}

\captionsetup*[subtable]{
	style=default, justification=centering,
	margin=0pt, parskip=0pt, skip=1ex,
	labelfont={small},textfont={small},
    position=top
}

\captionsetup*[example]{
	format=plain, justification=justified,
	margin=0pt, parskip=0pt, skip=0ex,
	labelfont={bf},textfont={bf}
}

\captionsetup*[wrapfigure]{
	style=default, justification=centering,
	margin=0pt, parskip=0pt, skip=2ex,
	labelfont={small,bf},textfont={small,bf}
}

\captionsetup*[wraptable]{
	style=default, justification=centering,
	margin=0pt, parskip=0pt, skip=1ex,
	labelfont={small,bf},textfont={small,bf}
}



\usepackage{blindtext}



\usepackage{tikz}
\usetikzlibrary{positioning,fit,backgrounds,calc,shapes.geometric,shadows}

\usepackage[framemethod=tikz]{mdframed}

\mdfdefinestyle{boxroundshadow}{linewidth=1pt,innerleftmargin=0in,innerrightmargin=0in,%
innertopmargin=0in,innerbottommargin=0in,%
align=center,roundcorner=3pt,shadow=true,shadowcolor=black!50,shadowsize=4pt,%
leftmargin=0pt,rightmargin=0pt,%
frametitlebackgroundcolor=black!15,%
skipabove=0ex,skipbelow=0ex,%
frametitlerulewidth=1pt,frametitleaboveskip=5pt,%
}

\newmdenv[style=boxroundshadow,align=center]{mdtightframe}

\newmdenv[style=boxroundshadow,align=center,%
	innertopmargin=3pt,innerbottommargin=3pt,%
	innerleftmargin=3pt,innerrightmargin=3pt]{mdlooseframe}


\usepackage[normalem]{ulem}


\usepackage{tocdata}[2019/03/21]% v2.02 or later

\usepackage{tocloft}
\setlength{\cftsubsecnumwidth}{3em}
\setlength{\cftsubsubsecindent}{2.8em}
\setlength{\cftsubsubsecnumwidth}{4em}
\setlength{\cftbeforesubsecskip}{1ex}

% \usepackage{titletoc}



\usepackage{titleps}

\newpagestyle{pageheadfoot}{
	\headrule
	\sethead{\pkg{\mypackagename}}{}{\thepage}
% 	\renewcommand{\makefootrule}{\rule[2.5ex]{\linewidth}{.4pt}}
	\setfoot{}{}{}
}

\pagestyle{pageheadfoot}


\usepackage{dtxdescribe}[2019/01/11]



\usepackage{splitidx}

\newindex[Index of Objects]{idx}
\newindex[General Index]{gen}
% \newindex[Troubleshooting Index]{trb}
\newindex[Index of Indexes]{meta}

\makeindex

\newcommand*{\gindex}[1]{\sindex[gen]{#1}\ignorespaces}

% \trouble[watchout phrase]{index entry}
\newcommand*{\trouble}[2][]{%
\ifblank{#1}{}{%
    \watchout[#1]%
}%
% \sindex[trb]{#2}%
\gindex{#2}%
\ignorespaces%
}




\newcommand{\testtable}{%
\begin{tabular}{cc}%
\hline\rule{0pt}{2.7ex}%
A & B \\
C & D \\
\hline
\end{tabular}%
}

\newcommand{\testwidetable}{%
\begin{tabular}{cccc}%
\hline\rule{0pt}{2.7ex}%
A & B & C \\
D & E & F \\
\hline
\end{tabular}%
}


\newcommand{\mainsubarg}{empty or ``\texttt{subgrp}''}
\newcommand{\keyvalsarg}{keys \Slash values}

\setlength{\floatsep}{5ex plus 1ex minus 1ex}
\setlength{\dblfloatsep}{5ex plus 1ex minus 1ex}


\usepackage{\mypackagename}


\usepackage[pdftex,bookmarks=true,hidelinks,%
colorlinks,linkcolor=mylinkcolor,urlcolor=myurlcolor,%
pageanchor=true,hyperindex=true,
]{hyperref}

\hypersetup{%
pdfinfo={%
Title={The LaTeX \mypackagename\ package},%
Author={Brian Dunn},%
Subject={A key/value interface for LaTeX floats.},%
Keywords={LaTeX, floats, key/val, subcaption, rows}%
}}

\pdfstringdefDisableCommands{
\def\quad{ }
\def\\{ }
\def\pkg#1{#1}
\def\cs#1{\textbackslash#1}
\def\env#1{#1}
\def\,{ }
\def\prog#1{#1}
\def\LuaLaTeX{LuaLaTeX}
\def\XeLaTeX{XeLaTeX}
\def\TeX{TeX}
\def\LaTeX{LaTeX}
\def\Dash{ --- }
\def\dash{ -- }
\def\element#1{#1}
\def\attribute#1{#1}
}


\usepackage{cleveref}



\setlength{\marginparsep}{1em}
\setlength{\marginparpush}{.7ex}
\setlength{\IndexMin}{40ex}

\setcounter{IndexColumns}{2}

\DisableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
  \DocInput{\mypackagename.dtx}
\end{document}
%
%</driver>
% 
% \fi
%
% \iffalse
%<*package>
% \fi
%
% \CheckSum{1392}
%
% \CharacterTable
% {Upper-case     \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote \"      Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent \'      Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than \>      Question mark \?
%   Commercial at \@     Left bracket \[      Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent \`      Left brace    \{     Vertical bar \|
%   Right brace   \}     Tilde         \~}

% \changes{v0.10}{2016/12/01}{\ 2016/12/01 Initial ver.}
% \changes{v0.11}{2016/12/02}{\ 2016/12/02}
% \changes{v0.12}{2016/12/09}{\ 2016/12/09}
% \changes{v0.12}{2016/12/02}{Docs: Loading keyfloat.}
% \changes{v0.12}{2016/12/05}{Docs: Improved index.}
% \changes{v0.13}{2017/01/18}{\ 2017/01/18}
% \changes{v0.13}{2017/01/12}{Docs: Other Settings.}
% \changes{v0.14}{2017/02/09}{\ 2017/02/09}
% \changes{v0.15}{2017/05/12}{\ 2017/05/12}
% \changes{v1.00}{2019/01/11}{\ 2019/01/11}
% \changes{v1.00}{2019/01/08}{Source formatting improvements.}
% \changes{v1.00}{2019/01/08}{Docs \PDF\ bookmark improvements.}
% \changes{v1.00}{2019/01/08}{Removed spurious spaces.}
% \changes{v2.00}{2019/03/21}{\ 2019/03/21}
% \changes{v2.00}{2019/03/17}{Added custom float types.}
% \changes{v2.00}{2019/03/17}{Added float authors.}
% \changes{v2.01}{2019/09/23}{2019/09/23}
% \changes{v2.02}{2021/05/28}{2021/05/27}
% \changes{v2.03}{2021/05/28}{Fixed \cs{hbadness} w/ \cs{relax}.}
% \changes{v2.03}{2021/05/28}{2021/05/28}
% \changes{v2.04}{2021/06/08}{2021/06/08}
% \changes{v2.05}{2021/06/11}{2021/06/11}
% \changes{v2.06}{2021/06/29}{2021/06/29}



% \GetFileInfo{\mypackagename.sty}
%
% \DoNotIndex{\newcommand,\renewcommand,\addtocounter,\begin,\end,\begingroup,\endgroup}
% \DoNotIndex{\global,\ifbool,\ifthenelse,\isequivalentto,\let}
% \DoNotIndex{\booltrue,\boolfalse}
% \expandafter\DoNotIndex\expandafter{\detokenize{\(,\),\,,\\,\#,\$,\%,\^,\_,\~,\ ,\&,\{,\}}}
%
%
% \thispagestyle{empty}
% \begin{center}
% \vfill
% ^^A \includegraphics[width=.3\linewidth]{\mypackagename_logo.pdf}
% \vfill
% {\Huge The \LaTeX\ \pkg{\mypackagename} Package}
% \bigskip
%
% \fileversion{} --- \filedate
%
% \bigskip
%
% {\small\textcopyright{} 2016--2021} Brian Dunn\\ \small \texttt{bd@BDTechConcepts.com}
%
% \vspace{.5in}
%
% {\Large \textup{\quicksummary}}
%
%
% \vfill
%
% 
% ^^A % \title{The \pkg{keyfloat} package\thanks{This document
% ^^A %   corresponds to \pkg{keyfloat}~\fileversion,
% ^^A %   dated \filedate.}}
% ^^A % \author{{\small\textcopyright{} 2016} Brian Dunn\\ \small \texttt{bd@BDTechConcepts.com}}
% ^^A % \published{}
% ^^A % \subtitle{\textup{Subtitle}}
% ^^A %
% ^^A % \maketitle
%
% \vfill
%
%
% \begin{abstract}
% \noindent
% The \pkg{keyfloat} package provides a key/value user interface for quickly
% creating figures with a single image each, figures with arbitrary contents,
% tables, subfloats, rows of floats, floats located [H]ere,
% floats in the [M]argin, and floats with text [W]rapped around them.
%
% Key/value combinations may specify a caption and label, a width proportional
% to \cs{linewidth}, a fixed width and/or height, rotation, scaling, a
% tight or loose frame, an \cs{arraystretch}, a continued float,
% additional supplemental text,
% and an artist/author's name with automatic index entry.
% When used with the \pkg{tocdata} package, the name also appears in the
% List of Figures.
%
% Floats may be moved into or rearranged inside a multi-row environment or subfloats,
% and are typeset to fit within the given number of columns,
% continuing to additional rows as necessary.
% Nested sub-rows may be used to generate layouts such as
% two small figures placed vertically next to
% one larger figure.
%
% As an example, a typical command to include a figure with a framed image of half \cs{linewidth}
% could be: \\
% \hspace*{1em}\verb|\keyfig*[hbp]{f,lw=.5,c={A caption},l={fig:label}}{image}|
%
% \pkg{keyfloat} uses the \pkg{caption}, \pkg{subcaption},
% \pkg{newfloat} or \pkg{float}, and \pkg{wrapfig} packages,
% \watchout[incompatible packages]
% and cannot be used with the
% \pkg{subfig}, \pkg{subfigure}, \pkg{subfloat}, \pkg{floatrow},
% or \pkg{floatflt} packages.
%
% See the \nameref{sec:indexgen} for an index of topics and troubleshooting.
% \watchout[Need help?]
%
% For the latest updates, see \nameref{sec:updates}.
% \margintag{What's new?}
%
% \vfill
%
% \footnotesize
% \begin{description}
% \item[License:] \
%
% 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.
% \end{description}
%
% \end{abstract}
%
% \vspace*{\fill}
% \vspace*{\fill}
% \vspace*{\fill}
% \end{center}
% \clearpage
%
% \tableofcontents
% \listofexamples
% \listoffigures
% \listoftables
%
%
% \thispagestyle{pageheadfoot}
%
% \clearpage
%
%^^A \part{keyfloat.sty}
%
% \section{Introduction}
%
% The \pkg{keyfloat} package simplifies the creation
% of \LaTeX\ floats, while still allowing a large number of useful features.
%
%
% \subsection{A problem with floats}
%
% When including a figure with a graphics image into a document,
% the user typically enters something such as:
% \begin{sourceverb}
% \begin{figure}
% \centering
% \includegraphics[width=3in]{filename}
% \caption{A Figure}
% \label{fig:somelabel}
% \end{figure}
% \end{sourceverb}
% \unskip
%
% When doing that often enough, it makes sense to factor the common code:
% \begin{sourceverb}
% \onefigure[3in]{filename}{A Figure}{fig:somelabel}
% \end{sourceverb}
% \unskip
% 
% Expanding the capability of \cs{onefigure} via \pkg{xparse} can lead to the general case of:
% \begin{sourceverb}
% \onefigure*[loc](width){filename}(add'l text)[shortcap]{caption}*[label]
% \end{sourceverb}
% \unskip
% Attempting to add additional features such as frames and continued floats
% hits the limit of nine parameters for a \TeX\ macro,
% requiring that new features use some kind of change-state macros instead.
% Attempting to support rows of floats or subfloats only makes things more complicated still.
% 
% A key/value system solves the problem of adding more features,
% does not require much additional typing, is a more self-documenting
% syntax, and allows a shared syntax with subfloats and groups of floats as well.
% Thus, the \pkg{keyfloat} package.
%
% \subsection{The \pkg{keyfloat} package}
% 
% Using \pkg{keyfloat}, the previous example becomes:
% \begin{sourceverb}
% \keyfig{w=3in,c=A figure,l=fig:somelabel}{filename}
% \end{sourceverb}
% \unskip
% 
% The \cs{onefigure} general case becomes:
% \begin{sourceverb}
% \keyfig*[loc]{w=width,t={add'l text},sc=shortcap,cstar=caption,
%     l=label}{filename}
% \end{sourceverb}
%
%
% \subsection{Features}
%
% The macros and environments provided by \pkg{keyfloat} include:
% \begin{description}
% \item[\cs{keyfig}:] A figure with an image.
% \item[\cs{keytab}:] A table.
% \item[\cs{keyflt}:] An arbitrary float type macro.
% \item[\cs{keyfigbox}:] A figure with arbitrary contents.
% \item[\cs{keyparbox}:] A ``figure'' without a caption, useful
%	to place uncaptioned text inside a group,
% \item[\env{keyfigure}:] A figure environment.
% \item[\env{keytable}:] A table environment.
% \item[\env{keyfloat}:] An arbitrary float type environment.
% \item[\env{keyfloats}:] A group of rows and columns of floats.
% \item[\env{keysubfigs}:] A figure containing a group of rows and columns of subfigures.
% \item[\env{keysubtabs}:] A table containing a group of rows and columns of subtables.
% \item[\env{keysubfloats}:] A float of arbitrary type containing a group of rows and columns of subfloats.
% \item[\env{keywrap}:] Wraps a keyfloat around an environment of text.  Usable inside a list.
% \item[\env{marginfigure}:] A figure environment placed into
%	the margin.\footnote{\env{marginfigure} and \env{margintable}: The environments
%	provided by the |tufte-book| class are used if loaded,
%	otherwise \pkg{keyfloat} provides its own versions.}
% \item[\env{margintable}:] A table environment placed in the margin.
% \end{description}
%
% Additional features include:
% \begin{itemize}
% \item Rows and columns of floats may be generated by placing them inside a \env{keyfloats}
% environment.
% \item Subfloats may be generated by placing them inside a \env{keysubfigs}
% or \env{keysubtabs} environment.
% \item Dynamic layout: The number of columns is specified. Extra
% 	floats are placed onto additional rows as needed, with the final row
% 	adjusted to compensate for leftovers.
% \item Floats may be placed \optn{[H]}ere.
% \item Floats may be placed in the \optn{[M]}argin.
% \item Floats may be placed with text \optn{[W]}rapped around them.
% \item Floats may be starred to span two columns.
% \item Continued floats may be used to repeat the previous float number.
% \item A figure may contain an image, with additional sizing, rotation, and a frame.
% \item Tables may be stretched. (\cs{arraystretch})
% \item Boxes of arbitrary contents may be assigned a width and framed.
% \item Floats may be moved into and out of the grouping environments as needed.
% \item An artist/author's name may be added to a figure and the index.
% \item If the \pkg{tocdata} package is loaded (use v0.12+),
%	the name is also added to the \acro{LOF}.
% \item Additional descriptive text may be added as well.
% \item Frames may be customized.
% \end{itemize}
%
% A large number of examples are provided, each showing \LaTeX\ source and
% \margintag{examples}
% the resulting float.
%
% A customized index is included at the back of the documentation,
% \margintag{index}
% including troubleshooting issues.
%
% Blue margin tags are used to help quickly find information, and often
% \margintag{margin tags}
% indicate the destination of index entries.
%
% Several warnings are noted in the text.  Watch out for these special cases.
% \watchout[warnings]
%
% ^^A % See the ``troubleshooting'' section of the index for help
% ^^A % \margintag{problems}
% ^^A % with specific problems which may occur.
%
% \subsection{Updates}
%
% \label{sec:updates}
%
% Recent changes include the following:
% \begin{description}
% \item[v2.06:] Added shared keys for groups of floats or subfloats.
%       Added the \optn{kar} key to keep the aspect ratio of an image.
%       Removed \texttt{:} for an empty caption.
%       Warns if an image is too wide to fit.
% \item[v2.02, v2.04:] Added keys for wrapped floats.
% \end{description}
%
% \subsection{Other float-related packages}
%
% Several other \LaTeX\ packages related to floats include:
% \begin{description}
% \item[\pkg{caption} and \pkg{subcaption}:] Improved control over captions.
% \item[\pkg{floatrow}:] A macro-based package for creating floats; including captions,
%       footnotes, and rows of floats.
% \item[\pkg{hvfloat}:] A key \Slash value system allowing the easy rotation of
%       captions and floats.
% \item[\pkg{nccfloats}:] Macros for minipage floats and side-by-side floats.
% \item[\pkg{newfloat}:] Macros for the creationg of float environments.
% \item[\pkg{rotfloat}:] Environments for rotated floats.
% \item[\pkg{subfig}:] Macros to add subfloats inside a float.
% \end{description}
%
%
% \clearpage
%
% \section{Using the \pkg{keyfloat} package}
%
% \subsection{Loading \pkg{keyfloat} and related packages}
%
% \pkg{keyfloat} is loaded with the usual command:
% \begin{sourcedisplay}
% 	\cs{usepackage}\{keyfloat\}
% \end{sourcedisplay}
%
%
% If you wish to have artists' names appear in the list of figures,
% \DescribePackage{tocdata}
% \DescribePackage{tocloft}
% \DescribePackage{titletoc}
% as provided by the \pkg{tocdata} package,
% load \pkg{tocdata},
% optionally followed by either \pkg{tocloft} or \pkg{titletoc},
% then \pkg{keyfloat}:
% \begin{sourcedisplay}
% 	\cs{usepackage}\{tocdata\} \\
%   \cs{usepackage}\{titletoc\}\% or titletoc, or neither \\
% 	\cs{usepackage}\{keyfloat\}
% \end{sourcedisplay}
%
% To use custom float types with the \pkg{float} package:
% \DescribePackage{float}
% \begin{sourceverb}
% \usepackage{float}
% \newfloat{diagram}{htb}{lod}
% \end{sourceverb}
%
% To use custom float types with the \pkg{newfloat} package:
% \DescribePackage{newfloat}
% \begin{sourceverb}
% \usepackage{newfloat}
% \DeclareFloatingEnvironment[
%     fileext={lod},
%     listname={List of Diagrams},
%     name={Diagram},
% ]{diagram}
% \end{sourceverb}
%
% For the \pkg{caption} package, to have table captions appear above the tables, and
% \DescribePackage{caption}
% to use custom float types:
% \begin{sourceverb}
% \usepackage[tableposition=top]{caption}
% \captionsetup[diagram]{
%     style=default, justification=centering,
%     margin=0pt, parskip=0pt, skip=1ex,
%     labelfont={small,bf},textfont={small,bf}
% }
% \end{sourceverb}
%
% To use custom float and subfloat types with \pkg{cleveref}:
% \DescribePackage{cleveref}
% \begin{sourceverb}
% \usepackage{cleveref}
% \crefname{diagram}{diagram}{diagrams}
% \crefname{subdiagram}{subdiagram}{subdiagrams}
% \end{sourceverb}
%
%
% \needspace{7\baselineskip}
% \subsection{Macros and environments}
%
% \DescribeMacro{\keyfig} * \oarg{loc} \marg{\keyvalsarg} \marg{image filename} \\
% A macro to generate a figure with an image from a file.
%
% \DescribeMacro{\keytab} * \oarg{loc} \marg{\keyvalsarg} \marg{tabular contents} \\
% A macro to generate a table with tabular contents.
% Usually use the \env{keytable} environment instead.
%
% \DescribeMacro{\keyflt} * \oarg{loc} \marg{float type} \marg{keys/values} \marg{contents} \\
% A macro to generate an arbitrary float type with its contents.
%
% \DescribeMacro{\keyfigbox} * \oarg{loc} \marg{\keyvalsarg} \marg{box contents} \\
% A macro to generate a figure with arbitrary paragraph contents.
% See \cref{ex:keyfigbox}.
%
% \DescribeMacro{\keyparbox} * \oarg{loc} \marg{\keyvalsarg} \marg{box contents} \\
% A macro to generate a figure with arbitrary paragraph contents,
% but no number or caption. This is equal to a \cs{keyfigbox} with |cstar={}|.
% Mostly useful to add supplemental information inside a row of floats or subfloats.
% See \cref{ex:keyparbox}.
%
% \DescribeEnv{keyfigure} * \oarg{loc} \marg{\keyvalsarg} \\
% An environment to generate a figure with arbitrary contents.
% Useful for multi-paragraph contents.
% See \cref{ex:keyfigure}.
%
% \DescribeEnv{keytable} * \oarg{loc} \marg{\keyvalsarg} \\
% An environment to generate a table with arbitrary contents.
% Useful for larger tables.
% See \cref{ex:keytable}.
%
% \DescribeEnv{keyfloat} * \oarg{loc} \marg{float type} \marg{\keyvalsarg} \\
% An environment to generate an arbitrary float type with its contents.
% Useful for multi-paragraph contents.
%
% \begin{docsidebar}
% \textbf{The above macros and environments may be used by themselves,
% or inside the following \env{keyfloats}, \env{keysubfigs}, or
% \env{keysubtabs} environments.}
% \end{docsidebar}
%
%
% \DescribeEnv{keyfloats} * \oarg{loc} \marg{num columns} \oarg{shared \keyvalsarg} \\
% A group of figures or tables typeset in rows.  May be nested, [H], [W], or [M].
% The optional shared \keyvalsarg\ are passed to each object within.
% See \cref{ex:keyfloats}.
%
% \DescribeEnv{keysubfigs} * \oarg{loc} \marg{numcols} \marg{keys} \oarg{shared \keyvalsarg} \\
% A group of subfigures typeset in rows.
% May \emph{not} be nested.  May be [H], [W], or [M].
% The optional shared \keyvalsarg\ are passed to each object within.
% See \cref{ex:keysubfigs}.
%
% \needspace{2\baselineskip}
% \DescribeEnv{keysubtabs} * \oarg{loc} \marg{numcols} \marg{keys} \oarg{shared \keyvalsarg} \\
% A group of subtables typeset in rows.
% May \emph{not} be nested.  May be [H], [W], or [M].
% The optional shared \keyvalsarg\ are passed to each object within.
% See \cref{ex:keysubtabs}.
%
% \needspace{2\baselineskip}
% \DescribeEnv{keysubfloats} * \oarg{loc} \marg{float type} \marg{numcols} \marg{keys} \oarg{shared \keyvalsarg} \\
% A group of subfloats typeset in rows.
% May \emph{not} be nested.  May be [H], [W], or [M].
% The optional shared \keyvalsarg\ are passed to each object within.
%
% \DescribeEnv{keywrap} \marg{width of keyfloat} \marg{keyfloat} \\
% Displays a keyfloat next to an environment of text.
% Two minipages are used side-by-side, which allows its use inside a list item
% where [W] will not work, but extra empty vertical space
% \watchout[empty space]
% will appear if the keyfloat and the text are of unequal vertical size.
% \meta{keyfloat} may be any of \cs{keyfig}, \env{keyfigure},
% \env{keyfloats}, \env{keysubfigs}, etc., each with its proper arguments.
% See \cref{ex:keywrapkeyfig}.
%
% \DescribeEnv{marginfigure} \oarg{offset} \\
% A figure placed into the margin, with an optional vertical offset.
% \cs{keyfloat} uses the version provided by the |tufte-book| class if available,
% or provides its own version otherwise.
% See \cref{ex:marginfigure}.
%
% \DescribeEnv{margintable} \oarg{offset} \\
% A table placed into the margin, with an optional vertical offset.
% \cs{keyfloat} uses the version provided by the |tufte-book| class if available,
% or provides its own version otherwise.
% See \cref{ex:margintable}.
%
% \medskip\hrule\medskip
%
% \DescribeArgument{*}
% The star option create floats which span both columns in a two-column
% document.
%
% \DescribeArgument{{[H]}}
% The |[H]| location forces a figure to be ``Here'', in the
% form of a minipage instead of a float.  A caption, label, etc.\ may
% still be assigned.
%
% \DescribeArgument{{[M]}}
% The |[M]| location places the float into the margin.  When the |tufte-book| class
% is used, its \env{marginfigure} and \env{margintable} environments are used,
% otherwise \pkg{keyfloat} provides and uses its own versions of the same environments.
% See \cref{ex:keyfigm,ex:keytablem}.
%
% \DescribeArgument{{[W]}}\DescribePackage{wrapfig}
% The |[W]| location wraps text around the float.  Use this just before the start of
% a paragraph with contents large enough to wrap around the float.  Do not use this
% inside a list environment.  Select placement with the |wp| key; see
% the \pkg{wrapfig} package documentation for more information.
% Use \optn{w} or \optn{lw} to set the width of the item \Slash image contained
% inside the wrap area.  By default the caption will also be contained in this width.
% To use a larger width for the overall container and caption,
% set \optn{w} or \optn{lw} for the size of the image, and also use
% \optn{ww} or \optn{wlw} for a larger size for the caption.
% Watch the log for warnings from \pkg{wrapfig}.\watchout[\pkg{wrapfig} warnings]
%
% \DescribeArgument{{[loc]}}
% The star and [loc] options are ignored for floats inside a \env{keyfloats},
% \env{keysubfigs}, or \env{keysubtabs} environment.  Note that these
% container environments may have their own star and [loc] options.
%
%
% \clearpage
%
%
%
%
% \subsection{Keys and values}
%
% \changes{v2.05}{2021/06/11}{Docs: Fixed braces for multi-word values.}
%
% \newcommand{\largebullet}{{\Large\textbullet}}
%
% \begin{keytable}[bp]{c={Keys and values — part I},l={tab:keyvals},stretch=1.5}
% \centering
% \gindex{keys>and values}
% \begin{threeparttable}
% \small
% \begin{tabular}{>{\ttfamily}cc>{\raggedright}p{2.5in}>{\centering\arraybackslash}>{\ttfamily\arraybackslash}p{1in}}
% \toprule
% \textrm{Key} & Sub\tnote{a} & Description & \textrm{Example} \\
% \midrule
% c & \largebullet &  An unstarred caption.
%	If empty, creates a figure with a number but no caption. & c=\{A caption\} \\
% cstar & \largebullet &  A starred caption.  Creates a float without a number.
% 	If empty, creates a figure with no number or caption. & cstar=\{No Num\} \\
% sc & \largebullet &  The short caption for the \acro{LOF}/\acro{LOT}, even if cstar. & sc=\{Short cap\} \\
% cont & \largebullet &  Continued float?  & cont \\
% l & \largebullet &  The label.  Enclose in braces if a comma is included.
%	Ignored in unnumbered floats. & l=fig:alabel  \\
% ap, aup & \largebullet & Artist/author's prefix, such as ``Mr.''\,\tnote{b} & ap=Mr. \\
% af, auf & \largebullet & Artist/author's first name.\tnote{b} & af=First \\
% al, aul & \largebullet & Artist/author's last name.\tnote{b} & al=Last \\
% as, aus & \largebullet & Artist/author's suffix, such as |~III|.\tnote{b} & |al=~III| \\
% t & \largebullet &  Additional text.  May include paragraphs. \\
% 	Enclose in braces if a comma is included. 
%	May need \cs{protect} before macro calls.
%	Fully-justified alignment.
%	& t=\{Paragraphs\} \\
% tc & \largebullet & Additional text, aligned to the center. & tc=\{Paragraphs\} \\
% tl & \largebullet & Additional text, aligned to the left. & tl=\{Paragraphs\} \\
% tr & \largebullet & Additional text, aligned to the right. & tr=\{Paragraphs\} \\
% \bottomrule
% \end{tabular}
% \begin{tablenotes}
% \item[a:] All the keys in Part I may be used with the main keys of the
%	\env{keysubfigs}, \env{keysubtabs}, and \env{keysubfloats} environments.
% \item[b:] Artist \Slash author keys:
%   |al| is an artist's last name, |aul| is an author's last name, etc.
%   Artists names are printed centered, authors are flush right.
%	A fixed-width non-breakable space is placed between parts of names, except that
%	the optional suffix is connected directly to the last name, allowing
%	``|as={, Title}|'', for example.
% \end{tablenotes}
% \smallskip
% \hrule\medskip\centering
% {\footnotesize \dots\ continued}
% \end{threeparttable}
% \end{keytable}


% \changes{v2.05}{2021/06/11}{Docs: Fixed \optn{r} key.}

% \begin{keytable}{
%	c={Keys and values — part II},cont,stretch=1.5}
% \centering
% \gindex{keys>and values}
% \begin{threeparttable}
% \small
% \begin{tabular}{>{\ttfamily}cc>{\raggedright}p{2.5in}>{\centering\arraybackslash}>{\ttfamily\arraybackslash}p{1in}}
% \toprule
% \textrm{Key} & Sub\tnote{c} & Description & \textrm{Example} \\
% \midrule
% lw & --- & Set the width to a fraction of \cs{linewidth}.  Cancels |w|.
% 	If a non-image float, sets the width of the text box.
%   For wrapped objects, may be used with \optn{wlw} for a smaller item
%       with a larger caption.
%           & lw=.5 \\  
% w &  --- & Set the actual width.  Cancels |lw|.
% 	If a non-image float, sets the width of the text box.
%   For wrapped objects, may be used with \optn{ww} for a smaller item
%       with a larger caption.
%           & w=2in \\
% h & --- & Set the actual height.  Images only.  & w=2in \\
% kar & --- & Keep aspect ratio: Use with \optn{w} or \optn{lw}, along with \optn{h},
%           to fit an image into a given area.  Images only. & kar \\
% s & --- & Set the image scale.  Images only.  & s=3 \\
% r & --- & Set the rotation angle; counter-clockwise degrees. & r=90 \\
% f & --- & Selects a loose frame with the current \cs{fboxsep}.
%	Only rotated with \cs{keyfig}.  & f \\
% ft & --- & Selects a tight frame with no \cs{fboxsep}.  Useful for photographs,
% 	or diagrams which already have some margin built in. & ft \\
% stretch & --- & Sets \cs{arraystretch} inside the float. & stretch=1.5 \\
% mo & --- & Sets the vertical offset for a margin float. & mo=-1.2ex \\
% wn & --- & Sets the number of lines for a wrapped float. & wn=2 \\
% wp & --- & Sets the wrap placement for a wrapped float. The default
%	is |O|, which places the wrapped float at the outside edge of the text.
%	See \cref{tab:wrapplacement}.
%	& wp=I \\
% wo & --- & Sets the wrap overhang for a wrapped float. & wo=8em \\
% wlw & --- & Sets the total width of the wrapped item to a fraction of \cs{linewidth}.
%       May be more than the \optn{w} or \optn{lw} width. & wlw=.6 \\
% ww & --- & Sets the total width of the wrapped item.
%       May be more than the \optn{w} or \optn{lw} width. & ww=2in \\
% va & --- & Sets the vertical alignment of the outermost minipage container for the keyfloat.
%	Defaults to 'c'.  Ignored by \env{subfigure}, \env{subtable}.
%	& va=t \\
% \bottomrule
% \end{tabular}
% \begin{tablenotes}
% \item[c:] None of the keys in Part II are used in the main keys of the
%	\env{keysubfigs}, \env{keysubtabs}, or \env{keysubfloats} environments,
%   but may be used in the optional shared keys to be passed to each object within.
% \end{tablenotes}
% \end{threeparttable}
% \end{keytable}
%
% \Cref{tab:keyvals} shows the key/value combinations which are allowed.
% In most cases these may be used in any order and any combination,
% except for the following:
%
% The keys labeled "Sub"\margintag{subfloat keys}
% \gindex{subfloat>keys}\gindex{keys>subfloats}
% may be used for the \env{keysubfigs} and
% \env{keysubtabs} environments, which group a number of subfloats together under
% one master float.  The master float has its own caption, label, and text, and
% each subfloat inside the group likewise has its own set of keys.
%
% \env{keyfloats} does not accept any keys at all.\margintag{keyfloats keys}
% \gindex{keyfloats>keys}\gindex{keys>keyfloats}
%
% The ``artist'' keys |ap|, |af|, |al|, and |as| are only used by figures.
%
% The |stretch| key increases space between tabular elements.
%
% The rest of the macros
% and environments accept all of the keys, as they each create an individual
% float or subfloat, and each may have its own assigned dimensions and frame.
%
% \Cref{tab:captions} shows the combinations of the caption-related keys
% \margintag{short/long\\caption combinations}
% |c|, |cstar|, and |sc|, and how they control the caption numbering and
% entries in the \acro{LOF}/\acro{LOT}.
% 
%
% \begin{keytable}{c={Caption-related key combinations},l=tab:captions,stretch=1.5}
% \gindex{caption>options}
% \centering
% \begin{threeparttable}
% \small
% \begin{tabular}{ccccc}
% \toprule
% \multicolumn{3}{c}{\bfseries Keys in Use} & \multicolumn{2}{c}{\bfseries Type of} \\
% \cmidrule(r){1-3}\cmidrule(l){4-5}
% |c| & |cstar| & |sc| & \textbf{Caption}\tnote{a} & \textbf{\LOF\Slash\LOT}\tnote{b} \\
% \cmidrule(r){1-3} \cmidrule(l){4-5}
% \largebullet & — & — & Numbered & Caption \\
% \largebullet & — & \largebullet & Numbered & Short Caption \\
% \midrule
% — & \largebullet & — & Unnumbered & None \\
% — & \largebullet & \largebullet & Unnumbered & Short Caption \\
% \midrule
% — & |cstar={}| & Ignored & None & None \\
% \bottomrule
% \end{tabular}
% \begin{tablenotes}
% \item[a:] Caption: Shows whether the float will
% be numbered, unnumbered, or have no caption.
% \item[b:] \LOF\Slash\LOT: Shows whether the regular or short caption
% will appear in the List of Figures or List of Tables, or if there will be no listing.
% \end{tablenotes}
% \end{threeparttable}
% \end{keytable}
%
%
% \Cref{tab:wrapplacement} shows the wrapped-float placement
% \margintag{wrapped float placement}
% options for the |wp| key
% for floats placed |[W]|.
%
% \begin{keytable}{c={Key \optn{wp}: Wrapped float placement options},l=tab:wrapplacement}
% \gindex{float>wrapped placement}\gindex{wrapped float placement}
% \centering
% \begin{tabular}{ccl}
% \toprule
% \multicolumn{2}{c}{Key} & Location \\
% \cmidrule(r){1-2}\cmidrule{3-3}
% r & R & to the right of the text body \\
% l & L & to the left of the text body \\
% i & I & to the inside margin \\
% o & O & to the outside margin \\
% \bottomrule
% \end{tabular}
%
% \raggedright\small
% The un-capitalized key attempts to place the float ``here'', and
% the capitalized key allows \LaTeX\ to try to find the best location.
% The default is |O|.
% \end{keytable}
%
%
% \clearpage
%
% \subsection{Other settings}
%
% \DescribeMacro{\KFLTtightframe} \marg{contents} Frames the contents without separation.
%
% \DescribeMacro{\KFLTlooseframe} \marg{contents} Frames the contents with separation.
%
% These may be used to re-define how contents are framed.  The default
% is a simple \cs{fbox}.
%
% \DescribeLength{\KFLTtightframewidth} Combined width of the frame and separation
%	for each of tight and loose frames.  These settings should be adjusted when
%	changing the frame width and/or separation.  The value should be equivalent
%	to \cs{fboxwidth} plus \cs{fboxsep}.
% \DescribeLength{\KFLTlooseframewidth}
%
% \DescribeLength{\KFLTimageboxwidth} The computed width of the image.
% Useful to enclose an mdframed environment to restrict its width.
% See \cref{ex:customframe}.
%
%
%
%
% \clearpage
%
% \subsection{Examples}
%
%
% \subsubsection{Single floats}
%
%
% \begin{dtxexample}[\Cref{fig:simple}]{Figure with an image from a file}
% \keyfig{c=A \cs{keyfig} with an image,l=fig:simple}{image}
% \end{dtxexample}
%
% This float (\cref{fig:simple}) is shown at its natural size
% \margintag{natural size}
% because no width or height modifiers were specified.  When used alone like this,
% a regular float is created.
% \gindex{image>natural size}
%
%
% \begin{dtxexample}[\Cref{fig:figbox}]{Figure with arbitrary contents\label{ex:keyfigbox}}
% \keyfigbox{f,c={A \cs{keyfigbox}},l=fig:figbox}
% 	{Some text.  More text. \par  Another paragraph.}
% \end{dtxexample}
%
% The \cs{keyfigbox} creates a figure with a box of arbitrary contents, instead of
% an image from a file.  Its default width is the full \cs{linewidth},\margintag{default width}
% \gindex{float>default width}
% unless |w| or |lw| keys are used.
%
%
% \begin{dtxexample}[\Cref{fig:environment}]
% {Figure environment with arbitrary contents\label{ex:keyfigure}}
% \begin{keyfigure}{f,c={A \env{keyfigure} environment},
% 	l=fig:environment}
% Arbitrary contents may go here.
% 
% Including multiple paragraphs.
% \end{keyfigure}
% \end{dtxexample}
%
% The \env{keyfigure} environment is preferred over the \cs{keyfigbox} macro when
% multiple lines of contents are to be included.
%
% \begin{dtxexample}[\Cref{tab:simpletable}]{Table macro}
% \keytab{c=A \cs{keytab} table,l=tab:simpletable}{\testtable}
% \end{dtxexample}
%
% Do not try to use tables which overflow the page.
%
% For anything other than a simple table, use the \env{keytable} environment.
% See \cref{ex:keytable}.
%
% For large tables, use the \pkg{longtable} or \pkg{supertabular} packages.
% \margintag{large tables}
% \trouble{table>large}
%
%
% \begin{dtxexample}[\Cref{tab:environment}]
% {Table environment with arbitrary contents\label{ex:keytable}}
% \begin{keytable}{f,c={A \env{keytable} environment},
% 	l=tab:environment}
% Arbitrary contents may go here.\footnote{A footnote.}
%
% \testtable
% \end{keytable}
% \end{dtxexample}
%
% The \env{keytable} environment is preferred over the \cs{keytab} macro
% since most tables are multi-line creations.
%
% \cs{keytab} centers the table, but \env{keytable} does not.
% Add \cs{centering} if desired.
%
% \clearpage
%
% \begin{dtxexample}[\Cref{fig:options}]{Figure with many options selected}
% \keyfig{
% 	w=2in,ft,r=15,
% 	c=A figure with many options,
% 	sc=A figure with options,
% 	t={Additional text.  Multiple paragraphs may be used.
% 	The entire text is enclosed in braces because a comma
% 	is included. Alignment may be set by using
% 	tags \optn{tc}, \optn{tl}, or \optn{tr}
% 	instead of \optn{t}},
% 	l=fig:options
% }{image}
% \end{dtxexample}
%
% \gindex{text>added}
% \gindex{float>text added}
%
% Width is fixed at 2\,in, a tight frame is specified (\cs{fboxsep} of 0\,pt),
% a short caption appears in the List of Figures, and the additional text
% is using the default fully-justified alignment.
%
% Since \cref{fig:options} is a float, it may appear on the following page.
%
%
% \clearpage
%
% \begin{dtxexample}[\Cref{fig:linewidth}]{Using \cs{linewidth}}
% \keyfig{lw=.5,c=Half of \cs{linewidth},l=fig:linewidth}{image}
% \end{dtxexample}
%
% \Cref{fig:linewidth} is half of \cs{linewidth} in size.
% \margintag{\cs{linewidth}}
% \gindex{image>\cs{linewidth}}\gindex{\cs{linewidth}}
% \gindex{subfloat>\cs{linewidth}}\gindex{keyfloats>\cs{linewidth}}
% When the |lw| key is used inside a \env{keyfloats} or \env{keysubfigs} environment,
% the \cs{linewidth} will be proportional to the sub-box for each element.
% When used alone, such as here, the \cs{linewidth} is the full width of the text on
% this page.
%
% |lw| and |w| are not used at the same time.
% If both |lw| and |w| are specified, the last one cancels any previous ones.
%
%
% \clearpage
%
% \begin{dtxexample}[\Cref%
%     {fig:looseframe,fig:tightframe,tab:looseframe,tab:tightframe}%
% ]{Using frames}
% \begin{keyfloats}[hbp]{4}
% \keyfig{f,c=Loosely-framed figure,l=fig:looseframe}{image}
% \keyfig{ft,c=Tightly-framed figure,l=fig:tightframe}{image}
% \keytab{f,c=Loosely-framed table,l=tab:looseframe}{\testtable}
% \keytab{ft,c=Tightly-framed table,l=tab:tightframe}{\testtable}
% \end{keyfloats}
% \end{dtxexample}
%
% The |f| key adds a loose frame with the current \cs{fboxsep}.
% This is desirable in most cases.
%
% The |tf| key adds a tight frame with no separation.
% This is useful for framing a photograph, or a diagram which already has a margin.
%
% Framing tables is seldom recommended.  In the case of the tight frame, \cref{tab:tightframe},
% note that the external frame almost overwrites the table's natural horizontal rules.
%
% Also see \cref{sec:customframes} for customizing frames.
% \margintag{custom frames}
%
%
% \clearpage
%
% \begin{dtxexample}[\Cref{tab:rotated}]{Using rotation with boxes}
% \keytab{f,w=.8in,c={Table, rotated},
% 	r=70,l=tab:rotated,
% 	tc=(Framed to show box width.)}
% 	{\testwidetable}
% \end{dtxexample}
%
% Unless a width is given, a box is the full \cs{linewidth}.
% \margintag{rotated whitespace}
% When rotated, this extra horizontal space is rotated into extra vertical space.
% \gindex{rotate>box width and vertical space}\gindex{\cs{linewidth}>with rotation}
% \trouble{rotate>extra space}
% To avoid this extra space, set a |w| or |lw| to be wide enough
% \watchout[box width]
% for the table or other contents,
% but not much wider.  When this box is rotated, it will not take much more
% vertical space than necessary.
%
% Unlike an image, the frame of a box does not rotate with its contents.
% \margintag{frame rotation}\gindex{frame>rotation}
% \trouble{rotate>frame}
%
% \clearpage
%
% \begin{dtxexample}[\Cref{tab:here}, \Cref{fig:here}]{Located [H]ere}
% \keytab[H]{c={A table [H]},l=tab:here}{\testtable}
% \keyfig[H]{f,w=1in,c={A keyfig [H]},l=fig:here}{image}
% \end{dtxexample}
%
% \gindex{h=[H]ere placement}
% \gindex{float>h=[H]ere placement}
% \gindex{float>inline}
% \Cref{tab:here} and \Cref{fig:here} are to be placed ``[H]ere'', and therefore may appear
% \watchout[Out of sequence]
% out-of-sequence with surrounding figures.
% \trouble{float>out of sequence}
% Place a \cs{clearpage} before or after to re-sync, if necessary.
%
%
% \clearpage
%
% \begin{dtxexample}[See fig: ``A starred caption''.]{Unnumbered float}
% \keyfig[H]{f,cstar={A starred caption}}{image}
% \end{dtxexample}
%
% \gindex{float>unnumbered}
%
% A starred caption creates a float without a number, and without
% an entry in the List of Figures unless there is a non-empty short caption.
% (See the next example.)
%
% Labels cannot be used when there is no number for a float.
% \trouble[No label]{label>missing}
% \trouble{label>unnumbered float}
% \trouble{float>unnumbered>no label}
%
% \begin{dtxexample}
% 	[See fig: ``Starred caption with a short caption''.]
% 	{Unnumbered float with a \acro{LOF} entry}
% \keyfig{
% 	f,cstar={Starred caption with a short caption.},
% 	sc={Starred short caption}
% }{image}
% \end{dtxexample}
%
% A starred caption with a non-empty short caption creates an
% unnumbered entry in the List of Figures.
%
%
% \clearpage
%
% \begin{dtxexample}
% 	[See fig: ``Optional text which is not a caption.'']
% 	{An unnumbered in-text image}
% \keyfig[H]{f,cstar={},
% 	tc={Optional text which is not a caption.}
% }{image2}
% \end{dtxexample}
%
% \gindex{float>inline without caption}
%
% By using [H] and |cstar={}|, the image is placed inline
% without a number or \acro{LOF} entry.
%
% Also see \cref{ex:keyparbox}.
%
%
% \clearpage
%
% \begin{dtxexample}[\Cref{fig:nexttoparbox}, and the box to its left.]
% 	{A box without a caption.\label{ex:keyparbox}}
% \begin{keyfloats}{2}
% \keyparbox{
% 	f,lw=.5,
% 	tc={A \cs{keyparbox} with no number or label.}
% }{Some contents.}
% \keyfig{c=Next to a \cs{keyparbox},l=fig:nexttoparbox}{image}
% \end{keyfloats}
% \keyparbox[H]{f,lw=.5}{A \cs{keyparbox} [H], outside the keyfloats.}
% \end{dtxexample}
%
% \gindex{float>without caption}
%
% A \cs{keyparbox} is a \cs{keyfigbox} with |cstar={}|,
% and is mostly useful as an information box inside a row or a set of subfloats.
%
%
%
%
% \clearpage
%
% \subsubsection{Groups of floats, shared keys, keep aspect ratio}
%
% \begin{dtxexample}[\Cref{fig:firstinrow} to \Cref{tab:seventhinrow}]{Groups of figures — \env{keyfloats} environment\label{ex:keyfloats}}
% \begin{keyfloats}{2}
% \keyfig{lw=1,c={First in a group},
% 	l=fig:firstinrow,tl={\cs{raggedright} text}
% 	}{image}
% \keyparbox{}{\centering A \cs{keyparbox} describing something.
% 	\par With several paragraphs.}
% \begin{keyfloats}{2}[f,lw=1,h=3em,kar,va=t]
%       \keyfig{lw=1,c={Third in a group},
%           l=fig:thirdinarow}{image}
%       \keyfig{lw=1,c={Fourth in a group, with a longer caption}}{image2}
%       \keyfig{lw=1,c={Fifth in a group}}{image}
%       \keyfig{lw=1,c={Sixth in a group},
%           l=fig:sixthinarow}{image2}
% \end{keyfloats}
% \keytab{c={Seventh in a group},l=tab:seventhinrow}{\testwidetable}
% \end{keyfloats}
% \end{dtxexample}
%
% 
% The \env{keyfloats} environment takes an argument for the number of columns.
% Additional floats
% \margintag{automatic layout}
% are automatically placed on following rows.
% Changing the number of columns will cause the floats to automatically readjust as
% necessary.  Leftovers will be centered on the last row.
% An optional argument
% \margintag{shared keys}
% \gindex{group>shared keys}
% \gindex{float>shared keys}
% \gindex{keys>shared in a group}
% may contain keys and values which are passed to each object
% inside the group.
%
% \Cref{fig:firstinrow} to \cref{tab:seventhinrow} are in a \env{keyfloats} environment.
% Furthermore,
% \margintag{nested groups}
% \Crefrange{fig:thirdinarow}{fig:sixthinarow} are in an
% additional nested \env{keyfloats} environment, forming a small box of floats inside
% the larger group.
% In this subgroup, shared keys are set so that each image is framed
% and keeps its aspect ratio while being resized to fit a fixed width and height.
%
% Note that \cs{linewidth} is adjusted for each row and nested row,
% \watchout[\cs{linewidth}]
% so the |lw| key may need to be changed if a float is moved to a different nesting level.
% \trouble{\cs{linewidth}}\gindex{\cs{linewidth}>subfloats}
% \gindex{subfloat>\cs{linewidth}}
%
% Fixed-width or fixed-height floats may be too large to fit
% \watchout[image too large]
% if they are moved into a group.  A warning is issued if so.
% It is the user's responsibility to adjust |w|, |h|, or |lw| as necessary.
% \trouble{image>too large}
% To allow images to automatically adjust, use |lw=1| or less, which adjusts
% to the \cs{linewidth}.
%
% Keyfloats may be located
% \margintag{location}
% [H], [M], or located [W] set with half the line width:\\
% \hspace*{2em}|\begin{keyfloats}[H]{2}| \dots
%
% Keyfloats may be starred
% \margintag{two columns}
% to span both columns in a two-column format: \\
% \hspace*{2em}|\begin{keyfloats}*{2}| \dots
%
% As shown in the sub group above,
% \margintag{grid of images}
% \gindex{group>nested}
% \gindex{float>nested group}
% \gindex{image>grid of}
% \gindex{image>keep aspect ratio}
% \gindex{aspect ratio}
% \gindex{keep aspect ratio}
% to display a group of images of varying shape inside a grid, use the shared option to
% select a maximum size, keep aspect ratio, and align at the top so that captions
% of varying length may wrap below each image:
% \begin{sourceverb}
% \begin{keyfloats}{2}[lw=1,h=3em,kar,va=t]
% ...
% \end{keyfloats}
% \end{sourceverb}
%
%
% \clearpage
%
% \subsubsection{Subfloats}
%
% \begin{dtxexample}[\Cref{fig:subfigs}]{Subfigures — \env{keysubfigs} environment\label{ex:keysubfigs}}
% \begin{keysubfigs}{3}{c=Subfigures,l=fig:subfigs}
% \keyfig{lw=1,f,c={First subfigure},
% 	l=fig:firstsubfig,t=Some text}{image}
% \keyfig{lw=1,f,r=90,c={Second subfigure},
% 	l=fig:secondsubfig,
% 	t=Lots of lots of lots of lots of text.}
% 	{image2}
% \begin{keyfloats}{1}
%       \keyfig{lw=1,f,c={Third subfigure},l=fig:thirdsubfig}{image}
%       \keytab{c={Fourth subfigure},l=fig:fourthsubfig}{\testtable}
%       \keyfig{lw=.5,f,c={Fifth subfigure},l=fig:fifthsubfig}{image}
% \end{keyfloats}
% \end{keysubfigs}
% \end{dtxexample}
% 
% \Crefrange{fig:firstsubfig}{fig:fifthsubfig} are in
% the \cref{fig:subfigs} \env{keysubfigs} environment.
% The \env{keysubtabs} environment is similar.
% Mixed types have the type of their container, as shown with \cref{fig:fourthsubfig}.
%
% Subfloats are associated floats (a, b, \dots) collected together into one common float
% (the enclosing \env{keysubfigs} or \env{keysubtabs} environment).
% The enclosing float can have its own caption (call ``Sub-Figures'' in the example),
% which appears in the \acro{LOF}/\acro{LOT}, and also a label.
% Each subfloat can have its own caption and label as well, but the
% subcaption does not appear in the \acro{LOF}/\acro{LOT}.
%
% All subfloats are forced to have the same type as
% its containing float.\trouble{mixed subfloats}
% \watchout[mixed subfloats]
% A table inside a figure will be labeled as a figure, for example.
% This avoids miss-labeling as each subfloat must clearly be identified
% as a child of its containing float.
%
% \env{keysubfigs} and \env{keysubtabs} may not be used inside\watchout[nested subfloats]
% \trouble{nested subfloats}\gindex{subfloat>nested}
% the \env{keyfloats} environment,
% and cannot be nested inside each other.  (No subfloat |12aa|, |12ab|, |12ba|, etc.)
%
% The \env{keyfloats} environment may be used inside \env{keysubfigs} or
% \margintag{nested keyfloats}\gindex{keyfloats>nested}
% \env{keysubtabs} to gather subfloats together, such as the
% three right-most figures in \cref{fig:subfigs}.
%
% Subfloats may be located
% \margintag{location}
% [H], [M], or located [W] set with half the line width: \\
% \hspace*{2em}|\begin{keysubfigs}[H]{3}{|key/vals \dots|}|
% 
% Subfloats may be starred
% \margintag{two columns}
% to span both columns in a two-column format: \\
% \hspace*{2em}|\begin{keysubfigs}*{2}{|key/vals \dots|}|
%
% A group of subfloats
% \margintag{shared keys}
% \gindex{group>shared keys}
% \gindex{subfloat>shared keys}
% \gindex{keys>shared in a group}
% may have an optional argument for shared keys and values,
% which are then passed to each subfloat within.
%
% The vertical alignment
% \watchout[va]
% option |va| does not work with subfloats.
%
% \begin{dtxexample}[\Cref{tab:subtabs}]{Subtables [H] — \env{keysubtabs} environment\label{ex:keysubtabs}}
% \begin{keysubtabs}[H]{2}{c=Subtables [H],l=tab:subtabs}
% \keytab{c={First subtable},l=fig:firstsubtab}{\testtable}
% \keytab{c={Second subtable},l=fig:secondsubtab}{\testwidetable}
% \end{keysubtabs}
% \end{dtxexample}
% 
%
%
% \clearpage
%
% \subsubsection{Continued floats}
%
% \gindex{float>continued}
% \gindex{continued float}
%
% The |cont| key may be used to generate a ``continued'' float.
% The continued float receives the same number as the previous float,
% and it is assumed that they are the same float, except that
% they are separated for some reason such as size on the page.
%
% The label may be placed in a continued float, and will still
% receive the same float number as the prior non-continued float.
%
% \begin{dtxexample}[\Cref{fig:firstcontinued}]{Continued figure}
% \begin{keyfloats}{2}
% \keyfig{,c=Figure to be continued}{image}
% \keyfig{c={\dots continued},cont,l=fig:firstcontinued}{image2}
% \end{keyfloats}
% \end{dtxexample}
%
%
% \clearpage
% \subsubsection{Continued subfloats}
%
% \gindex{float>subfloat continued}
% \gindex{subfloat>continued}
% \gindex{continued subfloat}
%
% The \env{keysubfigs} and \env{keysubtabs} environments may also
% be given the |cont| key.
% The containing environment's float receives the same number as the previous float
% (presumably another subfloat container).
%
% \begin{dtxexample}[\Cref{fig:continuedfigures}]{Continued subfloats}
% \begin{keysubfigs}{2}{c={A set of figures},l=fig:continuedfigures}
% \keyfig{c={First of a set},l=fig:contfirst}{image}
% \keyfig{c={Second of a set},l=fig:contsecond}{image}
% \end{keysubfigs}
% \begin{keysubfigs}{2}{c={\dots continued},cont}
% \keyfig{c={Third of a set},l=fig:contthird}{image2}
% \keyfig{c={Fourth of a set},l=fig:contfourth}{image2}
% \end{keysubfigs}
% \end{dtxexample}
%
%
% \clearpage
% \subsubsection{Margin floats}
% \changes{v0.12}{2016/12/02}{Docs: Margin float examples.}
%
% \gindex{float>margin placement}
% \gindex{margin placement}
%
% When a keyfloat is located [M], it will be placed in the margin.
%
% \DescribeClass{tufte-book}
% When the |tufte-book| class is used, its \env{marginfigure} or \env{margintable}
% environments will be used, otherwise \pkg{keyfloat} provides environments
% of the same name and uses those instead.
%
% \begin{dtxexample}[\Cref{fig:marginfigure}]{The \env{marginfigure} environment\label{ex:marginfigure}}
% \begin{marginfigure}
% \centering
% \includegraphics[width=.75\linewidth]{image}
%
% Some text added by hand.
% \caption{A \env{marginfigure}}
% \label{fig:marginfigure}
% \end{marginfigure}
% \end{dtxexample}
%
%
% \begin{dtxexample}[\Cref{fig:margintable}]{The \env{margintable} environment\label{ex:margintable}}
% \begin{margintable}
% \centering
% \testwidetable
% \caption{A \env{margintable}}
% \label{fig:margintable}
% \end{margintable}
% \end{dtxexample}
%
%
% \begin{dtxexample}[\Cref{fig:keyfigm}]{Using \cs{keyfig}\optn{[M]}\label{ex:keyfigm}}
% \keyfig[M]{c={A \cs{keyfig}\optn{[M]}},l=fig:keyfigm,ft,
% 	t=Additional text.
% 	Text text text text text text.
% 
% 	More paragraphs.
% }{image2}
% \end{dtxexample}
%
%
% \begin{dtxexample}[\Cref{tab:keytablem}]
%	{Using \env{keytable}\optn{[M]} and an offset\label{ex:keytablem}}
% \begin{keytable}[M]{c={A \env{keytable}\optn{[M]}},
% 	l=tab:keytablem,mo=-.9in}
% \centering
% \testwidetable
% \end{keytable}
% \end{dtxexample}
%
% A negative offset was used to shift the table upwards
% \margintag{margin float offset}
% to the top of the example.
%
% To set the minimum-allowed distance between \cs{marginpar}s and margin floats:
% \margintag{distance between floats}
% \gindex{distance between floats}\gindex{float>distance between}
% \begin{sourceverb}
% \setlength{\marginparpush}{3ex}
% \end{sourceverb}
%
%
%
% \clearpage
% \subsubsection{Wrapped floats}
% \changes{v0.12}{2016/12/03}{Docs: Wrapped float examples.}
%
% \begin{dtxexample}[\Cref{fig:keyfigw,tab:keytabw}]
%	{Using \cs{keyfig}\optn{[W]} and \cs{keytab}\optn{[W]}\label{ex:keyfigw}}
% \keyfig[W]{c={A \cs{keyfig}\optn{[W]}},
% 	l=fig:keyfigw,ft,lw=.4,wp=I, wo=8em, wn=12,
% 	t={.4\cs{linewidth} wide, placed \optn{I}.}
% }{image2}
% \blindtext

% \keytab[W]{c={A \cs{keytab}\optn{[W]}},l=tab:keytabw,w=.75in,
% }{\testtable}
% \blindtext
% \end{dtxexample}
%
% \begin{dtxexample}[\Cref{fig:keyfigboxw} and the \cs{keyparbox}.]
%	{Using \cs{keyfigbox}\optn{[W]} and \cs{keyparbox}\optn{[W]}\label{ex:keyfigboxw}}
% \keyfigbox[W]{c={A \cs{keyfigbox}\optn{[W]}},
% 	l=fig:keyfigboxw,f,lw=.25,wp=I, wn=7,
% 	t=Text text text text text text text text text
% }{The contents.}
% \blindtext

% \keyparbox[W]{w=1in}{A \cs{keyparbox}[W] and some more text.}
% \blindtext
% \end{dtxexample}
%
%
% \begin{dtxexample}[\Cref{fig:keyfigurew,tab:keytablew}]
%	{Using \cs{keyfigure}\optn{[W]} and \cs{keytable}\optn{[W]}\label{ex:keyfiguretablew}}
% \begin{keyfigure}[W]{c={A \cs{keyfigure}\optn{[W]}},
% 	l=fig:keyfigurew,f,w=1.5in, wo=4em,wn=5}
% This is a keyfigure.
% \end{keyfigure}
% \blindtext
%
% \begin{keytable}[W]{c={A \env{keytable}\optn{[W]}},
% 	l=tab:keytablew,w=2in,wp=L,
%   tc=Placed \optn{L} and 2in wide.}
% \centering
% \testwidetable
% \end{keytable}
% \blindtext
% \end{dtxexample}
%
%
% \clearpage
%
% \begin{dtxexample}[\Cref{fig:keywrapfig}]
%	{Using \env{keywrap} with a \cs{keyfig}\label{ex:keywrapkeyfig}}
% \begin{itemize}
% \item First item.
%     Several lines of text text text text text
%     text text text text text text text text.
% \item \begin{keywrap}{.3\linewidth}{\keyfig{%
%       lw=1,c={Keywrap with \cs{keyfig}},l=fig:keywrapfig%
%     }{image}}
%         Second item.
%         Several lines of text text text text text
%         text text text text text text text text text
%         text text text text text text text.
%
%         These paragraphs are inside the \texttt{keywrap}.
%         A vertical gap appears below if the text is not enough to
%         fill the space next to the \cs{keyfig}.
%     \end{keywrap}
%     Outside the \env{wrapfig},\margintag{notes}\
%     but still in the second item.
%     There is no elegant way to place only part of a paragraph
%     inside a \env{keywrap}, and attempting to do so requires
%     manually removing the vertical paragraph skip.
% \item Third item.
% \end{itemize}
% \end{dtxexample}
%
% \clearpage
%
% \begin{dtxexample}[\Cref{fig:keyfigwlw,fig:keyfigww}]
%   {Using wrap width \optn{ww} and \optn{wlw}\label{ex:keyfigwlw}}
% \keyfig[W]{c={A \cs{keyfig}\optn{[W] with \optn{wlw}}},
%   l=fig:keyfigwlw,ft,lw=.15,wlw=.4,wp=I,
%   t={.15\cs{linewidth} wide, in a .4\cs{linewidth} box.}
% }{image2}
% \blindtext[1]
%
% \keyfig[W]{c={A \cs{keyfig}\optn{[W] with \optn{ww}}},
%   l=fig:keyfigww,ft,w=1cm,ww=3cm,wp=I,
%   t={1cm wide, in a 3cm box.}
% }{image2}
% \blindtext[1]
% \end{dtxexample}
%
%
% \clearpage
% \subsubsection{Custom frames}
%
% \begin{dtxexample}[\Cref{fig:customframe,fig:customlooseframe}]
%	{Custom frames with \pkg{mdframed}\label{ex:customframe}}
% \renewcommand{\KFLTtightframe}[1]{%
% \begin{minipage}{\KFLTimageboxwidth}
% \begin{mdtightframe}%
% #1
% \end{mdtightframe}%
% \end{minipage}
% }
% \setlength{\KFLTtightframewidth}{1pt}
%
% \renewcommand{\KFLTlooseframe}[1]{%
% \begin{mdlooseframe}[leftmargin=1.5in,rightmargin=1.5in]%
% #1
% \end{mdlooseframe}%
% }
% \setlength{\KFLTlooseframewidth}{4pt}
%
% \keyfig{ft,c=Custom-framed image,l=fig:customframe,r=90}{image}
% \keyfigbox{f,c=Custom loosely-framed box,
% 	l=fig:customlooseframe}{A loosely-framed box.}
% \end{dtxexample}
%
% \gindex{frame>mdframed}
% \gindex{mdframed}
%
% \DescribePackage{mdframed}
% \Cref{ex:customframe} shows custom frames
% created with the \pkg{mdframed} package along with \pkg{tikz}.
% Note that \pkg{mdframed} uses the full \cs{linewidth}
% \watchout[\pkg{mdframed} width]
% even if the left/right margins are explicitly set, which
% causes extra vertical space when rotated.
% Because of this, the framed object is enclosed inside a minipage
% whose width is precomputed based on the object itself, then
% set in \cs{KFLTimageboxwidth}.  Any shadow may fall outside this
% box.
% \trouble{rotate>extra space}
% \trouble{mdframed}
%
% See \cref{sec:customframes} for more details.
%
% \begin{dtxexample}[\Cref{fig:customshadow,fig:customlooseshadow}]
%	{Custom shadows with \pkg{fancybox}\label{ex:customshadow}}
% \renewcommand{\KFLTtightframe}[1]{%
% \setlength{\fboxrule}{.4pt}
% \setlength{\fboxsep}{0pt}
% \setlength{\shadowsize}{2pt}
% \shadowbox{#1}%
% }
% \setlength{\KFLTtightframewidth}{0.4pt}
%
% \renewcommand{\KFLTlooseframe}[1]{%
% \setlength{\fboxrule}{.4pt}
% \setlength{\fboxsep}{3pt}
% \setlength{\shadowsize}{2pt}
% \shadowbox{#1}%
% }
% \setlength{\KFLTlooseframewidth}{3.4pt}
%
% \keyfig{ft,c=Custom shadow,l=fig:customshadow}{image}
% \keyfigbox{f,c=Custom loosely-framed shadow,lw=.5,
% 	l=fig:customlooseshadow}{A loosely-framed shadow box.}
% \end{dtxexample}
%
% \gindex{fancybox}
% \gindex{frame>fancybox}
%
% \DescribePackage{fancybox}
% \Cref{ex:customshadow} shows custom shadow frames
% created with the \pkg{fancybox} package.
% This combination respects |lw| and |w|.
%
% See \cref{sec:customframes} for more details.
%
%
%
%
%
% \renewcommand{\KFLTtightframe}[1]{%
% \setlength{\fboxsep}{0pt}%
% \setlength{\fboxrule}{.4pt}%
% \fbox{#1}%
% }
% \setlength{\KFLTtightframewidth}{.4pt}
% 
% \renewcommand{\KFLTlooseframe}[1]{%
% \setlength{\fboxsep}{3pt}%
% \setlength{\fboxrule}{.4pt}%
% \fbox{#1}%
% }
% \setlength{\KFLTlooseframewidth}{3.4pt}
%
%
%
%
%
% \clearpage
% \subsubsection{Artist's name}
%
% \gindex{author's or artist's name}
% \gindex{name>author or artist}
%
% \begin{dtxexample}[\Cref{fig:artist}]{Artist's name — image}
% \keyfig{ft,ap=Mr.,af=First,al=Last,as={~III},
%	tc={\textit{About the illustration.}},
%	c=Artist's name — image,l=fig:artist}{image}
% \end{dtxexample}
%
%
% \begin{dtxexample}[\Cref{fig:artistpar}]{Artist's name — arbitrary contents}
% \tdartistright
% \begin{keyfigure}{f,ap=Mr.,al=Last,
%	c=Artist's name — arbitrary contents,l=fig:artistpar}
% \centering Some text, a quotation, a TikZ\ diagram —
% anything not an image file.
% \end{keyfigure}
% \tdartistcenter
% \end{dtxexample}
%
% The artist's name and optional prefix/suffix are printed below the figure,
% and an index entry is made for the name in (Last, First) format,
% or (Last) if there is no first name.
% If the \pkg{tocdata} package is loaded, the artist's name is also added to
% the List of Figures, and the \pkg{tocdata} \cs{tdname}\dots\ macros
% may be used to align the name.
%
%
%
% \begin{dtxexample}[\Cref{fig:artistcollection}]{Subfloats with an artist}
% \begin{keysubfigs}{2}{
% 	c=Artist's collection, l=fig:artistcollection,
% 	t={Some fully-justified text just for illustrative purposes,
% 	in case you have use for long explanations.
% 	This text may be the full \cs{linewidth} in size. \par
% 	Multiple paragraphs of text are allowed.},
% 	ap=Prefix,af=First,al=Last,as={, Suffix}
% }
% 	\keyfig{c=Artist's First Work}{image}
% 	\keyfig{c=Artist's Second Work,
% 		tc={Commentary about the work.}}{image2}
% \end{keysubfigs}
% \end{dtxexample}
%
% A group of figures may be placed into a subfloat container,
% which may have its own artist keys and additional text.
% Furthermore, each subfloat inside the collection may also have its
% own artist tags and additional text.
%
%
% \clearpage
%
% \subsection{Customization}
%
% \subsubsection{Custom frames}
% \label{sec:customframes}
%
% \gindex{frame>custom}
%
% There are two user-redefinable framing macros: \\
% \hspace*{2em}\cs{KFLTtightframe} and \cs{KFLTlooseframe}
%
% A float's contents are placed into a box,
% which is passed to either of these two macros
% depending on the key |f| or |tf|.
%
% Each macro takes one argument and frames it.
%
% Each macro has a associated \LaTeX\ lengths: \\
% \hspace*{2em}\cs{KFLTtightframewidth} and \cs{KFLTlooseframewidth}
%
% These lengths must be redefined to the expected
% total frame width, equal to the frame thickness plus
% separation.
%
% The default definitions are:
% \begin{sourceverb}
% \newcommand{\KFLTtightframe}[1]{%
%   \setlength{\fboxsep}{0pt}%
%   \setlength{\fboxrule}{.4pt}%
%   \fbox{#1}%
% }
% \setlength{\KFLTtightframewidth}{.4pt}
% 
% \newcommand{\KFLTlooseframe}[1]{%
%   \setlength{\fboxsep}{3pt}%
%   \setlength{\fboxrule}{.4pt}%
%   \fbox{#1}%
% }
% \setlength{\KFLTlooseframewidth}{3.4pt}
% \end{sourceverb}
%
% See \cref{ex:customframe} for an example
% created with the \pkg{mdframed} package,
% and \cref{ex:customshadow} for an example
% created with the \pkg{fancybox} package.
%
%
%
% \subsubsection{Distance between floats and rows}
% \gindex{distance between floats}
% \gindex{subfloat>distance between}
% \gindex{float>distance between}
% \trouble{table>rows too close or far}
% To spread out the distance between floats and/or rows of floats
% \margintag{rows too close/far}
% on a busy page, the following settings may be changed.
% The settings used in this documentation are:
% \begin{sourceverb}
% \setlength{\floatsep}{5ex plus 1ex minus 1ex}
% \setlength{\dblfloatsep}{5ex plus 1ex minus 1ex}
% \end{sourceverb}
%
%
% \subsubsection{Formatting the captions}
%
% ^^A \trouble{caption format}
% To modify the typesetting of the captions, see the \pkg{caption} package.
% \gindex{caption>formatting}
% The settings used in this documentation are:
% \begin{sourceverb}
% % default applied to margin floats:
% \captionsetup{labelfont={small,bf},textfont={small,bf}}
% 
% \captionsetup[figure]{
% 	style=default, justification=centering,
% 	margin=0pt, parskip=0pt, skip=2ex,
% 	labelfont={small,bf},textfont={small,bf}
% }
% 
% \captionsetup[table]{
% 	style=default, justification=centering,
% 	margin=0pt, parskip=0pt, skip=1ex,
% 	labelfont={small,bf},textfont={small,bf}
% }
% 
% \captionsetup[subfigure]{
% 	style=default, justification=centering,
% 	margin=0pt, parskip=0pt, skip=2ex,
% 	labelfont={small},textfont={small}
% }
% 
% \captionsetup[subtable]{
% 	style=default, justification=centering,
% 	margin=0pt, parskip=0pt, skip=1ex,
% 	labelfont={small},textfont={small}
% }
% \end{sourceverb}



% \clearpage
%
% ^^A \StopEventually{\PrintChanges\PrintIndex}
%
% \makeatletter
%
% \StopEventually{
% ^^A \part{Change History and Index}
% ^^A  \part{Change History}
%
%
% \pagestyle{plain}
%
% ^^A Each index has a prologue which creates its own \part, label,
% ^^A and meta index entry.
%   \GlossaryPrologue{
%       \part{Change History}
% ^^A     \section{Chg Hist}
%       \label{sec:changehistory}
%       \sindex[meta]{Change History}
%       \markboth{{Change History}}{{Change History}}
%
%       For the most recent changes, see page \pageref{sec:changesend}.
%
%   }
%   \PrintChanges
%   \phantomsection
%   \label{sec:changesend}
%
%
% ^^A The instructions for the Index of Objects:
%   \IndexPrologue{
%       \clearpage
%       \expandafter\part\expandafter{\indexname}
%       \label{sec:index\indexshortcut}
%       \sindex[meta]{\indexname}
%         \markboth{Index of Objects}{Index of Objects}%
%
%       This is an index of macros, environments, booleans, counters, lengths,
%       packages, classes, options, keys, files, and various other programming objects.
%       Each is listed by itself, and also by category.
%       In some cases, they are further subdivided by [class].
%
%       Numbers written in italic refer to the page
%       where the corresponding entry is described;
%       numbers underlined refer to the
%       \ifcodeline@index
%       code line of the
%       \fi
%       definition.
% ^^A        ; numbers in roman refer to the
% ^^A         \ifcodeline@index
% ^^A         code lines
% ^^A         \else
% ^^A         pages
% ^^A         \fi
% ^^A         where the entry is used.
%   }
%
%   \printindex[idx][Index of Objects]
%
%
% ^^A The instructions for the General Index:
%   \IndexPrologue{
%       \clearpage
%       \expandafter\part\expandafter{\indexname}
%       \label{sec:index\indexshortcut}
%       \sindex[meta]{\indexname}
%
% ^^A      This is an index of instructions and concepts.
% ^^A      Look here when wondering how to do something, and
% ^^A      check the Troubleshooting Index when something goes wrong.
%       This is a general index, including how-to and troubleshooting.
%   }
%
%   \printindex[gen][General Index]
%
%
% ^^A% The instructions for the Troubleshooting Index:
% ^^A%   \IndexPrologue{
% ^^A%       \clearpage
% ^^A%       \expandafter\part\expandafter{\indexname}
% ^^A%       \label{sec:index\indexshortcut}
% ^^A%       \sindex[meta]{\indexname}
% ^^A%
% ^^A%       This index is a sorted reference of problems and solutions.
% ^^A%       In order to make it easier to locate a solution,
% ^^A%       the same issue may be addressed by more than one entry.
% ^^A%
% ^^A%       Entries with higher page numbers are often duplicates of entries with
% ^^A%       lower page numbers, as the same warning may occur within the user manual
% ^^A%       and again within the source code for a given package.
% ^^A%   }
% ^^A%
% ^^A%   \printindex[trb][Troubleshooting Index]
%
%
% ^^A The meta index does not get a meta index entry pointing  to itself:
%   \IndexPrologue{

%       \clearpage
%       \expandafter\part\expandafter{\indexname}
%       \label{sec:index\indexshortcut}
%   }
%
%   \printindex[meta][Index of Indexes]
% }
%
% \makeatother
%
%
%
%
% \section{Code}
% ^^A *source
%
% \subsection{Older packages}
%
% Ensure that \pkg{tocdata}, if loaded, is new enough:
%    \begin{macrocode}
\@ifpackageloaded{tocdata}{
    \@ifpackagelater{tocdata}{2019/03/21}{}{
        \PackageError{keyfloat}
        {%
            The tocdata package is out of date.\MessageBreak
            Update to tocdata v2.02 2019/03/21 or later\MessageBreak
            to use use this version of keyfloat%
        }
        {%
            Please update the tocdata package.  It's worth it!%
        }
    }
}{}
%    \end{macrocode}
%
% \subsection{Prohibited packages}
%
% Prohibits the use of a certain other packages.
%
% \begin{macro}{\KFLT@@prohibitpackage} \marg{packagename}
%    \begin{macrocode}
\newcommand*{\KFLT@@prohibitpackage}[2]{%
\@ifpackageloaded{#1}
{
    \PackageError{keyfloat}
    {%
        The keyfloat package conflicts with the #1\MessageBreak
        package. Remove #1 to use keyfloat.\MessageBreak
        Alternative(s):\MessageBreak
        \space\space#2%
    }
    {%
        Keyfloat uses the caption, subcaption, newfloat, and wrapfig packages.%
    }
}{}
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\KFLT@prohibitpackage} \marg{packagename}
%
% Prohibits the use of another package, both now and also \cs{AtBeginDocument}.
%
% \changes{v2.00}{2019/03/11}{Improved package conflict detection.}
%    \begin{macrocode}
\newcommand*{\KFLT@prohibitpackage}[2]{
    \KFLT@@prohibitpackage{#1}{#2}
    \AtBeginDocument{\KFLT@@prohibitpackage{#1}{#2}}
}
%    \end{macrocode}
% \end{macro}
%
%
% The list of prohibited packages:
% \changes{v2.02}{2021/05/18}{Work with \pkg{float}.}
%    \begin{macrocode}
\KFLT@prohibitpackage{floatrow}{caption and subcaption}
\KFLT@prohibitpackage{subfig}{subcaption}
\KFLT@prohibitpackage{subfigure}{subcaption}
\KFLT@prohibitpackage{subfloat}{subcaption}
\KFLT@prohibitpackage{floatflt}{wrapfig}
%    \end{macrocode}
%
%
%
% \subsection{Required packages}
% \changes{v1.00}{2019/01/08}{Removed \pkg{xifthen} dependency.}
%
% \DescribePackage{etoolbox} v2.6 or later
%	for \cs{BeforeBeginEnvironment}, \cs{AfterEndEnvironment}
%    \begin{macrocode}
\RequirePackage{etoolbox}[2011/01/03]%
%    \end{macrocode}
% \DescribePackage{xparse} Argument processing:
%    \begin{macrocode}
\RequirePackage{xparse}
%    \end{macrocode}
% \DescribePackage{keyval} Key processing:
%    \begin{macrocode}
\RequirePackage{xkeyval}
%    \end{macrocode}
% \DescribePackage{graphicx} For \cs{includegraphics} and \pkg{rotating}:
%    \begin{macrocode}
\RequirePackage{graphicx}
%    \end{macrocode}
% \DescribePackage{caption} Handles all caption-related functions:
%    \begin{macrocode}
\RequirePackage{caption}[2010/10/31]% v3.2 to support \phantomcaption
%    \end{macrocode}
% \DescribePackage{subcaption} Derived from \pkg{caption}, used to handle subfloats:
%    \begin{macrocode}
\RequirePackage{subcaption}
%    \end{macrocode}
% \DescribePackage{calc} Used to compute box width minus frame sep and width.
%    \begin{macrocode}
\RequirePackage{calc}
%    \end{macrocode}
% \DescribePackage{rotating} Provides rotation via the \env{turn} environment:
%    \begin{macrocode}
\RequirePackage{rotating}
%    \end{macrocode}
% \DescribePackage{placeins} Provides \FloatBarrier to process existing floats before adding new ones.
%    \begin{macrocode}
\RequirePackage{placeins}
%    \end{macrocode}
% \DescribePackage{wrapfig} Provides figure wrapping code.
%    \begin{macrocode}
\RequirePackage{wrapfig}
%    \end{macrocode}
%


% \DescribePackage{gettitlestring} Used by \pkg{hyperref} and \pkg{nameref}.
%
% \changes{v0.13}{2017/01/14}{Fix: Expands names in references.}
%
% Expand names used in titles:
%    \begin{macrocode}
\PassOptionsToPackage{expand}{gettitlestring}
%    \end{macrocode}


% Rows of floats are created by a simple \env{minipage} environment,
% instead of relying on a preexisting package.  This proved to be
% advantageous when support was added for multiple rows in one
% environment.
%

% \subsection{In-line figures and tables}

% These macros are commonly used by others.

% \begin{environment}{tablehere} Place a table exactly [H].
% \changes{v2.01}{2019/09/11}{Fix: Font and color.}
% \changes{v2.01}{2019/09/14}{Improved vertical space.}
%    \begin{macrocode}
\ProvideDocumentEnvironment{tablehere}{}
{%
    \vskip\intextsep\noindent%
    \minipage{\linewidth}%
    \def\@captype{table}%
    \normalcolor\reset@font\normalsize%
}%
{\endminipage\vskip\intextsep}%
%    \end{macrocode}
% \end{environment}

% \begin{environment}{figurehere} Place a figure exactly [H].
% \changes{v2.01}{2019/09/11}{Fix: Font and color.}
% \changes{v2.01}{2019/09/14}{Improved vertical space.}
%    \begin{macrocode}
\ProvideDocumentEnvironment{figurehere}{}
{%
    \vskip\intextsep\noindent%
    \minipage{\linewidth}%
    \def\@captype{figure}%
    \normalcolor\reset@font\normalsize%
}%
{\endminipage\vskip\intextsep}%
%    \end{macrocode}
% \end{environment}



% \subsection{Row counting and control}

% Used to count position and wrap at end of each row.


% \DescribeCounter{KFLT@numcols} Columns per row.
%    \begin{macrocode}
\newcounter{KFLT@numcols}
%    \end{macrocode}

% \DescribeCounter{KFLT@thiscol} Column currently processing.
% |0| if not yet in a keyfloats or subfloat.
%
%    \begin{macrocode}
\newcounter{KFLT@thiscol}
%    \end{macrocode}

% \DescribeLength{\KFLT@rowboxwidth} How wide is each box in the row.
%    \begin{macrocode}
\newlength{\KFLT@rowboxwidth}
%    \end{macrocode}





% \subsection{Float key handling}

% \DescribeBoolean{KFLT@cont} Continued float?
%    \begin{macrocode}
\newboolean{KFLT@cont}
%    \end{macrocode}
%
% \DescribeKey[main]{cont} Continued float?
%
%    \begin{macrocode}
\define@key{KFLT@keys}{cont}[true]{\setboolean{KFLT@cont}{#1}}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@c} Caption storage
%    \begin{macrocode}
\newcommand{\KFLT@c}{}
%    \end{macrocode}
% \end{macro}
%
% \DescribeBoolean{KFLT@cstar} Starred caption?
%    \begin{macrocode}
\newboolean{KFLT@cstar}
%    \end{macrocode}
%
% \DescribeKey[main]{c} Caption
%
%    \begin{macrocode}
\define@key{KFLT@keys}{c}{%
    \renewcommand{\KFLT@c}{#1}\setboolean{KFLT@cstar}{false}%
}
%    \end{macrocode}
%
% \DescribeKey[main]{cstar} Caption starred?
%
%    \begin{macrocode}
\define@key{KFLT@keys}{cstar}{%
    \renewcommand{\KFLT@c}{#1}\setboolean{KFLT@cstar}{true}%
}
%    \end{macrocode}
%
% \DescribeKey[main]{sc} Short caption
%
%    \begin{macrocode}
\define@key{KFLT@keys}{sc}{%
    \renewcommand{\KFLT@sc}{#1}%
    \setboolean{KFLT@scgiven}{true}%
}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@sc} Short caption storage
%    \begin{macrocode}
\newcommand{\KFLT@sc}{}
%    \end{macrocode}
% \end{macro}
%
% \DescribeBoolean{KFLT@scgiven} Was a short caption given?
%    \begin{macrocode}
\newboolean{KFLT@scgiven}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@type} Float type: ``|figure|'', ``|table|''
%    \begin{macrocode}
\newcommand*{\KFLT@type}{}
%    \end{macrocode}
% \end{macro}
%
%
% \DescribeKey[main]{l} Label
%    \begin{macrocode}
\define@key{KFLT@keys}{l}{\renewcommand{\KFLT@l}{#1}}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@l} Label storage
%    \begin{macrocode}
\newcommand*{\KFLT@l}{}
%    \end{macrocode}
% \end{macro}
%
%
% For the artist/author keys:
%
% \DescribeKey[main]{ap} Artist prefix
%    \begin{macrocode}
\define@key{KFLT@keys}{ap}{\renewcommand{\KFLT@ap}{#1}}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@ap} Storage for artist prefix
%    \begin{macrocode}
\newcommand*{\KFLT@ap}{}
%    \end{macrocode}
% \end{macro}
%
% \DescribeKey[main]{af} Artist first name
%    \begin{macrocode}
\define@key{KFLT@keys}{af}{\renewcommand{\KFLT@af}{#1}}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@af} Storage for artist first name
%    \begin{macrocode}
\newcommand*{\KFLT@af}{}
%    \end{macrocode}
% \end{macro}
%
% \DescribeKey[main]{al} Artist last name
%    \begin{macrocode}
\define@key{KFLT@keys}{al}{\renewcommand{\KFLT@al}{#1}}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@al} Storage for artist last name
%    \begin{macrocode}
\newcommand*{\KFLT@al}{}
%    \end{macrocode}
% \end{macro}
%
% \DescribeKey[main]{as} Artist suffix
%    \begin{macrocode}
\define@key{KFLT@keys}{as}{\renewcommand{\KFLT@as}{#1}}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@as} Storage for artist suffix
%    \begin{macrocode}
\newcommand*{\KFLT@as}{}
%    \end{macrocode}
% \end{macro}
%
%
% \DescribeKey[main]{aup} Author prefix
%    \begin{macrocode}
\define@key{KFLT@keys}{aup}{\renewcommand{\KFLT@aup}{#1}}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@aup} Storage for author prefix
%    \begin{macrocode}
\newcommand*{\KFLT@aup}{}
%    \end{macrocode}
% \end{macro}
%
% \DescribeKey[main]{auf} Author first name
%    \begin{macrocode}
\define@key{KFLT@keys}{auf}{\renewcommand{\KFLT@auf}{#1}}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@auf} Storage for author first name
%    \begin{macrocode}
\newcommand*{\KFLT@auf}{}
%    \end{macrocode}
% \end{macro}
%
% \DescribeKey[main]{aul} Author last name
%    \begin{macrocode}
\define@key{KFLT@keys}{aul}{\renewcommand{\KFLT@aul}{#1}}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@al} Storage for author last name
%    \begin{macrocode}
\newcommand*{\KFLT@aul}{}
%    \end{macrocode}
% \end{macro}
%
% \DescribeKey[main]{aus} Author suffix
%    \begin{macrocode}
\define@key{KFLT@keys}{aus}{\renewcommand{\KFLT@aus}{#1}}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@aus} Storage for author suffix
%    \begin{macrocode}
\newcommand*{\KFLT@aus}{}
%    \end{macrocode}
% \end{macro}
%
%
%
%
%
% \begin{macro}{\KFLT@textalign} Storage for text alignment.
%
% Used for the additional text in the float.
%    \begin{macrocode}
\newcommand*{\KFLT@textalign}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\KFLT@t} Additional text storage
%
% Used for the additional text in the float.
%    \begin{macrocode}
\newcommand{\KFLT@t}{}
%    \end{macrocode}
% \end{macro}
%
%
% Create replacement macros in case \pkg{tocdata} is not loaded:
% \changes{v0.12}{2016/12/02}{Adapts to older version of tocdata.}
% \changes{v2.00}{2019/03/20}{Adjustments for \pkg{tocdata} v2.00.}
%    \begin{macrocode}
\providecommand{\tdartisttextjustify}{}
\providecommand{\tdartisttextcenter}{}
\providecommand{\tdartisttextleft}{}
\providecommand{\tdartisttextright}{}
\providecommand{\tdauthortextjustify}{}
\providecommand{\tdauthortextcenter}{}
\providecommand{\tdauthortextleft}{}
\providecommand{\tdauthortextright}{}
\providecommand{\tdartistjustify}{}
\providecommand{\tdartistcenter}{}
\providecommand{\tdartistleft}{}
\providecommand{\tdartistright}{}
\providecommand{\tdauthorjustify}{}
\providecommand{\tdauthorcenter}{}
\providecommand{\tdauthorleft}{}
\providecommand{\tdauthorright}{}
%    \end{macrocode}
%
%
% \DescribeKey[main]{t} Additional text, justified alignment.
%    \begin{macrocode}
\define@key{KFLT@keys}{t}{%
    \renewcommand{\KFLT@t}{#1}%
    \renewcommand{\KFLT@textalign}{}%
}
%    \end{macrocode}
%
%
% \DescribeKey[main]{tc} Additional text, centered alignment.
%    \begin{macrocode}
\define@key{KFLT@keys}{tc}{%
    \renewcommand{\KFLT@t}{#1}%
    \renewcommand{\KFLT@textalign}{\centering}%
}
%    \end{macrocode}
%
%
% \DescribeKey[main]{tr} Additional text, aligned to the right.
%    \begin{macrocode}
\define@key{KFLT@keys}{tr}{%
    \renewcommand{\KFLT@t}{#1}%
    \renewcommand{\KFLT@textalign}{\raggedleft}%
}
%    \end{macrocode}
%
%
% \DescribeKey[main]{tl} Additional text, aligned to the left.
%    \begin{macrocode}
\define@key{KFLT@keys}{tl}{%
    \renewcommand{\KFLT@t}{#1}%
    \renewcommand{\KFLT@textalign}{\raggedright}%
}
%    \end{macrocode}
%
%
% \DescribeKey[main]{lw} Fraction of \cs{linewidth}
%    \begin{macrocode}
\define@key{KFLT@keys}{lw}{%
    \renewcommand{\KFLT@lw}{#1}%
    \setlength{\KFLT@w}{0pt}%
}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@lw} Fraction of linewidth storage: ``|.5|''
%    \begin{macrocode}
\newcommand*{\KFLT@lw}{}
%    \end{macrocode}
% \end{macro}
%
%
% \DescribeKey[main]{w} Fixed width
%    \begin{macrocode}
\define@key{KFLT@keys}{w}{%
    \setlength{\KFLT@w}{#1}%
    \renewcommand{\KFLT@lw}{}%
}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@w} Width storage: ``3cm''
%    \begin{macrocode}
\newlength{\KFLT@w}
%    \end{macrocode}
% \end{macro}
%
%
% \DescribeKey[main]{h} Fixed height
%    \begin{macrocode}
\define@key{KFLT@keys}{h}{\setlength{\KFLT@h}{#1}}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@h} Height storage: ``2in''
%    \begin{macrocode}
\newlength{\KFLT@h}
%    \end{macrocode}
% \end{macro}
%
%
% \DescribeKey[main]{kar} Keep aspect ratio
% \changes{v2.06}{2021/06/25}{Added \optn{kar}.}
%    \begin{macrocode}
\define@key{KFLT@keys}{kar}[false]{%
    \renewcommand{\KFLT@keepaspectratio}{keepaspectratio}%
}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@keepaspectratio} Stores ``\optn{keepaspectratio}'' if set.
% \changes{v2.06}{2021/06/25}{Added \optn{kar}.}
%    \begin{macrocode}
\newcommand{\KFLT@keepaspectratio}{}
%    \end{macrocode}
% \end{macro}
%
%
% \DescribeKey[main]{s} Scale
%    \begin{macrocode}
\define@key{KFLT@keys}{s}{\renewcommand{\KFLT@s}{#1}}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@s} Scale storage: ``3''
%    \begin{macrocode}
\newcommand*{\KFLT@s}{1}
%    \end{macrocode}
% \end{macro}
%
%
% \DescribeKey[main]{r} Angle.  90 is counter-clockwise 90 degrees.
%    \begin{macrocode}
\define@key{KFLT@keys}{r}{\renewcommand{\KFLT@r}{#1}}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@r} Angle storage: ``90''
%    \begin{macrocode}
\newcommand*{\KFLT@r}{0}
%    \end{macrocode}
% \end{macro}
%
%
% \DescribeKey[main]{f} Frame the image with \cs{KFLTlooseframe}.
%    \begin{macrocode}
\define@key{KFLT@keys}{f}[true]{\setboolean{KFLT@f}{#1}}
%    \end{macrocode}
%
% \DescribeBoolean{KFLT@f} Frame the image?
%    \begin{macrocode}
\newboolean{KFLT@f}
%    \end{macrocode}
%
%
% \DescribeKey[main]{ft} Tightly frame the image using \cs{KFLTtightframe}.
%	This is useful for photographs, or diagrams which
%	already have built-in margins.
%    \begin{macrocode}
\define@key{KFLT@keys}{ft}[true]{\setboolean{KFLT@ft}{#1}}
%    \end{macrocode}
%
% \DescribeBoolean{KFLT@ft} Tightly frame the image?
%    \begin{macrocode}
\newboolean{KFLT@ft}
%    \end{macrocode}


% \DescribeKey[main]{stretch} Set \cs{arraystretch} inside the table environment.
%    \begin{macrocode}
\define@key{KFLT@keys}{stretch}{\renewcommand{\KFLT@stretch}{#1}}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@stretch} Storage for \cs{arraystretch}.
%    \begin{macrocode}
\newcommand*{\KFLT@stretch}{1}
%    \end{macrocode}
% \end{macro}


% \DescribeKey[main]{mo} Set vertical offset for a margin float.
% \changes{v0.12}{2016/12/03}{Added \optn{mo} key.}
%    \begin{macrocode}
\define@key{KFLT@keys}{mo}{\setlength{\KFLT@mo}{#1}}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@mo} Storage for the vertical margin offset.
%    \begin{macrocode}
\newlength{\KFLT@mo}
%    \end{macrocode}
% \end{macro}


% \DescribeKey[main]{wn} Set wrap number of narrow lines for a wrapped float.
%
% \changes{v2.04}{2021/06/08}{Added \optn{wn} key.}
%    \begin{macrocode}
\define@key{KFLT@keys}{wn}{\renewcommand{\KFLT@wn}{#1}}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@wn} Storage for the wrap placement.
%    \begin{macrocode}
\newcommand{\KFLT@wn}{}
%    \end{macrocode}
% \end{macro}


% \DescribeKey[main]{wp} Set wrap placement for a wrapped float.
%
% See \cref{tab:wrapplacement} on \cpageref{tab:wrapplacement}.
% 
% \changes{v0.12}{2016/12/03}{Added \optn{wp} key.}
%    \begin{macrocode}
\define@key{KFLT@keys}{wp}{\renewcommand{\KFLT@wp}{#1}}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@wp} Storage for the wrap placement.
%    \begin{macrocode}
\newcommand{\KFLT@wp}{O}
%    \end{macrocode}
% \end{macro}


% \DescribeKey[main]{wo} Set wrap overhang for a wrapped float.
%
% \changes{v2.04}{2021/06/08}{Added \optn{wo} key.}
%    \begin{macrocode}
\define@key{KFLT@keys}{wo}{\renewcommand{\KFLT@wo}{#1}}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@wo} Storage for the wrap placement.
%    \begin{macrocode}
\newcommand{\KFLT@wo}{\wrapoverhang}
%    \end{macrocode}
% \end{macro}


% \DescribeKey[main]{wlw} Wrapped figure, fraction of \cs{linewidth}
% \changes{v2.02}{2021/05/27}{Added \optn{ww} and \optn{wlw}.}
%    \begin{macrocode}
\define@key{KFLT@keys}{wlw}{%
    \renewcommand{\KFLT@wlw}{#1}%
    \setlength{\KFLT@ww}{0pt}%
}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@wlw} Wrapped figure, fraction of linewidth storage: ``|.5|''
%    \begin{macrocode}
\newcommand*{\KFLT@wlw}{}
%    \end{macrocode}
% \end{macro}
%
%
% \DescribeKey[main]{ww} Wrapped figure, fixed width
% \changes{v2.02}{2021/05/27}{Added \optn{ww} and \optn{wlw}.}
%    \begin{macrocode}
\define@key{KFLT@keys}{ww}{%
    \setlength{\KFLT@ww}{#1}%
    \renewcommand{\KFLT@wlw}{}%
}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@ww} Wrapped figure, width storage: ``3cm''
%    \begin{macrocode}
\newlength{\KFLT@ww}
%    \end{macrocode}
% \end{macro}


% \DescribeKey[main]{va} Set vertical alignment of the outermost minipage container.
%
% \changes{v0.15}{2017/05/09}{Added vertical alignment key \optn{va}.}
%    \begin{macrocode}
\define@key{KFLT@keys}{va}{\renewcommand{\KFLT@va}{#1}}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@va} Storage for the vertical alignment.
%    \begin{macrocode}
\newcommand{\KFLT@va}{c}
%    \end{macrocode}
% \end{macro}





% \subsection{Nesting control}

% \DescribeCounter{KFLT@keyfloatdepth} Depth inside a keyfigs environment
%    \begin{macrocode}
\newcounter{KFLT@keyfloatdepth}
\setcounter{KFLT@keyfloatdepth}{0}
%    \end{macrocode}

% \DescribeBoolean{KFLT@inkeysubfloats} Inside a \env{keysubfigs} environment?
%    \begin{macrocode}
\newboolean{KFLT@inkeysubfloats}
\setboolean{KFLT@inkeysubfloats}{false}
%    \end{macrocode}



% \subsection{Subfloat key handling}
%
% These keys are for the container holding a collection of subfigures.

% \DescribeBoolean{KFLT@subgrpcont} Continued float?
%    \begin{macrocode}
\newboolean{KFLT@subgrpcont}{}
%    \end{macrocode}
%
% \DescribeKey[subfloat container]{cont} Continued float
%    \begin{macrocode}
\define@key{KFLT@subgrpkeys}{cont}[true]{%
    \setboolean{KFLT@subgrpcont}{#1}%
}
%    \end{macrocode}

% \begin{macro}{\KFLT@subgrpc} Sub-caption storage
%    \begin{macrocode}
\newcommand{\KFLT@subgrpc}{}
%    \end{macrocode}
% \end{macro}

% \DescribeBoolean{KFLT@subgrpcstart} Sub-caption starred?
%    \begin{macrocode}
\newboolean{KFLT@subgrpcstar}
%    \end{macrocode}
%
% \DescribeKey[subfloat container]{c} Caption
%    \begin{macrocode}
\define@key{KFLT@subgrpkeys}{c}{%
    \renewcommand{\KFLT@subgrpc}{#1}\setboolean{KFLT@subgrpcstar}{false}%
}
%    \end{macrocode}
%
% \DescribeKey[subfloat container]{cstar} Starred caption?
%    \begin{macrocode}
\define@key{KFLT@subgrpkeys}{cstar}{%
    \renewcommand{\KFLT@subgrpc}{#1}\setboolean{KFLT@subgrpcstar}{true}%
}
%    \end{macrocode}
%
% \DescribeKey[subfloat container]{sc} Short caption
%    \begin{macrocode}
\define@key{KFLT@subgrpkeys}{sc}{%
    \renewcommand{\KFLT@subgrpsc}{#1}%
    \setboolean{KFLT@subgrpscgiven}{true}%
}
%    \end{macrocode}

% \begin{macro}{\KFLT@subgrpsc} Sub-shortcaption storage
%    \begin{macrocode}
\newcommand{\KFLT@subgrpsc}{}
%    \end{macrocode}
% \end{macro}

% \DescribeBoolean{KFLT@subgrpscgiven} Sub-shortcaption was given?
%    \begin{macrocode}
\newboolean{KFLT@subgrpscgiven}
%    \end{macrocode}

% \begin{macro}{\KFLT@subgrptype} Subfloats collection type storage:
%	``|figure|'', ``|table|''
%    \begin{macrocode}
\newcommand*{\KFLT@subgrptype}{}
%    \end{macrocode}
% \end{macro}


%
% \DescribeKey[subfloat container]{l} Label
%    \begin{macrocode}
\define@key{KFLT@subgrpkeys}{l}{\renewcommand{\KFLT@subgrpl}{#1}}
\newcommand*{\KFLT@subgrpl}{}
%    \end{macrocode}
%
%
%
% \begin{macro}{\KFLT@subgrptextalign} Storage for text alignment.
%
% Used for the additional text in the float.
%    \begin{macrocode}
\newcommand*{\KFLT@subgrptextalign}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\KFLT@subgrpt} Additional text storage
%
% Used for the additional text in the float.
%    \begin{macrocode}
\newcommand{\KFLT@subgrpt}{}
%    \end{macrocode}
% \end{macro}
%
%
% \DescribeKey[subfloat container]{t} Additional text — full justification
%    \begin{macrocode}
\define@key{KFLT@subgrpkeys}{t}{%
    \renewcommand{\KFLT@subgrpt}{#1}%
    \renewcommand{\KFLT@subgrptextalign}{}%
}
%    \end{macrocode}
%
% \DescribeKey[subfloat container]{t} Additional text — center justification
%    \begin{macrocode}
\define@key{KFLT@subgrpkeys}{tc}{%
    \renewcommand{\KFLT@subgrpt}{#1}%
    \renewcommand{\KFLT@subgrptextalign}{\centering}%
}
%    \end{macrocode}
%
% \DescribeKey[subfloat container]{t} Additional text — aligned left
%    \begin{macrocode}
\define@key{KFLT@subgrpkeys}{tl}{%
    \renewcommand{\KFLT@subgrpt}{#1}%
    \renewcommand{\KFLT@subgrptextalign}{\raggedright}%
}
%    \end{macrocode}
%
% \DescribeKey[subfloat container]{t} Additional text — aligned right
%    \begin{macrocode}
\define@key{KFLT@subgrpkeys}{tr}{%
    \renewcommand{\KFLT@subgrpt}{#1}%
    \renewcommand{\KFLT@subgrptextalign}{\raggedleft}%
}
%    \end{macrocode}
%
%
%
% For the \pkg{tocdata} package:
%
% \DescribeKey[subfloat container]{ap} Artist prefix
%    \begin{macrocode}
\define@key{KFLT@subgrpkeys}{ap}{\renewcommand{\KFLT@subgrpap}{#1}}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@subgrpap} Storage for artist prefix
%    \begin{macrocode}
\newcommand*{\KFLT@subgrpap}{}
%    \end{macrocode}
% \end{macro}
%
% \DescribeKey[subfloat container]{af} Artist first name
%    \begin{macrocode}
\define@key{KFLT@subgrpkeys}{af}{\renewcommand{\KFLT@subgrpaf}{#1}}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@subgrpaf} Storage for artist first name
%    \begin{macrocode}
\newcommand*{\KFLT@subgrpaf}{}
%    \end{macrocode}
% \end{macro}
%
% \DescribeKey[subfloat container]{al} Artist last name
%    \begin{macrocode}
\define@key{KFLT@subgrpkeys}{al}{\renewcommand{\KFLT@subgrpal}{#1}}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@subgrpal} Storage for artist last name
%    \begin{macrocode}
\newcommand*{\KFLT@subgrpal}{}
%    \end{macrocode}
% \end{macro}
%
% \DescribeKey[subfloat container]{as} Artist suffix
%    \begin{macrocode}
\define@key{KFLT@subgrpkeys}{as}{\renewcommand{\KFLT@subgrpas}{#1}}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@subgrpas} Storage for artist suffix
%    \begin{macrocode}
\newcommand*{\KFLT@subgrpas}{}
%    \end{macrocode}
% \end{macro}

% \DescribeKey[subfloat container]{aup} Author prefix
%    \begin{macrocode}
\define@key{KFLT@subgrpkeys}{aup}{\renewcommand{\KFLT@subgrpaup}{#1}}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@subgrpaup} Storage for author prefix
%    \begin{macrocode}
\newcommand*{\KFLT@subgrpaup}{}
%    \end{macrocode}
% \end{macro}
%
% \DescribeKey[subfloat container]{auf} Author first name
%    \begin{macrocode}
\define@key{KFLT@subgrpkeys}{auf}{\renewcommand{\KFLT@subgrpauf}{#1}}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@subgrpauf} Storage for author first name
%    \begin{macrocode}
\newcommand*{\KFLT@subgrpauf}{}
%    \end{macrocode}
% \end{macro}
%
% \DescribeKey[subfloat container]{aul} Author last name
%    \begin{macrocode}
\define@key{KFLT@subgrpkeys}{aul}{\renewcommand{\KFLT@subgrpaul}{#1}}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@subgrpaul} Storage for author last name
%    \begin{macrocode}
\newcommand*{\KFLT@subgrpaul}{}
%    \end{macrocode}
% \end{macro}
%
% \DescribeKey[subfloat container]{aus} Author suffix
%    \begin{macrocode}
\define@key{KFLT@subgrpkeys}{aus}{\renewcommand{\KFLT@subgrpaus}{#1}}
%    \end{macrocode}
%
% \begin{macro}{\KFLT@subgrpaus} Storage for author suffix
%    \begin{macrocode}
\newcommand*{\KFLT@subgrpaus}{}
%    \end{macrocode}
% \end{macro}


% \subsection{Computing image width}

% \DescribeLength{\KFLT@imagewidth} Computed width of the image
%    \begin{macrocode}
\newlength{\KFLT@imagewidth}
%    \end{macrocode}

% \DescribeLength{\KFLT@boxwidth} Computed width of the container box
%    \begin{macrocode}
\newlength{\KFLT@boxwidth}
%    \end{macrocode}
%
% \DescribeLength{\KFLT@wrapwidth} Computed width of the wrapped figure
% \changes{v2.02}{2021/05/27}{Added \optn{ww} and \optn{wlw}.}
%    \begin{macrocode}
\newlength{\KFLT@wrapwidth}
%    \end{macrocode}

%
% \begin{macro}{\KFLT@findwidths} Figure out how wide to make an image and its container
%    \begin{macrocode}
\newcommand*{\KFLT@findwidths}{%
%    \end{macrocode}
%
% Default to a box of full \cs{linewidth} minus the potential frame:
%    \begin{macrocode}
    \ifbool{KFLT@ft}% tight frame?
        {\setlength{\KFLT@boxwidth}{\linewidth - 2\KFLTtightframewidth}}%
        {% not tight frame
            \ifbool{KFLT@f}% loose frame?
                {\setlength{\KFLT@boxwidth}{\linewidth - 2\KFLTlooseframewidth}}%
                {\setlength{\KFLT@boxwidth}{\linewidth}}% no frame
        }% not tight frame
%    \end{macrocode}
%
% Several width options exist.  First see if width was given:
%    \begin{macrocode}
    \ifdimgreater{\KFLT@w}{0pt}%
%    \end{macrocode}
%
%  Width was given:
%    \begin{macrocode}
        {\setlength{\KFLT@imagewidth}{\KFLT@w}}%
        {% width not given
%    \end{macrocode}
%
% Use full \cs{linewidth} or only a fraction:
%    \begin{macrocode}
            \ifcsempty{KFLT@lw}%
                {\setlength{\KFLT@imagewidth}{\KFLT@boxwidth}}%
                {\setlength{\KFLT@imagewidth}{\KFLT@lw\KFLT@boxwidth}}%
        }% width not given
%    \end{macrocode}
%
% The wrap width is the same as the image width, unless specified:
% \changes{v2.02}{2021/05/27}{Added \optn{ww} and \optn{wlw}.}
%    \begin{macrocode}
    \ifdimgreater{\KFLT@ww}{0pt}%
%    \end{macrocode}
%
%  Width was given:
%    \begin{macrocode}
        {%
            \setlength{\KFLT@wrapwidth}{\KFLT@ww}}%
        {% width not given
%    \end{macrocode}
%
% If \optn{wlw}, use a fraction of line width,
% else if none given use the same as the image width.
%    \begin{macrocode}
            \ifcsempty{KFLT@wlw}%
                {%
                    \setlength{\KFLT@wrapwidth}{\KFLT@imagewidth}}%
                {%
                    \setlength{\KFLT@wrapwidth}{\KFLT@wlw\KFLT@boxwidth}}%
        }% width not given
}
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Framing and rotation}
%
%
% A user-redefinable macro and length to tightly frame the contents.
%
% \begin{description}
% \item [\cs{KFLTtightframe}:] Redefine to a macro which frames its contents.
% \item [\cs{KFLTtightframewidth}:] Redefine to the total width of the new.
%   frame and its separation.
% \end{description}
%
% \begin{macro}{\KFLTtightframe} \marg{contents}
%    \begin{macrocode}
\newcommand{\KFLTtightframe}[1]{%
    \setlength{\fboxsep}{0pt}%
    \setlength{\fboxrule}{.4pt}%
    \fbox{#1}%
}

%    \end{macrocode}
% \end{macro}
%
% \DescribeLength{\KFLTtightframewidth} Must be set to the combined width of
%   the tight frame and separation used by \cs{KFLTtightframe}.
%    \begin{macrocode}
\newlength{\KFLTtightframewidth}
\setlength{\KFLTtightframewidth}{.4pt}
%    \end{macrocode}
%
%
% \begin{macro}{\KFLTlooseframe} \marg{contents}
%
% A user-redefinable macro and length to loosely frame the contents.
%
% \begin{description}
% \item[\cs{KFLTlooseframe}:] Redefine to a macro which frames its contents.
% \item[\cs{KFLTlooseframewidth}:] Redefine to the total width of the new
%   frame and its separation.
% \end{description}
%
%    \begin{macrocode}
\newcommand{\KFLTlooseframe}[1]{%
    \setlength{\fboxsep}{3pt}%
    \setlength{\fboxrule}{.4pt}%
    \fbox{#1}%
}
%    \end{macrocode}
% \end{macro}
%
% \DescribeLength{\KFLTlooseframewidth} Must be set to the combined width of
% the loose frame and separation used by \cs{KFLTlooseframe}.
%    \begin{macrocode}
\newlength{\KFLTlooseframewidth}
\setlength{\KFLTlooseframewidth}{3.4pt}
%    \end{macrocode}
%
%
% \begin{macro}{\KFLT@frame} \marg{contents}
%
% Frames the contents according to the |f| key.  To be nested for further processing.
%    \begin{macrocode}
\newcommand{\KFLT@frame}[1]
{%
    \ifbool{KFLT@ft}%
        {\KFLTtightframe{#1}}%
        {% not tightframe
            \ifbool{KFLT@f}%
                {\KFLTlooseframe{#1}}%
                {#1}% no frame
        }% not looseframe
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{KFLT@findenvboxwidth}
% Figures the width of the contents of \cs{KFLT@envbox} plus the frame:
%    \begin{macrocode}
\newcommand{\KFLT@findenvboxwidth}{%
    \settowidth{\KFLTimageboxwidth}{\usebox{\KFLT@envbox}}%
    \ifbool{KFLT@ft}%
        {\addtolength{\KFLTimageboxwidth}{2\KFLTtightframewidth}}%
        {% not tightframe
            \ifbool{KFLT@f}%
                {\addtolength{\KFLTimageboxwidth}{2\KFLTlooseframewidth}}%
                {}% no frame
        }% not looseframe
}
%    \end{macrocode}
% \end{macro}
%
%
%
%
% \subsection{A graphics image from a file}
%
% \DescribeLength{\KFLT@testwidth} Used to find the width of a graphics image.
%    \begin{macrocode}
\newlength{\KFLT@testwidth}
%    \end{macrocode}
%
%
% \begin{macro}{\KFLT@includegraphics} \oarg{keys} \marg{file name}
%
% Issue a warning if the image will be too wide, then display the image.
%    \begin{macrocode}
\newcommand*{\KFLT@includegraphics}[2][]{%
%    \end{macrocode}
%
% Find the width of the image:
%    \begin{macrocode}
    \settowidth{\KFLT@testwidth}{\includegraphics[#1]{#2}}%
%    \end{macrocode}
%
% Avoid rounding errors when using the \optn{lw} option,
% and also avoid the exact line width in case images are side-by-side.
%
% If close to \cs{linewidth}, use slightly less than the \cs{linewidth}:
% \changes{v2.06}{2021/06/25}{Clip if close to \cs{linewidth}.}
%    \begin{macrocode}
    \ifboolexpr{%
        test {\ifdimgreater{\KFLT@testwidth}{\linewidth-.01pt}} and
        test {\ifdimless{\KFLT@testwidth}{\linewidth+1pt}}
    }%
        {\setlength{\KFLT@testwidth}{\linewidth-.01pt}}%
        {}%
%    \end{macrocode}
%
%
% Issue a warning if wider than the \cs{linewidth}:
% \changes{v2.06}{2021/06/25}{Warn if image too wide.}
%    \begin{macrocode}
    \ifdimgreater{\KFLT@testwidth}{\linewidth}{%
        \PackageWarning{keyfloat}{The image is wider than the line width}%
    }{}%
%    \end{macrocode}
%
% Display the image:
%    \begin{macrocode}
    \includegraphics[#1]{#2}%
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\KFLT@onefigureimage} \marg{filename}
%
% Create an image with size, frame, and turn.
%
% \changes{v2.00}{2019/03/12}{Filename in arg instead of \cs{KFLT@i}.}
% \changes{v2.06}{2021/06/25}{Added \optn{kar}.}
%    \begin{macrocode}
\NewDocumentCommand{\KFLT@onefigureimage}{m}%
{%
%    \end{macrocode}
% Several possible combinations of linewidth, width, and height are available,
% and each is treated separately.
% Scaling and width/height are done first, then framing, then rotation.
%    \begin{macrocode}
    \begin{lrbox}{\KFLT@envbox}%
%    \end{macrocode}
% Handle the |lw| key.  If |lw| is used, width and height are ignored.
%    \begin{macrocode}
    \ifdefempty{\KFLT@lw}%
    {% not linewidth
%    \end{macrocode}
% Handle the |w| key, which may be used along with the |h| key:
%    \begin{macrocode}
        \ifdimgreater{\KFLT@w}{0pt}%
        {% width is given
            \ifdimgreater{\KFLT@h}{0pt}%
%    \end{macrocode}
% Width and height are both given:
%    \begin{macrocode}
            {% w and h
                \KFLT@includegraphics[%
                    scale=\KFLT@s,%
                    width=\KFLT@imagewidth,%
                    height=\KFLT@h,%
                    \KFLT@keepaspectratio,%
                ]{#1}%
            }% w and h
%    \end{macrocode}
% Only width:
%    \begin{macrocode}
            {% only w
                \KFLT@includegraphics[%
                    scale=\KFLT@s,%
                    width=\KFLT@imagewidth,%
                    \KFLT@keepaspectratio,%
                ]{#1}%
            }% only w
        }% width is given
%    \end{macrocode}
% Width was not given, so maybe handle |h| alone:
%    \begin{macrocode}
        {% width is not given
            \ifdimgreater{\KFLT@h}{0pt}%
%    \end{macrocode}
% |h| was given:
%    \begin{macrocode}
                {%
                    \KFLT@includegraphics[%
                        scale=\KFLT@s,%
                        height=\KFLT@h,%
                        \KFLT@keepaspectratio,%
                    ]{#1}%
                }%
%    \end{macrocode}
% If none were given, use the image's natural size:
%    \begin{macrocode}
                {%
                    \KFLT@includegraphics[%
                        scale=\KFLT@s,%
                        \KFLT@keepaspectratio,%
                    ]{#1}%
                }%
        }% width is not given
    }% not linewidth
    {% linewidth given
%    \end{macrocode}
% \changes{v2.06}{2021/06/25}{Fix: \optn{lw} with \optn{h}.}
%    \begin{macrocode}
        \ifdimgreater{\KFLT@h}{0pt}%
        {% lw and h given
            \KFLT@includegraphics[%
                scale=\KFLT@s,%
                width=\KFLT@imagewidth,%
                height=\KFLT@h,%
                \KFLT@keepaspectratio,%
            ]{#1}%
        }%
        {% lw w/o h
            \KFLT@includegraphics[%
                scale=\KFLT@s,%
                width=\KFLT@imagewidth,%
                \KFLT@keepaspectratio,%
            ]{#1}%
        }%
    }%
    \end{lrbox}%
    \unskip%
    \KFLT@findenvboxwidth%
    \begin{turn}{\KFLT@r}%
    \KFLT@frame{\usebox{\KFLT@envbox}}%
    \unskip%
    \end{turn}%
}
%    \end{macrocode}
% \end{macro}




% \subsection{Printing the caption}
%
%
% \begin{macro}{\KFLT@dosimplecaption} \marg{star?} \marg{short cap or |-NO VALUE-|} \marg{caption}
%
% Calls \cs{caption} depending on several combinations of star and short captions
% being given.
%    \begin{macrocode}
\NewDocumentCommand{\KFLT@dosimplecaption}{m m m}
{%
    \unskip%
    \IfBooleanTF{#1}% star?
        {\IfValueTF{#2}{\caption*[#2]{#3}}{\caption*{#3}}}%
        {\IfValueTF{#2}{\caption[#2]{#3}}{\caption{#3}}}%
}
%    \end{macrocode}
% \end{macro}
%
%
%
% There are two versions of \cs{KFLT@docaption},
% depending on whether \pkg{tocdata} is loaded.
%
%    \begin{macrocode}
\@ifpackageloaded{tocdata}
{% tocdata loaded
%    \end{macrocode}
%
%
% \begin{macro}{\KFLT@@docaption} {1: artist/author} \marg{2: empty or ''u''}
%       \marg{3: star?}
%       \marg{4: short caption} \marg{5: caption}
%       \marg{6: \mainsubarg}
% \changes{v2.00}{2019/03/19}{Factored.}
%    \begin{macrocode}
\newcommand*{\KFLT@@docaption}[6]{%
%    \end{macrocode}
% (\pkg{tocdata} does not expand its text argument before checking for empty.)
%    \begin{macrocode}
\addvspace{\smallskipamount}%
\ifcsempty{KFLT@#6t}{%
    \IfBooleanTF{#3}%
    {%
        \csuse{caption#1}*[#4]{#5}%
            []%
            [\csuse{KFLT@#6a#2p}]%
            {\csuse{KFLT@#6a#2f}}%
            {\csuse{KFLT@#6a#2l}}%
            [\csuse{KFLT@#6a#2s}]%
    }{%
        \csuse{caption#1}[#4]{#5}%
            []%
            [\csuse{KFLT@#6a#2p}]%
            {\csuse{KFLT@#6a#2f}}%
            {\csuse{KFLT@#6a#2l}}%
            [\csuse{KFLT@#6a#2s}]%
    }%
}{%
    \ifcsstring{KFLT@#6textalign}{}{\csuse{td#1textjustify}}{}%
    \ifcsstring{KFLT@#6textalign}{\centering}{\csuse{td#1textcenter}}{}%
    \ifcsstring{KFLT@#6textalign}{\raggedleft}{\csuse{td#1textright}}{}%
    \ifcsstring{KFLT@#6textalign}{\raggedright}{\csuse{td#1textleft}}{}%
    \IfBooleanTF{#3}%
    {%
        \csuse{caption#1}*[#4]{#5}%
            [\csuse{KFLT@#6t}]%
            [\csuse{KFLT@#6a#2p}]%
            {\csuse{KFLT@#6a#2f}}%
            {\csuse{KFLT@#6a#2l}}%
            [\csuse{KFLT@#6a#2s}]%
    }{%
        \csuse{caption#1}[#4]{#5}%
            [\csuse{KFLT@#6t}]%
            [\csuse{KFLT@#6a#2p}]%
            {\csuse{KFLT@#6a#2f}}%
            {\csuse{KFLT@#6a#2l}}%
            [\csuse{KFLT@#6a#2s}]%
    }%
}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\KFLT@docaption} * \oarg{2:short caption} \marg{3:caption} \marg{4: \mainsubarg}
%
% Depending on whether the \pkg{tocdata} package is present,
% and an artist is specified,
% use either \cs{caption} or \cs{captionartist}.
%
% The fourth argument is |{}| if a regular float, or
% |subgrp| if \env{keysubfigs} or \env{keysubtabs}.
%
% See Table \ref{tab:captions} for the possible combinations of
% the caption-related keys: |c|, |cstar|, and |sc|.
%
% \changes{v0.14}{2017/02/09}{Fix: No index entry if no artist given.}
%
% With \pkg{tocdata}:
%
%    \begin{macrocode}
\NewDocumentCommand{\KFLT@docaption}{s o m m}
{%
%    \end{macrocode}
% Is the last name empty?  Assume no artist if so.
%    \begin{macrocode}
    \ifcsempty{KFLT@#4al}%
    {% figure w/o artist
        \ifcsempty{KFLT@#4aul}%
        {% figure w/o artist or author
%    \end{macrocode}
% A figure without an artist or author uses the simple caption.
%    \begin{macrocode}
            \KFLT@dosimplecaption{#1}{#2}{#3}%
        }% figure w/o artist or author
%    \end{macrocode}
% A figure with an author uses the \pkg{tocdata} \cs{captionauthor} macro,
% which also creates an index entry.
%    \begin{macrocode}
        {% figure w/ author
            \KFLT@@docaption{author}{u}{#1}{#2}{#3}{#4}%
        }% figure w/ author
    }% figure w/o artist
    {% figure with an artist
%    \end{macrocode}
% A figure with an artist uses the \pkg{tocdata} \cs{captionartist} macro,
% which also creates an index entry.
%    \begin{macrocode}
        \KFLT@@docaption{artist}{}{#1}{#2}{#3}{#4}%
    }% figure with an artist
}% KFLT@tocdata
}% tocdata loaded
{% no tocdata
%    \end{macrocode}
% \end{macro}
%
% Without \pkg{tocdata}:
%
% \begin{macro}{\KFLT@docaption} * \oarg{2:short caption} \marg{3:caption} \marg{4: \mainsubarg}
% \changes{v2.00}{2019/03/19}{Added support for authors.}
%    \begin{macrocode}
\NewDocumentCommand{\KFLT@docaption}{s o m m}
{%
%    \end{macrocode}
% If \pkg{tocdata} is not loaded, use a simple caption.
%    \begin{macrocode}
    \KFLT@dosimplecaption{#1}{#2}{#3}%
%    \end{macrocode}
% Create an index entry depending on whether there is a last, first name:
%    \begin{macrocode}
    \ifcsempty{KFLT@#4al}%
    {%
        \ifcsempty{KFLT@#4aul}%
        {}%
        {% yes author
            \ifcsempty{KFLT@#4auf}%
                {\index{\csuse{KFLT@#4aul}}}%
                {\index{\csuse{KFLT@#4aul}, \csuse{KFLT@#4auf}}}%
        }% yes author
    }% no artist
    {% yes artist
        \ifcsempty{KFLT@#4af}%
            {\index{\csuse{KFLT@#4al}}}%
            {\index{\csuse{KFLT@#4al}, \csuse{KFLT@#4af}}}%
    }% yes artist
}% KFLT@docaption
}% no tocdata
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\KFLT@caption} \marg{\mainsubarg}
%
% Caption-creation logic.
%
% The argument is |{}| if a regular float, or
% |subgrp| if \env{keysubfigs} or \env{keysubtabs}.
%
% See Table \ref{tab:captions} for the possible combinations of
% the caption-related keys: |c|, |cstar|, and |sc|.
%    \begin{macrocode}
\newcommand{\KFLT@caption}[1]{%
%    \end{macrocode}
% A starred caption is printed but not numbered.
%    \begin{macrocode}
    \ifbool{KFLT@#1cstar}% starred caption?
%    \end{macrocode}
% This is a starred caption:
%    \begin{macrocode}
    {%starred caption
%    \end{macrocode}
% A key given as |cstar={}| yields a float with no caption at all.
%    \begin{macrocode}
        \ifcsempty{KFLT@#1c}% cstar={}?
        {}%
%    \end{macrocode}
% Non-empty starred caption might have a \acro{LOF} entry
% if it has a short caption |sc| key:
%    \begin{macrocode}
        {% non-empty starred caption
            \ifcsempty{KFLT@#1sc}%
%    \end{macrocode}
% No |sc| short caption, but there is a |cstar|, so no \acro{LOF} entry:
%    \begin{macrocode}
            {}%
%    \end{macrocode}
% Both |cstar| and |sc| were given, so add a \acro{LOF} entry:
% \changes{v2.00}{2019/01/22}{Generalized for float type.}
%    \begin{macrocode}
            {% non-empty cstar and sc:
                \edef\KFLT@listtype{\csuse{KFLT@#1type}}%
                \addcontentsline{\csuse{ext@\KFLT@listtype}}%
                    {\csuse{KFLT@#1type}}{\KFLT@sc}%
            }% non-empty cstar and sc
%    \end{macrocode}
%
% In the following,
% the test for an empty caption is because the \pkg{caption} package does not
% detect an empty caption if it is given as a macro.
%
% |cstar| was given, so create an unnumbered caption:
% \changes{v2.06}{2019/06/29}{Fix for empty caption.}
%    \begin{macrocode}
            \ifcsempty{KFLT@#1c}%
                {\KFLT@docaption*{}{#1}}%
                {\KFLT@docaption*{\csuse{KFLT@#1c}}{#1}}%
        }%
    }% starred caption
%    \end{macrocode}
% Unstarred caption |c| was given, so number this float:
% \changes{v2.06}{2019/06/29}{Fix for empty caption.}
%    \begin{macrocode}
    {% unstarred caption
        \ifcsempty{KFLT@#1sc}%
        {% no short cap
            \ifcsempty{KFLT@#1c}%
                {\KFLT@docaption{}{#1}}%
                {\KFLT@docaption{\csuse{KFLT@#1c}}{#1}}%
        }% no short cap
        {% short cap
            \ifcsempty{KFLT@#1c}%
                {\KFLT@docaption[\csuse{KFLT@#1sc}]{}{#1}}%
                {\KFLT@docaption[\csuse{KFLT@#1sc}]{\csuse{KFLT@#1c}}{#1}}%
        }% short cap
%    \end{macrocode}
% Optional label:
%    \begin{macrocode}
        \ifcsempty{KFLT@#1l}%
        {}%
        {\label{\csuse{KFLT@#1l}}}%
    }% unstarred caption
}
%    \end{macrocode}
% \end{macro}


% \subsection{Defaults for a new float}

% \begin{macro}{\KFLT@defaults} Defaults all settings before reading the keys.
% \changes{v2.06}{2021/06/25}{Added \optn{kar}.}
%    \begin{macrocode}
\newcommand*{\KFLT@defaults}{%
    \setboolean{KFLT@cont}{false}%
    \renewcommand{\KFLT@c}{}%
    \setboolean{KFLT@cstar}{false}%
    \renewcommand{\KFLT@sc}{}%
    \setboolean{KFLT@scgiven}{false}%
    \renewcommand{\KFLT@type}{figure}%
    \renewcommand{\KFLT@l}{}%
    \renewcommand{\KFLT@ap}{}%
    \renewcommand{\KFLT@af}{}%
    \renewcommand{\KFLT@al}{}%
    \renewcommand{\KFLT@as}{}%
    \renewcommand{\KFLT@aup}{}%
    \renewcommand{\KFLT@auf}{}%
    \renewcommand{\KFLT@aul}{}%
    \renewcommand{\KFLT@aus}{}%
    \renewcommand{\KFLT@t}{}%
    \renewcommand{\KFLT@textalign}{}%
    \renewcommand{\KFLT@lw}{}%
    \setlength{\KFLT@w}{0pt}%
    \setlength{\KFLT@h}{0pt}%
    \renewcommand{\KFLT@keepaspectratio}{}%
    \renewcommand{\KFLT@s}{1}%
    \renewcommand{\KFLT@r}{0}%
    \setboolean{KFLT@f}{false}%
    \setboolean{KFLT@ft}{false}%
    \renewcommand{\KFLT@stretch}{1}%
    \setlength{\KFLT@mo}{-1.2ex}%
    \renewcommand{\KFLT@wn}{}%
    \renewcommand{\KFLT@wp}{O}%
    \renewcommand{\KFLT@wo}{\wrapoverhang}%
    \renewcommand{\KFLT@wlw}{}%
    \setlength{\KFLT@ww}{0pt}%
    \renewcommand{\KFLT@va}{c}%
}
%    \end{macrocode}
% \end{macro}

% \subsection{Row start/end processing}

% \begin{macro}{\KFLT@maybestartfloatrow} Counts rows
%
% After ending a preexisting row, move to the next row.
% The use of \cs{defcounter} makes this counter change local.
%    \begin{macrocode}
\newcommand*{\KFLT@maybestartfloatrow}{%
    \KFLT@maybeendfloatrow%
    \defcounter{KFLT@thiscol}{\value{KFLT@thiscol}+1}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\KFLT@maybeendfloatrow} Counts rows
%
% Adds vertical space then resets to allow the start of a new row.
% The use of \cs{defcounter} makes this counter change local.
%    \begin{macrocode}
\newcommand*{\KFLT@maybeendfloatrow}{%
    \ifnumless{\value{KFLT@thiscol}}{\value{KFLT@numcols}}%
    {}% thiscol < numcols
    {% >=
        \par%
        \addvspace{.75\floatsep}%
        \defcounter{KFLT@thiscol}{0}%
    }%
}%
%    \end{macrocode}
% \end{macro}






% \subsection{Key environment helper macros}


% \begin{macro}{\KFLT@trackrows} Tracks and spaces rows and columns.
%    \begin{macrocode}
\newcommand{\KFLT@trackrows}%
{%
%    \end{macrocode}
% If are nested inside a keyfloats or a subfloat:
%    \begin{macrocode}
    \ifboolexpr{%
        test {\ifnumgreater{\value{KFLT@keyfloatdepth}}{0}} or%
        bool{KFLT@inkeysubfloats}%
    }%
    {% nested
%    \end{macrocode}
% Tracks row start and end:
%    \begin{macrocode}
        \KFLT@maybestartfloatrow%
%    \end{macrocode}
% Possibly fill space between columns:
%    \begin{macrocode}
        \ifnumgreater{\value{KFLT@thiscol}}{1}%
            {\hfill}%
            {}%
    }% nested
    {}% not nested
}
%    \end{macrocode}
% \end{macro}



% \begin{macro}{\KFLT@addtext} \marg{\mainsubarg}
%
% Adds optional additional text.
%
% The argument is |{}| if a regular float, or
% |subgrp| if \env{keysubfigs} or \env{keysubtabs}.
%
% \changes{v0.11}{2016/12/02}{Improved paragraph handling.}
%
%    \begin{macrocode}
\newcommand{\KFLT@addtext}[1]
{%
%    \end{macrocode}
% Is there text to add?
%    \begin{macrocode}
    \ifcsempty{KFLT@#1t}%
    {}% no text
    {% text to add
        {% local
%    \end{macrocode}
% Add some space, then create a full-width minipage to contain the text:
%    \begin{macrocode}
        \addvspace{\smallskipamount}%
        \begin{minipage}{\linewidth}%
%    \end{macrocode}
%
% Inside this minipage, temporarily prevent underfull \cs{hbox} warnings:
% \changes{v2.02}{2021/05/28}{Avoid underfull \cs{hbox} warning.}
%    \begin{macrocode}
        \hbadness=10000\relax%
%    \end{macrocode}
% Set the alignment and some text parameters:
%    \begin{macrocode}
        \csuse{KFLT@#1textalign}%
        \footnotesize%
        \setlength{\parskip}{1.5ex}%
        \setlength{\parindent}{0em}%
%    \end{macrocode}
% Typeset the actual text:
%    \begin{macrocode}
        \csuse{KFLT@#1t}%
%    \end{macrocode}
% Close it all out with a little more space:
%    \begin{macrocode}
        \end{minipage}%
        \par\addvspace{2ex}%
        }% local
    }% text to add
}
%    \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\KFLT@optionalname} \marg{name}
%
% Adds optional artist's name and the following space.
%
%    \begin{macrocode}
\newcommand{\KFLT@optionalname}[1]
{%
    \ifblank{#1}%
        {}%
        {#1~}%
}
%    \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\KFLT@addartisttext} \marg{\mainsubarg}
%
% Adds optional additional text.
%
% The argument is |{}| if a regular float, or
% |subgrp| if \env{keysubfigs} or \env{keysubtabs}.
%
% One of two versions is used, depending on whether the \pkg{tocdata}
% package is available.
%
% If \pkg{tocdata} is loaded and this float has an artist or author,
% then the float's artist's information and optional text will be printed
% elsewhere by \cs{KFLT@caption}.  Otherwise, the text is printed here.
%
% Two versions, depending on whether \pkg{tocdata} is loaded:
%    \begin{macrocode}
\@ifpackageloaded{tocdata}
{% tocdata loaded
%    \end{macrocode}
% If \pkg{tocdata} is loaded:
%    \begin{macrocode}
\newcommand{\KFLT@addartisttext}[1]
{%
%    \end{macrocode}
% Only add text if is a figure without an artist or author name.
% If an artist or author is given, the name and text will be added
% by \pkg{tocdata}.
%    \begin{macrocode}
    \ifcsempty{KFLT@#1al}% artist last name
        {%
            \ifcsempty{KFLT@#1aul}% author last name
                {\KFLT@addtext{#1}}
                {}%
        }%
        {}% fig w/ artist: text will be added by \captionartist in \KFLT@caption
}% KFLT@addartisttext
}% tocdata loaded
%    \end{macrocode}
% If \pkg{tocdata} is not loaded, the name and text are added here:
%    \begin{macrocode}
{% tocdata not loaded
%    \end{macrocode}

% Factored from \cs{KFLT@addartisttext}
%    \begin{macrocode}
\newcommand*{\KFLT@@addartisttext}[3]{%
%    \end{macrocode}
% Add space and create the name inside a full-width minipage:
%    \begin{macrocode}
        \addvspace{\medskipamount}%
    \begin{minipage}{\linewidth}%
%    \end{macrocode}
%
% Inside this minipage, temporarily prevent underfull \cs{hbox} warnings:
% \changes{v2.02}{2021/05/28}{Avoid underfull \cs{hbox} warning.}
%    \begin{macrocode}
    \hbadness=10000\relax%
%    \end{macrocode}
%
% Text alignment is |#3|, and depends on artist or author:
%    \begin{macrocode}
    #3%
%    \end{macrocode}
%
% |#1| is empty or '|subgrp'| \\
% |#2| is empty for artist, `|u|' for author:
%    \begin{macrocode}
    \footnotesize\textsc{%
        \KFLT@optionalname{\csuse{KFLT@#1a#2p}}%
        \KFLT@optionalname{\csuse{KFLT@#1a#2f}}%
        \csuse{KFLT@#1a#2l}%
        \csuse{KFLT@#1a#2s}%
    }%
    \end{minipage}%
    \par\addvspace{2ex}%
}

\newcommand{\KFLT@addartisttext}[1]
{%
%    \end{macrocode}
% Only use the artist information if a last name is given:
%    \begin{macrocode}
    \ifcsempty{KFLT@#1al}%
    {% artist last name not given
        \ifcsempty{KFLT@#1aul}%
        {}% author last name not given
        {% author last name given
            \KFLT@@addartisttext{#1}{u}{\raggedleft}%
        }% author last name given
    }% artist last name not given
    {% artist last name given
        \KFLT@@addartisttext{#1}{}{\centering}%
    }%
%    \end{macrocode}
% Any additional text follows the artist's name:
%    \begin{macrocode}
    \KFLT@addtext{#1}%
}% KFLT@addartisttext
}% tocdata not loaded
%    \end{macrocode}
% \end{macro}


% \DescribeLength{\KFLTimageboxwidth} The computed width of the object.
%
% \changes{v0.13}{2017/01/12}{\cs{KFLTimageboxwidth}: Added.}
%
% This may be used as the width parameter of a minipage to encase the object.
%
%    \begin{macrocode}
\newlength{\KFLTimageboxwidth}
%    \end{macrocode}


% \begin{environment}{KFLT@boxinner}
%
% Typeset the contents in a width which depends on the keys.
%    \begin{macrocode}
\newsavebox{\KFLT@envbox}

\NewDocumentEnvironment{KFLT@boxinner}{}
{% keyboxinner
%    \end{macrocode}
% (Possibly) frame the contents of an \env{lrbox}:
%    \begin{macrocode}
    \begin{lrbox}{\KFLT@envbox}%
%    \end{macrocode}
% Rotate the contents:
%    \begin{macrocode}
    \turn{\KFLT@r}%
%    \end{macrocode}
% Box the contents in the width computed by \cs{KFLT@findwidths}:
%    \begin{macrocode}
    \minipage{\KFLT@imagewidth}%
%    \end{macrocode}
% Spacing inside the box.
% Also default to regular justified text alignment.
%    \begin{macrocode}
    \setlength{\parskip}{2ex}%
    \renewcommand{\arraystretch}{\KFLT@stretch}%
}% keyboxinner
%    \end{macrocode}
% End of the environment:
%    \begin{macrocode}
{% endkeyboxinner
    \endminipage%
%    \end{macrocode}
% End the rotated box:
%    \begin{macrocode}
    \endturn%
%    \end{macrocode}
% Possibly frame:
%    \begin{macrocode}
    \end{lrbox}%
    \KFLT@frame{\usebox{\KFLT@envbox}}%
    \par%
}% endkeyboxinner
%    \end{macrocode}
% \end{environment}


% \begin{macro}{\KFLT@sharedkeys}
% Key/values to apply to each object in this group,
% such as a \env{keyfloats} or \env{keysubfigs}.
% \changes{v2.06}{2021/06/25}{Added shared keys.}
%    \begin{macrocode}
\newcommand*{\KFLT@sharedkeys}{}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\KFLT@boxkeys} \marg{keys} \marg{float type}
%
% Default the options, adjust for a table, then parse the keys:
% \changes{v2.06}{2021/06/25}{Added shared keys.}
%    \begin{macrocode}
\NewDocumentCommand{\KFLT@boxkeys}{+m m}
{%
%    \end{macrocode}
% Set the key defaults:
%    \begin{macrocode}
    \KFLT@defaults%
%    \end{macrocode}
% Remember the float type:
%    \begin{macrocode}
    \renewcommand{\KFLT@type}{#2}%
%    \end{macrocode}
% Set the shared keys.  Expansion seems to be required for \pkg{xkeyval}.
%    \begin{macrocode}
    \edef\next{\noexpand\setkeys{KFLT@keys}{\KFLT@sharedkeys}}%
    \next%
%    \end{macrocode}
% Set the float-specific keys, which might overright the group's keys:
%    \begin{macrocode}
    \setkeys{KFLT@keys}{#1}%
}
%    \end{macrocode}
% \end{macro}


% \DescribeBoolean{KFLT@captionistop} Saves the value of \cs{caption@position},
% which may become unreliable if using Komascript and
% \begin{sourceverb}
% \captionsetup[table]{position=above}
% \end{sourceverb}
%
%    \begin{macrocode}
\newbool{KFLT@captionistop}
%    \end{macrocode}


% \begin{macro}{\KFLT@LWR@hook@boxouter} Used by \pkg{lwarp}.
%    \begin{macrocode}
\newcommand*{\KFLT@LWR@hook@boxouter}{}%
%    \end{macrocode}
% \end{macro}


% \begin{environment}{KFLT@boxouter} \marg{star?} \marg{loc}
%
% Boxes the contents of figures and floats.
%
% Not used by subfigures.
%
% \changes{v0.12}{2016/12/03}{[M] and [W] floats.}
% \changes{v0.15}{2017/05/09}{Handle vertical alignment key \optn{va}.}
% \changes{v0.15}{2017/05/12}{Adjustments for \protect\env{keywrap}.}
%    \begin{macrocode}
\NewDocumentEnvironment{KFLT@boxouter}{m m}
{% boxouter
%    \end{macrocode}
% The \env{keyfigure} and \env{keytable} environments handle the contents in one of
% three possible ways, depending on whether it is
% called alone, inside a \env{keyfloats} environment, or
% inside a \env{keysubfigs} or \env{keysubtabs} environment.
%
% Start the new subfigure or subtable, of the given width:
%    \begin{macrocode}
    \ifbool{KFLT@inkeysubfloats}%
    {\csuse{sub\KFLT@type}{\KFLT@rowboxwidth}}% subfloat
%    \end{macrocode}
% If \env{keyfloats}, place the contents inside a \env{minipage}:
%    \begin{macrocode}
    {% not subfloat:
        \ifnumgreater{\value{KFLT@keyfloatdepth}}{0}%
        {% keyfloats
            \ifbool{KFLT@keywrap}%
                {\minipage[t]{\KFLT@rowboxwidth}}%
                {\minipage[\KFLT@va]{\KFLT@rowboxwidth}}%
            \captionsetup*{type=\KFLT@type}%
        }% keyfloats
        {% not keyfloats
%    \end{macrocode}
% A hook for \pkg{lwarp} to set \cs{linewidth}, etc.
%    \begin{macrocode}
            \KFLT@LWR@hook@boxouter%
%    \end{macrocode}
%
% Not a subfloat or \env{keyfloats}, so create a single float.
%
% See if inside a \env{keywrap}.
% If so, force [H] and vertical align top.
%    \begin{macrocode}
            \ifbool{KFLT@keywrap}%
            {%
                \par\addvspace{\baselineskip}%
                \noindent%
                \minipage[t]{\linewidth}%
                \captionsetup{type=\KFLT@type}%
            }%
            {% not a keywrap
%    \end{macrocode}
%
% See if the float should [W]rap:
%
%    \begin{macrocode}
                \ifstrequal{#2}{W}%
%    \end{macrocode}
% Place [W], so create a wrapfloat using the \pkg{wrapfig} package:
%    \begin{macrocode}
                {% [W]
%    \end{macrocode}
%
% Temporarily figure out \cs{KFLT@imagewidth},
% and make the wrapped figure environment as wide as the
% desired image size plus frame:
% \changes{v2.02}{2021/05/27}{Added \optn{ww} and \optn{wlw}.}
% \changes{v2.04}{2021/06/08}{Added \optn{wn} and \optn{wo}.}
%    \begin{macrocode}
                    \KFLT@findwidths%
%    \end{macrocode}
%
% Expand the arguments for \pkg{wrapfig}:
% \changes{v2.05}{2021/06/11}{No longer patch \pkg{wrapfig} for expansion.}
%    \begin{macrocode}
                    \edef\next{%
                        \noexpand\wrapfloat%
                            {\KFLT@type}[\KFLT@wn]{\KFLT@wp}[\KFLT@wo]%
                            {\KFLT@wrapwidth+2\KFLTlooseframewidth}%
                    }%
                    \next%
%    \end{macrocode}
%    \begin{macrocode}
                    \minipage{\KFLT@wrapwidth+2\KFLTlooseframewidth}%
%    \end{macrocode}
%
% Inside this minipage, temporarily prevent underfull \cs{hbox} warnings:
% \changes{v2.02}{2021/05/28}{Avoid underfull \cs{hbox} warning.}
%    \begin{macrocode}
                    \hbadness=10000\relax%
%    \end{macrocode}
%    \begin{macrocode}
                    \normalcolor\reset@font\normalsize%
%    \end{macrocode}
%
% Change the interior image to the discovered fixed width.
% \changes{v2.02}{2021/05/27}{Added \optn{ww} and \optn{wlw}.}
%    \begin{macrocode}
                    \renewcommand{\KFLT@lw}{}%
                    \renewcommand{\KFLT@w}{\KFLT@imagewidth}%
                    \renewcommand{\KFLT@wlw}{}%
                    \renewcommand{\KFLT@ww}{0pt}%
                }% [W]
                {% not [W]
%    \end{macrocode}
%
% See if the float should be positioned in the [M]argin:
%    \begin{macrocode}
                    \ifstrequal{#2}{M}%
%    \end{macrocode}
% Place [M], so create a marginfloat:
% \changes{v2.00}{2019/03/18}{Added custom float types.}
%    \begin{macrocode}
                    {% [M]
                        \KFLT@marginfloat[\KFLT@mo]{\KFLT@type}%
                    }% [M]
                    {% not [M]
%    \end{macrocode}
%
% See if the float should be positioned [H]ere:
%    \begin{macrocode}
                        \ifstrequal{#2}{H}%
%    \end{macrocode}
% Place [H], so create an inline minipage:
% \changes{v2.01}{2019/09/11}{Fix: Font and color.}
% \changes{v2.01}{2019/09/14}{Improved vertical space.}
%    \begin{macrocode}
                        {% [H]
                            \vskip\intextsep%
                            \noindent\minipage[\KFLT@va]{\linewidth}%
                            \normalcolor\reset@font\normalsize%
                            \captionsetup{type=\KFLT@type}%
                        }% [H]
%    \end{macrocode}
% Not [H], so create a float:
% For a starred float, make a two-column table in a two-col format.
%    \begin{macrocode}
                        {% not [H]
                            \IfBooleanTF{#1}%
                                {\csuse{\KFLT@type*}[#2]}%
                                {\csuse{\KFLT@type}[#2]}%
                        }% not [H]
                    }% not [M]
                }% not [W]
            }% not keywrap
        }% not keyfloats
    }% not subfloat
%    \end{macrocode}
% Handle a continued float.  Ignored if in a subfloat.
%    \begin{macrocode}
    \ifbool{KFLT@cont}{\ContinuedFloat}{}%
%    \end{macrocode}
% Figure out image and parbox widths for the contents:
%    \begin{macrocode}
    \KFLT@findwidths%
%    \end{macrocode}
% Place the caption above the contents depending on \pkg{caption} \optn{position} option:
% \changes{v2.01}{2019/09/11}{Fix: Positions with \brand{Komascript}.}
%    \begin{macrocode}
    \caption@iftop%
        {\booltrue{KFLT@captionistop}}%
        {\boolfalse{KFLT@captionistop}}%
    \ifbool{KFLT@captionistop}{\KFLT@caption{}}{}%
%    \end{macrocode}
% Typeset the contents:
%    \begin{macrocode}
    \center\unskip%
}% boxouter
%    \end{macrocode}
%
% End of the KFLT@boxouter environment:
%
%    \begin{macrocode}
{% endboxouter
    \endcenter\unskip%
    \addvspace{\smallskipamount}%
%    \end{macrocode}
% Optionally print artist's name and additional text:
%    \begin{macrocode}
    \KFLT@addartisttext{}%
%    \end{macrocode}
% Place the caption below the contents depending on \pkg{caption} \optn{position} option:
% \changes{v2.01}{2019/09/11}{Fix: Positions with \brand{Komascript}.}
%    \begin{macrocode}
    \ifbool{KFLT@captionistop}{}{\KFLT@caption{}}%
%    \end{macrocode}
% If are inside \env{keysubtabs}, end the subtable:
%    \begin{macrocode}
    \ifbool{KFLT@inkeysubfloats}%
    {%
        \csuse{endsub\KFLT@type}%
    }% subfloat
    {% not subfloat
        \ifnumgreater{\value{KFLT@keyfloatdepth}}{0}% keyfloats?
        {%
%    \end{macrocode}
%    \begin{macrocode}
            \endminipage%
        }% keyfloats
        {% not keyfloats
%    \end{macrocode}
%
% Not subfloat or \env{keyfloats}, so is an individual float.
%
% Close the minipage or float:
%
% See if in a \env{keywrap}:
%    \begin{macrocode}
            \ifbool{KFLT@keywrap}{%
                \endminipage%
                \par\addvspace{\baselineskip}%
            }%
            {% not keywrap
%    \end{macrocode}
%
% See if the float should [W]rap:
%    \begin{macrocode}
                \ifstrequal{#2}{W}%
%    \end{macrocode}
% Place [W], so close the wrap float:
%    \begin{macrocode}
                {% [W]
                    \endminipage%
                    \endwrapfloat%
                }% [W]
                {% not[W]
%    \end{macrocode}
%
% See if the float should be positioned in the [M]argin:
%    \begin{macrocode}
                    \ifstrequal{#2}{M}%
%    \end{macrocode}
% [M], so close the marginfloat:
% \changes{v2.00}{2019/03/18}{Added custom float types.}
%    \begin{macrocode}
                    {% [M]
                        \endKFLT@marginfloat%
                    }% [M]
%    \end{macrocode}
% [H] or float:
% \changes{v2.01}{2019/09/14}{Improved vertical space.}
%    \begin{macrocode}
                    {% not [M]
                        \ifstrequal{#2}{H}%
                        {%
                            \endminipage% [H]
                            \vskip\intextsep%
                        }%
                        {% not [H]
                            \IfBooleanTF{#1}% starred float?
                                {\csuse{end\KFLT@type*}}%
                                {\csuse{end\KFLT@type}}%
                        }% not [H]
                    }% not [M]
                }% not [W]
            }% not keywrap
        }% not keyfloats
    }% not subfloat
}% endkeyboxouter
%    \end{macrocode}
% \end{environment}


% \begin{macro}{\KFLT@@ignorespaces} \marg{commandname}
% Only do command if not nested inside something.
% \changes{v2.00}{2019/01/22}{Added.}
%    \begin{macrocode}
\newcommand*{\KFLT@@ignorespaces}[1]{%
    \ifboolexpr{%
        test {\ifnumgreater{\value{KFLT@keyfloatdepth}}{0}} or%
        bool{KFLT@inkeysubfloats}%
    }{}{\csuse{#1}}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\KFLT@ignorespaces}
% Only \cs{ignorespaces} if not nested inside something.
% \changes{v2.00}{2019/01/22}{Added.}
%    \begin{macrocode}
\newcommand*{\KFLT@ignorespaces}{%
    \KFLT@@ignorespaces{ignorespaces}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\KFLT@envignorespaces}
% Only \cs{ignorespaces} if not nested inside something.
% \changes{v2.00}{2019/01/22}{Added.}
%    \begin{macrocode}
\newcommand*{\KFLT@envignorespaces}{%
    \KFLT@@ignorespaces{ignorespacesafterend}%
}
%    \end{macrocode}
% \end{macro}


% \subsection{The \cs{KFLT@keyflt} macro}
%
% \begin{macro}{\KFLT@keyflt}
%   \marg{1:star} \marg{2:loc} \marg{3:type} \marg{4:\keyvalsarg} \marg{5:contents}
%
% A lower-level macro to generate a float with its contents.
% This is used by \cs{keyfig} and \cs{keyflt}.
%
% \changes{v2.00}{2019/03/17}{Added.}
%    \begin{macrocode}
\NewDocumentCommand{\KFLT@keyflt}{m m m +m +m}
{%
%    \end{macrocode}
%
% \changes{v2.02}{2021/05/18}{Work with \pkg{float}.}
%    \begin{macrocode}
    \ifcsdef{ftype@#3}{}{%
%    \end{macrocode}
%
%    \begin{macrocode}
        \PackageError{keyfloat}%
        {%
            \protect\keyflt: Invalid float type.\MessageBreak%
            \protect\keyflt*[loc]{type}{keys/values}{contents}\MessageBreak%
            Also, \protect\keyflt\space is not an environment
        }%
        {%
            Check argument order and float type.
        }%
    }%
    \KFLT@ignorespaces%
    \KFLT@trackrows%
    \KFLT@boxkeys{#4}{#3}%
    \begingroup%
    \KFLT@boxouter{#1}{#2}%
    #5%
    \endKFLT@boxouter%
    \endgroup%
    \KFLT@ignorespaces%
}
%    \end{macrocode}
% \end{macro}


% \subsection{The \cs{keyflt} macro}

% \begin{macro}{\keyflt} * \oarg{loc} \marg{type} \marg{\keyvalsarg} \marg{contents}
%
% A user-level macro to generate a float with its contents
% centered inside an inner box.
% This may be used by itself, or inside a \env{keyfloats} or
% \env{keysubtabs} environment.
%
% \changes{v0.12}{2016/12/03}{Group around contents.}
% \changes{v2.00}{2019/03/17}{Added.}
%    \begin{macrocode}
\NewDocumentCommand{\keyflt}{s O{tbp} m +m +m}
{%
    \KFLT@keyflt{#1}{#2}{#3}{#4}{%
        \KFLT@boxinner%
        \centering%
        #5%
        \endKFLT@boxinner%
    }%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\endkeyflt}
%
% Generates an error in case the user tried to use \cs{keyflt} as an environment.
% \changes{v2.00}{2019/03/17}{Added.}
%    \begin{macrocode}
\def\endkeyflt{%
    \PackageError{keyfloat}
    {%
        \protect\end{keyflt}:\MessageBreak
        \protect\keyflt\space is a macro, not an environment.\MessageBreak
        Perhaps you want the keyfloat environment instead%
    }
    {%
        Use \protect\begin{keyfloat} ... \protect\end{keyfloat}.
    }
}
%    \end{macrocode}
% \end{macro}


% \subsection{The \env{keyfloat} environment}

% \begin{macro}{\KFLT@keyfloatstart} \marg{star?} \marg{loc} \marg{float type} \marg{\keyvalsarg}
% \changes{v2.00}{2019/03/18}{Factored.}
%    \begin{macrocode}
\newcommand{\KFLT@keyfloatstart}[4]{%
    \KFLT@envignorespaces%
    \KFLT@boxkeys{#4}{#3}%
    \KFLT@boxouter{#1}{#2}%
    \KFLT@boxinner%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\KFLT@keyfloatend}
% \changes{v2.00}{2019/03/18}{Factored.}
%    \begin{macrocode}
\newcommand{\KFLT@keyfloatend}{%
    \endKFLT@boxinner%
    \endKFLT@boxouter%
    \KFLT@envignorespaces%
}
%    \end{macrocode}
% \end{macro}

% \begin{environment}{keyfloat} * \oarg{loc} \marg{float type} \marg{\keyvalsarg}
% \changes{v2.00}{2019/03/18}{Added.}
%    \begin{macrocode}
\NewDocumentEnvironment{keyfloat}{s O{tbp} m +m}
{%
    \KFLT@keyfloatstart{#1}{#2}{#3}{#4}%
}%
{%
    \KFLT@keyfloatend%
}
%    \end{macrocode}
% \end{environment}

% Extra code to track rows outside of the \env{keyfloat} environment,
% \DescribeObject{Before \env{keyfloat}}
% before it starts.  This is done to allow nesting without losing track
% of the prior level.
%
%    \begin{macrocode}
\BeforeBeginEnvironment{keyfloat}{%
    \KFLT@trackrows%
}
%    \end{macrocode}


% \subsection{The \env{keyfigure} environment}

% \begin{environment}{keyfigure} * \oarg{loc} \marg{\keyvalsarg}
%    \begin{macrocode}
\NewDocumentEnvironment{keyfigure}{s O{tbp} +m}
{%
    \KFLT@keyfloatstart{#1}{#2}{figure}{#3}%
}%
{%
    \KFLT@keyfloatend%
}
%    \end{macrocode}
% \end{environment}

% Extra code to track rows outside of the \env{keyfigure} environment,
% \DescribeObject{Before \env{keyfigure}}
% before it starts.  This is done to allow nesting without losing track
% of the prior level.
%
%    \begin{macrocode}
\BeforeBeginEnvironment{keyfigure}{%
    \KFLT@trackrows%
}
%    \end{macrocode}


% \subsection{The \cs{keyfig} macro}

% \begin{macro}{\keyfig} * \oarg{2:loc} \marg{3:\keyvalsarg} \marg{4:image filename}
%
% A user-level macro to generate a figure with an image.
% This may be used by itself, or inside a \env{keyfloats} or
% \env{keysubfigs} environment.
%
% \changes{v2.00}{2019/03/17}{Factored.}
%    \begin{macrocode}
\NewDocumentCommand{\keyfig}{s O{tbp} +m m}
{%
    \KFLT@keyflt{#1}{#2}{figure}{#3}{%
        \KFLT@onefigureimage{#4}%
    }%
}
%    \end{macrocode}
% \end{macro}



% \subsection{The \cs{keyfigbox} macro}

% \begin{macro}{\keyfigbox} * \oarg{loc} \marg{\keyvalsarg} \marg{box contents}
%
% A user-level macro to generate a figure with arbitrary paragraph contents.
% This may be used by itself, or inside a \env{keyfloats} or
% \env{keysubtabs} environment.
%
% \changes{v0.12}{2016/12/03}{Group around contents.}
%    \begin{macrocode}
\NewDocumentCommand{\keyfigbox}{s O{tbp} +m +m}
{%
    \KFLT@ignorespaces%
    \KFLT@trackrows%
    \KFLT@boxkeys{#3}{figure}%
    \begingroup%
    \KFLT@boxouter{#1}{#2}%
    \KFLT@boxinner%
    #4%
    \endKFLT@boxinner%
    \endKFLT@boxouter%
    \endgroup%
    \KFLT@ignorespaces%
}
%    \end{macrocode}
% \end{macro}


% \subsection{The \cs{keyparbox} macro}

% \begin{macro}{\keyparbox} * \oarg{loc} \marg{\keyvalsarg} \marg{box contents}
%
% A user-level macro to generate a figure with arbitrary paragraph contents,
% but no number or caption.
% This is equal to a \cs{keyfigbox} with |cstar={}|.
% This may be used by itself, or inside a \env{keyfloats} or
% \env{keysubtabs} environment.
%
% \changes{v0.12}{2016/12/03}{Group around contents.}
%    \begin{macrocode}
\NewDocumentCommand{\keyparbox}{s O{tbp} +m +m}
{%
    \KFLT@ignorespaces%
    \KFLT@trackrows%
    \KFLT@boxkeys{#3}{figure}%
%    \end{macrocode}
% Force |cstar={}|:
%    \begin{macrocode}
    \renewcommand{\KFLT@c}{}%
    \setboolean{KFLT@cstar}{true}%
%    \end{macrocode}
% Continue like \cs{figbox}:
%    \begin{macrocode}
    \begingroup%
    \KFLT@boxouter{#1}{#2}%
    \KFLT@boxinner%
    #4%
    \endKFLT@boxinner%
    \endKFLT@boxouter%
    \endgroup%
    \KFLT@ignorespaces%
}
%    \end{macrocode}
% \end{macro}


% \subsection{The \cs{keytab} macro}

% \begin{macro}{\keytab} * \oarg{loc} \marg{\keyvalsarg} \marg{tabular contents}
%
% A user-level macro to generate a table with tabular contents.
% This may be used by itself, or inside a \env{keyfloats} or
% \env{keysubtabs} environment.
%
% \changes{v2.00}{2019/03/17}{Factored.}
%    \begin{macrocode}
\NewDocumentCommand{\keytab}{s O{tbp} +m +m}
{%
    \IfBooleanTF{#1}{%
        \keyflt*[#2]{table}{#3}{#4}%
    }{%
        \keyflt[#2]{table}{#3}{#4}%
    }%
}
%    \end{macrocode}
% \end{macro}


% \subsection{The \env{keytable} environment}

% \begin{environment}{keytable} * \oarg{loc} \marg{\keyvalsarg}
%    \begin{macrocode}
\NewDocumentEnvironment{keytable}{s O{tbp} +m}
{%
    \KFLT@keyfloatstart{#1}{#2}{table}{#3}%
}%
{%
    \KFLT@keyfloatend%
}
%    \end{macrocode}
% \end{environment}

% Extra code to track rows outside of the \env{keytable} environment,
% \DescribeObject{Before \env{keytable}}
% before it starts.  This is done to allow nesting without losing track
% of the prior level.
%
%    \begin{macrocode}
\BeforeBeginEnvironment{keytable}{%
    \KFLT@trackrows%
}
%    \end{macrocode}



% \subsection{A row of floats}

% \begin{macro}{\KFLT@nonest} Error message if tried to nest subfloats.
%    \begin{macrocode}
\newcommand*{\KFLT@nonest}{%
    \ifboolexpr{%
        test {\ifnumgreater{\value{KFLT@keyfloatdepth}}{0}} or
        bool {KFLT@inkeysubfloats}%
    }%
    {%
        \PackageError{keyfloat}%
        {%
            Cannot nest keysubfigs or keysubtabs.\MessageBreak%
            (Not in outer par mode.)%
        }%
        {%
            The subcaption package do not support nested environments,%
                \MessageBreak
            so the keyfloat package cannot place a\MessageBreak
            keysubfigs or keysubtabs environment inside another,%
                \MessageBreak
            or inside a keyfloats.%
        }%
    }%
    {}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\KFLT@LWR@hook@keyfloats} Used by \pkg{lwarp}.
%    \begin{macrocode}
\newcommand*{\KFLT@LWR@hook@keyfloats}{}%
%    \end{macrocode}
% \end{macro}


% \begin{environment}{KFLT@LWR@hook@keyfloatsminipage} \marg{contents}
%
% Modified by \pkg{lwarp}.
% \changes{v2.06}{2021/06/25}{Added vertical alignment.}
%    \begin{macrocode}
\newenvironment*{KFLT@LWR@hook@keyfloatsminipage}[1]
    {\noindent\minipage[\KFLT@va]{#1}}
    {\endminipage}
%    \end{macrocode}
% \end{environment}


% \begin{environment}{keyfloats} * \oarg{loc} \marg{num columns} \oarg{shared keys/values}
%
% User-level macro to create rows of figures/tables.
% Wrapping occurs after the number of specified columns.
% \env{keyfloats} environments may be nested to create
% a vertical set of figures next to a single larger figure,
% for example.
%
% Place \cs{keyfig}, \cs{keyfigbox}, and \cs{keytab} commands
% inside the \env{keyfloats} environment.
%
% Note that |lw| linewidth keys may need to be adjusted inside
% a \env{keyfloats}, \env{keysubfigs}, or \env{keysubtabs}, since
% \cs{linewidth} changes depending on the number of columns.
% Likewise, manually-selected |w| width and |h| tags may need to be
% adjusted to prevent overflow.
%
% \changes{v0.15}{2017/05/12}{Adjustments for \protect\env{keywrap}.}
%
%    \begin{macrocode}
\NewDocumentEnvironment{keyfloats}{s O{tbp} m O{}}
{%
    \KFLT@envignorespaces%
%    \end{macrocode}
% A hook for \pkg{lwarp} to set \cs{linewidth}, etc.
%    \begin{macrocode}
    \KFLT@LWR@hook@keyfloats%
%    \end{macrocode}
% Track the depth:
%    \begin{macrocode}
    \addtocounter{KFLT@keyfloatdepth}{1}%
%    \end{macrocode}
% Nest the group's keys.
% \changes{v2.06}{2021/06/25}{Added shared keys.}
%    \begin{macrocode}
    \edef\KFLT@outersharedkeys{\KFLT@sharedkeys}%
    \edef\KFLT@sharedkeys{\KFLT@sharedkeys,#4}%
%    \end{macrocode}
% If [H], nested, subfloats, or keywrap, use a minipage instead of a float:
%    \begin{macrocode}
    \ifboolexpr{%
        test {\ifstrequal{#2}{H}} or
        test {\ifnumgreater{\value{KFLT@keyfloatdepth}}{1}} or
        bool {KFLT@inkeysubfloats} or
        bool {KFLT@keywrap}%
    }%
%    \end{macrocode}
% Create an inline minipage:
%    \begin{macrocode}
    {% [H] or nested
%    \end{macrocode}
% If nested, use different spacing as was computed in the outer nesting level:
% \changes{v2.01}{2019/09/14}{Improved vertical space.}
%    \begin{macrocode}
        \ifboolexpr{%
            test {\ifnumgreater{\value{KFLT@keyfloatdepth}}{1}} or
            bool {KFLT@inkeysubfloats}
        }%
        {%
%    \end{macrocode}
% Use the keys from the outer container.
% Expansion required for \pkg{xkeyval}.
% \changes{v2.06}{2021/06/25}{Added shared keys.}
%    \begin{macrocode}
            \edef\next{\noexpand\setkeys{KFLT@keys}{\KFLT@outersharedkeys}}%
            \next%
%    \end{macrocode}
% Create the containing minipage:
%    \begin{macrocode}
            \KFLT@LWR@hook@keyfloatsminipage{\KFLT@rowboxwidth}%
        }%
        {%
            \vskip\intextsep%
            \KFLT@LWR@hook@keyfloatsminipage{\linewidth}%
        }%
%    \end{macrocode}
% Reset font and color:
% \changes{v2.01}{2019/09/11}{Fix: Font and color.}
%    \begin{macrocode}
        \normalcolor\reset@font\normalsize%
%    \end{macrocode}
% If inside subfloats, generate subfigures by default:
%    \begin{macrocode}
        \ifbool{KFLT@inkeysubfloats}%
            {}%
            {\captionsetup*{type=figure}}%
    }% [H] or nested
%    \end{macrocode}
% Isn't [H] or nested
%    \begin{macrocode}
    {% See if [W]:
        \ifstrequal{#2}{W}
        {% [W]:
%    \end{macrocode}
% [W]:
% \changes{v2.01}{2019/09/16}{Added \env{keyfloats} [W].}
%    \begin{macrocode}
            \wrapfloat{figure}{O}{.5\linewidth}%
            \minipage{\linewidth}%
%    \end{macrocode}
%
% Inside this minipage, temporarily prevent underfull \cs{hbox} warnings:
% \changes{v2.02}{2021/05/28}{Avoid underfull \cs{hbox} warning.}
%    \begin{macrocode}
            \hbadness=10000\relax%
%    \end{macrocode}
%    \begin{macrocode}
            \normalcolor\reset@font\normalsize%
        }%
        {% not [H]:
            \ifstrequal{#2}{M}%
            {% [M]:
%    \end{macrocode}
% [M]:
% \changes{v2.01}{2019/09/16}{Added \env{keyfloats} [M].}
%    \begin{macrocode}
                \KFLT@marginfloat{figure}%
            }%
%    \end{macrocode}
% A normal figure:
%    \begin{macrocode}
            {% figure
                \IfBooleanTF{#1}% starred figure, two-col figure in a two-col format
                    {\begin{figure*}[#2]}%
                    {\begin{figure}[#2]}%
            }% figure
        }% not [H]
    }%
%    \end{macrocode}
% Compute the width of each entry:
%    \begin{macrocode}
    \ifboolexpr{%
        test {\ifnumgreater{\value{KFLT@keyfloatdepth}}{1}} or
        bool {KFLT@inkeysubfloats}
    }%
%    \end{macrocode}
% Nested or subfloats:
%    \begin{macrocode}
        {\setlength{\KFLT@rowboxwidth}{.9\KFLT@rowboxwidth/\real{#3}}}%
%    \end{macrocode}
% Keyfloats:
%    \begin{macrocode}
        {\setlength{\KFLT@rowboxwidth}{.9\linewidth/\real{#3}}}%
%    \end{macrocode}
% Center the contents:
%    \begin{macrocode}
    \centering%
%    \end{macrocode}
% Count columns using \cs{defcounter} for a local effect:
%    \begin{macrocode}
    \defcounter{KFLT@numcols}{#3}%
    \defcounter{KFLT@thiscol}{0}%
}% starting keyfloats environment
%    \end{macrocode}
%
% When ending a \env{keyfloats} environment:
%    \begin{macrocode}
{% ending keyfloats environment
%    \end{macrocode}
% [H] or rows/subfigs? Close a minipage:
%    \begin{macrocode}
    \ifboolexpr{%
        test {\ifstrequal{#2}{H}} or
        test {\ifnumgreater{\value{KFLT@keyfloatdepth}}{1}} or
        bool {KFLT@inkeysubfloats} or
        bool {KFLT@keywrap}
    }%
    {% was [H], etc.
        \endKFLT@LWR@hook@keyfloatsminipage%
%         \end{minipage}%
%    \end{macrocode}
% Spacing if nested or not:
% \changes{v2.01}{2019/09/14}{Improved vertical space.}
%    \begin{macrocode}
        \ifboolexpr{
            test {\ifnumgreater{\value{KFLT@keyfloatdepth}}{0}} or
            bool {KFLT@keywrap}
        }%
        {}{% not nested
            \vskip\intextsep%
        }%
    }% was [H], etc.
%    \end{macrocode}
% Not [H]:
%    \begin{macrocode}
    {% not [H], etc.
        \ifstrequal{#2}{W}%
        {% [W]:
%    \end{macrocode}
% [W]:
% \changes{v2.01}{2019/09/16}{Added \env{keyfloats} [W].}
%    \begin{macrocode}
            \endminipage%
            \endwrapfloat%
        }%
        {%
            \ifstrequal{#2}{M}%
            {% [M]:
%    \end{macrocode}
% [M]:
% \changes{v2.01}{2019/09/16}{Added \env{keyfloats} [M].}
%    \begin{macrocode}
                \endKFLT@marginfloat%
            }%
            {% figure
%    \end{macrocode}
% A figure:
%    \begin{macrocode}
                \IfBooleanTF{#1}% starred figure?
                    {\end{figure*}}{\end{figure}}%
            }%
        }%
    }% not [H], etc.
%    \end{macrocode}
% Unnest the environment:
%    \begin{macrocode}
    \addtocounter{KFLT@keyfloatdepth}{-1}%
    \KFLT@envignorespaces%
}
%    \end{macrocode}
% \end{environment}



% Extra code to track rows outside of the \env{keyfloats} environment,
% \DescribeObject{Before \env{keyfloats}}
% before it starts.  This is done to allow nesting without losing track
% of the prior level.
%
%    \begin{macrocode}
\BeforeBeginEnvironment{keyfloats}{%
    \KFLT@trackrows%
}
%    \end{macrocode}


% \subsection{Subfloats}

% \begin{macro}{\KFLT@subgrpdefaults} Sets defaults before reading the keys.
%    \begin{macrocode}
\newcommand*{\KFLT@subgrpdefaults}{%
    \setboolean{KFLT@subgrpcont}{false}%
    \renewcommand{\KFLT@subgrpc}{}%
    \setboolean{KFLT@subgrpcstar}{false}%
    \renewcommand{\KFLT@subgrpsc}{}%
    \setboolean{KFLT@subgrpscgiven}{false}%
    \renewcommand{\KFLT@subgrptype}{figure}%
    \renewcommand{\KFLT@subgrpl}{}%
    \renewcommand{\KFLT@subgrpap}{}%
    \renewcommand{\KFLT@subgrpaf}{}%
    \renewcommand{\KFLT@subgrpal}{}%
    \renewcommand{\KFLT@subgrpas}{}%
    \renewcommand{\KFLT@subgrpaup}{}%
    \renewcommand{\KFLT@subgrpauf}{}%
    \renewcommand{\KFLT@subgrpaul}{}%
    \renewcommand{\KFLT@subgrpaus}{}%
    \renewcommand{\KFLT@subgrpt}{}%
    \renewcommand{\KFLT@subgrptextalign}{}%
}
%    \end{macrocode}
% \end{macro}


% \DescribeBoolean{KFLT@subcaptionistop} Saves the value of \cs{caption@position},
% which may become unreliable if using Komascript and
% \begin{sourceverb}
% \captionsetup[table]{position=above}
% \end{sourceverb}
%
%    \begin{macrocode}
\newbool{KFLT@subcaptionistop}
%    \end{macrocode}



% \begin{macro}{\KFLT@subfloats} \marg{starred?} \marg{loc} \marg{cols} \marg{\keyvalsarg}
%
% \changes{v0.13}{2017/01/16}{Fix: Subfloat type selection.}
% \changes{v0.15}{2017/05/12}{Adjustments for \protect\env{keywrap}.}
%
% Start a subfloat environment
%    \begin{macrocode}
\NewDocumentCommand{\KFLT@subfloats}{m m m +m}
{%
    \KFLT@envignorespaces%
%    \end{macrocode}
% Parse the key-value combinations:
%    \begin{macrocode}
    \setkeys{KFLT@subgrpkeys}{#4}%
%    \end{macrocode}
% Nest the environment:
%    \begin{macrocode}
    \setboolean{KFLT@inkeysubfloats}{true}%
%    \end{macrocode}
% Figure out the width of each subfloat.
% If starred, use the full-page \cs{textwidth}, else use \cs{linewidth}.
% .9 is used to leave a little room between columns.
%    \begin{macrocode}
    \IfBooleanTF{#1}%
        {\setlength{\KFLT@rowboxwidth}{.9\textwidth/\real{#3}}}%
        {\setlength{\KFLT@rowboxwidth}{.9\linewidth/\real{#3}}}%
%    \end{macrocode}
% If [H], or in a \env{keywrap}, create an inline minipage:
% \changes{v2.01}{2019/09/11}{Fix: Font and color.}
% \changes{v2.01}{2019/09/14}{Improved vertical space.}
%    \begin{macrocode}
    \ifboolexpr{%
        test {\ifstrequal{#2}{H}} or
        bool {KFLT@keywrap}
    }%
    {%
        \vskip\intextsep\noindent\begin{minipage}{\linewidth}%
        \normalcolor\reset@font\normalsize%
    }%
%    \end{macrocode}
% Not [H]:
%    \begin{macrocode}
    {%
        \ifstrequal{#2}{W}%
        {% [W]
%    \end{macrocode}
% [W]:
% \changes{v2.01}{2019/09/16}{Added \env{keysubfloats} [W].}
%    \begin{macrocode}
            \wrapfloat{\KFLT@subgrptype}{O}{.5\linewidth}%
            \setlength{\KFLT@rowboxwidth}{.5\KFLT@rowboxwidth}%
            \minipage{\linewidth}%
%    \end{macrocode}
%
% Inside this minipage, temporarily prevent underfull \cs{hbox} warnings:
% \changes{v2.02}{2021/05/28}{Avoid underfull \cs{hbox} warning.}
%    \begin{macrocode}
            \hbadness=10000\relax%
%    \end{macrocode}
%    \begin{macrocode}
            \normalcolor\reset@font\normalsize%
        }%
        {% not [H]:
            \ifstrequal{#2}{M}%
            {% [M]:
%    \end{macrocode}
% [M]:
% \changes{v2.01}{2019/09/16}{Added \env{keysubfloats} [M].}
%    \begin{macrocode}
                \KFLT@marginfloat{\KFLT@subgrptype}%
                \setlength{\KFLT@rowboxwidth}{.9\marginparwidth/\real{#3}}%
            }% [M]
            {% subfloat
%    \end{macrocode}
% A subfloat:
%    \begin{macrocode}
                \IfBooleanTF{#1}%
                    {\begin{\KFLT@subgrptype*}[#2]}%
                    {\begin{\KFLT@subgrptype}[#2]}%
            }%
        }% not [H]
    }%
%    \end{macrocode}
% Set the caption type:
%    \begin{macrocode}
    \captionsetup*{type=\KFLT@subgrptype}%
%    \end{macrocode}
% Process continued floats:
%    \begin{macrocode}
    \ifbool{KFLT@subgrpcont}%
        {\ContinuedFloat}%
        {}%
%    \end{macrocode}
% Center the contents:
%    \begin{macrocode}
    \center\unskip%
%    \end{macrocode}
% Place the caption above the contents depending on \pkg{caption} \optn{position} option:
% \changes{v2.01}{2019/09/11}{Fix: Positions with \brand{Komascript}.}
%    \begin{macrocode}
    \caption@iftop%
        {\booltrue{KFLT@subcaptionistop}}%
        {\boolfalse{KFLT@subcaptionistop}}%
    \ifbool{KFLT@subcaptionistop}{\KFLT@caption{subgrp}}{}%
%    \end{macrocode}
% Not yet started a row of subfloats.
% The use of \cs{defcounter} makes these changes local.
%    \begin{macrocode}
    \defcounter{KFLT@numcols}{#3}%
    \defcounter{KFLT@thiscol}{0}%
%    \end{macrocode}
% Creat a group for the subfloats.
% Necessary in case they change \cs{tdartisttextcenter}, etc.
%    \begin{macrocode}
    \begingroup%
}
%    \end{macrocode}
% \end{macro}



% \begin{macro}{\KFLT@endsubfloats} \marg{starred?} \marg{loc}
%
% Ends a subfloat environment.
%    \begin{macrocode}
\newcommand*{\KFLT@endsubfloats}[2]{%
%    \end{macrocode}
% End the group containing the subfloats:
%    \begin{macrocode}
    \endgroup%
    \unskip%
    \endcenter%
%    \end{macrocode}
% A little extra space at the bottom:
%    \begin{macrocode}
    \par\addvspace{\bigskipamount}%
%    \end{macrocode}
% Optionally print artist's name and additional text:
%    \begin{macrocode}
    \KFLT@addartisttext{subgrp}%
%    \end{macrocode}
% Place the caption below the contents depending on \pkg{caption} \optn{position} option:
% \changes{v2.01}{2019/09/11}{Fix: Positions with \brand{Komascript}.}
%    \begin{macrocode}
    \ifbool{KFLT@subcaptionistop}{}{\KFLT@caption{subgrp}}%
%    \end{macrocode}
% End the float or minipage:
% \changes{v2.01}{2019/09/14}{Improved vertical space.}
%    \begin{macrocode}
    \ifboolexpr{%
        test {\ifstrequal{#2}{H}} or
        bool{KFLT@keywrap}
    }%
        {\end{minipage}\vskip\intextsep}% was [H]
        {% not [H]:
            \ifstrequal{#2}{W}%
            {% [W]
%    \end{macrocode}
% \changes{v2.01}{2019/09/16}{Added \env{keysubfloats} [W].}
%    \begin{macrocode}
                \endminipage%
                \endwrapfloat%
            }%
            {% not [W]:
                \ifstrequal{#2}{M}%
                {% [M]:
%    \end{macrocode}
% \changes{v2.01}{2019/09/16}{Added \env{keysubfloats} [M].}
%    \begin{macrocode}
                    \endKFLT@marginfloat%
                }% [M]
                {% subfloat
                    \IfBooleanTF{#1}% starred?
                        {\end{\KFLT@subgrptype*}}%
                        {\end{\KFLT@subgrptype}}%
                }%
            }% not [W]
        }% not [H]
%    \end{macrocode}
% Unnest the environment:
%    \begin{macrocode}
    \setboolean{KFLT@inkeysubfloats}{false}%
    \KFLT@envignorespaces%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\KFLT@LWR@hook@keysubfloats} Used by \pkg{lwarp}.
%    \begin{macrocode}
\newcommand*{\KFLT@LWR@hook@keysubfloats}{}
%    \end{macrocode}
% \end{macro}

% \begin{environment}{KFLT@keysubfloats} \marg{1: star?}
%       \marg{2: loc} \marg{3: float type} \marg{4: numcols}
%       \marg{5: \keyvalsarg} \marg{6: shared keys/values}
%
% A group of subfigures typeset in rows.
%
%    \begin{macrocode}
\NewDocumentEnvironment{KFLT@keysubfloats}{m m m m +m m}
{%
%    \end{macrocode}
% Error if trying to nest environments:
%    \begin{macrocode}
    \KFLT@nonest%
%    \end{macrocode}
% A hook for \pkg{lwarp} to set \cs{linewidth}, etc.
%    \begin{macrocode}
    \KFLT@LWR@hook@keysubfloats%
%    \end{macrocode}
% Default the options:
%    \begin{macrocode}
    \KFLT@subgrpdefaults%
%    \end{macrocode}
% Nest the group's keys:
% \changes{v2.06}{2021/06/25}{Added shared keys.}
%    \begin{macrocode}
    \edef\KFLT@sharedkeys{\KFLT@sharedkeys,#6}%
%    \end{macrocode}
% Default to figure float type:
%    \begin{macrocode}
    \renewcommand{\KFLT@subgrptype}{#3}%
%    \end{macrocode}
% Start of the environment:
%    \begin{macrocode}
    \KFLT@subfloats{#1}{#2}{#4}{#5}%
}% the start of the environment
%    \end{macrocode}
% end of the environment:
%    \begin{macrocode}
{%
    \KFLT@endsubfloats{#1}{#2}%
}
%    \end{macrocode}
% \end{environment}


% \begin{environment}{keysubfloats} * \oarg{2: loc} \marg{3: float type}
%       \marg{4: numcols} \marg{5: \keyvalsarg} \oarg{6: shared \keyvalsarg}
%
% A group of subfloats typeset in rows.
%
% \changes{v2.06}{2021/06/25}{Added shared keys.}
%    \begin{macrocode}
\NewDocumentEnvironment{keysubfloats}{s O{tbp} m m +m O{}}
    {\KFLT@keysubfloats{#1}{#2}{#3}{#4}{#5}{#6}}
    {\endKFLT@keysubfloats}
%    \end{macrocode}
% \end{environment}


% \begin{environment}{keysubfigs} * \oarg{2: loc} \marg{3: numcols}
%       \marg{4: \keyvalsarg} \oarg{5: shared \keyvalsarg}
%
% A group of subfigures typeset in rows.
%
% \changes{v2.06}{2021/06/25}{Added shared keys.}
%    \begin{macrocode}
\NewDocumentEnvironment{keysubfigs}{s O{tbp} m +m O{}}
    {\KFLT@keysubfloats{#1}{#2}{figure}{#3}{#4}{#5}}
    {\endKFLT@keysubfloats}
%    \end{macrocode}
% \end{environment}


% \begin{environment}{keysubtabs} * \oarg{2: loc} \marg{3: numcols}
%       \marg{4: \keyvalsarg} \oarg{5: shared \keyvalsarg}
%
% A group of subtables typeset in rows.
% \changes{v2.06}{2021/06/25}{Added shared keys.}
%    \begin{macrocode}
\NewDocumentEnvironment{keysubtabs}{s O{tbp} m +m O{}}
    {\KFLT@keysubfloats{#1}{#2}{table}{#3}{#4}{#5}}
    {\endKFLT@keysubfloats}
%    \end{macrocode}
% \end{environment}
%
%
%
%
% \subsection{Margin floats}
%
% \begin{environment}{KFLT@marginfloat} \oarg{offset} \marg{type}
% \changes{v2.01}{2019/09/11}{Fix: Font and color.}
%    \begin{macrocode}
\newsavebox{\KFLT@marginfloatbox}

\NewDocumentEnvironment{KFLT@marginfloat}{O{-1.2ex} m}
{% start
    \FloatBarrier% keep floats in order
    \KFLT@envignorespaces%
    \begin{lrbox}{\KFLT@marginfloatbox}%
    \begin{minipage}{\marginparwidth}%
    \captionsetup{type=#2}%
    \hbox{}\vspace*{#1}%
    \noindent%
    \normalcolor\reset@font\normalsize%
}% start
{% end
    \end{minipage}%
    \end{lrbox}%
    \marginpar{\usebox{\KFLT@marginfloatbox}}%
    \KFLT@envignorespaces%
}% end
%    \end{macrocode}
% \end{environment}
%
%
% Provided in case \pkg{tufte-book} is not loaded:
%
% \begin{environment}{marginfigure} \oarg{offset}
% \changes{v0.12}{2016/12/03}{Added.}
%    \begin{macrocode}
\ProvideDocumentEnvironment{marginfigure}{O{-1.2ex}}
  {\begin{KFLT@marginfloat}[#1]{figure}}
  {\end{KFLT@marginfloat}}
%    \end{macrocode}
% \end{environment}
%
%
% \begin{environment}{margintable} \oarg{offset}
% \changes{v0.12}{2016/12/03}{Added.}
%    \begin{macrocode}
\ProvideDocumentEnvironment{margintable}{O{-1.2ex}}
  {\begin{KFLT@marginfloat}[#1]{table}}
  {\end{KFLT@marginfloat}}
%    \end{macrocode}
% \end{environment}
%
%
%
%
% \subsection{Wrapped floats}
%
% \DescribeBoolean{KFL@keywrap} Tells the next keyfloat to wrap around some text.
%    \begin{macrocode}
\newboolean{KFLT@keywrap}
\boolfalse{KFLT@keywrap}
%    \end{macrocode}
%
%
% \DescribeLength{\KFLT@keywrapwidth} The width of the object to be wrapped beside the text.
%    \begin{macrocode}
\newlength{\KFLT@keywrapwidth}
%    \end{macrocode}
%
% \DescribeLength{\KFLT@keywrapparskip} The \cs{parskip} outside of the keywrap.
%    \begin{macrocode}
\newlength{\KFLT@keywrapparskip}
%    \end{macrocode}
%
% \DescribeLength{\KFLT@keywrapparindent} The \cs{parindent} outside of the keywrap.
%    \begin{macrocode}
\newlength{\KFLT@keywrapparindent}
%    \end{macrocode}
%
%
% \begin{environment}{keywrap} \marg{width} \marg{keyfloat}
%
% The main text is placed in a minipage to the left,
% and the wrapped content is later placed in another minipage to the right.
%
% \changes{v0.15}{2017/05/11}{Added.}
% \changes{v2.01}{2019/09/11}{Fix: Font and color.}
% \changes{v2.01}{2019/09/16}{Fix: \cs{noindent}.}
%    \begin{macrocode}
\DeclareDocumentEnvironment{keywrap}{m +m}%
{%
    \par\noindent%
    \setlength{\KFLT@keywrapwidth}{\linewidth}%
    \addtolength{\KFLT@keywrapwidth}{-#1}%
    \addtolength{\KFLT@keywrapwidth}{-2em}%
    \minipage[t]{\KFLT@keywrapwidth}%
%
    \setlength{\parskip}{\KFLT@keywrapparskip}%
    \setlength{\parindent}{\KFLT@keywrapparindent}%
    \booltrue{KFLT@keywrap}%
}
{%
    \par%
    \endminipage%
    \hfill%
    \begin{minipage}[t]{#1}%
    \booltrue{KFLT@keywrap}%
    \normalcolor\reset@font\normalsize%
%    \end{macrocode}
%
% Inside this minipage, temporarily prevent underfull \cs{hbox} warnings:
% \changes{v2.02}{2021/05/28}{Avoid underfull \cs{hbox} warning.}
%    \begin{macrocode}
    \hbadness=10000\relax%
%    \end{macrocode}
%    \begin{macrocode}
    #2%
    \par%
    \unskip\vspace{\smallskipamount}%
    \end{minipage}%
    \par%
}

\BeforeBeginEnvironment{keywrap}{%
    \setlength{\KFLT@keywrapparskip}{\parskip}%
    \setlength{\KFLT@keywrapparindent}{\parindent}%
}
%    \end{macrocode}
%
% \end{environment}
%
%
% \section{\pkg{keyfloat} package maintenance}
%
% To compile the \pkg{keyfloat} documentation from \filenm{keyfloat.dtx} and
% \filenm{keyfloat.ins}:
%
% \begin{sourceverb}
% pdflatex keyfloat.ins
% pdflatex keyfloat.dtx
% pdflatex keyfloat.dtx
% pdflatex keyfloat.dtx
% makeindex -s gglo.ist -o keyfloat.gls keyfloat.glo
% splitindex keyfloat.idx -- -s gind.ist
% pdflatex keyfloat.dtx
% pdflatex keyfloat.dtx
% \end{sourceverb}
%
%
% \iffalse
%</package>
% \fi
%
%
%
%
% \clearpage
% \pagestyle{plain}
%
% \renewcommand{\partname}{}
% \renewcommand{\thepart}{}
% ^^A \part{Change History and Index}
%
%
% \Finale
%
\endinput