summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/chessboard/chessboard.tex
blob: 31e8a15d3e8894f70ef12ffefa9661cda354c015 (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
% !Mode:: "TeX:DE:UTF-8:Main"
% -*- mode: TeX -*- -*- coding: UTF-8 -*-
\listfiles
\def\UFcurrentpackage{chessboard}
\def\UFcurrentversion{1.9}
%$Date$$Version$
\RequirePackage{l3pdf}
\ExplSyntaxOn
\pdf_uncompress:
%\pdf_version_gset:n{2.0}
\ExplSyntaxOff

\RequirePackage{fix-cm}

\documentclass[pagesize,parskip=half-,fontsize=12pt]{scrartcl}
%% chessboard specific commands
\usepackage[LSB1,LSB2, LSB3,LSBC2,LSBC3,LSBC4,LSBC5, T1]{fontenc}
%\usepackage[skak-parse]{xskak}
\usepackage{xskak}
\usepackage{pifont}
\usepackage{eqparbox}

\newcommand\Chess[1][1cm]{\boardfont\fontsize{#1}{#1}\setboardfontsize{#1}\selectfont}
\newcommand\Plus{\raisebox{0.5ex}{\normalfont\fontsize{1.5ex}{1.5ex}\bfseries\,+\,}}
\newcommand\Equal{\raisebox{0.5ex}{\normalfont\fontsize{1.5ex}{1.5ex}\bfseries\,=\,}}

\makeatletter
\newcommand\Describesetkey[4]{\par\index{#1}%
 \colorbox{yellow!50}{\makebox[\dimexpr\textwidth-2\fboxsep\relax]{\ttfamily%
  \eqparbox{setkey}{#1=\meta{#2}}\hfill
  \eqparbox{setexample}{%
     \ifthenelse{\equal{#3}{}}%
     {#1}
     {#1={#3}}}\hfill
  \eqparbox{setdefault}{\hfill #4}}}\par\nobreak\@afterheading}


\newcommand\Describefillkey[4][]{\par\index{#2}%
\makebox[0pt][r]{\scriptsize #1\hspace{1em}}%
 \colorbox{green!25}{\makebox[\dimexpr\textwidth-2\fboxsep\relax]{\ttfamily%
    \eqparbox{fillkey}{#2=\meta{#3}}\hfill
    \eqparbox{fillexample}{%
     \ifthenelse{\equal{#4}{}}%
     {#2}
     {#2={#4}}}}}%
    \par\nobreak\@afterheading}



\makeatother

%\usepackage{filecontents} only needed after change of docu.sty
\usepackage{UF-chessboard-documentation}

%initialisation
\setchessboard{smallboard, showmover=false}



\begin{document}
\newchessgame
\title{\packagename{chessboard}: A package to print chessboards}
\author{Ulrike Fischer}
\maketitle

\begin{center}
\newchessgame
\setchessboard{shortenend=5pt,color=red,margin=false}%
\unitlength1pt
\newcommand\currentboard[1][]{%
 \begin{picture}(150,150)
 \put(10,10){\chessboard[#1]}
 \end{picture}}%
\begin{animateinline}[autoplay,loop]{1}%
\currentboard
\newframe
\hidemoves{1.e4}%
\currentboard[pgfstyle=straightmove,markmove=e2-e4,
              pgfstyle=border,markfields={e2,e4}]
\newframe
\hidemoves{1... e5}%
\currentboard[pgfstyle=straightmove,markmove=e7-e5,
              pgfstyle=border,markfields={e7,e5}]
\newframe
\hidemoves{2. Nf3}%
\currentboard[pgfstyle=knightmove,markmove=g1-f3,
              pgfstyle=border,markfields={g1,f3}]
\newframe
\hidemoves{2... Nc6}%
\currentboard[pgfstyle=knightmove,markmove=b8-c6,
             pgfstyle=border,markfields={b8,c6}]
\newframe
\hidemoves{3.Bb5}%
\currentboard[pgfstyle=straightmove,markmove=f1-b5,
              pgfstyle=border,markfields={f1,b5}]
\newframe
\hidemoves{3... a6}%
\currentboard[pgfstyle=straightmove,markmove=a7-a6,
              pgfstyle=border,markfields={a7,a6}]
\end{animateinline}
\end{center}



\tableofcontents
\section{Changes}
\minisec{Attention!} From version 1.5 on the documentation uses the
(new) package \packagename{xskak} instead of \packagename{skak}. The
most notable difference is that in some examples \cs{newchessgame}
instead of \cs{newgame} is used. But in most cases all examples
should work with \packagename{skak} alone too. The package
\packagename{xskak} adds quite a lot new keys to \cs{chessboard} to
show arbitrary positions from previously parsed games. Read its
documentation if you want to use them.


In version 1.3 I made a lot of changes. I tried to preserve the
behaviour of existing keys and commands. But is possible that older
documents will look different when processed with this version.

Notably two things can give problems: The value of the
\key{padding} key now affects much more objects (marks) in the pgf
pictures. So it could be necessary to reset the padding. And the
\key{applycolor} has changed its behaviour. It will now also affect
the foreground picture.

\begin{description}
\item[2020-11-01 (Version 1.9)] Corrected a bug reported by 
  Phelype Oleinik. \texttt{colorbackareas} (and other area keys) didn't process lists of areas correctly.

\item[2019-06-23 (Version 1.8)] Uploaded the source of the documentation to ctan.
  No longer use \cs{arabic} internally, to avoid problems with packages redefining the command. (Issue \#1).

\item[2011-03-17 (Version 1.7)] Changed definition of the triangle mover
    style. It now uses \packagename{tikz} and no longer
    \packagename{amssymb}. \packagename{chessboard} no longer loads
    \packagename{amssymb} (it clashes with \packagename{xunicode}).

\item[2011-03-13 (Version 1.7)] Corrected a bug with spacing when the
    \packagename{amsart} is used.


\item[2008-11-27 (Version 1.6)] Corrected a bug in \key{getpiecelists}
(empty lists were undefined).


\item[2007-12-11 (Version 1.5)] Added the key \key{getpiecelists} to
retrieve the positions of pieces. Quite a lot new keys to show
arbitrary positions from previously parsed games are added by the
package \packagename{xskak}. Read its documentation if you want to
use them.

\item[2007-08-20 (Version 1.5)] Added curvemove-style to draw moves.
Corrected some bugs. Changed a lot internally to adapt the package to
\packagename{xskak.sty}.

\item[2007-07-03 (Version 1.4)] Rewrote the code that process the
keys saved globally (with \cs{chessboard}) and  in styles (with
\cs{storechessboardstyle}) to go around a problem due to a change in
\packagename{xkeyval 2.5}. Corrected some errors in the
documentation.
\item[2006-07-20 (Version 1.3)] Rearranged and rewrote the keys and commands for
the pgf-pictures. Now all styles and marks can be used in both
pictures. Added definitions for partial borders. Extended trim and
clip commands. \packagename{xifthen} is now required.
\item[2006-06-22] Added keys for fancy borders, added local commands for
the boardarea and the printarea. Disabled the option skaknew as it
not longer works in \chessfss.
\end{description}




\section{Introduction}
\minisec{What is does} \DescribeMacro{\chessboard} This package
offers a command \cs{chessboard}\keyoarg{} to print boards of chess
positions and similar games. It is intended to replace the
\cs{showboard} command of \skaksty which has some deficiencies:
\begin{itemize}
\item To print a special position one always has to type the
complete FEN.
\item It frames all boards with a  rule of 1pt -- which is okay
for a large board but doesn't look good on small boards.
\item It's difficult (up to impossible) to color some squares.
\item Even for simple markings like crosses or the mover \skaksty use
postscript. That makes it difficult to use pdf\LaTeX.
\item It's difficult to print partial boards.
\item It's difficult (up to impossible) to print boards with exotic
pieces e.g.\ fairy chess.
\item It's impossible to print boards with unusual dimension or unusual labels used by other games e.g.\
10\texttimes10 boards with numbers instead of characters.
\item The labels at the bottom changes the baseline which makes it
difficult to align boards.
\item Some commands e.g., \cs{notationoff} of  \skaksty redefines \cs{skakboard}, so it
is difficult to patch the command e.g.\ to get larger margins.
\end{itemize}


With \pchessboard you have now full control about size, content and
look of the board. I have tried to make \cs{chessboard} as flexible
as possible. So I added a lot of options to change values that
control the size, layout and filling of the board. In most cases you
can ignore them but being able to change them can come handy if you
need something unusual.

But I didn't tried to stretch flexibility too much. The main aim of
the package is to print chessboards easily, so e.g.\ the inputs use
the naming conventions of chess. That means that -- as the files are
numbered alphabetically -- the width of the board is restricted to 26
fields (27 with option \key{zero}). The board is build with
alternating black and white fields, changing to e.g.\ three colors
could be difficult. The pieces are named with simple ASCII-chars, so
the number of different pieces is restricted. (It is perhaps possible
to define piecenames consisting of two or more chars, and to use such
names by putting braces around the chars e.g.,
\verb+{KK}a3+.  A small test worked fine for me, but I wouldn't bet
that it really works everywhere.)

\minisec{What it doesn't} \Pchessboard doesn't offer commands to type
captions or titles or a list of the chessboards. There are no options
that control the placement of the board in the text flow, e.g. to
center it or to let it float. This is a design decision.
\cs{chessboard} prints only chessboards like \cs{includegraphics}
inserts only graphics.



\subsection{Bugs and errors}

I'm quite sure that they are bugs and errors in the package. I did
find some quite horrible while making the documentation and I'm sure
I overlooked some. E.g.\ I have a lot of doubts if spaces and braces
in keys saved in a style or with \cs{setchessboard} are handled
correctly in every case.

If you have questions ask them in the newsgroups
\nolinkurl{comp.text.tex} or
\nolinkurl{de.comp.text.tex}. I'm reading these groups regularly and
I'm much better in answering there than in answering e-mails.


If you find errors in this text  (this includes wrong english) or in
the package, you can write me a bugreport at
\nolinkurl{skak@nililand.de}. A bugreport should contain a complete \emph{minimal}
example and the log-file of the pdf\LaTeX\ run (this is the engine
that makes a pdf!).

Before sending a bug record check the following things:


\minisec{If you get mysterious error messages}
\begin{itemize}
\item  Check the commas in the \keylists.
\end{itemize}

\minisec{Missing or faulty pgf-decorations}
\begin{itemize}
\item Check if the borders or marks are hidden under other decorations or under board chars with solid fieldmasks.
\item Check if trimming is responsible: try the key \verb+trim=false+.
\item Check the state of the key \key{pgf}.
\item Try another previewer, zoom in and out, print the document.
\item Go through your log-file and search for chessboard warnings.
\end{itemize}


\subsection{Requirements}

\Pchessboard uses some primitives of e\TeX. It needs a recent version
of \chessfss (chess font selection), \packagename{xkeyval}
(\textit{key=value}-syntax) and \packagename{xifthen}. It also needs
the packages \packagename{pgfcore}, \packagename{pgfbaseshapes} (from
pgf for the highlighting commands), \packagename{pst-node} (from
pstricks).


\subsection{Installation}
Run \filetype{chessboard.ins} through \LaTeX\ and then put the four
\filetype{.sty}-files somewhere where \LaTeX\ finds them.
\path{<texmf>/tex/latex/chessboard/} is a good place. Update the
filename database.

\subsection{Robustness: using \texorpdfstring{\cs{chessboard}}{\textbackslash chessboard} in moving arguments}
I have used \cs{chessboard} in tabulars and in moving arguments. It
seems to work fine, so I would say the command is quite robust.

Putting chessboards in the table of contents or the header will in
most case not look very good, so it is sensible to avoid it with
\lstinline+\section[short text]{\chessboard Title}+.
But if you want to do some advices:
\begin{itemize}
\item
Boards in the title and in the table of contents are built at different times during the run, when perhaps
different options and different games are active, so they can look
different if you are not careful.
\item You can't put boards in the bookmarks of a pdf, use
\verb+\texorpdfstring+ from \packagename{hyperref} to provide a
replacement.
\item Some pagestyles puts a command to uppercase around the header.
This affects keys in the optional argument of \cs{chessboard} and
will give error messages about undefined keys. Try to surround the
\cs{chessboard} command with \cs{lowercase}\verb+{...}+.
\end{itemize}



\subsection{Setting the options}

\Pchessboard use the keyval syntax \meta{key}\texttt{=}\meta{value}.

It differs in some respects to other packages with keyval syntax:
\mynobreakpar
\begin{itemize}
\item
There are really \emph{very} much keys.
\item
Some keys don't set properties of a board (like a width) but
\emph{do} things like drawing.
\item
The order of the keys can matter.
\item
Some effects are achieved by using two or more keys after one other.
\end{itemize}

There are keys that need a certain type of argument, e.g.\ a length
or a list of fields.  There are boolean keys that accept only the
values \texttt{=true} and \texttt{=false} where the value
\texttt{=true} can always be omitted. And at last there are keys
that works as \emph{commands}, you can use whatever argument you want
or leave it blank. Don't confound this commands with boolean keys.
E.g.\
\texttt{clearboard}, \texttt{clearboard=hallo} and even
\texttt{clearboard=false} will always clear the board.


I'm struggling permanently with the naming of the keys. Giving them
names that are not to long, but descriptive and a bit systematic
isn't easy. Also it isn't easy to decide if a special effect should
be achieve with one key (which gives a short input) or with a
combination of keys (with is more flexible as it can be used to
implement similar effects but gives longer input). While the package
evolved I sometimes tumbled in problems and inconsistencies of the
current naming scheme and had to reconsider my decisions and
implemented better names or new key combinations. I didn't delete or
disable older, now perhaps obsolate keys in any case, as I wanted to
avoid that older documents breaks.  I also sometimes add a key that
is simply a copy of an existing key only to get a more consistent
naming. So ist quite possible that you can get the same result with
different key combination. For a lot of things there isn't one
correct way -- you can choose the one which suits you more.


It's easy to make mistakes when using a lot of keys. So if you get
mysterious errors check that you don't have forgot a comma between
the keys, that you put braces around lists used as value, that you
didn't use a backslash before a key, that you didn't used a list of
fields when a list of pieces is requested.


\DescribeMacro{\setchessboard} You can set an option either for one
board by using the optional argument of \cs{chessboard} or by using
\cs{setchessboard}\keymarg{} which sets the keys for all following
boards in the same environment/group.

\begin{LTXexample}
Default setting in this Dokumentation:
\setchessboard{
      smallboard,
      showmover=false}
\newchessgame
\chessboard
\end{LTXexample}

Even if they share the same name, keys used in the argument of
\cs{chessboard} are implementated differently than the keys used in
\cs{setchessboard}. They do different things: In the first case the
key gets «executed» while in the second case the \keyvalue pair is
only stored for later use. So it is quite possible that a key works
with \cs{chessboard} but fails because of a bug when used in
\cs{setchessboard} or vice-versa.


Values set by keys in the argument of \cs{chessboard} will if
appropriate overwrite the ones set by \cs{setchessboard}.

The keys belong roughly to two classes: There are the keys that set
one property of the board, e.g.\ the width of a rule or the size.
Such keys always have a default and only the last value set is used,
it overwrites all previous values. Internally I call such keys
«set-keys». In the second class there are keys that can be used more
than once, e.g.\ keys that add a piece or a mark or a color to the
board. I call such keys «fill-keys».\footnote{I did realize only
quite late that using keys not only to set some parameters but also
for the real content is a bit unusual. It is a bit as if one would
use keys for the items of a list or the lines of tabular or the code
in a listing -- in most cases quite a bad idea. But at my opinion it
works fine in this special case because a chessboard is a quite
restricted room with only 64 fields.}


The «set-keys» are always processed first. Inside the classes the
keys are processed in general from «left to right», so later keys can
overwrite values set by earlier keys. This is also true for values
hidden in a \key{style}.






For each «set-key» you will find in this documentation a box like
this:

\Describesetkey{zero}{true|false}{false, zero}{false}


It shows on the left the general description of the possible values,
in the middle one or more examples of correct input, and on the
right the default value.

For each «fill-key» you will find in this documentation a box like
this:

\Describefillkey{clearranks}{list of ranks}{8}

It shows on the left the general description of the possible values
and on the right one or more examples of correct input.



\subsection{Saving optionlists}

\Describefillkey{style}{name}{mystyle}

\DescribeMacro{\storechessboardstyle} With the
\cs{storechessboardstyle}\marg{name}\keymarg{} it is possible to
store a list of \keyvalue-pairs in a «style» and to use this style
instead of the keys themselves.

\begin{LTXexample}
\storechessboardstyle{10x10}{%
 maxfield=j10,
 clearboard,
 startfen=b9,
 restorefen=current,
 labelleftwidth=1.5ex}

\storechessboardstyle{red-yellow}{%
 boardfontencoding=LSBC3,
  whitepiececolor=red,
  blackpiececolor=yellow,
  setfontcolors}

\setchessboard{style=red-yellow}
\newchessgame
\chessboard

\chessboard[style=10x10]
\end{LTXexample}

\minisec{Attention} \cs{storechessboardstyle} and \cs{setchessboard}
only store the \keyvalue pair, they don't expand anything and they
don't do anything with them. So be careful when using commands that
could be redefined later:

\begin{LTXexample}
\def\mylist{Ke1, qe2, kf3}
\setchessboard{setpieces=\mylist}
\def\mylist{Ke1, ra1, ke3}
\chessboard
\end{LTXexample}





\subsection{Naming the board}

In chess the rows of the board are called \emph{ranks} and are
numbered from 1 to 8. The columns are called \emph{files} and are
«numbered» from a to h.\footnote{%
I have some difficulties to remember the english names, so I use the
following mnemonics:
\textbf{F}i\textbf{L}e = co\textbf{L}umn = \textbf{L}inie =
al\textbf{F}abet,
\textbf{R}ank = \textbf{R}ow = \textbf{R}eihe = numbe\textbf{R}ed}

\Pchessboard use this naming conventions for all inputs:
Every time \meta{field} is used in this documentation, you should
give a char from a--z followed by a number.


\subsection{Naming areas of the board}

Rectangular areas are normally described by giving the coordinates
of the left bottom corner and the right upper corner. But when using
the Forsyth Edwards Notation (FEN) chessboards are filled starting
from the left upper corner a8 and then going on to the right and
down to the right bottom corner -- like the normal typesetting
direction. So it is quite natural to use for FEN related areas this
corners. As it would be awkward to have two different ways to
describe areas, I decided to use the fen convention everywhere: Each
area has a
\emph{startfield}, the left upper corner, and a \emph{stopfield},
the right bottom corner. If some area related keys  don't seem to
work, check that you have used the correct corners!


An area can also be given as two fields separated by an hyphen. When
using this input you don't have to worry about the corners, the
package will sort them:\\
\meta{area}=\meta{a corner}-\meta{the opposite corner}.


\DescribeMacro{\printarea} \DescribeMacro{\board} \cs{chessboard}
sets at the start this two command to the current values of the
printarea and the total board as given by the keys \key{zero},
\key{maxfield} and \key{printarea}. You can use this commands in
later keys.


\subsection{FEN: Forsyth-Edwards Notation}\label{sec:FEN}

FEN describes a chess position. It consist of 6 fields, separated by
spaces. The first field represents the placement of the pieces on
the board. The second field represents the active color.  A lower
case «w» is used if White is to move; a lower case «b» is used if
Black is the active player. The third field represents castling
availability. The fourth field is the en passant target square. The
fifth field is a nonnegative integer representing the halfmove
clock. The sixth and last field is a positive integer that gives the
fullmove number.

In the first field the board contents are specified starting with
the eighth rank and ending with the first rank («in typesetting
direction» when the board has the standard orientation). For each
rank, the squares are specified from file a to file h. White pieces
are identified by uppercase piece letters («\texttt{PNBRQK}») and
black pieces are identified by lowercase  piece letters
(«\texttt{pnbrqk}»). Empty squares are represented by the digits one
through eight; the digit used represents the count of contiguous
empty squares along a rank. A solidus character «\texttt{/}» is used
to separate data of adjacent ranks.

\cs{chessboard} handles FEN-input but also only «FEN-like»-input. If
given a complete FEN \cs{chessboard} will store all fields in
commands and evaluate the first field to fill the board. But if they
are less than six fields, \cs{chessboard} will not complain but
simply fill up the missing fields with some default values.

In the first field there don't need to be exact 8 pieces in each rank
and exactly 8 rank descriptions. When there are more pieces than
needed, \cs{chessboard} will ignore them. When there are less pieces
than needed then \cs{chessboard} will leave the remaining fields in
this rank untouched.


The FEN can also be stored in a command. So all \cs{chessboard} will
accept all the following inputs as \meta{FEN}:

{\ttfamily
 rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1\\
 rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR \\
 8qK\\
 10 w - - 0 10}\\
 \verb+\myfen+

\subsection{The main parts of the board}
Each chessboard is build by printing three «layers» on top of each
other:

\minisec{1. The background layer}

This is a pgf-picture that lies under the board. It can be used for
background colors or fancy borders or other background decoration.
%Coloring or drawing something in this layers means adding a color
%command or pgf commands to the code of the picture. How to do this
%will be described in the section about decorating the background.

%\minisec{2. The (four) font layers}
\minisec{2. The main board layer}
This is the main part of the board. It lies above the background
picture. It uses only «normal» \LaTeX\ objects like rules and chars.
Labels, movers and figures are all build together in this layer.

\minisec{3. The mark layer}

This layer is again a pgf picture now over the board. It can be used
to draw crosses, arrows etc on the board.

The sections \ref{startmain} to \ref{stopmain} describe how to
manipulate the main layer. The section \ref{startpgf} describes
how to handle the pgf pictures.






\section{Setting the contents of the board}\label{startmain}

\subsection{The maximum number of fields}
\Describesetkey{maxfield}{field}{j10}{h8}%
Chessboards have 8\texttimes8 fields. So this is the default. If you
want another size you should declare a new right upper corner  with
\key{maxfield=}\meta{Field} e.g., \key{maxfield=j10} for a 10\texttimes10 board.
Don't use this key if you want only to print a partial board, there
is another key to achieve this. Use it to change the maximum size
of a board. All fields and areas you use in other arguments should lie inside this maximum size.

\begin{LTXexample}
\newchessgame
\chessboard[tinyboard,
            maxfield=f6]
\end{LTXexample}


\begin{LTXexample}
\newchessgame
\chessboard[tinyboard,
            maxfield=j10,
            labelleftwidth=2ex]
\end{LTXexample}

\Describesetkey{zero}{true|false}{false}{false}%
I was told that some games numbers the fields starting with 0. So I
added this option. When set to true the rank numbers start with 0 and
a file named Z is added left to the file a.

\begin{LTXexample}
\newchessgame
\chessboard[zero,
            labelbottomformat=\arabic{filelabel},
            addpieces={KZ0, QZ8}]
\end{LTXexample}


\subsection{Filling with \skaksty}
When \skaksty is loaded and there is a running game, \cs{chessboard}
will fill the board with the current position.

\begin{LTXexample}
\newchessgame
\mainline{1. e4 e5 2. Nf3 Nc6 3. Bb5 a6}
\chessboard
\end{LTXexample}

\subsection{Clearing}
\Describefillkey{clearboard}{arbitrary}{}
\Describefillkey{cleararea}{area}{a1-c3}
\Describefillkey{clearareas}{list of areas}{\{a1-c3,g7-h8\}}
\Describefillkey{clearfile}{file}{g}
\Describefillkey{clearfiles}{list of files}{\{g,h\}}
\Describefillkey{clearrank}{rank}{5}
\Describefillkey{clearranks}{list of ranks}{\{8,7\}}
\Describefillkey{clearfield}{field}{c6}
\Describefillkey{clearfields}{list of fields}{\{b5,c6\}}

You can't prevent that \cs{chessboard}  fills up the board with the
running game, so if you need an empty board, you should clear it --
either with the keys mentioned here, or by using one of the  keys
described later that clears the board before adding new pieces.

\begin{LTXexample}
\newchessgame
\mainline{1. e4 e5 2. Nf3 Nc6 3. Bb5 a6}
\def\ranklist{7 ,6 }
\def\cleararea{a1-b2}
\chessboard[clearfiles=g,
            clearranks=\ranklist,
            cleararea=\cleararea,
            clearfields={b5,c6}]
\end{LTXexample}


\subsection{Adding single pieces}

\Describefillkey{setpieces}{List of piece positions}{\{Ke4, Qe1, kd6\}}%
\Describefillkey{addpieces}{List of piece positions}{\{Ke4, Qe1, kd6\}}%

The \key{setpieces} first clears the board and then set the pieces,
the \key{addpieces} only set the new pieces but lets the existing
pieces undisturbed.

\begin{LTXexample}
\newchessgame
\mainline{1. e4 e5 2. Nf3 Nc6 3. Bb5 a6}
\def\piecelist{Ke1,Qd1 , Rg1}
\chessboard[setpieces={ra1, rh8, ke8},
            addpieces=\piecelist]
\end{LTXexample}

\Describefillkey{setwhite}{List of piece positions}{\{Ke4, Qe1, kd6\}}
\Describefillkey{addwhite}{List of piece positions}{\{Ke4, Qe1, kd6\}}
\Describefillkey{setblack}{List of piece positions}{\{Ke4, Qe1, kd6\}}
\Describefillkey{addblack}{List of piece positions}{\{Ke4, Qe1, kd6\}}

It is a bit cumbersome to have to be careful to use uppercase chars
for the white and lowercase chars for the black piece. With the keys
\key{setwhite}, \key{addwhite}, \key{setblack} and \key{addblack}
you can add white and black pieces
without caring about the cases. Like the keys for adding pieces, the
keys starting with \key{set} first clears the board, so if you don't
want to loose all the set pieces, you should use such a key only
once.

\begin{LTXexample}
\def\whitepieces{kc3, nc2, pa2, Pd4}
\chessboard[setwhite=\whitepieces,
            addblack={Kc8,bh7, pa7}]
\end{LTXexample}


\subsection{Adding FEN-positions}


\Describefillkey{setfen}{FEN}{\string\myfen, rnbqk/8/RNBQK}
\Describefillkey{addfen}{FEN}{\string\myfen, rnbqk/8/RNBQK}

With this keys you can add pieces to the board by given a FEN. The
\key{setfen} will clear the board, \key{addfen} will left pieces
outside the fields described by the FEN undisturbed.

\begin{LTXexample}
\newchessgame
\def\myfen{KK//KK}
\chessboard[addfen=\myfen]
\end{LTXexample}

\Describefillkey{startfen}{field}{b7}%

As a default \cs{chessboard} fills the board with a FEN-position
starting at the left upper corner. You can shift this start field
with the key \key{startfen}.

\begin{LTXexample}
\newchessgame
\def\myfen{KK//KK}
\chessboard[startfen=c7, addfen=KK//KK,
            startfen=f3, addfen=\myfen]
\end{LTXexample}


\Describefillkey{startfill}{field}{b7}
\Describefillkey{stopfill}{field}{f2}
\Describefillkey{fillarea}{area}{c2-d4}

With this keys you can restrict the part of the board that is filled
by a FEN. Only the pieces inside the fillarea are set.

\begin{LTXexample}
\newchessgame
\def\myfen{kqrb///KQRB}
\chessboard[setfen=\myfen, startfen=e4, fillarea=f2-g4, addfen=\myfen]
\end{LTXexample}

\subsection{Saving positions}
\Skaksty has the command \cs{storegame}\marg{name} that stores the
FEN of the current game in an internal command, and the command
\cs{savegame}\marg{name} that stores the FEN in a file
\marg{name}\filetype{.fen}

\Pchessboard defines similar keys. The key \key{storefen}=\meta{name}
stores the FEN in an internal command \emph{with the same name} as
used by \cs{storegame}\marg{name}. That means that you can exchange
the games stored by \skaksty and \pchessboard, but it also means that
\pchessboard can \emph{overwrite} games stored with \skaksty. So be
careful!

\medskip
\Describefillkey{storefen}{name}{game1}
\Describefillkey{savefen}{name of file}{game}

\key{storefen} saves the current position as FEN to a internal command.
\key{savefen} saves the current position as FEN to a file.

\medskip
\Describefillkey{startstore}{field}{b7}
\Describefillkey{stopstore}{field}{f2}
\Describefillkey{storearea}{area}{c2-d4}

With this keys you can restrict the area that is stored or saved. But
attention: \skaksty absolutly doesn't like «illegal» FENs that
doesn't describe a full 8\texttimes8 board.

\medskip
\Describefillkey{mover}{w|b}{w}
\Describefillkey{castling}{castling possibilies}{Kq}
\Describefillkey{enpassant}{field|-}{c4}
\Describefillkey{halfmove}{number}{14}
\Describefillkey{fullmove}{number}{20}

With this keys you can set the rest of the FEN-fields. Apart from
\key{mover} the values are only used if you save FENs. The values
are also set, if you use in the argument of a
\key{setfen} or \key{addfen} key complete FENs instead of only the position part.

\subsection{Getting the positions of pieces}

\Describefillkey{getpiecelists}{}{}

New in version 1.5 there is a key, that retrieves the position of the
pieces on the board. For each piece type there is a list called
\cs{cblist}\meta{piece}.\index{cblists=\verb!*+\cblist+\meta{piece}}.
The lists can be used everywhere where a list of fields is expected.
E.g. it is possible to use the lists to highlight all pawns (see
section \ref{sec:drawfields}).

Unlike almost all other commands of \packagename{chessboard} this
commands are saved globally. This makes it possible to use the lists
after the board:

\begin{LTXexample}
 \newchessgame
 \chessboard[getpiecelists]

 White pieces: \king\cblistK, \queen\cblistQ,
               \rook\cblistR, \bishop\cblistB,
               \knight\cblistN, \pawn\cblistP.

 Black pieces: \king\cblistk, \queen\cblistq,
               \rook\cblistr, \bishop\cblistb,
               \knight\cblistn, \pawn\cblistp.
\end{LTXexample}


\subsection{Using saved and stored games}

When you are using \skaksty, you can use the saved games to set the
start position of a game with the \skaksty-commands
\cs{restoregame}\marg{name} (restores the game stored with
\cs{storegame}) and \cs{loadgame}\marg{name} (loads the game saved
with \cs{savegame}). This only works if you have saved the position
of a normal 8\texttimes8-board!



\medskip
\Describefillkey{restorefen}{name}{game1}
\Describefillkey{loadfen}{name}{game}

You can also use the saved games to set positions on \cs{chessboard}.
\key{restorefen} will use games saved with \cs{storegame} and
\key{storefen}, \key{loadfen} will load games saved with
\cs{savegame} and \key{savefen}.




\begin{LTXexample}
\newchessgame
\def\gamename{rank7}
\chessboard[storearea=a7-h7, storefen=\gamename,
            startfen=a5, restorefen=rank7]
\end{LTXexample}
\begin{LTXexample}
\mainline{1. e4 e5}
\savegame{file} % to file.fen
\mainline{2. Nf3 Nf6}
\def\filename{file}
\chessboard[loadfen=\filename]
\end{LTXexample}

\subsection{Restoring the running game}

\cs{chessboard} saves the running game at the start under the name
«current».

\begin{LTXexample}
\newchessgame
\mainline{1. e4 e5 2. Nf3 Nc6 3. Bb5 a6}

\chessboard[maxfield=j10,
            clearboard,
            startfen=b9,
            restorefen=current]
\end{LTXexample}


\subsection{Changing the input language}

\Describefillkey{language}{name}{german}
\DescribeMacro{\cbDefineLanguage}
\DescribeMacro{\cbDefineTranslation} With this key you can change the
language used for input of pieces. The key doesn't affect the input
language of \skaksty. It also doesn't affect the language of saved
and restored games. \cs{chessboard} will always switch to english in
this cases! Up to now only german translations are built in (I don't
know how chess pieces are called in other languages), but it isn't
difficult to add other languages. The code for german should be quite
selfexplanatory:

\begin{lstlisting}
\cbDefineLanguage{german}%
\cbDefineTranslation{german}{K}{K}%
\cbDefineTranslation{german}{Q}{D}%
\cbDefineTranslation{german}{R}{T}%
\cbDefineTranslation{german}{B}{L}%
\cbDefineTranslation{german}{N}{S}%
\cbDefineTranslation{german}{P}{B}%
\cbDefineTranslation{german}{k}{k}%
\cbDefineTranslation{german}{q}{d}%
\cbDefineTranslation{german}{r}{t}%
\cbDefineTranslation{german}{b}{l}%
\cbDefineTranslation{german}{n}{s}%
\cbDefineTranslation{german}{p}{b}%
\end{lstlisting}

You can mix the languages in the input (but I don't think you should
do it, it can get quite confusing, it's better to stick to one
language).

\begin{LTXexample}
\def\whitepieces{lc4, sg1}
\chessboard[setpieces={qd8, ra8, bh8},
            language=german,
            addpieces={Da1, Th4},
            addwhite=\whitepieces,
            addblack={Bb7}]
\end{LTXexample}

\section{The look of the board}

\subsection{Units for  lengths}

For many of the following commands you will have to enter a length.
This can be an absolute length like 1in, 2cm, 4pt. But often you will
prefer a relative length. In most cases the font related length 1ex,
1em and \cs{baselineskip} will be the same as a half of the square
width, the width of the square and the total height of a
square.\footnote{I learned on the hard way that you shouldn't rely
that fonts sets em and ex correctly, e.g.\ the font
\chessfontname{skak} doesn't do it and so the units default to zero
which can be quite confusing. So I decided to set the fontdimen
values explicitly.} The package uses internally the three lengths
offered by \chessfss\ -- \cs{len@cfss@squarewidth},
\cs{len@cfss@squaretotalheight} and \cs{len@cfss@squaredepth} --. In
most cases they will only give inside \cs{chessboard} (locally) the
correct sizes, but if you use the key \key{psset} they are set
globally.


\subsection{Some words about box sizes}

In \TeX\ almost everything is either a box (a character box, a line
box, a page box, a box with a tabular in it~\ldots) or a space. And
larger objects are build by putting boxes and spaces in a surrounding
box. In the real world a box has always to be larger as its content.
In the virtual
\TeX-world a lot of magic is possible: The content can be much larger
than the surrounding box or even be partly or completely outside the
surrounding box.


\begin{LTXexample}
x% shows the current line
\fbox{% a box
\raisebox{3ex}[0pt][0pt]{%
    \makebox[0pt]{%
    large content outside the box}}}%
x% and here something after the fbox
\end{LTXexample}

So the outside size of a box can be quite different from the inside
size. And the outside baseline of a box can be at quite different
place as the inside baseline.

In the concrete case of \cs{chessboard} the outside size of the board
is determined through the size of the font, the fields shown and the
margin. All other things like border, label, highlighting, mover will
not affect this size. The baseline of a chess board is always at the
bottom of the bottom rank. Margins, labels or borders or anything
else will not change this. If you want to move the baseline you will
have to use a \cs{raisebox}.


\subsection{Margins}

The «outside size» («the bounding box») of a chess board is the size
of the printed fields plus a margin.

\medskip
\Describesetkey{marginleftwidth}{length}{1em}{1em}
\Describesetkey{marginrightwidth}{length}{1em}{1em}\goodbreak
\Describesetkey{margintopwidth}{length}{1em}{1em}\goodbreak
\Describesetkey{marginbottomwidth}{length}{1em}{1em}\goodbreak
\Describesetkey{hmarginwidth}{length}{1em}{1em}\goodbreak
\Describesetkey{vmarginwidth}{length}{1em}{1em}\goodbreak
\Describesetkey{marginwidth}{length}{1em}{1em}


With this keys you can set and change the thickness of the margin. As
you can see you can set each margin differently, but there are also
keys to set more than one margin at one time.




\medskip
\Describesetkey{marginleft}{true|false}{}{true}
\Describesetkey{marginright}{true|false}{false}{true}\goodbreak
\Describesetkey{margintop}{true|false}{}{true}\goodbreak
\Describesetkey{marginbottom}{true|false}{}{true}\goodbreak
\Describesetkey{hmargin}{true|false}{}{true}\goodbreak
\Describesetkey{vmargin}{true|false}{}{true}\goodbreak
\Describesetkey{margin}{true|false}{}{true}

You can disable the margin either by setting its width to 0pt or with
this boolean keys.

\goodbreak
\begin{LTXexample}
x\fbox{\chessboard[printarea=a1-a1,
                   marginwidth=0pt]}

x\fbox{\chessboard[printarea=a1-a1,
                  marginwidth=0.5cm]}

x\fbox{\chessboard[printarea=a1-a1,
                  marginwidth=0.5cm,
                  margin=false]}
\end{LTXexample}

\goodbreak
\subsection{Borders}

The borders are made with rules. You will perhaps notice that on
screen the edges looks like as if they don't contact properly. This
is a  problem of the rather bad resolution of a screen. When you zoom
in you can see that the edges are fine. If this bothers you, you can
try the fancy borders made with the pgf-commands decribed later. As
they are made with one line, they seem to have better edges -- but
you can't color them individually and it isn't yet possible to
disable the borders of single sides.

\Describesetkey{borderleftwidth}{length}{1em}{0.04em}
\Describesetkey{borderrightwidth}{length}{1em}{0.04em}
\Describesetkey{bordertopwidth}{length}{1em}{0.04em}
\Describesetkey{borderbottomwidth}{length}{1em}{0.04em}
\Describesetkey{hborderwidth}{length}{1em}{0.04em}
\Describesetkey{vborderwidth}{length}{1em}{0.04em}
\Describesetkey{borderwidth}{length}{1em}{0.04em}


With this keys you can set and change the thickness of the border.
The border doesn't change the bounding box of the board. If there
isn't an adequate margin it will stick outside!

\medskip
\Describesetkey{borderleft}{true|false}{}{true}
\Describesetkey{borderright}{true|false}{false}{true}
\Describesetkey{bordertop}{true|false}{}{true}
\Describesetkey{borderbottom}{true|false}{}{true}
\Describesetkey{hborder}{true|false}{}{true}
\Describesetkey{vborder}{true|false}{}{true}
\Describesetkey{border}{true|false}{}{true}

You can disable the border either by setting its width to 0pt or with
this boolean keys.


\medskip
\Describesetkey{borderleftcolor}{color}{red}{black}
\Describesetkey{borderrightcolor}{color}{red}{black}
\Describesetkey{bordertopcolor}{color}{red}{black}
\Describesetkey{borderbottomcolor}{color}{red}{black}
\Describesetkey{hbordercolor}{color}{red}{black}
\Describesetkey{vbordercolor}{color}{red}{black}
\Describesetkey{bordercolor}{color}{red}{black}

With this keys you can set and change the color of the border.

{\bfseries You must load a color package like \packagename{xcolor} or
\packagename{color} to be able to use colors!}\footnote{I must
correct myself: the pgf-package will load \packagename{xcolor}, so
you should load a color package only if you want to use it with other
options}

\begin{LTXexample}
\raggedright
some text above the board\\
the board will overwrite this!\\
left%
\def\borderwidth{12pt}
\def\mycolor{red!50}
\chessboard[tinyboard,
            marginleftwidth=1em,
            margintopwidth=0pt,
            bordertopwidth=\borderwidth,
            borderleftcolor=\mycolor,
            bordertopcolor=yellow!25,
            marginright=false]%
right\\
text below the board
\end{LTXexample}


\subsection{The size of the boardfont}

\Describesetkey{boardfontsize}{length}{10pt}{20pt}
\Describesetkey{fontsize}{length}{10pt}{20pt}
\Describesetkey{tinyboard}{arbitrary}{}{}
\Describesetkey{smallboard}{arbitrary}{}{}
\Describesetkey{normalboard}{arbitrary}{}{default}
\Describesetkey{largeboard}{arbitrary}{}{}

With this keys you can change the size of the board font. The keys
\key{tinyboard} etc.\ gives the same sizes as the similar commands
\cs{tinyboard} of \skaksty, they also change the size of the font of
the labels.

You can also change the size of the board font with the commands
described in the documentation of \chessfss. But you should be aware
that the keys used in \cs{setchessboard} or \cs{chessboard} will
always win over the commands from \chessfss.


\subsection{Changing the boardfont}

Instead of using the keys described below you can also change the
board font with the commands described in the documentation of
\chessfss. But you should be aware that the keys used in
\cs{setchessboard} or \cs{chessboard} will always win over the
commands from \chessfss.


\Describesetkey{boardfontfamily}{family name}{maya}{skak/skaknew}

With the above key you can change the board font by setting the
family. This works quite similar as for text font where you can
switch e.g. from times to helvetica by changing the font family. The
font families
\chessfontname{skak} and \chessfontname{skaknew} will work from the
start. You must install other families before being able to use them!

\begin{LTXexample}
\chessboard[boardfontfamily=maya]
\end{LTXexample}

\goodbreak
\Describesetkey{boardfontseries}{series name}{b}{}

Setting the series  to bold (b) only works for a quite small set of
fonts which have the chars in two weights. But to tell the truth: I
don't find the result very satisfying.


There are no keys to change the shape of the font as I really don't
know what an italic (\cs{itshape}) or slanted board font should be.
(And I never saw such a font).


\begin{LTXexample}
\newchessgame
\chessboard[boardfontfamily=millennia,
            tinyboard]
\chessboard[boardfontfamily=millennia,
            boardfontseries=b,
            tinyboard]

\end{LTXexample}



\Describesetkey{boardfontencoding}{encoding}{LSB1}{LSB}


With this key you can change the encoding of the board font. While in
a normal document you probably seldom or never need to bother with
encodings they are highly useful in connection chess board if you
want to add colors to the chars on the board. When using other
encodings that the standard LSB the chars on the board are composed
with special chars that allows to color e.g. the lines of the black
field differently to the figure on the field. I will come back to
this when I describe how to color the chars.

There are simple encodings called LSB, LSB1, LSB2 \ldots, which works
with almost every font family. And there are special encodings LSBC1,
LSBC2 \ldots, which works only with professional chess fonts with
special chars. Happily the default board font, the  free font
\chessfontname{skaknew}, is such a professional chess font.



If you want to use one of the extended encodings LSB1, LSB2, etc and
LSBC1, LSBC2 etc you must load the definition files e.g.\ with
\lstinline+\usepackage[LSB1,T1]{fontenc}+. You find more
informations in the documentation of \chessfss.




\subsection{Coloring and emphasizing the board chars}
\subsubsection{In short}

\begin{itemize}

\item Coloring the board or parts of the chars is a two step process:

First you set the colors you want, then you apply them.

\item
Colors can be applied to the whole board (to set the default colors
of the white and black pieces and fields). This done with the keys
\key{setfontcolors} and \key{addfontcolors}.

\item Colors can be applied to part of the board together with other commands like \cs{bfseries}
 (e.g. to emphasize special fields or ranks)
by first enabling color emphasing with the key \key{coloremph} and
then by setting the area or field that should get the colors with
e.g. the key \key{empharea}.


\end{itemize}



\subsubsection{Introduction: About composed chars and encodings}
In simple chess fonts each field with and without a figure on it is
\emph{one} char. You can color such a char but -- as in the case of normal chars -- only
in one color:

\textcolor{red}{\Large A \BlackKingOnBlack}

This is certainly not very satisfying. You probably would like to be
able to color the white figures diffently from the black ones, and
the black fields in a third color.

To be able to do this, one has to use more than one char to build a
field and to print them on top of each other. Look e.g. at this
example:

 \colorbox{yellow}{\Chess
 \makebox[0pt][l]{\color{blue}\BlackEmptySquare}%
 \color{green}T%
 \color{red}K}

It is build by putting four different objects on top of each other:

At start there is a standard yellow colorbox

\colorbox{yellow}{\Chess\phantom{\BlackEmptySquare}}

Above there is a black empty square colored in blue:

{\Chess\color{blue}\BlackEmptySquare}

Then comes a solid, filled and colored char with the same shape as
the king:

{\Chess\color{green}T}

At last there is the char for the king:

{\Chess\color{red}K}

So

{\Chess\colorbox{yellow}{\phantom{\BlackEmptySquare}}\Plus
 {\color{blue}\BlackEmptySquare}\Plus
 {\color{green}T\phantom{\BlackEmptySquare}}\Plus
 {\color{red}K}\Equal
 \colorbox{yellow}{%
 \makebox[0pt][l]{\color{blue}\BlackEmptySquare}%
 \color{green}T%
 \color{red}K}}


There are a lot of other possibilities to compose the board fields.
Some more «poor man's» compositions that use only chars present in
every chess font, other that need special masking chars which only
special chess fonts provide.

{\bfseries Each such construction is connected to a font encoding: By
changing the encoding of the board font you change the rules that
compose the board chars and so you change also the options to color
the chars.}


In \chessfss I have defined a bundle of such «construction rules»
(=encodings) to use and color composed board chars. As it would be a
strain if each of this construction rules would let to a different
set of commands to color the chars I had to systemize the
construction rules. For this I have divided the possible individual
components of a composed chars in four logical layers and assign to
each layer generic color commands that are used in the definition of
the composed chars and can be used to color the components. The four
layers are named fieldmask, field, piecemask and piece.

As an example table~\ref{tab:encLSBC3} shows a tabular that
demonstrates how the encoding LSBC3 is built. As you can see the
chars are built by putting up three or four chars on top of each
other. (The green and yellow colors are not the default settings!).
The documentation of
\chessfss shows the other encodings.
%The colors have been set with the
%\chessfss-command
%\begin{lstlisting}
%\setboardfontcolors{
%               whitepiece=red!70,
%               blackfield=green,
%               whiteonwhitepiecemask=yellow}
%\end{lstlisting}



\begin{table}
\setboardfontcolors{whitepiece=red!70,
blackfield=green,whiteonwhitepiecemask=yellow}%

\caption{The contruction rules of encoding LSBC3}\label{tab:encLSBC3}

%\medskip
\showchessboardencoding{LSBC3}


\end{table}

Table~\ref{tab:intcom} shows the internal commands used to color the
different part of a composed char. You will probably never need them
but they will give you an idea what can be colored (I hope that is
clear that it makes only sense to change the colors of layers that
are used in the actual encoding -- you can't color an solid fieldmask
that isn't there).

%\begin{minipage}[t]{\textwidth}
\begin{table}
\caption{The internal color commands}\label{tab:intcom}

\begin{tabular}[t]{@{}lll}
\itshape layer  & \itshape internal color commands & \itshape default definition\\\hline\\

fieldmask       & \cs{cfss@whitefieldmaskcolor}   &\cs{color}\ttfamily\{white\}\\
                & \cs{cfss@blackfieldmaskcolor}   &\cs{color}\ttfamily\{gray\}\\
field           & \cs{cfss@whitefieldcolor}       &\ttfamily\{\}\\
                & \cs{cfss@blackfieldcolor}       &\ttfamily\{\}\\
piecemask       & \cs{cfss@whiteonwhitepiecemaskcolor}&\cs{color}\ttfamily\{white\}\\
                & \cs{cfss@whiteonblackpiecemaskcolor}&\cs{color}\ttfamily\{white\}\\
                & \cs{cfss@blackonwhitepiecemaskcolor}&\cs{color}\ttfamily\{white\}\\
                & \cs{cfss@blackonblackpiecemaskcolor}&\cs{color}\ttfamily\{white\}\\
piece           & \cs{cfss@whitepiececolor}       &\ttfamily\{\}\\
                & \cs{cfss@blackpiececolor}       &\ttfamily\{\} \\
\end{tabular}


\end{table}
%\end{minipage}


I would like to draw your attention to two things:

\begin{enumerate}
\item The field-layers distinguish between black and white field
while the piece layer distinguish between black and white pieces and
the piecemask offers all possible combinations.

\item
The fieldmask and the piecemask are colored by default and so they
will overwrite or block out external colors from \cs{colorbox} or
\cs{textcolor} commands:

\begin{LTXexample}
%Uses commands from chessfss.sty
\setboardfontencoding{LSBC3}%
\setboardfontsize{2cm}

\colorbox{yellow}{%
 \textcolor{red}{\WhiteKingOnWhite}}
%
\setboardfontcolors{
 whitefieldmask=yellow,
 whiteonwhitepiecemask=red}
\colorbox{yellow}{%
 \textcolor{red}{\WhiteKingOnWhite}}
\end{LTXexample}

\end{enumerate}





So coloring the board is not really difficult: one must only redefine
the internal commands mentioned above to the wanted color. That's
what the \cs{setboardfontcolors} command of \chessfss does and it
will work fine with chessboard.

Naturally I also wanted to add keys for \cs{chessboard} and
\cs{setchessboard} to change the colors. This is a bit more
complicated because I wanted not only to be able to change the colors
of the whole board but also of single fields or areas. And I had also
to add keys to change the color in the two pgf pictures. Finding
names for all this keys and effects wasn't easy. And I hope that it
isn't to confusing.

\subsubsection{Setting the default colors of the board}

\Describefillkey{clearfontcolors}{arbitrary}{}

When you set with the following keys a color for one of the font
layers, \cs{chessboard} adds simply the color definition to an
internal command (the «font color stack»). When you use later a key
to apply the colors to the board or an area this internal command is
inserted at the start of the board or the fields of the area. The
internal command can get quite long if you set a lot of colors. With
the key \key{clearfontcolors} you can empty the internal command
(this will not destroy the colors that you have already applied).




\Describefillkey{whitefieldmaskcolor}{color}{red!50}
\Describefillkey{blackfieldmaskcolor}{color}{red!50}
\Describefillkey{fieldmaskcolor}{color}{red!50}\goodbreak

\Describefillkey{whitefieldcolor}{color}{red!50}
\Describefillkey{blackfieldcolor}{color}{red!50}
\Describefillkey{fieldcolor}{color}{red!50}\goodbreak

\Describefillkey{whiteonwhitepiecemaskcolor}{color}{red!50}\goodbreak
\Describefillkey{whiteonblackpiecemaskcolor}{color}{red!50}
\Describefillkey{blackonwhitepiecemaskcolor}{color}{red!50}
\Describefillkey{blackonblackpiecemaskcolor}{color}{red!50}\goodbreak
\Describefillkey{whitepiecemaskcolor}{color}{red!50}
\Describefillkey{blackpiecemaskcolor}{color}{red!50}\goodbreak
\Describefillkey{onwhitepiecemaskcolor}{color}{red!50}
\Describefillkey{onblackpiecemaskcolor}{color}{red!50}
\Describefillkey{piecemaskcolor}{color}{red!50}\goodbreak

\Describefillkey{whitepiececolor}{color}{red!50}
\Describefillkey{blackpiececolor}{color}{red!50}
\Describefillkey{piececolor}{color}{red!50}


With this keys you set the colors of the different parts of a
composed char. The colors are saved to an internal stack. A key like
\key{whitepiececolor} saves the color for one of the layer color
commands. \key{piecemaskcolor} will set the color for all four
piecemasks in one go.




The keys \obsoletekey{colorwhite} and \obsoletekey{colorblack} of the
previous version of this package are copies of the keys
\key{whitepiececolor} and \key{blackpiececolor}.



\subsubsection{Applying the colors to the whole board}

\Describefillkey{setfontcolors}{arbitrary}{}
\Describefillkey{addfontcolors}{arbitrary}{}

This keys will put the «font color stack» in a command that is
executed at the start of the board. So the colors will affect any
fields that don't get individual colors with the command described in
the next subsection.
\key{setfontcolors} will replace any font colors that have been set
before, \key{addfontcolors} will add the new colors to perhaps
already existing ones.

\begin{LTXexample}
\def\mycolor{yellow!50}
\setchessboard{
 boardfontencoding=LSBC3,
 piecemaskcolor=\mycolor,
 setfontcolors}

\chessboard[tinyboard]

\def\mycolor{green}% will set the
% piecemask to green:
\chessboard[tinyboard,
            whitepiececolor=red,
            blackpiececolor=blue,
            fieldcolor=white,
            addfontcolors]
\end{LTXexample}

\subsubsection{Emphasising and coloring individual areas}


\Describefillkey{emphstyle}{commands}{\cs{bfseries}}

With this key you can set a command that should be applied to an
area. The commands can be whatever you want, (it is a good idea not
use something that takes up some space). In my opinion the only
senseful commands are \cs{color} and -- for the few fonts that have a
bold boardfont -- \cs{bfseries}. You can use the key e.g. for simple
coloring.

\begin{LTXexample}
\newchessgame
\def\empharea{ h8-f4 }
\chessboard[emphstyle=\color{red},
            empharea=\empharea]
\end{LTXexample}

You can't color with \key{emphstyle} the fieldmask and the piecemask
of chars as they have a default color that takes precedence.

\Describefillkey{coloremph}{true|false}{}
With this key you enable or disable color emphasising. When set to
true, font colors set earlier will be added to emphstyle and so used
to color the area. The colors are added after the commands of the key
\key{emphstyle} and so will eventually overwrite them.
This allows more complicated coloring:

\begin{LTXexample}
\newchessgame
\def\empharea{ h8-f1 }
\chessboard[boardfontencoding=LSBC3,
            whiteonwhitepiecemaskcolor=green,
            whitepiececolor=red,
            blackpiececolor=blue,
            emphstyle=\color{yellow},
            %doesn't affect the default white color
            %of the piecemask
            empharea=a1-c8,
            coloremph,
            empharea=\empharea]
\end{LTXexample}





\goodbreak

\Describefillkey{coloremphstyle}{commands}{\cs{bfseries}}

This key combines the keys \key{coloremph} and \key{emphstyle}.



\goodbreak
\Describefillkey{emphboard}{arbitrary}{}
\Describefillkey{empharea}{area}{a1-c3}
\Describefillkey{emphareas}{list of areas}{\{f6-h7,a1-c3\}}
\Describefillkey{emphfile}{file}{a}
\Describefillkey{emphfiles}{list of files}{\{g,h\}}
\Describefillkey{emphrank}{rank}{5}
\Describefillkey{emphranks}{list of ranks}{\{8,7\}}
\Describefillkey{emphfield}{field}{a3}
\Describefillkey{emphfields}{list of fields}{\{b5,c6\}}

This keys apply the emphasize commands and eventually the colors to
the area they define.

\begin{LTXexample}
\def\empharea{ h8-f4 }
\chessboard[boardfontfamily=millennia,
            coloremphstyle=\bfseries,
            empharea=\empharea,
            whitepiececolor=red,
            emphrank=1,
            whitepiececolor=blue,
            emphareas={a2-a2, c1-e2},
            coloremph=false,
            emphfield=f2]
\end{LTXexample}


\begin{LTXexample}
\chessboard[boardfontencoding=LSBC3,
            coloremph,
            emphfield={f1},
            whitepiececolor=red,
            emphranks={1},
            whitepiececolor=blue,
            emphfields=a2,
            blackpiececolor=green,
            empharea=a8-c7]
\end{LTXexample}


The key \obsoletekey{colorpieces} doesn't work anymore, it will issue
only a warning. Use
\key{emphfields} instead.


\subsubsection{Transparency/opacity}

Pgf has commands to set the opacity of a color. This works only for
some drivers and output formats (e.g.\ with pdf\LaTeX), but it also
works outside pgf pictures in running text. The main drawbacks are
that the opacity settings gets lost at a pagebreak and that
\TeX-groups and boxes are not respected, that means that you must
reset the opacity explicitly. It is possible to add to boxes that use
internally
\cs{color@begingroup}/""\cs{color@endgroup}\footnote{Almost all
\LaTeX-boxes but not e.g.\ \cs{mbox} and \cs{makebox} when used
without optional argument.} some code that resets the opacity outside
the box to 1. As \cs{chessboard} uses only such safe boxes it is
possible to smuggle transparency in parts of the composed chars. But
the whole is not very safe so use it at your own risk.

\begin{LTXexample}
\makebox[0pt][l]{\rule{12em}{10pt}}%
\color{red}%
\rule{1em}{14pt} ABC
\pgfsetfillopacity{0.5}%
\rule{1em}{14pt} ABC
\pgfsetfillopacity{1}%
\rule{1em}{14pt} ABC

\makeatletter
\let\color@endgroupORI\color@endgroup
\def\color@endgroup
 {\color@endgroupORI\pgfsetfillopacity{1}}

\chessboard[boardfontencoding=LSBC4,
    whitepiececolor=red,
    blackpiececolor=blue,
    setfontcolors]

\def\cfss@whitepiececolor
 {\pgfsetfillopacity{0.5}\color{red}}
\def\cfss@blackpiececolor
 {\pgfsetfillopacity{0.5}\color{blue}}

\chessboard[boardfontencoding=LSBC4]

\end{LTXexample}


\subsection{Labels}

In \chessfss I used the name sidefont for the label. I did it mostly
because I didn't dare to use the command \cs{labelfont}, I was quite
sure that somewhere in the packages for \LaTeX\ someone else had
already used this name. When using keys name clash are not a problem
as internally a unique prefix is used, so I decided to use names
starting with «label» in this package.

\medskip
\Describesetkey{labelleft}{true|false}{}{true}
\Describesetkey{labelright}{true|false}{false}{false}\goodbreak
\Describesetkey{labeltop}{true|false}{}{false}\goodbreak
\Describesetkey{labelbottom}{true|false}{}{true}\goodbreak
\Describesetkey{hlabel}{true|false}{}{false}\goodbreak
\Describesetkey{vlabel}{true|false}{}{false}\goodbreak
\Describesetkey{label}{true|false}{}{false}

You can disable the labels with this boolean keys.

\Describesetkey{labelleftwidth}{length}{1em}{1ex}
\Describesetkey{labelrightwidth}{length}{1em}{1ex}
\Describesetkey{hlabelwidth}{length}{1em}{1ex}

The labels on the left side are set raggedleft, the ones on the right
side raggedright at the distance given by the keys.  This width don't
change the size of the board! The top and bottom labels are centered.

\begin{LTXexample}
\def\mywidth{1em}
left%
\chessboard[maxfield=j10,
            tinyboard,
            printarea=d5-j10,
            hmarginwidth=1em,
            hlabelwidth=\mywidth,
            hlabel,
            vlabel=false]%
right
\end{LTXexample}

\Describesetkey{labelleftlift}{length}{1em}{0.35em}
\Describesetkey{labelrightlift}{length}{1em}{0.35em}
\Describesetkey{hlabellift}{length}{1em}{0.35em}

With this keys you can move up and down the left and right labels.




\medskip
\Describesetkey{labeltoplift}{length}{1em}{1.1\cs{baselineskip}}
\Describesetkey{labelbottomlift}{length}{1em}{0.2\cs{baselineskip}}
\Describesetkey{vlabellift}{length}{1em}{--}

With this keys you can set the distance of the baselines of the top
and bottom labels from the board sides. \cs{baselineskip}, ex and em
refer in this keys \emph{not} to the size of the board, but to the
size of the label font -- I thought this would be easier to handle.

\medskip
\Describesetkey{labelleftfont}{fontcommand}{\cs{itshape}}{\cs{sfdefault}}
\Describesetkey{labelrightfont}{fontcommand}{\cs{itshape}}{\cs{sfdefault}}\goodbreak
\Describesetkey{labeltopfont}{fontcommand}{\cs{itshape}}{\cs{sfdefault}}\goodbreak
\Describesetkey{labelbottomfont}{fontcommand}{\cs{itshape}}{\cs{sfdefault}}\goodbreak
\Describesetkey{hlabelfont}{fontcommand}{\cs{itshape}}{\cs{sfdefault}}\goodbreak
\Describesetkey{vlabelfont}{fontcommand}{\cs{itshape}}{\cs{sfdefault}}\goodbreak
\Describesetkey{labelfont}{fontcommand}{\cs{itshape}}{\cs{sfdefault}}

With this keys you can set the font used by the labels. As a default
(this is set in \chessfss) the sans serif font of the document is
used. You can also use the \chessfss commands to change the font.


\Describesetkey{labelfontsize}{length}{0.5em}{10pt}

This key sets the font size of the label. The default value is set by
the key \key{normalboard}.  There aren't keys to set the size of each
label separatly. If you really need different sizes, use the key
\key{hlabelfont} etc (and be careful when using font relative sizes).

\begin{LTXexample}
\setchessboard{labelfont=\bfseries}
\setsidefontfamily{ptm} % from chessfss.sty
\chessboard[labelfontsize=6pt]
\end{LTXexample}


\Describesetkey{labelleftformat}{commands}{}{\arabic{ranklabel}}
\Describesetkey{labelrightformat}{commands}{}{\arabic{ranklabel}}\goodbreak
\Describesetkey{labeltopformat}{commands}{}{\alph{filelabel}}\goodbreak
\Describesetkey{labelbottomformat}{commands}{}{\alph{filelabel}}\goodbreak
\Describesetkey{hlabelformat}{commands}{}{\arabic{ranklabel}}\goodbreak
\Describesetkey{vlabelformat}{commands}{}{\alph{filelabel}}\goodbreak
\Describesetkey{labelformat}{commands}{}{}

With this keys you can control how the number of the files and ranks
are printed. \texttt{ranklabel} and \texttt{filelabel} are counters
that contain the current rank and file. You can use them freely (even
change if you want).

The commands can be a lot of things. You can e.g.\ use them to color
the labels or to move the labels around. When you use commands with
optional arguments you must put braces around the value of the key!

\begin{LTXexample}
\def\mylabelformat{%
 {\makebox[0pt][r]{%
   \ifthenelse{\isodd{\value{ranklabel}}}
     {\color{red}\roman{ranklabel}}
     {\color{green}\roman{ranklabel}}}}}

\chessboard[hlabelformat=\mylabelformat,
    vlabelformat=\arabic{filelabel}\hfill]
\end{LTXexample}


\subsection{The mover}
The «mover» is a sign at the side of the board that indicates which
player is to move. \cs{chessboard} gets this information either from
the FEN (if it contains the information as is the case when the FEN
comes from \skaksty), or through the following key:

\Describefillkey{mover}{w|b}{b}

You can use this key more than once, e.g.\ to control the mover
field in the FEN that you save, the last value is used for the
print.

\medskip
\Describesetkey{showmover}{true|false}{false}{true}

This key switch the print of  the mover sign on and off.

\begin{LTXexample}
\chessboard[smallboard,showmover=true]
\end{LTXexample}


\Describesetkey{moversize}{length}{1ex}{1em}

This key sets the fontsize of the mover. It only has an effect if
the mover sign comes from a font -- and if the definition doesn't
change the fontsize.

The value is saved in an inner command with the name
\cs{board@val@moversize}, you can use this command in your own mover
definitions.

\medskip
\Describesetkey{moverlift}{length}{1ex}{0pt}
\Describesetkey{movertoplift}{length}{1ex}{0pt}
\Describesetkey{moverbottomlift}{length}{1ex}{0pt}

With this keys you can move the mover vertically. Positive values
will move the bottom mover up and the top mover down\footnote{This
isn't perhaps the correct meaning of the word «lift» but I guessed
that user expect the mover to move either both towards or apart.}.
0pt will align the bottom mover along the baseline, and the top of
the upper mover along the upper side of the board.


\begin{LTXexample}[width=0.55\textwidth]
\setchessboard{showmover}%
\chessboard[tinyboard, setfen=k1K b]%
\chessboard[tinyboard, setfen=k1K w]


\chessboard[tinyboard, setfen=k1K b,
            moverlift=-1ex]%
\chessboard[tinyboard, setfen=k1K w,
            moverlift=-1ex]
\end{LTXexample}


\Describesetkey{movershift}{length}{1ex}{1ex}
\Describesetkey{movertopshift}{length}{1ex}{1ex}
\Describesetkey{moverbottomshift}{length}{1ex}{1ex}

With this keys you can shift the mover horizontaly. If you want to
put it on the left side of the board, use a large negative value.

\begin{LTXexample}[width=0.55\textwidth]
\setchessboard{showmover}%
\chessboard[setfen=k1K b,
            movershift=-9em,
            labelleft=false,
            labelright]%
\end{LTXexample}

\Describesetkey{moverstyle}{typename}{squarearrow}{square}

With this key you can change the mover type. Up to now four types
are defined, but you can define your own one if you want.



\begin{LTXexample}[width=0.55\textwidth]
\setchessboard{showmover}%
\chessboard[tinyboard, setfen=k1K b,
            moverstyle=circle]%
\chessboard[tinyboard, setfen=k1K w,
            moverstyle=triangle]

%This moverstyle needs pifont and graphics!
\chessboard[tinyboard, setfen=k1K b,
            moverstyle=squarearrow]%
%This will give a warning and square is used:
\chessboard[tinyboard, setfen=k1K w,
            moverstyle=unknown]
\end{LTXexample}


\DescribeMacro{\cbDefineMoverStyle} With this command you can define
your own moverstyle. \cs{cbDefineMoverStyle} takes six arguments (the
first is optional). The first mandatory argument is the name of the
style, the following arguments get the definitions for the mover for
black and white for normal and inverse board.

\cs{cbDefineMoverStyle}\oarg{commands}\marg{name of style}\marg{white
top}\newline%
\hspace*{4em}\marg{white bottom}\marg{black top}\marg{black bottom}.

The listing shows the definition of the mover «squarearrow»:



\begin{lstlisting}
\cbDefineMoverStyle%
 %#1: optional, can be used e.g. for checks
 %#2=style name, #3=white top, #4=white bottom,
 %#5=black top, #6=black bottom
    [\@ifundefined{rotatebox}%
      {\PackageError{chessboard}%
        {You must load the package graphics or graphicx
         if you want to use the mover style squarearrow}{}}%
      {}%
     \@ifundefined{ding}%
      {\PackageError{chessboard}%
        {You must load the package pifont
         if you want to use the mover style squarearrow}{}}%
      {}]
    {squarearrow}% #2
    {\rotatebox{-90}{$\square$\,\ding{222}}}%
    {\rotatebox{90}{$\square$\,\ding{222}}}%
    {\rotatebox{-90}{$\blacksquare$\,\ding{222}}}%
    {\rotatebox{90}{$\blacksquare$\,\ding{222}}}%
\end{lstlisting}




\section{Controlling the printing}\label{stopmain}
\subsection{Printing partial boards}
\Describesetkey{print}{true|false}{false}{true}

With this key you can disable the printing of the board. This is
useful if you want to use \cs{chessboard} to save FEN.



\begin{LTXexample}
left\chessboard[print=false]right
\end{LTXexample}


\Describefillkey{startprint}{field}{b7}
\Describefillkey{stopprint}{field}{f2}
\Describefillkey{printarea}{area}{c2-d4}


With this keys you can define the  area that gets printed.

\begin{LTXexample}
\newchessgame
left\chessboard[printarea=a4-d8]right
\end{LTXexample}


\subsection{Rotating the board}
\Describesetkey{inverse}{true|false}{false}{false}

With this key you can print the black side at the bottom. It won't
switch labels or margins etc.

\begin{LTXexample}
\newchessgame
left\chessboard[inverse]right
\end{LTXexample}


\subsection{Hiding the content of the board}

\subsubsection{Hiding the content of fields}

\Describefillkey{hideboard}{arbitrary}{}
\Describefillkey{hidearea}{area}{a1-c3}
\Describefillkey{hideareas}{list of areas}{\{a1-c3,g7-h8\}}
\Describefillkey{hidefile}{file}{g}
\Describefillkey{hidefiles}{list of files}{\{g,h\}}\goodbreak
\Describefillkey{hiderank}{rank}{5}
\Describefillkey{hideranks}{list of ranks}{\{8,7\}}
\Describefillkey{hidefield}{field}{c6}
\Describefillkey{hidefields}{list of fields}{\{b5,c6\}}


With this keys you can hide pieces on certain fields. The pieces are
not deleted, e.g.\ when you save the position to FEN they will be
there. But the content of hidden fields don't appear if you add
pieces to this fields!

\begin{LTXexample}[width=0.55\textwidth]
\newchessgame
\def\myfiles{a,b}
\setchessboard{tinyboard}
\chessboard[hidefiles=\myfiles,
            addpieces=Ra2,
            hidearea=d7-e8,
            storefen=myfen]
\chessboard[restorefen=myfen]
\end{LTXexample}

\subsubsection{Hiding piecetypes}

\Describefillkey{hidepiece}{piece char}{q}
\Describefillkey{hidepieces}{list of piece chars}{\{K, b\}}
\Describefillkey{hidewhite}{arbitrary}{}
\Describefillkey{hideblack}{arbitrary}{}
\Describefillkey{hideall}{arbitrary}{}


This keys doesn't hide the content of fields but piecestypes like
the kings or the pawns. Here too: you can't add pieces if their type
is hidden.


\begin{LTXexample}[width=0.55\textwidth]
\newchessgame
\def\mypieces{R,Q}
\setchessboard{tinyboard}
\chessboard[hidepieces=\mypieces,
            addpieces={Ra2, ra7},
            hideblack,
            storefen=myfen]%
\chessboard[restorefen=myfen]
\end{LTXexample}

\subsubsection{Showing the content of fields}

\Describefillkey{showboard}{arbitrary}{}
\Describefillkey{showarea}{area}{a1-c3}\goodbreak
\Describefillkey{showareas}{list of areas}{\{a1-c3,g7-h8\}}
\Describefillkey{showfile}{file}{g}
\Describefillkey{showfiles}{list of files}{\{g,h\}}\goodbreak
\Describefillkey{showrank}{rank}{5}
\Describefillkey{showranks}{list of ranks}{\{8,7\}}
\Describefillkey{showfield}{field}{c6}
\Describefillkey{showfields}{list of fields}{\{b5,c6\}}

With this keys you can let reappear the content of hidden fields.

\begin{LTXexample}
\newchessgame
\def\myfiles{a,b}
\chessboard[hidefiles=\myfiles,
            addpieces=Ra2,
            showfiles=a,
            showranks=2]
\end{LTXexample}

\subsubsection{Showing piecetypes}

\Describefillkey{showpiece}{piece char}{q}
\Describefillkey{showpieces}{list of piece chars}{\{K, b\}}
\Describefillkey{showwhite}{arbitrary}{}
\Describefillkey{showblack}{arbitrary}{}
\Describefillkey{showall}{arbitrary}{}
And this keys lets reappear hidden piecestypes.  Attention: hidden
pieces on hidden fields reappear only if you use the key to show the
field
\emph{and} the key to show the piece!

\begin{LTXexample}
\newchessgame
\def\myfiles{a,e}
\chessboard[hidefiles=\myfiles,
            hidepieces={K,R},
            showfiles=a,
            showranks=1,
            showpieces=K]
\end{LTXexample}


Keys like \key{showonlypawns} or \key{showonlybut} could be easily
added as they are simple combinations of the existing keys:

\begin{LTXexample}
\newchessgame
\chessboard[hideall,
            showpieces={P,p},
            addpieces=pe5]
\end{LTXexample}




\section{«Decoration»: Colors, background, fancy borders, highlighting}\label{startpgf}


%\section{Coloring and emphasizing the board chars}

{\bfseries You must load a color package like \packagename{xcolor} or
\packagename{color} to be able to use colors!}\footnote{I must
correct myself: the pgf-package will load \packagename{xcolor}, so
you should load a color package only if you want to use it with other
options.}

Coloring and decorating  the board is a bit complicated as there is
so much that can get different colors and so much different
possibilities for marks, arrows, fancy borders and so on. So it can
take some time to find out how to achieve a certain effect.

Don't forget that not every effect is sensible or even works
everywhere. Transparency/opacity e.g.\ don't work for every driver or
output format or printer or previewer (the documentation of pgf says
that it works for dvips only with new ghostscript versions). Some
colors looks good on screen but bad if printed with a greyscale
printer. Colors can change if you use another monitor. Some color
combinations are a problem for color blinds.

\Skaksty has some own highlighting commands. They use
postscript/pstricks commands and they only work if you load
\skaksty with the option \textsf{ps}. That means that you have to use the
\filetype{.tex}$\rightarrow$\filetype{.dvi}$\rightarrow$\filetype{.ps}$\rightarrow$\filetype{.pdf}-way
to process the document. If you want to use pdf\LaTeX\ directly you
have to use a package like \packagename{pst-pdf} to first make pdf
graphics from all boards and then include this graphics during the
pdf\LaTeX-run. I find this quite cumbersome and sometimes it is even
difficult to get it to work.

So I decided to use \packagename{pgf} to implement my own
highlighting commands. But I also tried to offer a possibility to use
the commands of \skaksty.

The pgf-commands  used by \pchessboard need only
\packagename{pgfcore.sty} and \packagename{pgfbaseshapespackage.sty}
from the \packagename{pgf}-bundle. If you need pgf-commands from
other parts of the bundle, you will have to load the styles yourself.

\Describesetkey{pgf}{true|false}{}{true}

Pgf-commands works fine with \LaTeX\ and pdf\LaTeX\ but in some case
(e.g.\ if you use \cs{chessboard} in an environment that calls the
environment \texttt{preview}) they can induce errors. So I added a
key to disable all the pgf-commands. It is also useful to disable
most of the highlighting.





\subsection{The  pgf-pictures}
The decorations in the two other layers (background layer and mark
layer) use pgf-commands -- or to be more precise: the two other
layers are pgf-pictures.




In the first version of \pchessboard the background picture wasn't
used much. I had only implemented some code to color the fields. But
then I got the request to add some more commands for fancy borders
which did mean that I had to transfer the code which draws borders in
the foreground picture to the background picture. And I got a request
for coloring fields in the foreground picture which did mean that I
had to transfer the code from the background to the foreground.

So I decided to rewrite and extend the codes so that each
highlighting/drawing in the pgf-pictures can be done in either the
background or the foreground or in both. I don't know if someone will
ever have a need for a cross under the figures, but why shouldn't I
offer some code to do it?

I also tried to unify the keys that affect the pgf-pictures, to
improve the possibilities for the user to  control which pgf-picture
is affected and put a bit more order in the keys. At the end quite a
lot of the code has been rearranged and changed.


\subsubsection{Naming of the pgf related keys}

There are more or less three set of keys

\begin{itemize}
\item Keys which affect only the foreground picture. The keys starts with or contains the
string «\bfseries\ttfamily mark».
\item  Keys which affect only the background picture. The keys starts with or contains the
string «\bfseries\ttfamily back».

\item
Keys that saves or set properties that are used in both picture,
e.g.\ to change the color or the linewidth. Such keys start or
contain in most cases the string  «\bfseries\ttfamily pgf» (with some
exceptions like the key for clipping and trimming). For a lot of such
keys there exist a shorter (but less descriptive) name without the
«\ttfamily pgf». In most cases there isn't a difference between the
two.

\end{itemize}
%Using two pictures raises the question how properties that make sense
%for both pictures should be implemented and how commands that should
%affect only one picture should be distinguish from a similar command
%that affect the other picture. E.g.\ there are  a lot of keys that
%sets properties that are or can be of interest in both pictures like
%setting the color or some variables like  linewidth or some padding.
%I stood for the choice if I should define two keys e.g.
%\key{colorback} and \key{colormark} or one key \key{color} that puts
%the color in both pictures. The first alternative is longer and more
%tiresome, the second can give confusing results if the user don't
%realize that a key can also affect the other picture.
%
%I used both alternatives depending on which I thought more natural in
%the special cases.




\subsubsection{Executing the drawing commands}

A chessboard consists of fields on which figures make moves and so
the decoration of the board is field and move orientated.

There are three different types of graphical object:
\begin{itemize}
\item You can draw something on  a set of
single \emph{fields} e.g., put a cross on each of the fields or put a
border around each field. To get these pictures on or under the field
the inner commands first shift the origin to the middle of field and
then inserts the code stored in the style definition in the
foreground or background image.


\item
You can draw something on or around a \emph{region} -- a rectangle
made of fields --, e.g.\ by putting a border around the center or a
rank or the whole board. Here the inner commands shift the origin to
the left upper corner of the region. The name of the other corner is
available in the style definition through
\lstinline+#1+.


\item And you can mark a \emph{move}.
The main difference between a move and a region is that the order of the «corners» given in the argument matters.
For moves the origin is in the first corner (the from field).
\end{itemize}

The drawing is done by first setting with various key the style and
the properties of the pgf object and then executed by telling
\cs{chessboard} which fields, moves or regions should get the
drawings.

\subsubsection{Drawing on and under fields}\label{sec:drawfields}

\Describefillkey{markboard}{arbitrary}{}
\Describefillkey{markarea}{area}{a1-c3}
\Describefillkey{markareas}{list of areas}{\{a1-c3,d5-e5\}}
\Describefillkey{markfiles}{file}{g}
\Describefillkey{markfiles}{list of files}{\{g,h\}}
\Describefillkey{markrank}{rank}{7}
\Describefillkey{markranks}{list of ranks}{\{8,7\}}
\Describefillkey{markfield}{field}{c6}
\Describefillkey{markfields}{list of fields}{\{b5,c6\}}
\Describefillkey{backboard}{arbitrary}{}
\Describefillkey{backarea}{area}{a1-c3}
\Describefillkey{backareas}{list of areas}{\{a1-c3,d5-e5\}}
\Describefillkey{backfiles}{file}{g}
\Describefillkey{backfiles}{list of files}{\{g,h\}}
\Describefillkey{backrank}{rank}{7}
\Describefillkey{backranks}{list of ranks}{\{8,7\}}
\Describefillkey{backfield}{field}{c6}
\Describefillkey{backfields}{list of fields}{\{b5,c6\}}


This keys executes the pgf-commands stored in the style command for
each single field.

In the following example you should look at the difference it makes
if you put a cross or a border in the background or the foreground.

\begin{LTXexample}
\newchessgame
\def\myarea{a1-b8}
\chessboard[pgfstyle=cross,
            color=blue,
            markfile=h,
            backarea=\myarea,
            color=red,
            padding=-0.2em,
            pgfstyle=circle,
            markfields=g1,backfields=g8,
            linewidth=0.1em,
            pgfstyle=border,
            markranks=6, backrank=4]
\end{LTXexample}

The new key \key{getpiecelists} can be used to mark e.g. all pawns on
a board:

\begin{LTXexample}
 \newchessgame
 \mainline{1. e4 e6 2.d4 d5}

 \chessboard[pgfstyle=cross,
             color=blue,
             getpiecelists,
             markfields={\cblistP,\cblistp}]
\end{LTXexample}



\subsubsection{Drawing on regions}

\Describefillkey{markregions}{list of regions}{\{a1-c3, b7-c6\}}
\Describefillkey{markregion}{list of regions}{\{a1-c3, b7-c6\}}
\Describefillkey{backregions}{list of regions}{\{a1-c3, b7-c6\}}
\Describefillkey{backregion}{list of regions}{\{a1-c3, b7-c6\}}


\begin{LTXexample}
\newchessgame
\def\pawnranks{a2-h2, h7-a7}
\chessboard[inverse,
            pgfstyle=border,
            markregions=\pawnranks,
            color=red, padding=0.3ex,
            linewidth=0.1ex,
            backregions={\board,d4-e5},
            pgfstyle=text,
            text=$\leftarrow$%
                 \currentbk-\currentwq
                 $\rightarrow$,
            markregion=a3-h3,
            pgfstyle={[rotate=45]text},
            backregion=h8-a1]
\end{LTXexample}


\subsubsection{Drawing move related}

\Describefillkey{markmoves}{list of moves}{\{a1-c3, b7-c6\}}
\Describefillkey{markmove}{list of moves}{\{a1-c3, b7-c6\}}
\Describefillkey{backmoves}{list of moves}{\{a1-c3, b7-c6\}}
\Describefillkey{backmove}{list of moves}{\{a1-c3, b7-c6\}}


\begin{LTXexample}
\def\mymove{d1-d5}%
\chessboard[pgfstyle=straightmove,
            markmoves={a1-a3, c3-e5, g1-f3},
            pgfstyle=knightmove,
            backmoves={g8-f6, h1-f4},
            arrow=to, linewidth=0.2em,
            markmove= \mymove]
\end{LTXexample}

I'm not very good in designing beautiful curves and moves arrows. If
someone could offer me better code I will be happy to implement it.







\subsubsection{Choosing what is drawn: pgf styles}



%\subsubsection{Mark styles}
\Describefillkey{markstyle}{[options]style name}{cross}
\Describefillkey{backstyle}{[options]style name}{cross}
\Describefillkey{pgfstyle}{[options]style name}{[left]text}


With this keys you set the style the drawing commands will use.
\key{markstyle} sets only the style for the foreground (the «mark»
picture). \key{backstyle} sets only the style for the background
picture. \key{pgfstyle} sets the style for both pictures (\key{style}
is not a shorter version of \key{pgfstyle}!).

If the value starts with \verb+[+ the text until \verb+]+ is
interpreted as an option of the style. It depends on the definition
of the style if and how this option is used (until now the text
style, the circle style and (since version 1.5) the curvemove style
use such options). \textbf{Attention}: to prevent \cs{chessboard} to
interpret the \verb+]+ as the end of its optional argument you must
put braces around the whole value if you want to use options.

Not every style is useful for everything, e.g.\ it doesn't make sense
to put a border around a move. The following tabular shows the
predefined styles and the types for which they work.

\begin{tabular}{lccc}
      & fields    & regions   & moves \\
cross & \ding{52} &           &       \\
circle& \ding{52}                      \\
text  & \ding{52} & \ding{52}          \\
border(s)& \ding{52} & \ding{52}       \\
color &\ding{52} &\ding{52}\\
straightmove &    &           & \ding{52}\\
knightmove &      &           & \ding{52}\\
curvemove &      &           & \ding{52}\\
\end{tabular}



\DescribeMacro{\cbDefinePgfFieldStyle}
\DescribeMacro{\cbDefinePgfRegionStyle}
\DescribeMacro{\cbDefinePgfMoveStyle}
With this commands you can define your own styles. The commands take
two argument: the first is the name of the style, the second should
be the pgf-commands needed to draw.

In previous version of the package the commands were called.
\cs{cbDefineMarkFieldStyle}%
\index{cbDefineMarkF=\textbackslash cbDefineMarkFieldStyle (obsolete)|see{\textbackslash cbDefinePgfFieldStyle}},
\cs{cbDefineMarkRegionStyle}%
\index{cbDefineMarkR=\textbackslash cbDefineMarkRegionStyle (obsolete) |see{\textbackslash cbDefinePgfRegionStyle}}
and \cs{cbDefineMarkMoveStyle}%
\index{cbDefineMarkM=\textbackslash cbDefineMarkMoveStyle (obsolete) |see{\textbackslash cbDefinePgfMoveStyle}}.
%
I have changed the names to indicate that the commands will define
the styles for the background picture too. The older commands still
work  but I suggest that you switch to the new names.


The listing shows first an example for a field mark, then an example
for a region where the second corner is accessed through the
\lstinline+#1+,
and at last the definition for the text mark -- here it is necessary
to rotate the text if the key \key{inverse} is true and the
definition shows how the optional argument of the \key{pgfstyle} key
can be use with \verb+#2+:

\begin{lstlisting}
\cbDefinePgfFieldStyle{circle}{%
    \pgfsetlinewidth{\board@pgf@linewidth}%
    \setlength\len@board@tempx{%
     \dimexpr 0.55em + \board@pgf@padding \relax}%
    \pgfpathcircle{\pgfpointxy{0}{0}}{\len@board@tempx}%
    \pgfusepath{stroke,#2}}%%

\cbDefinePgfRegionStyle{border}{%
    \pgfsetlinewidth{\board@pgf@linewidth}%
    \pgfsetcornersarced{\pgfpoint{\board@pgf@corner}{\board@pgf@corner}}
    \pgfpathrectanglecorners%
      {\pgfpointadd%
       {\pgfpoint{-\board@pgf@padding}{\board@pgf@padding}}
       {\pgfpointxy{-0.5}{0.5}}}%
      {\pgfpointadd%
       {\pgfpointanchor{#1}{center}}
       {\pgfpointadd%
        {\pgfpoint{\board@pgf@padding}{-\board@pgf@padding}}
        {\pgfpointxy{0.5}{-0.5}}}}%
    \pgfusepath{stroke}}%

\cbDefinePgfFieldStyle{text}{%
    \ifthenelse%
     {\boolean{\XKV@UFCB@locset@inverse@value}}%
     {\pgftext[rotate=180,#2]{\normalfont\board@pgf@curtext}}%
     {\pgftext[#2]{\normalfont\board@pgf@curtext}}}%
\end{lstlisting}

\subsubsection{Introduction to the predefined pgf styles}

%\subsubsection{Graphic properties}
%
%Some of the graphic properties can be changed with predefined keys:
%You already know about the keys \key{color} and \key{opacity}.

%\medskip
%\Describefillkey{linewidth}{length}{1ex}
%\Describefillkey{marklinewidth}{length}{1ex}
%With this keys you can change an internal command that is used to set
%the linewidth. The first will affect also the linewidth in the
%background layer, will the second affect only the mark layer.

\minisec{Borders}

\index{border (style)}%
\index{border (style)>leftborder}%
\index{border (style)>rightborder}%
\index{border (style)>topborder}%
\index{border (style)>bottomborder}%
\index{border (style)>lefttopborder}%
\index{border (style)>lefttoprightborder}%
\index{border (style)>toprightborder}%
\index{border (style)>toprightbottomborder}%
\index{border (style)>rightbottomborder}%
\index{border (style)>rightbottomleftborder}%
\index{border (style)>bottomleftborder}%
\index{border (style)>bottomlefttopborder}%
Borders can be put around fields and regions. There exist also
partial borders for one, two or three margins of an area, this
borders are drawn and named «clockwise». «left», «right», «top», and
«bottom» refer to the position of the border if the white player is
at the bottom. If you use the key
\key{inverse} the positions of the lines don't change in relation to
the players colors.

\begin{LTXexample}
\newchessgame
\setchessboard{smallboard,
            pgfstyle=rightbottomborder,
            color=orange,
            markrank=7,
            pgfstyle=lefttoprightborder,
            markregion=a1-b3,
            shortenstart=-1ex,
            padding=1ex,
            linewidth=0.3em,
            pgfstyle=leftborder,color=red,
            markregion=\mycenter,
            pgfstyle=topborder,color=blue,
            markregion=\mycenter,
            pgfstyle=rightborder,color=green,
            markregion=\mycenter,
            pgfstyle=bottomborder,color=yellow,
            markregion=\mycenter}
\def\mycenter{d4-e5}
\chessboard\
\chessboard[inverse]
\end{LTXexample}

\minisec{Circle}

\index{circle (style)}%
\index{circle (style)>fill (option)}%
This style can only be used in connection with fields. The optional
argument can be used to fill the circle (default is stroke).

\begin{LTXexample}
\newchessgame
\def\mycenter{d4-e5}
\chessboard[pgfstyle=circle,
            color=red,
            markrank=7,
            linewidth=0.2em,
            markrank=6,
            pgfstyle={[fill]circle},
            markarea=\mycenter,
            padding=-0.8ex,color=blue,
            backfile=b]
\end{LTXexample}


\minisec{Cross}

\index{cross (style)}%
This style can only be used in connection with fields.

\begin{LTXexample}
\newchessgame
\def\mycenter{d4-e5}
\chessboard[pgfstyle=cross,
            color=red,
            markrank=7,
            linewidth=0.2em,
            markrank=6,
            shortenstart=0.5ex,
            markarea=\mycenter,
            shortenend=0.5ex,color=blue,
            backfile=b]
\end{LTXexample}

\minisec{Text}

\index{text (style)}%
\index{text (style)>options}%
Text can be used for fields and regions. It is the only style where
it isn't enough to simply chose the style, you must also give a value
to the text content with the key \key{text} (don't confuse the key
«text» with the style «text»!).

The option of the style is passed to the optional argument of the
\cs{pgftext} command, so everything that is allowed there can be put
in the option. In the definition of the text content you can use
informations about the current field or the current region.
\cs{currentbk}\index{currentbk=\textbackslash currentbk} e.g. gives
the \textit{b}lack \textit{k}ing corner of the region (when you draw
in a region) or the field name (when you draw in a field). The
opposite corner ist
\cs{currentwq}\index{currentwq=\textbackslash currentwq},%
\index{currentbq=\textbackslash currentbq}
\index{currentwk =\textbackslash currentwk}
the
\textit{w}hite \textit{q}ueen corner.

As a default the text is centered on the middle of the field or the
region. You can use the options to move it around, please look in the
documentation of pgf to find out what is possible.

\begin{LTXexample}
\newchessgame
\setchessboard{tinyboard,color=magenta,clearboard}
\chessboard[
  pgfstyle=
      {[base,at={\pgfpoint{0pt}{-0.4ex}}]text},
  text= \fontsize{1.2ex}{1.2ex}\bfseries
        \sffamily\currentwq,
  markboard]

\chessboard[
  inverse,
  pgfstyle=
     {[base,at={\pgfpoint{0pt}{-0.4ex}}]text},
  text=\fontsize{1.2ex}{1.2ex}\bfseries
       \sffamily\currentwq,
  trimtocolor=black, markboard,
  trimtocolor=white,color=green,
  markboard]%

\chessboard[pgfstyle={[rotate=90]text},
            text=
            \fontsize{1.2ex}{1.2ex}
            \bfseries file from \currentwq\ to \currentbk,
            markregions={a1-a8,b1-b8,c1-c8}]%%
\end{LTXexample}

\begin{LTXexample}
\newchessgame
\setchessboard{tinyboard,color=red}

\chessboard[pgfstyle={[rotate=45]text},
            text=
            \fontsize{1.2ex}{1.2ex}
            \bfseries this is the diagonal
            \currentwq\ to \currentbk,
            markregions=\board]

\chessboard[inverse, pgfstyle={[rotate=45]text},
            text=
            \fontsize{1.2ex}{1.2ex}
            \bfseries this is the diagonal
            \currentwq\ to \currentbk,
            markregions=\board]

\end{LTXexample}


\minisec{Color}

\index{color (style)}%
This style puts a colored square on or under the field or region. At
the start it was meant to color the background of the fields (and so
it was only defined for the background). If used for the foreground
on should set an adequate opacity.

\begin{LTXexample}[width=0.55\textwidth]
\newchessgame
\setchessboard{tinyboard,
        color=orange!80}
\chessboard[boardfontencoding=LSBC5,
            pgfstyle=color,
            trimtocolor=black,
            backboard,
            trimtocolor=white,
            color=gray!50,
            backboard]%
\chessboard[pgfstyle=color,
            padding=-0.2em,
            opacity=0.5,
            markfiles={a,b},
            markregion={e1-h8}]%
\end{LTXexample}


\minisec{Moves}

\index{straightmove (style)}%
\index{curvemove (style)}%
\index{knightmove (style)}%
Three styles draw arrows for moves. Two are quite simple:
\key{straightmove} which draws straight arrows,
\key{knightmove} which make a curve suited for knight moves.





\begin{LTXexample}
\newchessgame
\chessboard[pgfstyle=straightmove,
            markmove=a1-a8,
            arrow=to,linewidth=0.2ex,
            color=red,
            pgfstyle=knightmove,
            markmoves={g1-f3, e1-h4},
            shortenstart=-1ex,
            markmoves=h1-g3]%
\end{LTXexample}


\paragraph*{curvemove} New in version 1.5 there is the more sophisticated
\key{curvemove} which draws an arbitrary bezier curve between start
and end field.

\key{curvemove} accept an optional argument in  key val syntax. (If you use it,
don't forget to put braces arround the value!).

\index{curvemove (style)>x1 (key)}%
\index{curvemove (style)>x2 (key)}%
\index{curvemove (style)>y1 (key)}%
\index{curvemove (style)>y2 (key)}%
\index{curvemove (style)>clockwise (key)}%
First, there are keys that lets you change the support points of the
bezier curve. The curve use a local coordinate system: The x-axis
goes along the line from the start point to the end point. The
x-values set with the keys listed below are relative to the length of
this arrow from start to end, while the y-values are absolute (unit
it the width of a square). Positive y values give a curve going
clockwise, negative y values give a curve going anticlockwise. With
the
\texttt{clockwise=false} you can change the sign of the y values.

\begin{tabular}{>{\ttfamily}l>{~=~}l}
x1 & \meta{number}\\
x2 & \meta{number}\\
y1 & \meta{number}\\
y2 & \meta{number}\\
clockwise & \meta{true|false}
\end{tabular}

Second, there are keys to change \emph{locally} (only for the curve)
the look of the arrow. They work like the keys for \cs{chessboard}
with the same name:
\index{curvemove (style)>arrow (key)}%
\index{curvemove (style)>pgfarrow (key)}%
\key{arrow}, \key{pgfarrow},
\index{curvemove (style)>linewidth (key)}%
\index{curvemove (style)>pgflinewidth (key)}%
\key{linewidth}, \key{pgflinewidth},
\index{curvemove (style)>shortenstart (key)}%
\index{curvemove (style)>pgfshortenstart (key)}%
\key{shortenstart}, \key{pgfshortenstart},
\index{curvemove (style)>shortenend (key)}%
\index{curvemove (style)>pgfshortenend (key)}%
\key{shortenend}, \key{pgfshortenend}.

\index{curvemove (style)>style (key)}%
At last there is a key \key{style} which you can use to reuse saved
keyval-lists. Until now only style \texttt{knight} exists and there
is no user command to define new ones. You want to use own keys, sent
me either a feature request or do it by defining the low level
command:

\verb+\def\board@pgf@curvemovestyle@+\meta{name}\verb+{\setkeys[UFCB]{bez}{+\meta{keyval-list}\verb+}}+

\begin{LTXexample}
\newchessgame
\def\mystyle{[clockwise=false,style=knight]curvemove}
\chessboard[arrow=latex,
           pgfstyle=straightmove,
           shortenstart=0.1em,
           color=blue,
           linewidth=3pt,
           markmoves={e1-e8},
           pgfstyle={[linewidth=2pt,arrow=to,
                      style=knight]curvemove},
           markmove=b1-c3,
           color=red,
           pgfstyle=\mystyle,
           markmoves={b1-c3,b1-a3},
           pgfstyle=curvemove,
           markmoves={e1-g1,h1-f1}]
\end{LTXexample}
\subsubsection{Setting graphic properties}

As the previous examples showed  you can change quite a lot things of
the pictures. Now here a complete description of the needed keys. The
keys don't draw anything directly. They only put commands or
definitions like
\verb+\color{red}+, \verb+\pgfsetfillopacity{0.3}+ or
\verb+\def\board@pgf@arrow{to}+ in the pgf-picture(s).




\bigskip
Let us now start with the keys which put a command in the pictures:


\Describefillkey{color}{color}{red}
\Describefillkey{pgfcolor}{color}{red}

This keys stores a color command (\verb+\color{red}+) in the pgf
picture(s).


\medskip
\Describefillkey{opacity}{number}{0.5}
\Describefillkey{pgfopacity}{number}{0.5}
\Describefillkey{fillopacity}{number}{0.5}
\Describefillkey{pgffillopacity}{number}{0.5}
\Describefillkey{strokeopacity}{number}{0.5}
\Describefillkey{pgfstrokeopacity}{number}{0.5}


This keys add \cs{pgfsetfillopacity}\marg{number} and/or
\cs{pgfsetstrokeopacity}\marg{number} to the  pgf-picture(s). The
number should be between zero and one.

\begin{LTXexample}
\chessboard[padding=-0.5ex,
            color=red,fillopacity=0.5,
            markstyle=circle,markfields=a1,
            markstyle=color,markfields=b1,
            fillopacity=1,
            strokeopacity=0.5,
            pgfstyle=circle,
            markfields=d1,backfield=d8,
            pgfstyle=color,
            markfields=e1,backfield=c8]
\end{LTXexample}


\bigskip
The following keys puts only a definition in the pgf-pictures. The
values will only affect the styles that use the internal commands in
their definitions.

\medskip
\Describefillkey{padding}{length}{0.1ex}
\Describefillkey{pgfpadding}{length}{0.1ex}

This keys save \verb+\def\board@pgf@padding+\marg{length} to the
pgf-picture(s). The value can be used in various situations to change
the offset of a line or a border of the area that is covered by a
color.

Used currently by the border styles, the styles that color fields in
the background or the foreground to enlarge or reduce the covered
area and the circle (the length is added to a start diameter).

\begin{LTXexample}
\chessboard[color=red,
            markstyle=circle,markfields=a1,
            markstyle=border,markfields=a3,
            markstyle=color,markfields=a5,
            padding=0.3ex,color=green,
            markstyle=circle,markfields=c3,
            markstyle=border,markfields=c5,
            markstyle=color,markfields=e5,
            padding=-0.3ex,color=blue,
            markstyle=circle,markfields=g3,
            markstyle=border,markfields=g5,
            backstyle=color,backfields=g1]
\end{LTXexample}

\medskip
\Describefillkey{arrow}{arrow type}{to}
\Describefillkey{pgfarrow}{arrow type}{to}

This keys save \verb+\def\board@pgf@arrow+\marg{arrow type} to the
pgf-picture(s). Styles can use the command to set the arrow
tips. Look at the documentation of pgf to learn about the existing
arrow types (and how to define new ones).

Default is \texttt{latex}. Used currently by the move styles.

\begin{LTXexample}
\chessboard[markstyle=straightmove,
            markmove=a1-a3,
            arrow=to,
            markmove=b1-b3]
\end{LTXexample}

\Describefillkey{shortenstart}{length}{to}
\Describefillkey{pgfshortenstart}{length}{to}
\Describefillkey{shortenend}{length}{to}
\Describefillkey{pgfshortenend}{length}{to}
\Describefillkey{shorten}{length}{to}
\Describefillkey{pgfshorten}{length}{to}

This keys save the definitions
\verb+\def\board@pgf@shortenstart+\marg{length} or\\
\verb+\def\board@pgf@shortenend+\marg{length}  or both to the
pgf-picture(s). The commands can  be used e.g. in a
\cs{pgfsetshortenstart} command to shorten a line a the start or the
end.

As default the lengths are 0pt.  Used e.g.\ by the styles
straightmove, knightmove, cross and the partial borders. The lengths
are
\emph{added} to some start values that I thought reasonable. If you
use large length (over 1ex) this can change the meaning of move marks
as the mark will start in another field!

\begin{LTXexample}
\chessboard[markstyle=straightmove,
            markmove=a1-a3,
            markstyle=cross,markfield=a5,
            shortenend=1ex,color=red,
            markstyle=straightmove,
            markmove=b1-b3,
            markstyle=cross,markfield=b5,
            shorten=-0.5em,color=green,
            pgfstyle=straightmove,
            backmove=d1-d3,
            backstyle=cross,backfield=d5]
\end{LTXexample}

\Describefillkey{linewidth}{length}{1ex}
\Describefillkey{pgflinewidth}{length}{1ex}
\Describefillkey[relict]{marklinewidth}{length}{1ex}
\Describefillkey[relict]{backlinewidth}{length}{1ex}

This keys save \verb+\def\board@pgf@linewidth+\marg{length} to the
pgf-picture(s). The command can be used e.g. in \cs{pgfsetlinewidth}.
The keys \key{marklinewidth} and \key{backlinewidth} are remains from
an older version. There put the commands only in one picture, and
they ignore the values of the \key{usepgf} keys.

\begin{LTXexample}
\chessboard[markstyle=straightmove,
            markmove=a1-a3,
            markstyle=cross,markfield=a5,
            linewidth=1ex,color=red,
            markstyle=straightmove,
            markmove=b1-b3,
            markstyle=cross,markfield=b5,
            pgfstyle=border,backfield=d5]
\end{LTXexample}

%??????????????????????????????????
%vachange an internal command that can be use to set the linewidth
%e.g. of an arrow or a border. The first key affects both
%pgf-pictures, the other only the mark or the background layer

\Describefillkey{cornerarc}{length}{2pt}
\Describefillkey{pgfcornerarc}{length}{2pt}
\Describefillkey[relict]{backcornerarc}{length}{2pt}

The first two keys save \verb+\def\board@pgf@corner+\marg{length} to
the pgf-picture(s). The last  key will save the same definition only
to the background picture and it will ignore the value of the
\key{usebackpgf} and \key{usepgf} keys. \verb+\board@pgf@corner+ can
be used e.g. in \cs{pgfsetcornersarced} to round the corners of a
border. To get sharp corners use the value 0pt.

The value is used currently only used in the border styles.

\begin{LTXexample}
\chessboard[linewidth=0.3ex,color=red,
            padding=1ex,
            pgfstyle=border,
            backregion=\board,
            cornerarc=1ex,
            padding=1.5ex,
            backregion=\board,
            pgfstyle=bottomlefttopborder,
            backregion=c3-f6]
\end{LTXexample}


\Describefillkey{addpgf}{(pgf)-commands}{\cs{pgfsetroundcap}}

With this key you can add arbitrary (pgf)-commands to the pictures.
Use it with care. When you use the key without an argument it will
end a pgf scope\index{scope} and  so  reset colors and
linewidth and some of the other values to their defaults.

\begin{LTXexample}
\chessboard[
        showmover=false,
        inverse,markstyle=leftborder,
        color=red,linewidth=0.3em,
        markregion=d3-d5,
        color=blue,
        addpgf=\pgfsetroundcap,
        markregion=e3-e5,
        addpgf,
        markstyle=cross,
        markfield=c4]
\end{LTXexample}

\Describefillkey{usepgf}{back|mark|all|both|none}{}

With this key you can control in which picture the commands or
definitions are saved when using the keys described above.

The default is to save everything in both pictures. This means that
is also adds some superfluous code to the other picture, but I don't
think this is a problem. In most cases you won't need the key.



\subsubsection{A special shortcut key for background border}


\Describefillkey{pgfborder}{area}{c3-e4}

With this key you can put a border around the area in the background
picture. The key saves the current style, calls the \key{backstyle}
and the \key{backregions} keys to draw the border and then restores
the old style. If you don't give a value to the key, the border is
around the printarea.

\begin{LTXexample}
\newchessgame
\chessboard[%
 showmover=false,
 border=false,
 linewidth=0.4pt,
 padding=0.4pt,
 pgfborder,
 linewidth=1pt,
 padding=2pt,
 pgfborder]
\end{LTXexample}


\begin{LTXexample}
\chessboard[
 showmover=false,
 border=false,
 hlabelwidth=0.6em,
 vlabellift=1.3em,
 printarea=c3-f6,
 pgfstyle=cross,
 color=red,
 linewidth=1ex,
 padding=1ex,
 pgfborder,
 markfield=d4,
 color=blue,
 linewidth=0.5ex,
 padding=2.5ex,
 pgfborder,
 padding=0ex,
 color=green,
 trim=false,%to show the next border
 pgfborder=\board,
 markfield=e5]
\end{LTXexample}




\subsubsection{Special shortcut keys for background color}



\medskip
\Describefillkey{colorbackboard}{arbitrary}{}
\Describefillkey{colorbackarea}{area}{a1-c3}
\Describefillkey{colorbackareas}{list of areas}{\{a1-c3, f1-f2\}}
\Describefillkey{colorbackfile}{file}{h}
\Describefillkey{colorbackfiles}{list of files}{\{g,h\}}
\Describefillkey{colorbackrank}{rank}{5}
\Describefillkey{colorbackranks}{list of ranks}{\{8,7\}}
\Describefillkey{colorbackfield}{field}{g4}
\Describefillkey{colorbackfields}{list of fields}{\{b5,c6\}}
\Describefillkey{colorwhitebackfields}{list of fields}{\{b5,c6\}}
\Describefillkey{colorblackbackfields}{list of fields}{\{b5,c6\}}


This keys are shortcuts to color the background of the board. They
save the current style, color the fields and then restore the style.


\begin{LTXexample}
\chessboard[
 showmover=false,
 border=false,
 pgfstyle=cross,
 color=red!50,
 colorwhitebackfields,
 markfield=d4,
 color=blue!50,
 colorblackbackfields,
 markfield=e5,
 color=green!50,
 colorbackarea=d4-e5]
\end{LTXexample}


%\subsection{Marks and highlighting: Adding decoration to the foreground layer}

%
%
%\subsection{Coloring the pieces}
%
%Coloring the fields isn't really satisfactory. It would be nicer if
%one could color only the pieces. But as the background and the piece
%is one char this isn't possible, one needs a font where for each
%piece there a background mask.  One can fake such a font by either
%using two chars for the fields with black background, or by not
%using the chars with black background. I added three experimental
%encodings to
%\chessfss and some keys to use them. This isn't perfect but it's a
%start until better fonts are available.
%
%To use the encodings you must load
%\filetype{lsb1enc.def}, \filetype{lsb2enc.def} and
%\filetype{lsb3enc.def} e.g.\ with
%\lstinline+\usepackage[LSB1, LSB2, LSB3, T1]{fontenc}+.
%
%\Describesetkey{colorwhite}{color}{red}{--}
%\Describesetkey{colorblack}{color}{green}{--}
%
%This keys colors all black and white pieces.
%
%\begin{LTXexample}
%\chessboard[boardfontencoding=LSB1,
%            emphstyle=\color{green},
%            emphboard,
%            colorwhite=red,
%            colorblack=blue]
%\end{LTXexample}
%


%\Describefillkey{piececolor}{color}{red}
%\Describefillkey{colorpieces}{list of fields}{\{a1,c3\}}
%With this keys you can color the pieces on some fields.
%
%\begin{LTXexample}
%\def\fieldlist{a1,b1 , c1}%
%\def\mycolor{blue}%
%\chessboard[boardfontencoding=LSB1,
%            emphstyle=\color{green},
%            emphboard,
%            piececolor=red,
%            colorpieces={a8,b8},
%            piececolor=\mycolor,
%            colorpieces=\fieldlist]
%\end{LTXexample}

%\begin{LTXexample}
% \chessboard[boardfontencoding=LSB1,
%        colorwhite=red,
%        colorblack=blue,
%        addpieces={qd5,ke5,Qd4,Ke4}]
%\end{LTXexample}

%\subsection{The foreground picture: Marking}

%The following highlighting commands all use one large pgf-picture
%that is printed above the board. Putting marks on the boards means
%inserting some pgf code in this picture. The units of the picture are
%equal to the width and height of a square. For each field there exist
%a node  with the same name as the field in the middle of field. With
%the command
%\lstinline+\pgftransformshift{\pgfpointanchor{+\meta{field}\lstinline+}{center}+
%one can shift the origin to this field and start to draw.
%



%\subsubsection{Adding arbitrary pgf-code}




\subsubsection{Clearing the pgf-pictures}




Removing pgf decoration from the board is easy if you used the
optional argument of \cs{chessboard}. But what should you do if you
had added e.g.\ a mark with \cs{setchessboard} for the next four
board and now want to get rid of it for the fifth? That isn't so easy
as the code is burried quite deep in a large list.

On the whole there are three possibilities:


\begin{itemize}
\item Use grouping to keep the marks local to some boards.


\begin{LTXexample}[width=0.55\textwidth]
\newchessgame
\setchessboard{tinyboard}
{\setchessboard{markstyle=cross,
                markranks=4}
\chessboard}%
\chessboard
\end{LTXexample}

\item Store the keys in a style that you can redefine:

\begin{LTXexample}[width=0.55\textwidth]
\newchessgame
\storechessboardstyle{mymarks}
   {markstyle=cross,
    markranks=4}

\setchessboard{style=mymarks}
\chessboard%
\storechessboardstyle{mymarks}{}
\chessboard
\end{LTXexample}



\item Use the following keys to clear the pgf pictures.

\end{itemize}

\Describefillkey{clearpgf}{arbitrary}{}
\Describefillkey{clearbackpgf}{arbitrary}{}
\Describefillkey{clearmarkpgf}{arbitrary}{}

(I renamed the keys \key{clearforegroundpgf}%
\index{clearforegroundpgf (obsolete)|see{clearmarkpgf}} and
\key{clearbackgroundpgf},%
\index{clearbackgroundpgf (obsolete)|see{clearbackpgf}} the older names will work too, but I
suggest that you switch to the new ones.)

\begin{LTXexample}[width=0.55\textwidth]
\newchessgame
\setchessboard{tinyboard,
               color=blue,
               opacity=0.6,
               colorblackbackfields,
               color=red,
               markstyle=cross,
               markfiles=h}
\chessboard%
\chessboard[clearmarkpgf]
\chessboard[clearbackpgf]%
\chessboard[clearpgf,
            markstyle=circle,
            markranks=4]
\setchessboard{clearmarkpgf}%
\chessboard
\end{LTXexample}


\subsubsection{Clipping the pgf pictures}


\Describesetkey{clip}{\keylist}{}{false}
\Describesetkey{markclip}{\keylists}{}{false}
\Describesetkey{backclip}{\keylists}{}{false}

\index{clip>true (subkey)}%
\index{clip>false (subkey)}%
\index{clip>left (subkey)}%
\index{clip>right (subkey)}%
\index{clip>top (subkey)}%
\index{clip>bottom (subkey)}%
With this keys you can add \emph{one} clipping path to each pgf
pictures. The clipping paths are always around the print area.  The
argument of the keys is key-value-list with the possible keys
\key{true},
\key{false} to enable or disable the clipping and the four keys
\key{left}, \key{top}, \key{right} and \key{bottom} which take as
value a length and are used to set the padding.

As in other keys the value \texttt{true} can be omitted, but this
also means that you have to use the value \texttt{false} explicitly
if you only want to set some of the  padding values but not enable
clipping.


\begin{LTXexample}[width=0.55\textwidth]
\newchessgame
\setchessboard{
   trim=false,printarea=b2-g7,
   clip={left=0.5ex,top=0.5ex,
         right=-0.5ex,bottom=-0.5ex,
         false},
   %
   border=false,linewidth=0.3em,
   pgfborder,
   %
   pgfstyle=color,
   color=blue!50,
   backrank=6,backfile=c,
   color=red!50,
   markrank=4,markfile=f,
   %
   pgfstyle=text,color=black,
   text=a text in the foreground,
   markfield=b4,
   text=a text in the background,
   backfield=f6}%

\chessboard

\chessboard[markclip]

\chessboard[backclip]

\chessboard[clip]
\end{LTXexample}


\subsubsection{Trimming}
Clipping cuts simply through the pgf-pictures and throws everything
away that is outside the printarea. This has the drawback that  in
the picture there could be e.g. remains of a move arrow that started
outside the shown board.

Trimming is an attempt for a more intelligent approach: Objects like
crosses, circles, text, borders and arrows are discarded completely
if they lie partly or completely outside the defined scope of fields.

\minisec{Trimming to a area}
\Describefillkey{trimarea}{area|empty}{}

This sets and activates an trimarea. If you omit a value printarea is
used. If you don't give an area but use the keyword \verb+empty+
everything following the key will be trimmed. If you want to disable
trimming use \verb+trimarea=\board+ (or \verb+trim=false+). As a
default the trimarea is set to  the print area (and so activated).

The value of \key{trimarea} will affect all \emph{following} objects
drawn with the
\key{pgfstyle} and the related \key{mark\ldots} and
\key{back\ldots} keys.

Field related objects will be drawn if the field lies in the area.
Region related objects will be drawn if the complete region lies in
the area. Move related objects will be drawn if the complete move
lies in the area.


\begin{LTXexample}
\newchessgame
\setchessboard{pgfstyle=color,
            color=blue!50,
            backrank=6,
            trimarea=\myarea,
            backrank=5,
            pgfstyle=border,
            color=red,
            markregion=d4-d5,
            markregion=c3-d5,%will disappear
            pgfstyle=knightmove,
            color=yellow,
            markmove=f6-e4,
            markmove=f7-d5%will disappear
            }
\def\myarea{a1-h8}% nothing trimmed
\chessboard

\def\myarea{d4-f6}% some deco will disappear
\chessboard
\end{LTXexample}

\begin{LTXexample}
\newchessgame
\setchessboard{pgfstyle=color,
            color=blue!50,
            backrank=6,
            trimarea=\myarea,
            backrank=5,
            pgfstyle=border,
            color=red,
            markregion=d4-d5,
            markregion=c3-d5,%will disappear
            pgfstyle=knightmove,
            color=yellow,
            markmove=f6-e4,
            markmove=f7-d5%will disappear
            }
\def\myarea{empty}
\chessboard
\end{LTXexample}
As shown in the previous examples you can set a manual trimarea. But
you should be aware that you can get unexpected results if this
area is larger than the printarea:


\begin{LTXexample}
\chessboard[printarea=d4-e5,
            trimarea=c4-g4,
            pgfstyle=color,
            trimtocolor=white,
            color=red,
            backboard]
\end{LTXexample}

\Describefillkey{captrimtoprint}{true|false}{true}

With this key you can force the \emph{following} trimarea commands to
respect the printarea.

\begin{LTXexample}
\chessboard[printarea=d4-e5,
            trimarea=c3-f6,
            captrimtoprint,
            pgfstyle=cross,
            color=red,
            backboard,
            trimarea=c3-f6,%now captrimtoprint
                           %has an effect
            pgfstyle=circle,
            color=green,
            backboard]
\end{LTXexample}


\Describefillkey{trim}{true|false}{true}

This is a shorter version of \key{trimarea}. It can only be used to
set the trimarea to printarea (true) or the complete board (false).

%Until now I have only implement some code to draw colored squares in
%the background. I don't know really what else could be useful. The
%only idea that comes to my mind is some code to insert a real
%background image, but it is difficult to decide how size and position
%of such an image should be controlled.


\begin{LTXexample}
\newchessgame
\mainline{1. e4 e5 2. Nf3 Nc6 3. Bb5 a6}
\setchessboard{linewidth=0.1em,border=false,
    label=false,showmover=false}
\chessboard[printarea=a5-d8,
   padding=0.25em,
   trim=false,
   shortenend=-1ex,
   pgfstyle=rightborder,
   markregion=d1-d8,
   padding=-0.25em,
   pgfstyle=topborder,
   markrank=4,
   marginrightwidth=0.5em,
   marginbottomwidth=0.5em]%
\chessboard[printarea=e5-h8,
   marginleftwidth=0em,
   marginbottomwidth=0.5em]\\%
\chessboard[printarea=a1-d4,
   margintopwidth=0em,
   marginrightwidth=0.5em]%
\chessboard[printarea=e1-h4,
   margintopwidth=0em,
   marginleftwidth=0em]%
\end{LTXexample}


\minisec{Trimming to the white or black fields}

\Describefillkey{trimtocolor}{white|black|false}{}

The key affects only the field related pgf-objects. Regions and moves
will ignore it. The key \obsoletekey{applycolor} from previous
versions has now a similar effect\footnote{I couldn't retain the older behaviour due to the changes
made in the code.}. This means that the key has changed
its behaviour: it will now affect also the foreground picture!

\begin{LTXexample}
\chessboard[printarea=c3-f6,
            trim, %not really needed, default
            pgfstyle=color,
            trimtocolor=white,
            color=red,
            backboard,
            trimarea=b2-g7,
            trimtocolor=black,
            color=gray!50,
            backboard]
\end{LTXexample}


%\medskip
%\Describefillkey{applycolor}{white|black|all|none}{white}
% \Describefillkey{colorwhitefields}{arbitrary}{}
%\Describefillkey{colorblackfields}{arbitrary}{}

%With this key you can chose to color  only the black or the white
%fields.
%\begin{LTXexample}
%\def\myareas{f6-f7, h7-h8}
%\chessboard[inverse,
%            printarea=b2-g7,
%            opacity=0.5,
%            color=green, padding=-0.2ex,
%            colorbackareas=\myareas, %trimmed
%            color=red,
%            trim=false, %next fields not trimmed
%            colorbackfields={a1,c3,d4,g8}]
%\end{LTXexample}


\begin{LTXexample}
\chessboard[printarea=f3-c6,
            padding=.3ex,
            trimtocolor=white,
            color=blue,
            pgfstyle=cross,
            backranks=5,
            color=yellow,
            trimtocolor=black,
            trim=false,
            backfiles={d,e}]
\end{LTXexample}


\begin{LTXexample}
\chessboard[padding=.3ex,
            printarea=f3-c6,
            trimtocolor=white,
            color=blue,
            pgfstyle=text,
            text=\tiny\bfseries white,
            markboard,
            color=yellow,
            trimtocolor=black,
            text=\tiny\bfseries black,
            markboard]
\end{LTXexample}


\begin{LTXexample}
\chessboard[inverse, printarea=a2-g7,
            boardfontencoding=LSB2,
            color=lightgray!50,
            trimtocolor=white,
            colorbackboard,
            color=gray!60,
            trimtocolor=black,
            colorbackboard]
\end{LTXexample}\label{stoppgf}



\subsection{Using a graphic as background}

It isn't really difficult to use a graphic as background of the
board. You must use a boardfont encoding that hasn't fields and
fieldmasks. And then you must use trial and error to find out which
scalefactor and which viewport is fine. There is absolutly no way to
do this automatically as the border of the board in the graphic is
unknown. If you change the board size or the size of the left margin,
you will have to adjust the values.


\begin{LTXexample}[width=0.55\textwidth]
\newchessgame
\includegraphics
 [scale=0.477,viewport=-20 17 -20 17]
 {brett}%
\chessboard[showmover=false,
            border=false,
            label=false,
            boardfontencoding=LSBC5,
            boardfontsize=20pt,
            whitepiececolor=brown!70,
            blackpiececolor=black,
            setfontcolors]
\end{LTXexample}

\subsection{Using the commands of \skaksty}

When used with the option \textsf{ps} \skaksty puts in the middle of
the right bottom field (that is either h1 or a8) a postscript node
with the name BM. The highlighting commands of \skaksty use this
node.

To be able to use the commands also with \cs{chessboard} you must
load \skaksty with the option \textsf{ps}.

As arguments in the commands of \skaksty you can only use the fields
of a 8\texttimes8-board.

\medskip
\Describesetkey{psset}{true|false}{}{false}

This key sets the  node BM at the place where \skaksty expect it,
\emph{and it sets the psunits to the size of the board}. This can
affect other pspictures as the changes are made after the board and
so aren't local to the board (the commands of \skaksty must have a
fighting chance to get the correct values).

\medskip
\Describesetkey{psskak}{true|false}{}{false}

This key redefines some internal commands of \skaksty. I had to do it
in order to get the highlighting commands to work. I don't think that
it will destroy anything but didn't want to activate the changes
unasked. The changes are also \emph{not} local to the board (but
local to the group).

\begin{LTXexample}[graphic={chessboard-skakps}]
\documentclass[parskip]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[ps]{skak}
\usepackage{chessboard}

\pagestyle{empty}
\begin{document}
\newchessgame
\chessboard[psskak,psset,pgf=false,
            inverse]
\ifpdf\else
\highlight[X]{c4}
\highlight[o]{a8}
\highlight[O]{g1}
\printknightmove{g8}{f6}
BM\pnode{A}\ncline{->}{A}{BM}
\fi
\end{document}
\end{LTXexample}





\subsection{Intelligent highlighting}

\cs{chessboard} doesn't know anything about chess rules. It can't do
things like «show me the possible moves of the rock», «show me the
allowed moves» or «highlight the last move». But as the examples show
it accepts commands as arguments in the highlighting keys, so it can
use the intelligence of external commands or applications. E.g.\
highlighting of the last move would be easy if \skaksty would somehow
save the last from-field and the last to-field -- something it
doesn't do now.

\section{Extending the game}
\subsection{Adding new pieces}
\DescribeMacro{\cbDefineNewPiece}
With this command you can add new pieces that can be used on the
board.

\cs{cbDefineNewPiece}\oarg{game}\marg{color}\marg{char}\marg{on
white}\marg{on black}

The optional argument \meta{game} has not much use yet as there is
only one sensible value \texttt{skak} which is the default anyway.
So leave it out.

\meta{color} should by either \texttt{white} or \texttt{black}, it
will put the character in the list used by e.g.\ the key
\key{hidewhite}.

\meta{char} is the character used in FEN and the other input
arguments. Use a uppercase char for white pieces and a lowercase
char for the black pieces or the keys like \key{addwhite} won't work
correctly.

\meta{on white} and \meta{on black} should contain the commands
needed to print the piece on white and black fields. The symbols
should be scalable. So you should either use symbols from a font or
use some resizing command from the graphicx package.

\begingroup
\begin{LTXexample}[width=0.25\textwidth]
\makeatletter
\cbDefineNewPiece{white}{C}
  {\raisebox{\depth}{\cfss@whitepiececolor
    $\heartsuit$}}
  {\BlackEmptySquare%
   \makebox[0pt][r]{\cfss@whitepiececolor
    \raisebox{\depth}{%
     \makebox[1em]{$\heartsuit$}}}}
\cbDefineNewPiece{black}{c}
  {\raisebox{\depth}{\cfss@blackpiececolor
    $\clubsuit$}}
  {\BlackEmptySquare%
   \makebox[0pt][r]{\cfss@blackpiececolor
    \raisebox{\depth}{%
     \makebox[1em]{$\clubsuit$}}}}
\makeatother
\setchessboard{tinyboard,
  addpieces={cd4,Ce5},addwhite={ca1,Cb1},
  addblack={ca8,Cb8}}
\chessboard[addpieces={cd4,Ce5, Ke4}]
\chessboard[hidewhite]
\chessboard[boardfontencoding=LSB3,
  whitepiececolor=red,blackpiececolor=blue,
  setfontcolors,color=lightgray,
  trimtocolor=black, colorbackboard]
\end{LTXexample}
\endgroup

%\subsection{Clipping and trimming the picture}



\subsection{Using \texorpdfstring{\cs{chessboard}}{\textbackslash chessboard} for other games}

I have tried to prepare \cs{chessboard} for other games. A lot of
internal commands can be changed simply by changing the «name of the
game». Up to now there isn't another game, so I don't know if this
will really work.


It should be easy to make boards for checkers if I find a font
somewhere. Chinese chess is a bit more complicated as one would have
to decide how to make the background lines. Go is more complicated
as the pieces are sometimes numbered, I don't know yet if I could
implement a good input handling -- but as there is a quite good
package named igo I don't think I will really look into it.


The main problem in any cases is the missing partner: \Pchessboard
isn't «intelligent». As already mentioned above it doesn't know
anything about the rules of chess. To be able to show «the running
game» it needs a partner that does the calculation.



\section{Compability with other packages}

\subsection{\packagename{skak}}
\Pchessboard works fine with \skaksty. You can use \cs{chessboard}
everywhere instead of \cs{showboard} etc.

\subsection{\packagename{texmate}}

The new \packagename{texmate} version use \skaksty to follow the
game. There is no problem to use \cs{chessboard} where the manual
suggest \cs{showboard}.  \packagename{texmate} also defines its own
diagram commands. They use internaly \cs{showboard}. I haven't made
much tests until now, but it looks like after a simple
\lstinline+\let\showboard\chessboard+ you can use \cs{chessboard}
instead. The main problem is that you can't use the argument of
\cs{chessboard}. You will have to set the board properties with
\cs{setchessboard}.


\subsection{\packagename{beamer}}

I wouldn't have thought it, but I had no problem to use
\cs{chessboard} with \packagename{beamer}.

The following listing shows an example. If your pdf-reader can handle
annotations you can see the result in the attached file:
\attachfile{chessboard_and_beamer.pdf}

\begin{lstlisting}
\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage{chessboard, skak}
\begin{document}

\begin{frame}
\newchessgame
\only<1->{\setchessboard{hideall,showmover=false}}
\only<2->{\setchessboard{showpieces={p,P}}}
\only<3->{\setchessboard{showpieces={K,k}}}
\only<4->{\setchessboard{showpieces={Q,q}}}
\only<5->{\setchessboard{showpieces={R,r}}}
\only<6->{\setchessboard{showpieces={B,b}}}
\only<7->{\setchessboard{showpieces={N,n}}}
\chessboard
\end{frame}

\begin{frame}
\newchessgame\setchessboard{markstyle=border,color=blue}
\only<1>{\mainline{1.e4}}
\only<1>{\setchessboard{markfields=e4}}
\only<2>{\hidemoves{1.e4}\mainline{1... e5}}
\only<2>{\setchessboard{markfields=e5}}
\only<3>{\hidemoves{1.e4 e5}\mainline{2. Nf3}}
\only<3>{\setchessboard{markfields=f3}}
\only<4>{\hidemoves{1.e4 e5 2.Nf3}\mainline{2... Nc6}}
\only<4>{\setchessboard{markfields=c6}}

\chessboard
\end{frame}
\end{document}
\end{lstlisting}

\subsection{animate}

It also possible to use animate to get «moving» boards (you need a
recent pdf-viewer to see the effect). But it is quite tiresome to
input all the moves. That's why I wrote the package
\packagename{xskak}. It offers a possibility to store all positions
of a game  with \skaksty and then to loop through them. For an
example please read the documentation of \packagename{xskak}. Here an
example of the more tiresome input:

\begin{lstlisting}
\newchessgame
\unitlength1pt
\newcommand\currentboard{%
 \begin{picture}(150,150)
 \put(10,10){\chessboard}
 \end{picture}}
\begin{animateinline}[autoplay,loop]{1}%
\currentboard
\newframe\hidemoves{1.e4}%
\currentboard
\newframe\hidemoves{1... e5}%
\currentboard
\newframe\hidemoves{2. Nf3}%
\currentboard
\newframe\hidemoves{2... Nc6}%
\currentboard
\newframe\hidemoves{3.Bb5}%
\currentboard
\newframe\hidemoves{3... a6}%
\currentboard
\end{animateinline}
\end{lstlisting}


\phantomsection
\makeatletter\def\index@prologue{\section*{Index}\addcontentsline{toc}{section}{Index}}\makeatother
\printindex
\end{document}

\end{document}