summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/wargame/source/wargame.dtx
blob: a2e7d06a9485faf1236e6cc01bd0363e7ab3558c (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
% \iffalse
%<*driver>
% This is the preamp used in various documents 
\documentclass{ltxdoc}
%<symbols>\usepackage[noterrainpic]{wgdoc}
%<!symbols>\usepackage{wgdoc}
%</driver>
%\fi
%\iffalse
%<*doc>
% This is for the main documentation
\usepackage{wgdoc}
\input{testmap}
\input{testchits}
\usetikzlibrary{external}
\tikzexternalize[prefix=cache/]
\CodelineIndex
\EnableCrossrefs
\DisableCrossrefs
\DoNotIndex{\a,\advance,\args,\bfseries,\breakforeach,\cc,\ccc,
  \divide,\def,\h,\filldraw,\node,\path,\RequirePackage,\ProvidesPackage,
  \Large,\large,\huge,\Huge,\normalsize,\tiny,
  \long,\n,\mc,\o,\p,
  \usetikzlibrary,\draw,\foreach,\fv,\tikzinputsegmentfirst,
  \tikzinputsegmentsupporta,\tikzinputsegmentsupportb,
  \tikzinputsegmentlast,\pgfmathparse,\pgfpoint,\edef,\pgfmathresult,
  \relax,\ifx,\else,\fi,\definecolor,\tikz,\tikzset,\tikzstyle,
  \maxdimen,\pgfseteorule,\message,\global,\clip,\let,\end,\begin,
  \sffamily,\selectfont,\fontsize,\DeclareTextFontCommand,
  \selectfont,\define@key,\pgf@x,\pgf@y,\xdef,\expandafter,\@ifundefined,
  \pgfpointxy,\csname,\endcsname,\pgfpointadd,\fill,\@empty,\@ifnextchar,
  \@undefined,\@undefinedb,\arrow,\b,\c,\color,\fontfamily,\fontseries,
  \gdef,\i,\k,\m,\newcommand,\newcount,\newif,\newlength
  \pgf@pathmaxx,\pgf@pathminx,\pgf@pathmaxy,\pgf@pathminy,
  \pgf@picmaxx,\pgf@picminx,\pgf@picmaxy,\pgf@picminy,
  \pgf@relevantforpicturesizefalse,\pgf@relevantforpicturesizetrue,
  \pic,\r,\setkeys,\setlength,\show,\t,\temp,\the,
  \tikzdeclarecoordinatesystem,\tmp@x,\tmp@y,\v,\x,\y}
%% \OnlyDescription
\def\PrintMacroName#1{}
\def\PrintEnvName#1{}
\title{The \textsf{wargame} package}
\author{Christian Holm Christensen}
\date{\today}
\begin{document}
\maketitle
\begin{abstract}
  This package provides tools to typesetting manuals, board, and
  counters for wargames using \LaTeX{}.

  Licensed under
  \href{http://creativecommons.org/licenses/by-sa/4.0}{Creative
    Commons Attribution-ShareAlike International License, version 4}
  \tikz[scale=.2,transform shape]{\pic{cc by sa};}.
\end{abstract}
\tableofcontents
\wargamedbglvl=0
\hexdbglvl=0
\chitdbglvl=0
\natoappdbglvl=0
% To avoid:  Package multicol Error: Error saving partial page.
\setlength{\IndexMin}{100pt} 
\DocInput{wargame.dtx}
\end{document}
%</doc>
%\fi
%
% \iffalse
% ====================================================================
%
% Documentation
%
% ====================================================================
% \fi
% 
% \newif\ifShowSymbols\ShowSymbolsfalse
% \newif\ifShowCompat\ShowCompatfalse
%
% \iffalse
% --------------------------------------------------------------------
%
% Introduction
%
% --------------------------------------------------------------------
% \fi
% 
% \section{Introduction}
% 
% This package provides tools for typesetting classic, hex-based
% wargames.  The package allows an author to design a board, or map,
% comprised of hex, using a relatively simple interface.  Units are
% typeset using a similar interface.  Unit types are identified using
% the NATO Joint Military Symbology \cite{app6c} standard.
%
% \iffalse
% --------------------------------------------------------------------
%
% Hexes
%
% --------------------------------------------------------------------
% \fi
% 
% \section{Hex Boards}
%   
% The package provides a number of facilities to set-up a board
% comprised of hexagon fields (``hexes'').
%
% \subsection{Placing hexes}
%       
% A hex can be added to the current \texttt{tikzpicture} using the
% macro \cs{hex}.  It takes up to 4 arguments
%       
% \begin{MacroSyntax}{\hex}
%   \cs{hex}\oarg{key-value-pairs}\parg{location}\parg{name}
% \end{MacroSyntax}
%
% The \meta{key-value-pairs} specify the hex.  Valid options are
% \begin{description}
% \item[\keyval{terrain}{\meta{terrain-keys}}] specifies the terrain
%   of the hex.  More on in this in
%   \sectionname~\ref{sec:hex:terrain}. 
% \item[\keyval{ridges}{\meta{ridges-keys}}] specifies where ridges
%   are drawn in the hex. \sectionname~\ref{sec:hex:ridges}. 
% \item[\keyval{label}{\meta{label-keys}}] specifies the how to output
%   the hex label, if any.  This is expanded upon in
%   \sectionname~\ref{sec:hex:label}.
% \item[\keyval{town}{\meta{town-keys}}] specifies that a town (or
%   similar) is present in the hex.  The various keys are described in
%   \sectionname~\ref{sec:hex:town}.
% \item[\keyval{extra}{\meta{extra-keyx}} \textrm{and} \keyval{extra
%   clipped}{\meta{extra-keyx}}]  allows the user to put custom
%   graphics in the hexes.  See also \sectionname~\ref{sec:hex:extra}
%   for more.
% \item any style key defined for \TikZ{} pictures.
% \end{description}
% 
% The \meta{location} argument specifies the coordinates, in the hex
% coordinate system where to put the hex.  More about the coordinate
% system is given in \sectionname~\ref{sec:hex:cs}. Note, the numbers
% starts from the lower--left corner.
%
% The elements are rendered in the following order
% \begin{enumerate}
% \item The terrain, clipped to the hex shape.
% \item The hex, including circumference and fill
% \item The ridges, if any
% \item The label, if any
% \item Extra graphics clipped to the hex
% \item Town, if any
% \item Extra graphics which may extend beyond the confines of the
%   hex. 
% \end{enumerate}
%
% \figurename~\ref{fig:hex:parts} illustrates some of the components
% of a hex.  The hexes are 2 unit lengths wide.  Typically, the unit
% length is one centimetre, which means the hexes are roughly
% $2\,\text{cm}\times 1.86\,\text{cmm}$ --- or roughly $3/4"\times
% 3/4"$ --- big.  This allows the hexes to fit chits (see
% Section~\ref{sec:chit}) of size $12\,\mathrm{mm}\times12\,\mathrm{mm}$
% --- or roughly $1/2"\times1/2"$ --- nicely.  If one wants larger
% chits or hexes one should take care to scale both by a similar
% amount. 
%
% {\makeatletter\global\let\hexyy\hex@yy}
% \tikzset{wg arrow/.style={red!50!black,thick,<-}}
% \begin{figure}[htbp]
%   \centering
%   \begin{tikzpicture}[scale=2]
%     \hex[terrain={woods},label={text=A1},color=blue](r=0,c=0)
%     \draw[red]($(hex cs:e=N)-(0,.2)$)
%       ellipse [x radius=.8, y radius=.4] node(label){};
%     \draw[wg arrow] (label)--(1.3,1.2)
%       node[align=right,anchor=south]{\texttt{label=\{text=A1\}}};
%     \draw[wg arrow] (0,0)--(-2,-1)node[align=right,anchor=base east]{
%       \texttt{terrain=\{woods\}}};
%     \pic[draw,transform shape]{wg/x axis={-1,1,  -1.2,{0},}};
%     \pic[draw,transform shape]{wg/y axis={1.2, -1,1,  {0},{-\hexyy,\hexyy}}};
%   \end{tikzpicture}
%   \caption{Hex parts. The bar on the bottom and to the right
%   indicate two units of length.}
%   \label{fig:hex:parts}
% \end{figure}
% 
% \subsection{Styling hexes}
%
% Typical \TikZ{} options can be passed to the \cs{hex} macro.  For
% example, if you want to draw the hex borders in red, simply pass
% \spec{draw=red} in the \oarg{optional} arguments to
% \cs{hex}. Individual parts of the hexes can be styled separately.
% the default style used by \cs{hex} is \spec{tikz/hex/hex}.  Users
% can redefine this style to suit their needs.  If one does not want
% to change the default style, or pass the same argument to all
% \cs{hex}s one can define the style \spec{tikz/every hex}.  For example,
% if one wants to auto label all hexes, one can do
%
% \begin{verbatim}
% \begin{tikzpicture}
%   \begin{scope}[every hex/.style={label=auto}]
%     % Hexes
%   \end{scope}
% \end{tikzpicture}
% \end{verbatim}
% 
% \subsection{Hex coordinate system}
% \label{sec:hex:cs}
%
% The package defines a coordinate system based on hexes.  The centre
% of a hex is specified as \meta{column}-\meta{row} pairs, while
% vertexes and mid-point on edges can be specified separately.  The
% syntax of the coordinates is
%
% \begin{Syntax}
%    (hex cs:row=\meta{hex-row},column=\meta{hex-column},vertex=\meta{vertex},edge=\meta{edge})
% \end{Syntax}
%
% where \meta{vertex} and \meta{edge} are optional.  The hex row and
% column defaults both to 0 and can be decimal numbers. The
% \spec{row}, \spec{column}, \spec{vertex}, and \spec{edge} keywords
% may be shorted to \spec{r}, \spec{c}, \spec{v}, and \spec{e},
% respectively.  Possible vertexes and edges are listed in
% \tablename~\ref{tab:hex:ve}.
%
% \begin{table}[htbp]
%   \centering
%   \begin{tabular}{m{.3\linewidth}m{.65\linewidth}}
%     \begin{tikzpicture}
%       \hex(r=0,c=0)
%       \foreach \v in {E,NE,NW,W,SW,SE}{
%         \fill(hex cs:v=\v) circle(0.05);
%         \node[inner sep=2pt] (v\v) at ($1.6*(hex cs:v=\v)$){\spec{v=\v}};
%         \draw[<-](hex cs:v=\v)--(v\v); }
%       \foreach \e in {NE,N,NW,SW,S,SE}{
%         \fill(hex cs:e=\e) circle(0.05);
%         \node[inner sep=2pt] (e\e) at ($1.6*(hex cs:e=\e)$) {\spec{e=\e}};
%         \draw[<-](hex cs:e=\e) -- (e\e);}
%     \end{tikzpicture}
%     &
%     \begin{tabular}{|ccr|ccr|}
%       \hline
%       \rowcolor{headbg}
%       \multicolumn{2}{c}{\color{headfg}\spec{vertex=}}
%       & {\color{headfg}\textbf{Angle}}
%       & \multicolumn{2}{c}{\color{headfg}\spec{edge=}}
%       & {\color{headfg}\textbf{Angle}}
%       \\
%       \hline
%       \rowcolor{white}
%       \spec{east}       & \spec{E}  & $  0^{\circ}$ &
%       \spec{north east} & \spec{NE} & $ 30^{\circ}$\\
%       \spec{north east} & \spec{NE} & $ 60^{\circ}$ &
%       \spec{north}      & \spec{N}  & $ 90^{\circ}$\\
%       \spec{north west} & \spec{NW} & $120^{\circ}$ &
%       \spec{north west} & \spec{NW} & $150^{\circ}$\\
%       \spec{west}       & \spec{W}  & $180^{\circ}$ &
%       \spec{south west} & \spec{SW} & $210^{\circ}$\\
%       \spec{south west} & \spec{SW} & $240^{\circ}$ &
%       \spec{south}      & \spec{S}  & $270^{\circ}$\\
%       \spec{south east} & \spec{SE} & $300^{\circ}$ &
%       \spec{south east} & \spec{SE} & $330^{\circ}$\\
%       \hline
%     \end{tabular}
%   \end{tabular}
%   \caption{Vertex and edge positions}
%   \label{tab:hex:ve}
% \end{table}
% 
% In \figurename~\ref{fig:hex:cs} is an example of a picture drawn in
% this coordinate system.
%
% \begin{figure}[htbp]
%   \begin{tabular}{m{.3\linewidth}m{.65\linewidth}}
%       \begin{tikzpicture}[]
%       \hex[color=lightgray](r=0,c=0)
%       \hex[color=lightgray](r=0,c=1)
%       \hex[color=lightgray](r=1,c=0)
%       \hex[color=lightgray](r=1,c=1)
%       \draw[blue!50!black] (hex cs:r=0,c=0) -- (hex cs:r=1,c=1);
%       \draw[red!50!black]  (hex cs:r=0,c=0,vertex=E) --
%         (hex cs:r=1,c=1,edge=north west);
%       \fill (hex cs:r=0,c=0) circle(.1)
%         node[color=gray,anchor=north] {\spec{(r=0,c=0)}};
%       \fill (hex cs:r=1,c=1) circle(.1)
%         node[color=gray,anchor=west]  {\spec{(r=1,c=1)}};
%       \fill (hex cs:r=0,c=0,v=east) circle(.1)
%         node[color=gray,anchor=north west]{\spec{(r=0,c=0,v=E)}};
%       \fill (hex cs:r=1,c=1,e=north west) circle(.1)
%         node[color=gray,anchor=south]{
%         \spec{(r=1,c=1,e=NW)}};
%       \fill[lightgray](hex cs:r= .3,c= .3) circle(0.1)
%       node[anchor=south,inner sep=0]{(0.3,0.3)};  
%       \fill[lightgray](hex cs:r=1.3,c= .3) circle(0.1)
%       node[anchor=south,inner sep=0]{(1.3,0.3)};  
%       \fill[lightgray](hex cs:r=0.3,c=1.3) circle(0.1)
%       node[anchor=south,inner sep=0]{(0.3,1.3)};  
%       \fill[lightgray](hex cs:r=1.3,c=1.3) circle(0.1)
%       node[anchor=south,inner sep=0]{(1.3,1.3)};  
%     \end{tikzpicture}
%       &
%           Hexes and lines drawn with 
% \begin{verbatim}
% \hex(0,0)\hex(0,1)\hex(1,0)\hex(1,1)
% \draw[blue!50!black] (hex cs:r=0,c=0) --
%                      (hex cs:r=1,c=1);
% \draw[red!50!black]  (hex cs:r=0,c=0,vertex=E) --
%                      (hex cs:r=1,c=1,edge=NW);
% \fill[lightgray](hex cs:r= .3,c= .3) circle(0.1);
% \fill[lightgray](hex cs:r=1.3,c= .3) circle(0.1);
% \fill[lightgray](hex cs:r=0.3,c=1.3) circle(0.1);
% \fill[lightgray](hex cs:r=1.3,c=1.3) circle(0.1);
% \end{verbatim}
%   \end{tabular}
%   \caption{Hex coordinate system}
%   \label{fig:hex:cs}
% \end{figure}
%
%
% \textbf{Important}: When the horizontal distance to the centre of a
% hex becomes less than $-\cos60^{\circ}$ or larger than
% $b-\cos60^{\circ}$ we effectively have a new hex column, and the
% coordinates are shifted upward or downward for smaller or larger
% numbers.  Figure~\ref{fig:hex:coord:nb} illustrates. this.  This can
% make it a little hard to specify coordinates relative to a hex
% centre.  Alternatively one may use vertex or edge specifciations
% together with a relative offset in those directions.
% \
% \begin{figure}
%   \centering
%   \begin{tikzpicture}
%     \begin{scope}[scale=2,every node/.style={inner sep=0}]
%       \hex
%       
%       \begin{scope}[red,fill]
%         \draw[anchor=south east](hex cs:c=-0.66,r=-0.67)circle(.01)node{(-2/3,-2/3)};
%         \draw[anchor=south east](hex cs:c=-0.67,r=-0.33)circle(.01)node{(-2/3,-1/3)};
%         \draw[anchor=south east](hex cs:c=-0.67,r=0)circle(.01)node{(-2/3,0)};
%         \draw[anchor=south east](hex cs:c=-0.67,r=0.33)circle(.01)node{(-2/3,1/3)};
%         \draw[anchor=north](hex cs:c=-0.33,r=-0.67)circle(.01)node{(-1/3,-2/3)};
%         \draw[anchor=north](hex cs:c=-0.33,r=-0.33)circle(.01)node{(-1/3,-1/3)};
%         \draw[anchor=south](hex cs:c=-0.33,r=0.33)circle(.01)node{(-1/3,1/3)};
%         \draw[anchor=south](hex cs:c=-0.33,r=0.67)circle(.01)node{(-1/3,2/3)};
%         \draw[anchor=south](hex cs:c=0.33,r=-0.67)circle(.01)node{(1/3,-2/3)};
%         \draw[anchor=south](hex cs:c=0.33,r=-0.33)circle(.01)node{(1/3,-1/3)};
%         \draw[anchor=north](hex cs:c=0.33,r=0.33)circle(.01)node{(1/3,1/3)};
%         \draw[anchor=north](hex cs:c=0.33,r=0.67)circle(.01)node{(1/3,2/3)};
%         \draw[anchor=north west](hex cs:c=0.67,r=-0.33)circle(.01)node{(2/3,-1/3)};
%         \draw[anchor=north west](hex cs:c=0.67,r=0)circle(.01)node{(2/3,0)};
%         \draw[anchor=north west](hex cs:c=0.67,r=0.33)circle(.01)node{(2/3,1/3)};
%         \draw[anchor=north west](hex cs:c=0.67,r=0.67)circle(.01)node{(2/3,2/3)};
%       \end{scope}
%       
%       \hex(c=2)
%       \begin{scope}[blue,fill]
%         \draw[anchor=south west](hex cs:c=2,v=NE,o=0.5)circle(.01)node{NE by 1/2};
%         \draw[anchor=south west](hex cs:c=2,v=NE,o=1.0)circle(.01)node{NE by 1};
%         \draw[anchor=south west](hex cs:c=2,v=NE,o=1.5)circle(.01)node{NE by 3/2};
%         \draw[anchor=south east](hex cs:c=2,v=NW,o=0.5)circle(.01)node{NW by 1/2};
%         \draw[anchor=south east](hex cs:c=2,v=NW,o=1.0)circle(.01)node{NW by 1};
%         \draw[anchor=south east](hex cs:c=2,v=NW,o=1.5)circle(.01)node{NW by 3/2};
%         \draw[anchor=north](hex cs:c=2,v=W,o=0.5)circle(.01)node{W by 1/2};
%         \draw[anchor=south](hex cs:c=2,v=W,o=1.0)circle(.01)node{W by 1};
%         \draw[anchor=north](hex cs:c=2,v=W,o=1.5)circle(.01)node{W by 3/2};
%         \draw[anchor=north east](hex cs:c=2,v=SW,o=0.5)circle(.01)node{SW by 1/2};
%         \draw[anchor=north east](hex cs:c=2,v=SW,o=1.0)circle(.01)node{SW by 1};
%         \draw[anchor=north east](hex cs:c=2,v=SW,o=1.5)circle(.01)node{SW by 3/2};
%         \draw[anchor=north west](hex cs:c=2,v=SE,o=0.5)circle(.01)node{SE by 1/2};
%         \draw[anchor=north west](hex cs:c=2,v=SE,o=1.0)circle(.01)node{SE by 1};
%         \draw[anchor=north west](hex cs:c=2,v=SE,o=1.5)circle(.01)node{SE by 3/2};
%         \draw[anchor=north](hex cs:c=2,v=E,o=0.5)circle(.01)node{E by 1/2};
%         \draw[anchor=south](hex cs:c=2,v=E,o=1.0)circle(.01)node{E by 1};
%         \draw[anchor=north](hex cs:c=2,v=E,o=1.5)circle(.01)node{E by 3/2};
%       \end{scope}
%     \end{scope}
%   \end{tikzpicture}
%   \caption{Relative coordinates}
%   \label{fig:hex:coords:nb}
% \end{figure}
% \subsection{Terrains}
% \label{sec:hex:terrain}
%
% Terrains are rendered using tile images or \TikZ{}
% \texttt{pic}tures.  The available terrains are shown in
% \tablename{}s~\ref{tab:hex:terrain:image}
% and~\ref{tab:hex:terrain:pic}. Users can provide their own tile
% images and select those via \texttt{terrain=\{image=\meta{image}\}}
% or defined \TikZ{} \texttt{pic}tures and select those via
% \texttt{terrain=\{pic=\meta{pic-name}\}}.  In all cases, the terrain
% graphics is clipped to the hex.
%
% The terrain of a hex is selected via the multi-valued key
% \spec{terrain}.  Sub-keys of this key are
%
% \begin{description}
% \item[\spec{image=}\meta{graphics-file}] Specifies terrain tile
%   image \meta{graphics-file}.
% \item[\spec{pic=}\meta{picture-key}] Specifies terrain tile \TikZ{}
%   \spec{pic}ture.
% \item[\spec{code=}\meta{tikz-code}] Any valid \TikZ{} code
% \item[\spec{clip=}\meta{path(s)}] \TikZ{} path specification to clip
%   the terrain within the hex.
% \end{description}
%   
% \begin{table}[htbp]
%   \centering
%   \begin{tabular}{|m{2cm}|ll|m{2cm}|ll|}
%     \hline
%     \rowcolor{headbg}
%     {\color{headfg}\textbf{Symbol}}
%     & {\color{headfg}\textbf{Name}}
%     & {\color{headfg}\texttt{terrain=\{image=\meta{image}\}}}
%     & {\color{headfg}\textbf{Symbol}}
%     & {\color{headfg}\textbf{Name}}
%     & {\color{headfg}\texttt{terrain=\{image=\meta{image}\}}}\\
%     \hline
%     &&&&&\\[-1ex]
%     \tikz{\hex[](r=0,c=0) }
%     & Clear
%     & \texttt{}
%     & \tikz{\hex[terrain={image=beach}](r=0,c=0) }
%     & Beach
%     & \texttt{\{image=beach\}}\\
%     \tikz{\hex[terrain={image=light_woods}](r=0,c=0) }
%     & Light woods
%     & \texttt{\{image=light\_woods\}}
%     & \tikz{\hex[terrain={image=woods}](r=0,c=0)}
%     & Woods
%     & \texttt{\{image=woods\}}\\
%     \tikz{\hex[terrain={image=rough}](r=0,c=0) }
%     & Rough
%     & \texttt{\{image=rough\}}
%     & \tikz{\hex[terrain={image=swamp}](r=0,c=0) }
%     & Swamp
%     & \texttt{\{image=swamp\}}\\
%     \tikz{\hex[terrain={image=mountains}](r=0,c=0) }
%     & Mountains
%     & \texttt{\{image=mountains\}}
%     & \tikz{\hex[fill=blue!40!white](r=0,c=0) }
%     & Sea
%     & \texttt{\{image=sea\}}\\
%     \hline
%   \end{tabular}
%   \caption{Terrains specified via tile images}
%   \label{tab:hex:terrain:image}
% \end{table}
%   
% \begin{table}[htbp]
%   \centering
%   \begin{tabular}{|m{2cm}|l|l|}
%     \hline
%     \rowcolor{headbg}
%     {\color{headfg}\textbf{Symbol}}
%     & {\color{headfg}\textbf{Name}}
%     & {\color{headfg}\texttt{terrain=\{pic=\meta{image}\}}}\\
%     \hline
%     &&\\[-1ex]
%     \tikz{\hex[terrain={pic=hex/terrain/mountain,line width=3pt}](r=0,c=0) }
%       & Mountains
%       & \texttt{\{pic=hex/terrain/mountain,line width=3pt\}}\\
%     \hline
%   \end{tabular}
%   \caption{Terrains specified via \TikZ{} \spec{pic}tures}
%   \label{tab:hex:terrain:pic}
% \end{table}
%
% The terrain can be clipped by the sub-key \spec{clip}.  This can be
% useful if the game specifies movement costs in terms of hex-edge
% crossing, for example \emph{First Blood}~\cite{fb}.  In that case, a
% hex may be, for example, a jungle hex, but some edges a clear.  Thus
% movements across such an edge would count as moving into clear
% territory while moving over other edges will count as moving into a
% jungle.   This is, of course, not how most games count movement
% costs, but this package nonetheless facilitates such rules.
% \tablename~\ref{tab:hex:terrain:clip} shows a few examples of
% predefined clippings of terrain.
%
% Users can define \TikZ{} \spec{pic}tures that specify clipping paths
% as needed.  For example, one could add clipping to the terrain to
% ensure that other graphics in the hex stands out. 
% 
% \begin{table}[htbp]
%   \centering
%   \begin{tabular}{|m{2cm}m{.3\linewidth}|m{2cm}m{.3\linewidth}|}
%     \hline
%     \rowcolor{headbg}
%     {\color{headfg}\textbf{Symbol}}
%     & {\color{headfg}\texttt{terrain=\{clip=,...\}}}
%     & {\color{headfg}\textbf{Symbol}}
%     & {\color{headfg}\texttt{terrain=\{clip=,...\}}}\\
%     \hline
%     &&&\\
%     \tikz{\hex[terrain={woods,
%                         clip={hex/sextant=NE}}](r=0,c=0) }
%     & \spec{\{hex/sextant=NE\}}
%     & \tikz{\hex[terrain={woods,
%         clip={
%           hex/large sextant=NE,
%           hex/large sextant=N}}](r=0,c=0) }
%     & \spec{\{hex/large sextant=NE,hex/large sextant=N\}}\\
%     \hline
%     \tikz{\hex[terrain={woods,
%                         clip={hex/sextant=N}}](r=0,c=0) }
%     & \spec{\{hex/sextant=N\}}
%     & \tikz{\hex[terrain={woods,
%         clip={hex/sextant=NE,
%         hex/sextant=N,
%         hex/sextant=NW}}](r=0,c=0) }
%     & \spec{\{hex/sextant=NE,
%         hex/sextant=N,
%         hex/sextant=NW\}}\\
%     \hline
%     \tikz{\hex[terrain={woods,
%                         clip={hex/sextant=NW}}](r=0,c=0) }
%     & \spec{\{hex/sextant=NW\}}
%     & \tikz{\hex[terrain={woods,
%         clip={hex/sextant=NE,
%         hex/sextant=N,
%         hex/sextant=NW,
%         hex/sextant=SW}}](r=0,c=0) }
%     & \spec{\{hex/sextant=NE,
%         hex/sextant=N,
%         hex/sextant=NW,
%         hex/sextant=SW\}}\\
%     \hline
%     \tikz{\hex[terrain={woods,
%                         clip={hex/sextant=SW}}](r=0,c=0) }
%     & \spec{\{hex/sextant=SW\}}
%     & \tikz{\hex[terrain={woods,
%         clip={hex/sextant=NE,
%         hex/sextant=N,
%         hex/sextant=NW,
%         hex/sextant=SW,
%         hex/sextant=S}}](r=0,c=0) }
%     & \spec{\{hex/sextant=NE,
%         hex/sextant=N,
%         hex/sextant=NW,
%         hex/sextant=SW,
%         hex/sextant=S\}}\\
%     \hline
%     \tikz{\hex[terrain={woods,
%                         clip={hex/sextant=S}}](r=0,c=0) }
%     & \spec{\{hex/sextant=S\}}
%     & \tikz{\hex[terrain={woods,
%         clip={hex/sextant=NE,
%         hex/sextant=N,
%         hex/sextant=NW,
%         hex/sextant=SW,
%         hex/sextant=S,
%         hex/sextant=SE}}](r=0,c=0) }
%     & \spec{\{hex/sextant=NE,
%         hex/sextant=N,
%         hex/sextant=NW,
%         hex/sextant=SW,
%         hex/sextant=S,
%         hex/sextant=SE\}}\\
%     \hline
%     \tikz{\hex[terrain={woods,
%                         clip={hex/sextant=SE}}](r=0,c=0) }
%     & \spec{\{hex/sextant=SE\}}
%     & \tikz{\hex[terrain={woods,
%         clip={hex/sextant=NE,
%         hex/sextant=N,
%         hex/sextant=NW,
%         hex/sextant=SW,
%         hex/sextant=S,
%         hex/sextant=SE,
%         hex/sextant=C}}](r=0,c=0) }
%     & \spec{\{hex/sextant=NE,
%         hex/sextant=N,
%         hex/sextant=NW,
%         hex/sextant=SW,
%         hex/sextant=S,
%         hex/sextant=SE,
%         hex/sextant=C\}}\\
%     \hline
%     \tikz{\hex[terrain={woods,
%                         clip={hex/sextant=C}}](r=0,c=0) }
%     & \spec{\{hex/sextant=C\}}
%     & \tikz{\hex[terrain={woods,
%         clip={hex/sextant=NE,
%         hex/sextant=N,
%         hex/sextant=S,
%         hex/sextant=SE,
%         hex/sextant=C}}](r=0,c=0) }
%     & \spec{\{hex/sextant=NE,
%         hex/sextant=N,
%         hex/sextant=S,
%         hex/sextant=SE,
%         hex/sextant=C\}}\\
%     \hline
%   \end{tabular}
%   \caption{Terrain clipped via \spec{clip} sub-key}
%   \label{tab:hex:terrain:clip}
% \end{table}
%
% \subsubsection{Styling terrains}
%
% Terrains use the key \spec{tikz/hex/terrain} to render the
% terrains. This is mainly useful for terrains made from \TikZ{}
% \spec{pic}tures.
% 
% \subsection{Ridges}
% \label{sec:hex:ridges}
% 
% Ridges, or hill or mountain slopes, can be added to a hex via the
% keyword \spec{ridges}.  The keyword takes a list of hex edges and
% generates symbology for the ridge on the chosen edges.  Note that
% the edges does not have to be continuous, as illustrated in the
% bottom right of \tablename~\ref{tab:hex:ridges}, nor in any
% particular order.  The edges are specified as compass direction
%
% \begin{Syntax}
%   north east, north, north west, south west, south, south east.\\
%   NE, N, NW, SW, S, SE
% \end{Syntax}
%
% \tablename~\ref{tab:hex:ridges} shows some examples. 
% 
% \begin{table}[htbp]
%   \centering
%   \begin{tabular}{|m{2cm}|c|m{2cm}|c|}
%     \hline
%     \rowcolor{headbg}
%     {\color{headfg}\textbf{Symbol}}
%     & {\color{headfg}\spec{ridges=}}
%     & {\color{headfg}\textbf{Symbol}}
%     & {\color{headfg}\spec{ridges=}}\\
%     \hline
%     &&&\\[-1ex]
%     \tikz{\hex[ridges=NE]}
%     & \spec{NE}
%     & \tikz{\hex[ridges={NE,N}]}
%     & \spec{NE,N}\\
%     \tikz{\hex[ridges=N]}
%     & \spec{N}
%     & \tikz{\hex[ridges={NE,N,NW}]}
%     & \spec{NE,N,NW}\\
%     \tikz{\hex[ridges=NW]}
%     & \spec{NW}
%     & \tikz{\hex[ridges={NE,N,NW,SW}]}
%     & \spec{NE,N,NW,SW}\\
%     \tikz{\hex[ridges=SW]}
%     & \spec{SW}
%     & \tikz{\hex[ridges={NE,N,NW,SW,S,line width=3pt}]}
%     & \spec{NE,N,NW,SW,S,line width=3pt}\\
%     \tikz{\hex[ridges=S]}
%     & \spec{S}
%     & \tikz{\hex[ridges={NE,N,NW,SW,S,SE,color=brown!70!black}]}
%     & \spec{NE,N,NW,SW,S,SE,color=brown!70!black}\\
%     \tikz{\hex[ridges=SE]}
%     & \spec{SE}
%     & \tikz{\hex[ridges={N,S,NW,SE},terrain={rough}]}
%     & \spec{N,S,NW,SE}\\
%     \hline
%   \end{tabular}
%   \caption{Ridges}
%   \label{tab:hex:ridges}
% \end{table}
% 
% \subsubsection{Styling ridges}
%
% Every ridge is drawn with the style \spec{tikz/hex/ridges}.  Users
% can customise this style.  The default is to draw thin black wave
% lines (\TikZ{} decoration \spec{waves}).  The default style also
% takes care to auto scale line widths. 
%
% \subsection{Labels}
% \label{sec:hex:label}
%
% Labels can be placed on the hexes via the keyword \spec{label}.  The
% label can either be auto-generated or given explicitly.
% \tablename~\ref{tab:hex:label} shows the various choices.
%
% \begin{table}[htbp]
%   \centering
%   \begin{tabular}{|m{2cm}|l|c|m{6cm}|}
%     \hline
%     \rowcolor{headbg}
%     {\color{headfg}\textbf{Symbol}}
%     & {\color{headfg}\textbf{Name}}
%     & {\color{headfg}\textbf{Column/Row}}     
%     & {\color{headfg}\spec{label=}}\\
%     \hline
%       &&&\\[-1ex]
%     \tikz{\hex[label=none](r=0,c=0) }
%       & No label
%       & n/a
%       & \spec{none}\\
%     \tikz{\hex[label={text=B10}](r=0,c=0) }
%       & User specified
%       & n/a
%       & \spec{text=B10}\\
%     \tikz{\hex[label={color=blue,text=A1}](r=0,c=0) }
%       & User specified
%       & n/a
%       & \spec{\{color=blue,text=A1\}}\\
%     \tikz{\hex[label=auto](r=3,c=9) }
%       & Two-digit, zero padded numbers
%       & 9/3
%       & \spec{auto}\\
%     \tikz{\hex[label={auto=alpha column,font=\noexpand\rmfamily}](r=3,c=2)}
%       & Column letter, number row
%       & 2/3
%       & \spec{\{auto=alpha column,font=\cs{noexpand}\cs{rmfamily}\}}
%       \textsuperscript{$\dag$}\\
%     \tikz{\hex[label={auto=alpha 2 column,anchor=north east}](r=24,c=6) }
%       & Two letter column, two digit row
%       & 6/24
%       & \spec{\{auto=alpha 2 column,anchor=north east\}}\\
%     \hline
%   \end{tabular}
%   \caption{Labels\newline
%   \textsuperscript{$\dag$}When specifying macros as key values in
%   the options, for example the value \cs{rmfamily} for the key
%   \spec{font} above, we have to put a \cs{noexpand} in front if the
%   macro.  This is to prevent early expansion of the macro, which
%   would cause errors.  A minor nuisance.}
%   \label{tab:hex:label}
% \end{table}
%
% The option \spec{auto=inv y x plus 1} will label the rows
% inversely, and add one to the column number.  This requires that the
% key \spec{tikz/max hex row} has been set to the largest row number
% used.
% 
% In addition to the sub-keys \spec{none}, \spec{auto}, and
% \spec{text}, one can also specify the following keys
%
% \begin{description}
% \item[\keyval{place}{\meta{coordinates}}] specifies the Location of
%   label within the hex. The anchor point of the text will be placed
%   at this point.
% \item[\oarg[options]] at the start of the option (but inside braces
%   \spec{\{\textellipsis\}}) can be used to give additional style
%   options. 
% \end{description}
%
% \subsubsection{Styling labels}
%
% All labels use the style \spec{tikz/hex/label}. By default, this
% places the label at the top of the hex, and renders the text as gray
% script sized text. Users can customise this style. If a user does
% not want to change the default style, or want to pass the same
% option to all labels, then one can set the key \spec{tikz/every
% label} to those options.
%
%
% \subsection{Towns}
% \label{sec:hex:town}
%
% Towns in hexes are made via the key \spec{town}.  This key takes
% several sub-keys, as illustrated in \tablename~\ref{tab:hex:town}
%
% 
% \begin{table}[htbp]
%   \centering
%   \begin{tabular}{|m{2cm}l|m{2cm}l|}
%     \hline
%     \rowcolor{headbg}
%     {\color{headfg}\textbf{Symbol}}
%     & {\color{headfg}\spec{town=}}
%     & {\color{headfg}\textbf{Symbol}}
%     & {\color{headfg}\spec{town=}}\\
%     \hline
%     &&&\\[-1ex]
%     \tikz{\hex[town](r=0,c=0) }
%     & \spec{}
%     & \tikz{\hex[town={name=Copenhagen}](r=0,c=0) }
%     & \spec{\{name=Copenhagen\}}\\
%     \tikz{\hex[town={pic=hex/town/city}](r=0,c=0) }
%     & \spec{\{pic=hex/town/city\}}
%     & \tikz{\hex[town={red,pic=hex/town/city}](r=0,c=0) }
%     & \spec{\{red,pic=hex/town/city\}}\\
%     \tikz{\hex[town={fill=red}](r=0,c=0) }
%     & \spec{\{fill=red\}}
%     & \tikz{\hex[town={pic=hex/town/city,name=London}](r=0,c=0) }
%     & \spec{\{name=London\}}\\
%     \tikz{\hex[town={color=red,name=Paris}](r=0,c=0) }
%     & \spec{\{red,name=Paris\}}
%     &\tikz{\hex[town={above=0.8,name=Berlin}](r=0,c=0) }
%     & \spec{\{above=0.8,name=Berlin\}}\\
%     \tikz{\hex[town={place={(.2,.2)}}](r=0,c=0) }
%     & \spec{\{place=\{(.2,.2)\}\}}
%     &\tikz{\hex[town={font=\noexpand\itshape,name=Amsterdam}](r=0,c=0) }
%     & \spec{\{font=\cs{noexpand}\cs{itshape},name=Amsterdam\}}
%       \textsuperscript{$\dag$}\\
%     \hline
%   \end{tabular}
%   \caption{Towns\newline
%   \textsuperscript{$\dag$}When specifying macros as key values in
%   the options, for example the value \cs{rmfamily} for the key
%   \spec{font} above, we have to put a \cs{noexpand} in front if the
%   macro.  This is to prevent early expansion of the macro, which
%   would cause errors.  A minor nuisance.}
%   \label{tab:hex:town}
% \end{table}
%
% The sub-keys available for the \spec{town} key are
%
% \begin{description}
% \item[\keyval{pic}{\meta{town-pic}}] The name of a \TikZ{}
%   \spec{pic}ture.  Currently defined are \spec{hex/town/town} and
%   \spec{hex/town/city}.  Users can provide alternate definitions or new types
%   by defining \TikZ{} \spec{pic}tures.
% \item[\keyval{place}{\meta{coordinates}}] Location of label within
%   the hex. The anchor point of the text will be placed at this
%   point. 
% \item[\keyval{name}{\meta{name}}] Name of town
% \end{description}
% 
% \subsubsection{Styling towns}
%
% Towns uses two styles: \spec{tikz/hex/town} for the town graphics,
% and \spec{tikz/hex/town name} for the name of the town. In addition,
% a user may set the key \spec{tikz/every hex town} to contain options
% to be passed to all towns. 
%  
% \subsection{Extra graphics for hexes} 
% \label{sec:hex:extra}
%
% Additional graphics for hexes can be added by the two keys
% \spec{extra} and \spec{extra clipped}.  The difference between the
% two are that graphics specified by \spec{extra clipped} are clipped
% (restricted) to the hex, while graphics given by \spec{extra} may
% extend beyond the hex.  Both keys accept a comma separated list of
% arguments, where each element has the syntax
%
% \begin{Syntax}
%   \oarg{options}\parg{placement}\meta{picture}
% \end{Syntax}
%
% Both \meta{options} and \meta{placement} are optional, and specifies
% keys to draw \meta{picture} with and the relative location in the
% hex, respectively.  The required argument \meta{picture} must name a
% \TikZ{} \spec{pic}ture, for example \spec{hex/fortress}.  This can
% be useful for marking hexes on the board.  For example to mark a
% set-up hex for one faction of the game.
%
% One could for example define the following pictures to define set-up
% points for a Sovjet and German faction
%
% \tikzset{
%   setup/sovjet/.pic={
%     \path[fill=red,draw=yellow,pic actions]
%       ( 90:.4)--(126:.15)--
%       (162:.4)--(198:.15)--
%       (234:.4)--(270:.15)--
%       (306:.4)--(342:.15)--
%       ( 18:.4)--( 54:.15)--cycle;},
%   setup/german/.pic={
%     \path[fill,pic actions]
%       (-.4, -.1) rectangle(.4,.1)
%       (-.1, -.4) rectangle(.1,.4);
%     \path[draw,pic actions]
%       (-.4,-.2) -- (-.2,-.2) -- (-.2,-.4)
%       (-.4, .2) -- (-.2, .2) -- (-.2, .4)
%       ( .4, .2) -- ( .2, .2) -- ( .2, .4)
%       ( .4,-.2) -- ( .2,-.2) -- ( .2,-.4);},
%   foo/large/.pic={
%     \path[fill=gray,pic actions] (-1,-.5) rectangle(1,.5);},
% }
% \begin{verbatim}
%   setup/sovjet/.pic={
%     \path[fill=red,draw=yellow,pic actions]
%       ( 90:.4)--(126:.15)--
%       (162:.4)--(198:.15)--
%       (234:.4)--(270:.15)--
%       (306:.4)--(342:.15)--
%       ( 18:.4)--( 54:.15)--cycle;},
%   setup/german/.pic={
%     \path[fill,pic actions]
%       (-.4, -.1) rectangle(.4,.1)
%       (-.1, -.4) rectangle(.1,.4);
%     \path[draw,pic actions]
%       (-.4,-.2) -- (-.2,-.2) -- (-.2,-.4)
%       (-.4, .2) -- (-.2, .2) -- (-.2, .4)
%       ( .4, .2) -- ( .2, .2) -- ( .2, .4)
%       ( .4,-.2) -- ( .2,-.2) -- ( .2,-.4);}
%   foo/large/.pic={
%     \path[fill=gray,pic actions] (-1,-.5) rectangle(1,.5);},
% }
% \end{verbatim}
%       
% We can place extra graphics in hexes as shown in
% \tablename~\ref{tab:hex:extra}.
%     
% \begin{table}[htbp]
%   \centering
%   \begin{tabular}{|m{2cm}l|}
%     \hline
%     \rowcolor{headbg}
%     {\color{headfg}\textbf{Symbol}}
%     & {\color{headfg}\spec{extra=}}\\
%         \hline
%     &\\[-1ex]
%     \tikz{\hex[extra=hex/fortress](r=0,c=0) }
%     & \spec{hex/fortress}\\
%     \tikz{\hex[extra=setup/sovjet](r=0,c=0) }
%     & \spec{setup/sovjet}\\
%     \tikz{\hex[extra=setup/german](r=0,c=0) }
%       & \spec{setup/german}\\
%     \tikz{\hex[extra={setup/german,hex/fortress}](r=0,c=0) }
%     & \spec{\{setup/german,hex/fortress\}}\textsuperscript{$\dag$}\\
%     \tikz{\hex[extra={[{line width=2pt,color=brown}]hex/fortress 2}](r=0,c=0) }
%     & \spec{\{[\{line width=2pt,brown\}]
%         fortress 2\}}\textsuperscript{$\ddag$}\\
%     \tikz{\hex[extra={[shift={(.2,.2)}]setup/sovjet}](r=0,c=0) }
%     & \spec{\{[shift=\{(.2,.2)\}]setup/sovjet\}}\textsuperscript{$\ddag$}\\
%     \tikz{\hex[extra={[{shift={(.2,.2)},scale=.5,color=gray}]setup/german}](r=0,c=0) }
%     & \spec{\{[\{shift=\{(.2,.2)\},scale=.5,color=gray\}]
%         setup/german\}}\textsuperscript{$\ddag$}\\
%     \tikz{\hex[extra=foo/large]} & \spec{foo/large}\\
%     \rowcolor{headbg}
%     {\color{headfg}\textbf{Symbol}}
%     & {\color{headfg}\spec{extra clipped=}}\\
%     \hline
%     &\\[-1ex]
%     \iftrue
%     \tikz{\hex[extra clipped=foo/large]} & \spec{foo/large}\\
%     \fi
%     \hline
%   \end{tabular}
%   \caption{Hex extra graphics.  Note that in the last line we use
%   the graphics \spec{foo/large} with \spec{extra clipped} (compare
%   to line just above) to restrict the graphics to the hex.\newline%
%   \textsuperscript{$\dag$}When specifying more than one item, the
%   list must be enclosed in braces
%   (\spec{\{\textellipsis\}})\newline%
%   \textsuperscript{$\ddag$}When an item in the list of \spec{extra}
%   contains a comma (\spec{,}), for example in a list of graphics
%   options, then we need to enclose the inner list \emph{and} the
%   whole list in braces (\spec{\{\textellipsis\}}) to protect against
%   unwanted expansion.}
%   \label{tab:hex:extra}
% \end{table}
%     
% To finish off this part on hexes and what we can do with those, we
% generate a map in \figurename~\ref{fig:hex:placing}.
% 
% \begin{figure}[htbp]
%   \centering
%   \begin{tabular}{m{.3\linewidth}m{.68\linewidth}}
%     \begin{tikzpicture}[scale=.8]
%         \hex[town={pic=hex/town/city,name=Berlin}](r=0,c=0) 
%         \hex[]                                 (r=0,c=1) 
%         \hex[]                                 (r=0,c=2) 
%         \hex[terrain={swamp},label=auto]       (r=0,c=3) 
%         \hex[]                                 (r=1,c=0) 
%         \hex[terrain={light woods}]            (r=1,c=1) 
%         \hex[terrain={woods}]                  (r=1,c=2) 
%         \hex[terrain={swamp}]                  (r=1,c=3) 
%         \hex[town={name=Freiburg},extra=hex/fortress](r=2,c=0) 
%         \hex[extra=hex/fortress]               (r=2,c=1) 
%         \hex[terrain={rough}]                  (r=2,c=2) 
%         \hex[]                                 (r=2,c=3) 
%         \hex[terrain={mountains}]              (r=3,c=0) 
%         \hex[terrain={mountains}]              (r=3,c=1) 
%         \hex[terrain={mountains}]              (r=3,c=2) 
%         \hex[]                                 (r=3,c=3) 
%     \end{tikzpicture}
%     &
%     \begin{verbatim}
% \hex[town={pic=hex/town/city,name=Berlin}]   (r=0,c=0) 
% \hex[]                                       (r=0,c=1) 
% \hex[]                                       (r=0,c=2) 
% \hex[terrain={swamp},label=auto]             (r=0,c=3) 
% \hex[]                                       (r=1,c=0) 
% \hex[terrain={light woods}]                  (r=1,c=1) 
% \hex[terrain={woods}]                        (r=1,c=2) 
% \hex[terrain={swamp}]                        (r=1,c=3) 
% \hex[town={name=Freiburg},extra=hex/fortress](r=2,c=0) 
% \hex[extra=hex/fortress]                     (r=2,c=1) 
% \hex[terrain={rough}]                        (r=2,c=2) 
% \hex[]                                       (r=2,c=3) 
% \hex[terrain={mountains}]                    (r=3,c=0) 
% \hex[terrain={mountains}]                    (r=3,c=1) 
% \hex[terrain={mountains}]                    (r=3,c=2) 
% \hex[]                                       (r=3,c=3) 
%     \end{verbatim}
%   \end{tabular}
%   \caption{Placing hexes}
%   \label{fig:hex:placing}
% \end{figure}
%   
% \subsection{Rivers, borders, and roads}
%
% Rivers and borders follow the hex sides and are added to the current
% \spec{tikkzpicture} using \cs{river} and \cs{border} macros
% respectively.  They are specified as regular \TikZ{} paths.  It is
% useful to utilise the hex coordinate system for this.
%   
% \begin{MacroSyntax}{\river,\border}
%   \cs{river}\oarg{options} \meta{path};\\
%   \cs{border}\oarg{options} \meta{path};
% \end{MacroSyntax}
% 
% Rivers are essentially borders, but are randomized to giver a more
% aesthetically pleasing output.  
% 
% Roads and railroads typically go from hex--center to hex--center,
% and are added using the macro \cs{road}.  The road or railroad is
% specified via a regular \TikZ{} path.
%   
% \begin{MacroSyntax}{\addriver}
%   \cs{road}\oarg{options} \meta{path};\\
%   \cs{railroad}\oarg{options} \meta{path};
% \end{MacroSyntax}
%   
% Towns and cities conveniently serve as places to split up a road at. 
% 
% \begin{figure}[htbp]
%   \centering
%   \begin{tikzpicture}
%     \testmap
%   \end{tikzpicture}
%   \caption{Adding rivers, boarders, and roads}
% \end{figure}
% 
% \subsection{Board clipping and frame}
% 
% In the river, border, and road example above, the roads extend beyond
% the hexes, which does not look very nice.  One way to deal with this,
% is to draw a clipping box around the hexes
% 
% \begin{figure}[htbp]
%   \centering
%   \begin{tabular}{m{.\linewidth}m{.\linewidth}}
%     \begin{tikzpicture}
%       \draw[clip](-.5,-.5) rectangle (5,5);
%       \testmap
%     \end{tikzpicture}
%     &
% \begin{verbatim}
% \draw[clip](-.5,-.5) rectangle (5,5);
% \testmap
% \end{verbatim}
%   \end{tabular}
%   \caption{Clipping for a manual using a \TikZ{}
%   \cs{draw}\spec{[clip]} command.}
%   \label{fig:hex:boxclip}
% \end{figure}
%   
% This technique works fine for examples in a manual, it has a
% somewhat displeasing effect for a full board.  The package therefor
% defines the macro \cs{boardclip} which clips the graphics
% according to the defined hexes.
% 
% \begin{MacroSyntax}{\boardclip}
%   \cs{boardclip}\parg{lower-left}\parg{upper-right}\marg{options} 
% \end{MacroSyntax}
%   
% A clipping path of that spans from the hex at \meta{lower-lest} to
% \meta{upper-right}.  Note, that both of these arguments should only
% specify the column and row keys.  If \meta{options} is non-empty,
% then the clipping path is drawn with those options.
% 
% \begin{figure}[htbp]
%   \centering
%   \begin{tabular}{m{.4\linewidth}m{.4\linewidth}}
%     \begin{tikzpicture}
%       \begin{scope}
%         \boardclip(c=0,r=0)(c=3,r=3){}
%         \testmap
%       \end{scope}
%     \end{tikzpicture}
%       &
% \begin{verbatim}
% \begin{scope}
%   \boardclip(c=0,r=0)(c=3,r=3){}
%   \testmap
% \end{scope}
% \end{verbatim}
%   \end{tabular}
%   \caption{Snug--fit clipping of board using the macro \cs{boardclip}}
%   \label{fig:hex:clip}
% \end{figure}
%   
% This is particularly useful together with the \cs{boardframe} macro.
% This macro will put a frame around the board, optionally with a
% margin.
%   
% \begin{MacroSyntax}{\boardframe}
%   \cs{boardframe}\oarg{margin}\parg{lower-left}{upper-right}
% \end{MacroSyntax}
% 
% where \meta{lower-left} and \meta{upper-right} are as for
% \cs{boardclip}. The \meta{margin} must be a number, and specifies an
% optional margin around the hexes, The argument \meta{options}
% specifies how the frame is drawn.  The idea is to first draw the
% frame, then the clipping shape, and then the hexes.  One should take
% care to use the \meta{options} argument to \cs{boardclip} to specify
% a default background color. The frame is drawn with the style
% \spec{hex/board frame}
%
% \begin{figure}[htbp]
%   \centering
%   \begin{tabular}{m{4.\linewidth}m{4.\linewidth}}
%     \begin{tikzpicture}[hex/border/.append style={color=red},
%                         hex/board frame/.style={fill=Tan}]
%       \begin{scope}[every hex/.style={label=auto}]
%         \boardframe[0.5](c=0,r=0)(c=3,r=3){0.5}
%         \boardclip(c=0,r=0)(c=3,r=3){fill=white}
%         \testmap{}
%       \end{scope}
%     \end{tikzpicture}
%       &
% \begin{verbatim}
% \begin{scope}[every hex/.style={label=auto}]
%   \boardframe[0.5](c=0,r=0)(c=3,r=3)
%   \boardclip(c=0,r=0)(c=3,r=3){fill=white}
%   \testmap{}
% \end{scope}
% \end{verbatim}
%   \end{tabular}
%   \caption{Combining a frame and clipping}
%   \label{fig:hex:frame}
% \end{figure}
% 
% The \cs{boardframe} macro prints the position of the rectangle to
% the log output, if one needs to do some more stuff around the board.
%
% \iffalse
% --------------------------------------------------------------------
%
% Chits
%
% --------------------------------------------------------------------
% \fi
% 
% \cleardoublepage
% \section{Chits}
%
% Chits, or playing counters\footnote{Since \TeX{} has the concept of
% counters as in `\cs{count}' and \LaTeX{}'s `\cs{newcounter}', we
% choose the name `chit' for playing pieces instead.}, can be made
% with the macro \cs{chit}.  The syntax for rendering a chit is
%
% \begin{MacroSyntax}{\chit}
%   \cs{chit}\oarg{key-value-pairs}\parg{location}\parg{name}
% \end{MacroSyntax}
%
% \figurename~\ref{fig:chit:overview} shows an example of a chit.
%
% \begin{figure}[htbp]
%   \centering
%   \begin{tikzpicture}[scale=2]
%     \firstchit
%     \pic[draw,transform shape]{wg/x axis={-1,1,  -1.2,{0},{-.6,.6}}};      
%     \pic[draw,transform shape]{wg/y axis={1.2,-1,1,   {0},{-.6,.6}}};
%     \draw[wg arrow] (-.2,-.4)--(-0.9,-.6)
%       node[anchor=east]{\spec{factors=\{chit/2 factors=\{4,8\}\}}};
%     \draw[wg arrow] (-.5,.2)--(-1.1,.6)
%       node[anchor=east]{\spec{left=\{chit/identifier=\{1\}\}}};
%     \draw[wg arrow] (.5,.2)--(.7,1.2)
%       node[anchor=south west]{\spec{right=\{chit/identifier=\{2\}\}}};
%     \draw[wg arrow] (-.2,.4)--(-1,1)
%       node[anchor=east]{\spec{symbol=\{\meta{nato app 6(c) spec}\}}};
%   \end{tikzpicture}
%   \caption{An example of a chit.  The lines below and to the right
%   shows two unit lengths. Other global options used are
%   \spec{color=white} to set the foreground colour, \spec{fill=blue}
%   for the background, and \spec{text=yellow} to set the font colour
%   to yellow.  The \spec{symbol} key also contains
%   \spec{frame=\{fill=yellow!50!black} to set the frame fill colour,
%   and \spec{ultra thick} to set the line width of the NATO App6(C)
%   symbol. Note that the line width is automatically scaled.}
%   \label{fig:chit:overview}
% \end{figure}
%
%
% The example in \figurename~\ref{fig:chit:overview} shows an infantry
% mountaineer army unit with attack factor 4, and movement factor 8.
% The NATO App6(c) symbol is given in terms of keywords for the
% \cs{natoapp} macro (see \sectionname~\ref{sec:nateoapp6c}).  The
% other parts of the chit (\spec{factors}, \spec{left}, \spec{right},
% and \spec{below}) are rendered onto the chit via \TikZ{}
% \spec{pic}tures.  This allows for a great deal of flexibility in
% generating chits.  For example, above we use the \spec{pic}tures
% \spec{chit/identifier} and \spec{chit/2 factors} to render the left-
% and right-hand identifiers, and the factors, respectively.
%
% Full frame chits --- that is chits which are not typically
% designating units or faction specific chits, e.g., a turn marker ---
% can be made by using the key \spec{full}.  In that case, all other
% keys (\spec{symbol}, \spec{factors}, \spec{left}, \spec{right},
% and \spec{below}) are ignored. \figurename~\ref{fig:chit:full} shows
% such an example.
%
% \begin{figure}[tbp]
%   \centering
%   \begin{tabular}{m{.45\linewidth}m{.45\linewidth}}
%     \begin{tikzpicture}[scale=2]
%       \turnchit
%     \end{tikzpicture}
%     &
%     chit made with
%     \begin{verbatim}
% \tikzset{
%   wg/big text/.pic={
%     \node[font=\sffamily\fontsize{18}{0}%
%           \selectfont]{#1};}}
%  \tikz{
%   \chit[full={wg/big text={Turn}},
%         black,fill=yellow!20!white](0,0)}
% \end{tikzpicture}
% \end{verbatim}
%   \end{tabular}
%   \caption{An example of a full-frame chit. }
%   \label{fig:chit:full}
% \end{figure}
%
% The size of the chits are $1.2\times1.2$ unit lengths squared.  This
% is tuned so that the chits will fit within the hexes produced by the
% \cs{hex} command (see \sectionname~\label{sec:hex}).  In
% \figurename~\ref{fig:chit:hex} we illustrate this.  Typically the
% unit is one centimetre. which means the chits are
% $12\,\text{mm}\times12\,\text{mm}$ --- or roughly $1/2"\times1/2"$,
% which is a fairly good size for most games. 
% 
% \begin{figure}[tbp]
%   \centering
%   \begin{tikzpicture}
%     \hex
%     \firstchit(hex cs:r=0,c=0)
%     \hex(c=1,r=0)
%     \secondchit(hex cs:r=0,c=1)
%     \hex(c=2,r=0)
%     \thirdchit(hex cs:r=0,c=2)
%   \end{tikzpicture}
%   \caption{Example of chits fit within hexes. }
%   \label{fig:chit:hex}
% \end{figure}
% 
% \subsection{Styling chits}
%
% Typical \TikZ{} options can be passed to the \cs{chit} macro.  For
% example, if you want to draw the chit with a red foreground, simply pass
% \spec{draw=red} in the \oarg{optional} arguments to
% \cs{chits}. Individual parts of the hexes can be styled separately.
%
% \paragraph{Important:} To set the colours of the various elements,
% 
% one should use 
% \begin{description}
% \item[\spec{color}=\meta{foreground and text}] Selects the
%   foreground colour of lines, text, and so on, including for the
%   NATO App6(C) symbol.
% \item[\spec{fill}=\meta{background}] Selects the background colour
%   of the full chit.  By default this is transparent.
% \item[\spec{text}=\meta{text foreground}] Selects the colour used
%   for text in the chit.  This overrides \spec{color} for text.
% \item[\spec{draw}=\meta{foreground}] This sets the colour for
%   foreground elements, excluding text. 
% \end{description}
% \TikZ{} allows one to pass a \meta{colour} as arguments for drawing
% and understands that as giving the foreground and text colours.
% However, that key is \emph{deprecated} for this library, as it does
% not properly propagate through\footnote{The colour
% \spec{pgfstrokecolor} is not modified by that.}.
%
% The styles used by the \spec{left}, \spec{right}, \spec{setup},
% \spec{factors}, and \spec{symbol} elements are
% \spec{tikz/chit/left}, \spec{tikz/chit/right}, \spec{tikz/setup},
% \spec{tikz/factors}, and \spec{tikz/symbol} respectively. A user can
% redefine these to change the appearance of the chits.  For example,
% one could make the symbol larger by setting a different
% \spec{scale}, move the factors to the side by changing \spec{shift},
% and so on. 
%
% Pictures used by these elements are also styled by
% similar keys.  For example, the picture \spec{chit/identifier} is
% styled by \spec{tikz/chit/identifier}.
%
% In addition, one can define the key \spec{tikz/every chit} to be the
% default options for all chits.
%
% \subsection{Defining preset chit types}
%
% One can conveniently pre-define some chit styles.  For example,
% given the style definition
%
% \begin{verbatim}
% \tikzset{
%   my chit/.style={/chit/symbol={[
%       faction=friendly,
%       command=land,
%       main=armoured]},
%     /chit/left={chit/identifier={Mine}},
%     /chit/factors={chit/2 factors={2,4}}}}
% \end{verbatim}
%
% We can use that to make different chits with some commonalities
% defined by that style.   For example
%
% \begin{tikzpicture}
%  \chit[my chit](0,-2)
%  \chit[my chit,color=white,fill=red,right={chit/identifier=1}](2,-2)   
% \end{tikzpicture}
%
% where, in the second example, we have passed additional options to
% \cs{chit}.  Note that we \emph{must} give the full path to the
% \spec{chit} keys when defining a style like this. 
%
% \iffalse
% --------------------------------------------------------------------
%
% NATO App6(c) symbols
%
% --------------------------------------------------------------------
% \fi
% 
% \cleardoublepage
% \section{NATO App 6(c) symbols}
% \label{sec:nateoapp6c}
%
% The NATO markers are designed to fit within the template shown in
% \figurename~\ref{fig:natoapp:template}. The template is serves as a
% placement guide of the the various parts of the NATO marker as
% illustrated in \figurename{fig:natoapp:usage}.
%
% \begin{figure}[htbp]
%   \centering
%   \begin{tikzpicture}[scale=2]
%     \node[natoapp6c={command=base}] {};
%   \end{tikzpicture}
%   \caption{Template for NATO symbols}
%   \label{fig:natoapp:template}
% \end{figure}
% 
% \begin{MacroSyntax}{\natoapp}
%   \cs{natoapp}\oarg{key-value-pairs}\parg{location}\parg{name}
% \end{MacroSyntax}
% 
% where all arguments are optional.
% Keys are defined to fill in the various parts of the markers.  These
% keys are
% \begin{description}
% \item[\keyval{faction}{\meta{faction}}] Selects the faction used for
%   the symbol. See also
%   \sectionname~\ref{sec:natoapp:faction:command}.
% \item[\keyval{command}{\meta{command}}] Selects the command used for
%   the symbol.  See also
%   \sectionname~\ref{sec:natoapp:faction:command}.
% \item[\keyval{main}{\meta{mains}}] Specifies the main symbol(s).
%   This can be a comma separated list of specifiers (delimited by
%   braces \marg{first,second,\textellipsis}), and each symbol can be
%   preceeded by an optional argument to shift, scale, rotate, etc.,
%   the individual symbols.  \ifShowSymbols See also
%   \sectionname~\ref{sec:natoapp:mains}\fi.
% \item[\keyval{left}{\meta{lefts}}, \keyval{right}{\meta{rights}},
%   \keyval{top}{\meta{tops}}, \keyval{bottom}{\meta{bottoms}},
%   \keyval{below}{\meta{belows}}] Specifies the left-, right-hand,
%   top, bottom, and lower symbol(s). The format of the arguments
%   \meta{lefts}, \meta{rights}, \meta{tops}, \meta{bottoms}, and
%   \meta{belows} has the same format as \meta{mains}.
% \end{description}
%
% \begin{figure}[htbp]
%   \begin{tabular}{m{.45\linewidth}m{.45\linewidth}}
%     \begin{center}
%       \begin{tikzpicture}[scale=2]
%         \natoapp[
%         faction=none,
%         command=base,
%         echelon=army,
%         main={text=M},
%         top={text=T},
%         bottom={text=B},
%         left={text=L},
%         right={text=R},
%         below={text=V}]
%         \pic[draw,transform shape]{wg/x axis={-.5,.5,-.7,,}};
%         \pic[draw,transform shape]{wg/y axis={.7,-.62,.74,,{-.5,.5,-.2,.2}}};
%       \end{tikzpicture}
%     \end{center}
%     & The figure is typeset by
% \begin{verbatim}
% \natoapp[faction=none,
%          command=base,
%          echelon=army,
%          main={text=M},
%          top={text=T},
%          bottom={text=B},
%          left={text=L},
%          right={text=R},
%          below={text=V}]
% \end{verbatim}
%     \end{tabular}
%   \caption{Main keys of \cs{natoapp}. The bottom and right hand
%   bars indicate one unit of length.}
%   \label{fig:natoapp:usage}
% \end{figure}
%
% Other keys are available to further customise the appearance of the
% symbols
% 
% \begin{description}
% \item[\keyval{echelon}{\meta{size}}] The size of the unit described.
%   Possible values are \spec{team}, \spec{squad}, \spec{section},
%   \spec{platoon}, \spec{company}, \spec{battalion}, \spec{regiment},
%   \spec{brigade}, \spec{division}, \spec{corps}, \spec{army},
%   \spec{army group}, \spec{theatre}, and \spec{command}.
% \item[\keyval{frame}{\meta{keys}}] Extra keys for frame.
% \end{description}
%
% \subsection{Faction and Command Selection}
% \label{sec:natoapp:faction:command}
%   
% Table~\ref{tab:frames} shows the various bases used for the various
% {\ttfamily{\itshape faction}/{\itshape command}} combinations.  Also
% shown in the table is the base template for main identifiers.
%   
% \makeatletter
% \def\tabledata{}
% \foreach \c in {air,land,equipment,installation,sea surface,sub surface,space,activity}{%
%   \protected@xappto\tabledata{\spec{\c}}
%   \foreach \f in {friendly,hostile,neutral,unknown}{%
%     \protected@xappto\tabledata{
%       &\noexpand\tikz[scale=.8]{%
%       \noexpand\path (-.75,-.75) rectangle (.75,.75);
%       \noexpand\node[natoapp6c={faction=\f,command=\c},fill=\f]{};
%       \noexpand\node[natoapp6c={command=base},draw=lightgray]{};
%     }}}
%     \protected@xappto\tabledata{\\ \noexpand\hline}}
% \makeatother
%
% \begin{table}[htbp]
%   \centering
%   \begin{tabular}{|l|m{2cm}m{2cm}m{2cm}m{2cm}|}
%     \hline
%     \rowcolor{headbg}
%       & \multicolumn{4}{c|}{{\color{headfg}\meta{faction}}}\\
%       \rowcolor{headbg}
%       {\color{headfg}\meta{command}}
%       & {\color{headfg}\spec{friendly}}
%       & {\color{headfg}\spec{hostile}}
%       & {\color{headfg}\spec{neutral}}
%       & {\color{headfg}\spec{unknown}}
%       \\
%       \hline
%       \tabledata
%   \end{tabular}
%   \caption{Frames for various combinations of \meta{faction} and
%   \meta{command} combinations.  These are drawn with the 
%   \spec{pic} given by
%   \spec{natoapp6c/\meta{faction}/\meta{command}} with the options
%   \spec{draw=blue,fill=\meta{faction}}.  If no \spec{fill} is
%   specified, then the background will be transparent.  Note, the
%   template for main identifiers is also shown on top of each frame.}
%   \label{tab:frames}
% \end{table}
% 
% The fill color of the frame is set by the key \spec{frame}.  If
% this is or contains the special value \spec{faction}, then the
% frame fill colour will be the standard for the faction as
% illustrated in figure~\ref{fig:faction:color}.
% 
% \begin{figure}[htbp]
%   \centering
%   \begin{tikzpicture}
%     \foreach[count=\i] \f in {friendly,hostile,neutral,unknown}{
%     \natoapp[frame=faction,faction=\f,
%     command=space,main={infantry}](2*\i-2,0)}
%   \end{tikzpicture}
%   \caption{Illustration of using the special value \spec{faction}
%   for the \spec{frame} key}
%   \label{fig:faction:color}
% \end{figure}
%   
% Elements of the frame can be controlled by the key \spec{frame}.
% \begin{description}
% \item[\keyval{frame}{\meta{keys}}] Additional keys to pass to the
%   frame drawing.  The special option \spec{faction} will make the
%   frame be filled with the standard faction color.
% \end{description}
%
% \tablename~\ref{tab:frame:color} illustrates this.
% \begin{table}[htbp]
%   \centering
%   \begin{tabular}{|c|cccc|}
%     \hline
%     \rowcolor{headbg}
%     {\color{headfg}\textbf{Example}}
%     & {\color{headfg}\textbf{\spec{frame=\{color,...\}}}}
%     & {\color{headfg}\textbf{\spec{frame=\{fill,...\}}}}
%     & {\color{headfg}\textbf{\spec{frame=\{draw,...\}}}}
%     & {\color{headfg}\textbf{\spec{frame=\{line width,...\}}}}
%     \\
%     \hline
%     \cellcolor{white}
%     \tikz{\natoapp[main={fixed wing},command=air]}
%     &
%     &
%     &
%     &
%     \\
%     \hline
%     \rowcolor{altcol}
%     \cellcolor{white}
%     \tikz{\natoapp[main={fixed wing},command=air,color=red,
%                    frame={line width=2pt}]}
%     & \spec{red}
%     &
%     &
%     & \spec{thick}
%     \\
%     \hline
%     \cellcolor{white}
%     \tikz{\natoapp[main={fixed wing},command=air,
%                    frame={fill=yellow,line width=.5pt}]}
%     & 
%     & \spec{yellow}
%     &
%     & \spec{thin}
%     \\
%     \hline
%     \rowcolor{altcol}
%     \cellcolor{white}
%     \tikz{\natoapp[main={fixed wing},command=air,frame={blue}]}
%     & 
%     & 
%     & \spec{blue}
%     &
%     \\
%     \hline
%     \cellcolor{white}
%     \tikz{\natoapp[main={fixed wing},command=air,frame={fill=pink,magenta}]}
%     & 
%     & \spec{pink}
%     & \spec{magenta}
%     &
%     \\
%     \hline
%     \rowcolor{altcol}
%     \cellcolor{white}
%     \tikz{\natoapp[main={fixed wing},command=air,color=red,
%                    frame={fill=green,draw=blue,line width=3pt}]}
%     & \spec{red}
%     & \spec{green}
%     & \spec{blue}
%     & \spec{ultra thick}
%     \\
%     \hline
%   \end{tabular}
%   \caption{Illustration of frame colour choices}
%   \label{tab:frame:color}
% \end{table}
%
% \subsection{Unit Size (\spec{echelon})}
%
% The size of a unit a marker represents is given by the
% \spec{echelon} keyword.  \tablename~\ref{tab:natoapp6c:echelon}
% shows the various markers and approximate unit sizes.
%
% \let\foo\empty
% \begin{table}[htbp]
%   \centering
%   \begin{tabular}{|m{1.2cm}|cr@{--}lm{.27\linewidth}m{.27\linewidth}|}
%     \hline
%     \rowcolor{headbg}
%     {\color{headfg}\textbf{Example}}
%     & {\color{headfg}\spec{echelon}}
%     & \multicolumn{2}{c}{{\color{headfg}\textbf{Approx.~size}}}
%     & \foo{} {\color{headfg}\textbf{Sub-units}}
%     & \foo{} {\color{headfg}\textbf{Officer}}
%     \\
%     \hline
%     \tikz[scale=.8]{\natoapp[command=land,faction=friendly,main=infantry,echelon=team,lower=airborne]}
%     & \spec{team}
%     & 3
%     & 5
%     & \foo{} none
%     & \foo{} Corporal or Sergeant
%     \\
%     \hline
%     \rowcolor{altcol}
%     \tikz[scale=.8]{\natoapp[command=land,faction=friendly,main=infantry,echelon=squad]}
%     & \spec{squad}
%     & 5
%     & 10
%     & \foo{} 1--2 teams
%     & \foo{} Sergeant
%     \\
%     \hline
%     \tikz[scale=.8]{\natoapp[command=land,faction=friendly,main=infantry,echelon=section]}
%     & \spec{section}
%     & 7
%     & 13
%     & \foo{} 2--3 teams
%     & \foo{} Sergeant
%     \\
%     \hline
%     \rowcolor{altcol}
%     \tikz[scale=.8]{\natoapp[command=land,faction=friendly,main=infantry,echelon=platoon]}
%     & \spec{platoon}
%     & $25$
%     & $40$
%     & \foo{} Several squads/sections
%     & \foo{} Second Lieutenant
%     \\
%     \hline\tikz[scale=.8]{\natoapp[command=land,faction=friendly,main=infantry,echelon=company]}
%     & \spec{company}
%     & $60$      
%     & $250$
%     & \foo{} Several platoons
%     & \foo{} Captain
%     \\
%     \hline
%     \rowcolor{altcol}
%     \tikz[scale=.8]{\natoapp[command=land,faction=friendly,main=infantry,echelon=battalion]}
%     & \spec{battalion}
%     & $300$
%     & $1\,000$
%     & \foo{} 2--6 companies
%     & \foo{} Lieutenant colonel 
%     \\
%     \hline
%     \tikz[scale=.8]{\natoapp[command=land,faction=friendly,main=infantry,echelon=regiment]}
%     & \spec{regiment}
%     & $500$
%     & $2\,000$
%     & \foo{} 3--7 battalions
%     & \foo{} Colonel
%     \\
%     \hline
%     \rowcolor{altcol}
%     \tikz[scale=.8]{\natoapp[command=land,faction=friendly,main=infantry,echelon=brigade]}
%     & \spec{brigade}
%     & $2\,000$
%     & $5\,000$
%     & \foo{} Several battalions
%     & \foo{} Colonel
%     \\
%     \hline
%     \tikz[scale=.8]{\natoapp[command=land,faction=friendly,main=infantry,echelon=division]}
%     & \spec{division}
%     & $10\,000$
%     & $20\,000$
%     & \foo{} Several brigades/regiments
%     & \foo{} Major General
%     \\
%     \hline
%     \rowcolor{altcol}
%     \tikz[scale=.8]{\natoapp[command=land,faction=friendly,main=infantry,echelon=corps]}
%     & \spec{corps}
%     & $30\,000$
%     & $60\,000$
%     & \foo{} Several divisions
%     & \foo{} Lieutenant General
%     \\
%     \hline
%     \tikz[scale=.8]{\natoapp[command=land,faction=friendly,main=infantry,echelon=army]}
%     & \spec{army}
%     & \multicolumn{2}{c}{$100\,000$}
%     & \foo{} Several corps (5--10 divisions)
%     & \foo{} General
%     \\
%     \hline
%     \rowcolor{altcol}
%     \tikz[scale=.8]{\natoapp[command=land,faction=friendly,main=infantry,echelon=army group]}
%     & \spec{army group}
%     & $120\,000$
%     & $500\,000$
%     & \foo{} Several armies 
%     & \foo{} Field Marshal
%     \\
%     \hline
%     \tikz[scale=.8]{\natoapp[command=land,faction=friendly,main=infantry,echelon=theatre]}
%     & \spec{theatre}
%     & \multicolumn{2}{c}{$250\,000+$}
%     & \foo{} Several army groups 
%     & \foo{} Field Marshal
%     \\
%     \hline
%     \rowcolor{altcol}
%     \tikz[scale=.8]{\natoapp[command=land,faction=friendly,main=infantry,echelon=command]}
%     & \spec{command}
%     & \multicolumn{4}{c|}{Not a unit size, but designator}
%     \\
%     \hline
%   \end{tabular}
%   \caption{Illustration of echelon values.  Approximate sizes and
%   command officer titles are typical modern day United States of
%   America army values and identifiers.  Historically the unit
%   sizes have changed, as has officer titles.  Furthermore, both
%   the unit sizes, names, and command officer titles may vary from
%   country to country, even across command.}
%   \label{tab:natoapp6c:echelon}
% \end{table}
%
% \subsection{Unit type identification}
%
% \begin{table}
%   \centering%
%   \def\typemark#1{%
%   \tikz[scale=.3]{\natoapp[faction=friendly,command=land,#1]}}
%   \def\sizemark#1{%
%   \tikz[scale=.2]{\pic{natoapp6c/s/echelon=#1};}}
%   \begin{tabular}{|clc|}
%       \rowcolor{headbg}
%       {\color{headfg}\textbf{Symbol}}
%       & \multicolumn{2}{c|}{\color{headfg}\textbf{Type \& Abbreviation}}
%       \\
%       \hline
%       \typemark{upper=air assault}
%         & Air assault
%           & AA\\
%       \rowcolor{altcol}
%       \typemark{upper=air defence}
%         & Air defence
%           & ADA\\
%       \typemark{lower=airborne}
%         & Airborne
%           & AB\\
%       \rowcolor{altcol}
%       \typemark{lower=amphibious}
%         & Amphibious
%           & AM\\
%       \typemark{main=anti tank anti armour}
%         & Anti tank/armoured
%           & AT\\
%       \rowcolor{altcol}
%       \typemark{main=armoured}
%         & Armoured
%           & AR\\
%       \typemark{main=chemical biological radiological nuclear}
%         & Chemical biological radiological nuclear
%           & CB\\
%       \rowcolor{altcol}
%       \typemark{main=combined arms}
%         & Combined arms
%           & CAR\\
%       \typemark{main=engineer}
%         & Engineer
%           & ENG\\
%       \rowcolor{altcol}
%       \typemark{main={[fill=pgfstrokecolor]artillery}}
%         & Field artillery
%           & FA\\
%       \typemark{main=infantry}
%         & Infantry
%           & IN\\
%       \rowcolor{altcol}
%       \typemark{main={infantry,armoured}}
%         & Mechanised infantry
%           & M\\
%       \typemark{lower=mountain}
%         & Mountaineer
%           & MTN\\
%       \rowcolor{altcol}
%       \typemark{upper=naval}
%         & Naval
%           & N\\
%       \typemark{main=reconnaissance}
%         & Reconnaissance
%           & REC\\
%       \rowcolor{altcol}
%       \typemark{main={text=sof}}
%         & Special Operations Forces
%           & SOF\\
%       \hline
%       \rowcolor{headbg}
%       {\color{headfg}\textbf{Symbol}}
%         & \multicolumn{2}{c|}{\color{headfg}\textbf{Echelon \& Abbreviation}}
%       \\
%       \hline
%     \sizemark{army group}
%         & Army group
%           & AG\\
%       \rowcolor{altcol}
%       \sizemark{army}
%         & Army
%           & A\\
%       \sizemark{corps}
%         & Corps
%           & -\\
%       \rowcolor{altcol}
%       \sizemark{division}
%         & Division
%           & D\\
%       \sizemark{brigade}
%         & Brigade
%           & BD\\
%       \rowcolor{altcol}
%       \sizemark{regiment}
%         & Regiment
%           & REGT\\
%       \sizemark{battalion}
%         & Battalion
%           & BN\\
%       \rowcolor{altcol}
%       \sizemark{company}
%         & Company
%           & COY\\
%       \sizemark{platoon}
%         & Platoon
%           & PLT\\
%       \rowcolor{altcol}
%       \sizemark{section}
%         & Section
%           & \\
%       \sizemark{squad}
%         & Squad
%           & \\
%       \hline
%     \end{tabular}
%     \caption{Some abbreviations of unit type identifications}
%     \label{tab:natoapp6c:abbr}
%   \end{table}
%
%
% \ifShowSymbols
% \subsection{Symbols Available}
% \label{sec:natoapp:mains}
% 
% \tablename~\ref{tab:natoapp6c:main:symbols} lists all the symbols
% defined.  Note, these do \emph{not} correspond to \emph{all} the
% symbols defined in NATO APP-6(C) \cite{app6c}.  However, using
% combinations of these symbols one can construct \emph{all} of
% those symbols (and so more if so desired).
% 
% \ifShowCompat
% See also
% Appendix~\ref{app:natoapp6c:compat} for compatibility charts
% between this library and \textsf{milsymb} \cite{milsymb}.
% \fi
% 
% {\makeatletter\SymbolTable{land}{\n@to@pp@s@ll}}
% \fi
% 
% \begin{thebibliography}{99}
% \bibitem{fb} Hanover,C., Hendrix,C.E., \& Llewelyn,S.,
%   \textit{First Blood}, 1997, \url{https://grognard.com/fb/}
% \bibitem{app6c} \textit{NATO Joint Military Symbology}, APP-6(C),
%   May 2011,
%   \url{https://en.wikipedia.org/wiki/NATO_Joint_Military_Symbology}.
% \bibitem{app6d} \textit{NATO Joint Military Symbology}, APP-6(D),
%   October 2017,
%   \url{https://nso.nato.int/nso/nsdd/main/standards/ap-details/1912/EN}
% \bibitem{milsymb} \textsf{milsymb} package,
%   \url{https://www.ctan.org/pkg/MilSymb}. 
% \end{thebibliography}
%
% \StopEventually{}
%
%
% \iffalse
% ====================================================================
%
% Implementation
%
% ====================================================================
%
% The wargame main package
% 
% --------------------------------------------------------------------
% \fi
% 
% \section{Implementation}
% \label{sec:impl}
% 
% \input{package.dtx}
% \input{util/core.dtx}
% \input{hex/core.dtx}
% \input{chit/core.dtx}
% \input{natoapp6c/core.dtx}
%
% \appendix
%
% \iffalse
% ====================================================================
%
% Appendices
% 
% ====================================================================
%
% Compat tables
% 
% --------------------------------------------------------------------
% \fi
% 
% \ifShowCompat
% \section{Compatibility tables}
% \label{app:natoapp6c:compat}
% 
% The following tables provides compatibility with the the 
% \textsf{milsymb} package available from CTAN.
%
% \let\CompatSection\subsection
% \let\CompatSubSection\subsubsection
% \input{cmp_air}
% \input{cmp_missile}
% \input{cmp_land}
% \input{cmp_equipment}
% \input{cmp_installation}
% \input{cmp_seasurface}
% \input{cmp_subsurface}
% \input{cmp_seamine}
% \input{cmp_space}
% \input{cmp_activity}
% \fi
%
% \iffalse
% ====================================================================
%
% Draft VASSAL module
% 
% --------------------------------------------------------------------
% \fi
% \section{Generate draft VASSAL module}
% \label{app:vassal}
%
% We can use the code you wrote for your game pieces (counters, maps,
% tables), to generate a draft VASSAL module.  To that end, use the
% document class \textsf{wgexport}, and some simple macros to export
% your graphics to a single PDF.  A provided Python script then
% processes this to generate the draft VASSAL module.
%
% The generated VASSAL module is not the final thing, but it is a good
% start.
%
% \subsection{Example}
%
% Suppose we have defined counters and markers like
% \begin{verbatim}
% allied 1 id      axis 1 ad     out of supply
% allied 2 ad      axis 2 ad     game turn  
% allied 3 abid    axis 3 ic
% \end{verbatim}
% via Tikz styles.  Also assume that we have macros
% \begin{verbatim}
% \board   \oob    \charts   \front
% \end{verbatim}
% which produces \textsf{tikzpicture}s to the board, OOBs, charts, and
% cover, respectively.  All this is defined in our package
% \texttt{mygame}. Of course that we have our rules in the file
% \texttt{game.pdf}.
%
% We prepare a simple \LaTeX{} source file
%
% \begin{verbatim}
% \documentclass{wgexport}
% \usepackage{mygame}
% \begin{document}
% \begin{imagelist}  %% Records image meta info
%   \chitimages{{%
%      {allied 1 id,allied 2 ad,allied 3 abid}/Allied,%
%      {axis 1 ad,axis 2 ad,axis 3 ic}/Axis,%
%      {out of supply, game turn}/Markers}}
%   \info{Board}{board}{} \board
%   \info{OOB}{oob}{}     \oob
%   \info{Charts}{chart}{}\chart
%   \info{Cover}{front}{} \front
% \end{imagelist}
% \end{document}
% \end{verbatim}
%
% When we run \LaTeX{} on this, we will get a PDF where each page is a
% separate image and the page is cropped to image.  \emph{In addition}
% we will get a CSV (comma-separated-values) file \texttt{export.csv}
% which contains some meta information about each page.   In
% particular, it identifies the name of each page, the category, and
% sub category of the image.
%
% For chits, the name of the image is the style name (e.g., \texttt{game
% turn}).  For other images, it is the first argument to \cs{info}
% above.
%
% The category is for chits is always \texttt{counter}. For other
% images, it is the second argument to the \cs{info} macro (e.g.,
% \texttt{board}).
%
% The category of an image is important later on when we generate the
% VASSAL module.  Recognised categories are
%
% \begin{itemize}
% \item \texttt{counter} for counter images.  Such an image will
%   trigger the creation of a VASSAL game piece.
% \item \texttt{board} for board images.  Images of this kind will
%   result in VASSAL board (or Map) elements.
% \item \texttt{oob} for Order of Battle tables.  This will also
%   result in a VASSAL map being created, but one that is displayed as
%   a pop-up and with a rectangular grid.  This is useful for placing
%   units in an Order of Battle chart.
% \item \texttt{chart} for charts.  These images will be made VASSAL
%   charts --- i.e., pop-up windows which contains some graphics for the
% players reference.
% \item \texttt{front} for the cover image.  This will become the
%   module splash image.  Only one such image (the first) will be used. 
% \end{itemize}
%
% Other categories may be used, and the corresponding image will be
% added to the VASSAL module.  However, they will no be processed in
% any specific way.
%
% The \emph{sub-category} is mainly used for counters.  Above, we gave
% the sub-categories \texttt{Allied}, \texttt{Axis}, and
% \texttt{Markers}.  The sub-categories will help to identify the
% factions of the game, and counter prototypes will be made for each
% category.  The sub-categories of \texttt{board}, \texttt{charts},
% \texttt{oob}, and \texttt{front} has no or little effect.
%
% One we have processed the file above to generate our PDF (Say
% \texttt{export.pdf}), then we can process it (and the CSV file) with
% a Python script to make our draft VASSAL module
%
% \begin{verbatim}
% export.py export.pdf export.csv -o Game.vmod -t Game -v 0.1 \
%     -d "My game" -r rules.pdf 
% \end{verbatim}
%
% This will generate the draft module \texttt{Game.vmod}.  Note that
% we add the rules (\texttt{-r rules.pdf}) to the module so that the
% module is complete.
%
% Once the module has been generated, one can open it in the VASSAL
% editor and further customise it.   For example, the grids used in
% the boards needs to be adjusted, and one may want to make initial
% set-ups or add all counters to the OOB.
%
% Of course, running the Python script will overwrite all changes, so
% perhaps it is a good idea to work on a copy of the output file. 
%
% \iffalse
% This is the package used by the documentation
%<*docsty>
\ProvidesPackage{wgdoc}
\DeclareOption{noterrainpic}{%
  \PassOptionsToPackage{noterrainpic}{wargame}}
\ProcessOptions\relax
%
\RequirePackage{etoolbox}
\RequirePackage{wargame}
\RequirePackage{longtable}
\RequirePackage{colortbl}
\RequirePackage{hyperref}
\RequirePackage{textcomp}
\RequirePackage{float}
\RequirePackage[a4paper,right=1cm,left=2cm]{geometry}
%
\usetikzlibrary{external}
\tikzexternalize[mode=graphics if exists,prefix=.cache-]
%
\newcommand\TikZ{{\mdseries Ti{\itshape k}Z}}
\newcommand\sectionname{Section}
\let\subsubsubsection\paragraph
%
\colorlet{headbg}{LightSlateGrey!50}
\colorlet{headfg}{black}
\colorlet{altcol}{LightSteelBlue!50}
\newcommand\spec[1]{{\obeyspaces\ttfamily #1}}
\newcommand\tspec[1]{{\ttfamily\footnotesize\obeyspaces #1}}
\newcommand\keyval[2]{\spec{#1}=#2}
%
\setlength{\parindent}{0pt}
\setlength{\parskip}{1ex}
\setlength\hfuzz{15pt} 
\hbadness=7000
%
\tikzset{
  cc name/.pic={
    \draw[fill=pgfstrokecolor,draw=none,even odd rule]
    (0,0) circle(.5) circle(.41)
    node[fill=none,transform shape,
    font=\sffamily\bfseries\fontsize{16}{0}\selectfont] {cc}
    ;
  },
  cc by/.pic={
    \draw[fill=pgfstrokecolor,draw=none,even odd rule]
    (0,0) circle(.5) circle(.41) (0,.26) circle(.07)
    (0,.15)
    --++(.11,0)
    to[bend left] ++(.02,-.02)
    --++(0,-.20)
    --++(-.05,0)
    --++(0,-.25)
    --++(-.15,0)
    --++(0,.25)
    --++(-.05,0)
    --++(0,.2)
    to[bend left] ++(.02,.02)
    --cycle
    ;
  },
  cc sa/.pic={
    \draw[fill=pgfstrokecolor,draw=none,even odd rule]
    (0,0) circle(.5) circle(.41)
    (-.22,-.08)
    to[bend right=40] ++(.23,-.20)
    to[bend right=40] ++(.23, .20)
    to[bend right=10] ++(0,   .16)
    to[bend right=40] ++(-.23, .20)
    to[bend right=40] ++(-.23, -.20)
    --++(-.05,0)
    --++(-45:.15)
    --++( 45:.15)
    --++(-.05,0)
    to[bend left=40] ++(.12, .1)
    to[bend left=40] ++(.12, -.1)
    to[bend left=10] ++(0,   -.16)
    to[bend left=40] ++(-.12, -.1)
    to[bend left=40] ++(-.12,  .1)
    --cycle
    ;
  },
  cc by sa/.pic={
    \pic at(-1,0) {cc name};
    \pic at( 0,0) {cc by};
    \pic at( 1,0) {cc sa};
  }
}

%
\newcommand\Continued[1]{\multicolumn{#1}{c}{%
    \textit{\small continued from previous page}}\\}
\newcommand\Continues[1]{\multicolumn{#1}{c}{%
    \textit{\small continues on next page}}\\}
\newcommand\SymbolTable[3][]{%
  \setlength{\LTcapwidth}{\linewidth}
  \def\tabledata{}
  \foreach \m in #3{%
    \protected@xappto\tabledata{\spec{\m}}
    \foreach \f in {friendly,hostile,neutral,unknown}{%
      \protected@xappto\tabledata{
        &\noexpand\tikz[scale=.8]{%
          \noexpand\natoapp[faction=\f,%
                            command=#2,%
                            main={\m},%
                            frame={faction},%
                            #1]}}}
    \protected@xappto\tabledata{\\ \noexpand\hline}}
  \def\colheaders{%
    \hline%
    & \multicolumn{4}{c|}{\meta{faction}}\\%
    \meta{symbol}%
    & \spec{friendly}%
    & \spec{hostile}%
    & \spec{neutral}%
    & \spec{unknown}%
    \\%
    \hline}
  \begin{longtable}{|l|
      m{.1\linewidth}
      m{.1\linewidth}
      m{.1\linewidth}
      m{.1\linewidth}|}
      \caption{Symbols\label{tab:natoapp6c:main:symbols}}\\
      \colheaders         
    \endfirsthead
    \Continued{5}
    \colheaders
    \endhead
    \Continues{5}
    \endfoot
    \endlastfoot
    \tabledata
  \end{longtable}
}
%
\def\CompatSection#1{}
\def\CompatSubSection#1{}
\newcommand\CompatTable[3]{% command, where, list
  \CompatSubSection{\spec{#2}}
  \setlength{\LTcapwidth}{\linewidth}
  \def\tabledata{}
  \foreach \m/\s in #3{%
    \n@to@pp@dbg{2}{Compatibility: `\m' -> `\s'}
    \protected@xappto\tabledata{\tspec{\m} & \tspec{\s}}
    \foreach \f in {{none,frame={draw=lightgray}},%
      friendly,hostile,neutral,unknown}{%
      \protected@xappto\tabledata{
        &\noexpand\tikz[scale=.5]{%
          \noexpand\natoapp[faction=\f,command=#1,\s,frame={faction}]}}}
    \protected@xappto\tabledata{\\ \noexpand\hline}}
  \def\colheaders{%
    \hline%
    &
    & \multicolumn{5}{c|}{\meta{faction}}\\%
    \textsf{milsymb}%
    &\textsf{wargame}%
    & \spec{none}%
    & \spec{friendly}%
    & \spec{hostile}%
    & \spec{neutral}%
    & \spec{unknown}%
    \\%
    \hline}
  \begin{longtable}{|
      m{.15\linewidth}|
      m{.20\linewidth}|
      m{.08\linewidth}
      m{.08\linewidth}
      m{.08\linewidth}
      m{.08\linewidth}
      m{.08\linewidth}|}
    \caption{Compatibility with \textsf{milsymb} \spec{#1},\spec{#2}
      symbols\label{tab:compat:#1:#2}}\\
      \colheaders         
    \endfirsthead
    \Continues{7}
    \colheaders
    \endhead
    \Continues{7}
    \endfoot
    \endlastfoot
    \tabledata
  \end{longtable}
}
%
\newenvironment{Syntax}{% 
  \par
  \vspace{1ex}
  \hspace*{-1cm}
  \ttfamily
  \begin{tabular}{|>{\columncolor{altcol}}p{.8\textwidth}|}
    \hline}{\\\hline\end{tabular}\par\vskip 1ex}
\def\MacroSyntax{%
  \leavevmode\begingroup%
  %\catcode`\\12
  \MakePrivateLetters\M@croSyntax}
\def\M@croSyntax#1{\endgroup%
  \foreach \k in {#1}{\expandafter\Special@Usage@Index\k}
  \Syntax}
\let\endMacroSyntax\endSyntax
%
\@ifundefined{SpecialIndex@}{
  \gdef\SpecialIndex@#1#2{%
    \@SpecialIndexHelper@#1\@nil
    \def\@tempb{ }%
    \ifcat \@tempb\@gtempa
    \special@index{\quotechar\space\actualchar
      \string\verb\quotechar*\verbatimchar
      \quotechar\bslash\quotechar\space\verbatimchar#2}%
    \else
    \def\@tempb##1##2\relax{\ifx\relax##2\relax
      \def\@tempc{\special@index{\quotechar##1\actualchar
          \string\verb\quotechar*\verbatimchar
          \quotechar\bslash\quotechar##1\verbatimchar#2}}%
      \else
      \def\@tempc{\special@index{##1##2\actualchar
          \string\verb\quotechar*\verbatimchar
          \bslash##1##2\verbatimchar#2}}%
      \fi}%
    \expandafter\@tempb\@gtempa\relax
    \@tempc
    \fi}}{}
%
\def\Special@Usage@Index#1{\@bsphack
  {\let\special@index\index\SpecialIndex@{#1}{}}%
  \@esphack}
%    
\def\Speci@lIndex#1#2#3#4{%
  \@bsphack\special@index{%
    #1\actualchar
    {\string\ttfamily\space#1}
    (#3)%
    \encapchar main}%
  \special@index{#4:\levelchar#2\actualchar{%
      \string\ttfamily\space#2}\encapchar main}\@esphack}
%
\def\SpecialHexKeyIndex#1#2{\Speci@lIndex{#1}{#2}{key}{Hex keys}}
\def\SpecialNatoSymbolIndex#1#2{%
  \Speci@lIndex{#1}{#2}{symbol}{NATO App6(c) symbols}}
\def\SpecialNatoFrameIndex#1#2{\Speci@lIndex{#1}{#2}{frame}{NATO App6(c) frame}}
\def\SpecialNatoKeyIndex#1#2{\Speci@lIndex{#1}{#2}{key}{NATO App6(c) keys}}
\def\SpecialKeyIndex#1{\Speci@lIndex{#1}{#1}{key}{TikZ keys}}
%  
\def\get@third #1/#2/#3/{\gdef\curr@third{#3}}
\def\get@second #1/#2/#3/{\gdef\curr@second{#2}}
%
\def\KeyT@ble#1#2{
  \leavevmode
  \par
  \vspace{1ex}
  \hspace*{-1cm}
  \begin{tabular}{#1}
    \hline
    #2
    \hline
  \end{tabular}\par}
%
\def\ShowKeyT@ble#1{
  \KeyT@ble{|p{.1\textwidth}|>{\columncolor{altcol}}p{.7\textwidth}|}{#1}}
%
\def\Macro{%
  \begingroup%
  \catcode`\\12
  \MakePrivateLetters\M@cro}
%
\def\M@cro#1{%
  \endgroup
  \def\tabledata{}
  \foreach \k in {#1}{%
    \protected@xappto\tabledata{%
      \noexpand\spec{\noexpand\string\k}\noexpand\SpecialMainIndex{\k}\\}}
  \KeyT@ble{|>{\columncolor{altcol}}p{.8\textwidth}|}{\noexpand\tabledata}}
\def\endMacro{}
%
\newenvironment{NatoAppSymbol}[1]{%
  \def\tabledata{}
  \foreach \k in {#1}{%
    \expandafter\get@third\k/
    \protected@xappto\tabledata{%
      \noexpand\tikz[scale=.5]{\noexpand\natoapp[main=\curr@third,
        faction=none,command=base,frame={draw=lightgray}]}
      &\noexpand\spec{\k}
      \noexpand\SpecialNatoSymbolIndex{\k}{\curr@third}\\}}
  \ShowKeyT@ble{\tabledata}}{}
\newenvironment{NatoAppFrame}[1]{%
  \def\tabledata{}
  \foreach \k in {#1}{%
    %\expandafter\get@third\k/
    %\expandafter\get@second\k/
    \protected@xappto\tabledata{%
      \noexpand\tikz[scale=.5]{\noexpand\node[shape=\k] {};}
      &\noexpand\spec{\k}
      \noexpand\SpecialNatoFrameIndex{\k}{\k}\\}}
  \ShowKeyT@ble{\tabledata}}{}
\newenvironment{NatoAppKey}[1]{%
  \def\tabledata{}
  \foreach \k in {#1}{%
    \expandafter\get@second\k//
    \protected@xappto\tabledata{%
      \noexpand\spec{\k}\noexpand\SpecialNatoKeyIndex{\k}{\curr@second}\\}}
  \KeyT@ble{|>{\columncolor{altcol}}p{.8\textwidth}|}{\tabledata}}{}
%
\newenvironment{HexKey}[1]{%
  \def\tabledata{}
  \foreach \k in {#1}{%
    \expandafter\get@second\k//
    \protected@xappto\tabledata{%
      \noexpand\spec{\k}\noexpand\SpecialHexKeyIndex{\k}{\curr@second}\\}}
  \KeyT@ble{|>{\columncolor{altcol}}p{.8\textwidth}|}{\tabledata}}{}
\newenvironment{HexKey*}[1]{%
  \def\tabledata{}
  \foreach \k in {#1}{%
    \expandafter\get@second\k/
    \expandafter\get@third\k/
    \protected@xappto\tabledata{%
      \noexpand\spec{\k}\noexpand\SpecialHexKeyIndex{\k}{\curr@second/\curr@third}\\}}
  \KeyT@ble{|>{\columncolor{altcol}}p{.8\textwidth}|}{\tabledata}}{}
%
\newenvironment{TikzKey}[1]{%
  \def\tabledata{}
  \foreach \k in {#1}{%
    \protected@xappto\tabledata{%
      \noexpand\spec{\k}\noexpand\SpecialKeyIndex{\k}\\}}
  \KeyT@ble{|>{\columncolor{altcol}}p{.8\textwidth}|}{\tabledata}}{}
%
\tikzset{
  pics/wg/x axis/.style args={#1,#2,#3,#4,#5}{
    code={
      \begin{scope}[/pgf/number format/.cd,fixed,precision=2]
        \path[pic actions] (#1,#3)--(#2,#3)
        \foreach \t in {#1,#2,#4}{
          \ifx\t\@empty\else
          (\t,#3)--++(0,-.2)
          node[anchor=north]{$\pgfmathprintnumber{\t}$}\fi}
        \foreach \t in {#5}{
          \ifx\t\@empty\else
          (\t,#3)--++(0,-.1)
          node[anchor=north,font=\small]{$\pgfmathprintnumber{\t}$}\fi};
      \end{scope}}},
  pics/wg/y axis/.style args={#1,#2,#3,#4,#5}{
    code={
      \begin{scope}[/pgf/number format/.cd,fixed,precision=2]
        \path[pic actions] (#1,#2)--(#1,#3)
        \foreach \t in {#2,#3,#4}{
          \ifx\t\@empty\else
          (#1,\t)--++(.2,0)
          node[anchor=west]{$\pgfmathprintnumber{\t}$}\fi}
        \foreach \t in {#5}{
          \ifx\t\@empty\else
          (#1,\t)--++(.1,0)
          node[anchor=west,font=\small]{$\pgfmathprintnumber{\t}$}\fi};
      \end{scope}}},
  pics/wg/xaxis/.style args={#1,#2,#3,#4}{%
    code={
      \pic[draw]{wg/x axis={-#1,#1,#2,#3,#4}};}},
  pics/wg/yaxis/.style args={#1,#2,#3,#4}{%
    code={
      \pic[draw]{wg/y axis={#1,-#2,#2,#3,#4}};}},
}
%</docsty>
%
% \iffalse
% --------------------------------------------------------------------
%
% Symbols documentation driver 
% 
% --------------------------------------------------------------------
% \fi
% 
% Driver for symbols only document
%<*symbols>
\title{The \textsf{wargame} package\\
  Symbols}
\author{Christian Holm Christensen}
\date{\today}
\begin{document}
\maketitle
% \natoappdbglvl=3
{\makeatletter\SymbolTable{land}{\n@to@pp@s@ll}}
\end{document}
%</symbols>
%
%
%
%
%
% \iffalse
% --------------------------------------------------------------------
%
% Compatibility documentation driver 
% 
% --------------------------------------------------------------------
% \fi
% 
%
%<*compat>
% Driver for compatibility  only document
\title{The \textsf{wargame} package\\
  \textsf{milsymb} Compatibility}
\author{Christian Holm Christensen}
\date{\today}
\begin{document}
\newgeometry{margin=1cm}
\maketitle
% \natoappdbglvl=1
\let\CompatSection\section
\let\CompatSubSection\subsection
\input{cmp_air}
\input{cmp_missile}
\input{cmp_land}
\input{cmp_equipment}
\input{cmp_installation}
\input{cmp_seasurface}
\input{cmp_subsurface}
\input{cmp_seamine}
\input{cmp_space}
\input{cmp_activity}
\restoregeometry
\end{document}
%</compat>
% \fi
%
% \PrintIndex
% \Finale
%
%
% 
% \iffalse
% EOF
% Local Variables:
%   TeX-command-extra-options: "-shell-escape"
% End:
% \fi