% \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{center}
  \begin{tikzpicture}
    \wargamelogo
  \end{tikzpicture}
\end{center}
\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.
%
% This document is meant as a reference manual (although far from
% complete). A separate tutorial is available, and may be the best
% starting point. 
%
% \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{bevel}{\meta{bevel-keys}}] specifies that a bevel
%   should be added to the hex.   The various keys are described in
%   \sectionname~\ref{sec:hex:bevel}.
% \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[\keyval{row}{\meta{row}} \textrm{and}
%   \keyval{column}{\meta{column}}] Keys to set hex coordinates.
%   Mainly used when using \cs{node} rather than \cs{hex}.  These
%   coordinates should be specified in the \spec{hex cs} coordinate
%   system (\sectionname~\ref{sec:hex:cs}).
% \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
% by default starts from the lower--left corner, but can be changed
% via options. 
%
% 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 Bevel if selected
% \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}
%
% Note that the macro \cs{hex} is really a short hand for \TikZ{}'s
% \cs{node} macro, but with preset options.  An alternative to using
% the \cs{hex} macro is to do
% 
% \begin{MacroSyntax}{\hex}
%   \cs{node}[hex=\marg{key-value-pairs}] \parg{name} at \parg{location};
% \end{MacroSyntax}
%
% This can be useful when placing explanatory graphics or the like.
% The main difference between using \cs{hex} and the raw
% \cs{node}\texttt{[hex=\textellipsis]} is that the former can
% automatically generate labels and set shape coordinates in the
% picture.  If you want that for your board, it is recommended to use
% \cs{hex}.  For example, if one does
%
% \begin{verbatim}
%   \begin{tikzpicture}[
%     every hex={label={auto=alpha column}},
%     hex/labels is name=true]
%     \hex(c=1,r=1);
%   \end{tikzpicture}
% \end{verbatim}
%
% then one can refer to the location of the hex by its label i.e.,
% \texttt{(A1)}.  Since the hex is really a \TikZ{} \texttt{node}, we
% can also use anchors defined for \texttt{hex} node shape, such as
% \texttt{(A1.west)}, \texttt{(A1.north edge)}, and so on.  This is
% not possible if one uses the \cs{node} macro. 
%
% \subsection{Hex bevels}
% \label{sec:hex:bevel}
%
% A bevel (or ``shadow-effect'') can be added to hexes using the key
% \spec{bevel}, with a value that specifies where the light comes from
% (e.g., north west or NW).  The percentage of the half width of a
% chit of the bevel can be specified by the key \spec{bevel fraction}
% (default 10\%). 
%
%
% \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}
%
% For example, to render only the corners of the hexes, as popular
% among some designers, one can do
%
% \begin{verbatim}
%   every hex/.style={
%     dash pattern=on .2cm off .6cm on .2cm off 0cm
%   },
% \end{verbatim}
% Note that the dash pattern should be 1cm long and the last element
% should be \spec{off 0cm} so the dash pattern is started afresh on
% each hex edge. 
% 
% \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 shortened 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 specifications
% together with a relative offset in those directions.   If one
% require even more flexibility, one can use the \TikZ{} library
% \spec{calc} to add arbitrary offsets, e.g.,
%
% \begin{verbatim}
%   \coordinate at ($(hex cs:c=1,r=10)+(.2,.2)$);
% \end{verbatim}
% 
% \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.
% \item[\spec{random rotation}] Applies a random rotation to the
%   terrain image or picture.  This will create an effect where the
%   hexes look less alike. 
% \item[\spec{rotate}=\meta{angle}] Applies a rotation by \meta{angle}
%   to the terrain image or picture.  Note that the \meta{angle}
%   should most likely be multiples of $60^{\circ}$. 
% \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=wargame.beach}](r=0,c=0) }
%     & Beach
%     & \texttt{\{beach\}}\\
%     \tikz{\hex[terrain={image=wargame.light_woods}](r=0,c=0) }
%     & Light woods
%     & \texttt{\{light\_woods\}}
%     & \tikz{\hex[terrain={image=wargame.woods}](r=0,c=0)}
%     & Woods
%     & \texttt{\{woods\}}\\
%     \tikz{\hex[terrain={image=wargame.rough}](r=0,c=0) }
%     & Rough
%     & \texttt{\{rough\}}
%     & \tikz{\hex[terrain={image=wargame.swamp}](r=0,c=0) }
%     & Swamp
%     & \texttt{\{swamp\}}\\
%     \tikz{\hex[terrain={image=wargame.mountains}](r=0,c=0) }
%     & Mountains
%     & \texttt{\{mountains\}}
%     & \tikz{\hex[fill=blue!40!white](r=0,c=0) }
%     & Sea
%     & \texttt{\{sea\}}\\
%     \tikz{\hex[terrain={image=wargame.fields},fill=yellow](r=0,c=0) }
%     & Fields
%     & \texttt{\{fields\},fill=yellow}
%     &\tikz{\hex[terrain={image=wargame.speckle},fill=hostile!25!white](r=0,c=0) }
%     & Fields
%     & \texttt{\{speckle\},fill=hostile}\\
%     \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}
% 
% \subsubsection{Styling paths}
%
% Rivers, roads, railroads, and borders are styled by
% \spec{hex/river}, \spec{hex/road}, \spec{hex/railroad}, and
% \spec{border}, respectively, and the keys \spec{every hex river},
% \spec{every hex road}, \spec{every hex railroad}, and \spec{every
% hex border} will also be applied.   The latter can be defined by the
% user.
%  
% \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.
%
% \subsection{Constructing the physical board}
%
% If the board is not too large, so that it may fit on a paper format
% that can easily be printed (say A4, A3, Letter, or Tabloid), one can
% simply print the board and glue it onto a sturdy surface (say
% 1\textonehalf\,mm poster carton).   However, if the board is large,
% meaning it does not fit on a piece of printable paper, then one has
% two options.
% \begin{description}
% \item[\textit{Either}] scale the board down so that it fits.  Use
%   the \TikZ{} key \spec{scale=}\meta{factor} as an argument to the
%   \spec{tikzpicture} environment in which you create the board. In
%   this case, you should make sure you also scale the chits by the
%   same \meta{factor}, again via the \spec{scale} key.
% \item[\textit{Or}] you can split the board over several pages. The
%   package provides a number of tools to help with this. 
% \end{description}
%
% \subsubsection{Split the board over multiple sheets}
%
% First, make sure you produce a standalone PDF of the board only.
%
% \begin{verbatim}
% \documentclass{standalone}
% \usepackage{wargame}
% \begin{tikzpicture}[scale=SCALE]
%   % Define the board here. 
% \end{tikzpicture}
% \end{verbatim}
%
% and that you have created this PDF --- say \texttt{board.pdf}.
%
% Next, prepare another document in which we will do the calculations.
% For example
%
% \begin{verbatim}
%   \documentclass[11pt]{standalone}
%   \usepackage{wargame}
%   \begin{document}
%   \splitboard{paper=letter,margin=.7,ncol=2,nrow=2,overlap=1}
%   \end{document}
% \end{verbatim}
%
% to calculate the split of \spec{board.pdf} over $2\times2$ letter
% paper sheets, with a non-printable margin of 7mm, and an overlap
% between the segments of 1cm.
% 
% The possible keys for the \cs{splitboard} macro are
% 
%  \begin{itemize}
%  \item \spec{paper}=\meta{format}: Specifies the paper format.  One
%    of \spec{a4}, \spec{a3}, \spec{letter}, \spec{tabloid}. Default
%    is \spec{a4}.
%  \item \spec{landscape}: Sets the paper format to be in landscape
%    mode (default is portrait).
%  \item \spec{margin}=\meta{size in centimetres}: Size of margins on
%    each sheet in centimetres \emph{without} unit.  That is put
%    \spec{0.6} for 6mm, \emph{not} \spec{6mm}. Default is \spec{0.6}.
%    This should be \emph{slightly} larger (by roughly 5\%) than the
%    \emph{least} margin required by the printer used. \emph{Must} be
%    given \emph{before} \spec{paper} to have any effect.
%  \item \spec{ncol}=\meta{number of columns}: Sets the number of
%    columns of sheets.  
%  \item \spec{nrow}=\meta{number of rows}: Set the number of rows of
%    sheets.
%  \item \spec{overlap}=\meta{size in centimetres}: Sets the size of
%    the overlap between sheets in centimetres \emph{without} unit.
%    That is put \spec{2} for 2cm, \emph{not} \spec{2cm}. Default is
%    \spec{2}. 
%  \item \spec{image}=\meta{image file name}: File name of the board
%    image (a PDF). Default is \spec{board}
%  \item \spec{output}=\meta{output file name}: File name (without
%    \spec{.tex} ending) to write calculated split to.
%  \item \spec{standalone}: Boolean flag.  If true, then output file
%    will be a standalone document (i.e., has a \cs{documentclass}).
%  \item \spec{scale}=\meta{scale}: Set scale of board. 
%  \end{itemize}
%
%  The macro will produce a file named \meta{output file
%  name}\spec{.tex} which can be included in another document to
%  generate the split board PDF.  Crop marks will be added to the
%  board segments to make it easier to align the parts.
%
% \subsubsection{Foldable board}
%
% To make a fold-able board use for example the below template to
% create grooves and cuts.
%
% \begin{tikzpicture}[
%   cut/.style={red!50!black,thick},
%   front groove/.style={green!50!black,dashed,thick},
%   back groove/.style={blue!50!black,dash dot,thick},
%   ]
%   \node[minimum width=8.4cm,
%   minimum height=5.9cm,
%   inner sep=0pt,
%   draw,
%   thick] (a) {};
%   \coordinate (middle)       at (a);
%   \coordinate (top)          at (a.north);
%   \coordinate (top left)     at ($(a.north west)!.5!(a.north)$);
%   \coordinate (middle left)  at ($(a.west)!.5!(a)$);
%   \coordinate (bottom left)  at ($(a.south west)!.5!(a.south)$);
%   \coordinate (top right)    at ($(a.north)!.5!(a.north east)$);
%   \coordinate (middle right) at ($(a)!.5!(a.east)$);
%   \coordinate (bottom right) at ($(a.south)!.5!(a.south east)$);
%   \coordinate (bottom)       at (a.south);
%   \draw[cut] (middle)--(bottom);
%   \draw[cut] (top left)--(middle left);
%   \draw[cut] (top right)--(middle right);
%   \draw[back groove] (middle)--(top);
%   \draw[back groove] (bottom left)--(middle left);
%   \draw[back groove] (bottom right)--(middle right);
%   \draw[front groove] (a.west)--(a.east);
% 
%   \draw[cut] ($(a.south west)+(0,-1)$)--++(2,0) node[anchor=west]{%
%     Cut through carton};
%   \draw[back groove] ($(a.south west)+(0,-1.5)$)--++(2,0) node[anchor=west]{%
%     Cut groove (\textonehalf{} through) in carton on \emph{back} side};
%   \draw[front groove] ($(a.south west)+(0,-2)$)--++(2,0) node[anchor=west]{%
%     Cut groove (\textonehalf{} through) in carton on \emph{front} side};
% \end{tikzpicture}
%
% This will fold the board down to a fourth of the size of the full
% map.  For example, if the board is A1
% ($84\,\mathrm{cm}\times59.4\,\mathrm{cm}$) it will fold down to A4
% ($21\,\mathrm{cm}\times29.7\,\mathrm{cm}$) for easier storage.
% 
% \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}
%
% Just as \cs{hex} is really a wrapper around \TikZ{}'s \cs{node}
% macro, so it is with \cs{chit}.  This means that an alternative way
% of making a chit is to do
%
% \begin{MacroSyntax}{\chit}
%   \cs{node}[chit=\marg{key-value-pairs}] \parg{name} at \parg{location};
% \end{MacroSyntax}
%
% Since chits are really \TikZ{} \texttt{node}s we can use anchors
% on the chit.  Unlike for \cs{hex} where there are additional
% features available when using the dedicated macro, there really
% isn't much difference between \cs{chit} and
% \cs{node}\texttt{[chit=\textellipsis]}. 
% 
%
% \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}.
%
%
% A bevel (or ``shadow-effect'') can be added to chits using the key
% \spec{bevel}, with a value that specifies where the light comes from
% (e.g., north west or NW).  The percentage of the half width of a
% chit of the bevel can be specified by the key \spec{bevel fraction}
% (default 10\%). This can be used for both symbol or full chits. 
%
% In addition, one can define the key \spec{tikz/every chit} to be the
% default options for all chits.
%
% By default, the outer ``frame'' of a chit is drawn with the same
% graphics options as the chit it self (i.e., same fill and stroke
% colour).  To change that, one can pass \spec{frame}=\marg{options}
% as part of the chit options. 
% 
% \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. 
%
% \subsection{Kriegspiel chits}
%
% By passing the option \texttt{kriegspiel} to the \cs{chit} command
% or in a \texttt{chit} node, the shape of the chits will be changed
% from square to rectangular.
%
% \paragraph{Important} Not all NATO symbols have been adapted to
% facilitate that shape.
%
% Here are some examples
%
% \begin{tikzpicture}[
%   chit/factor/.append style={font=\sffamily\bfseries\small},
%    /chit/.cd,
%    hex/.style={lower right={#1}},
%    turn/.style={lower left={#1}}]
%    \chit[symbol={
%        main=infantry,
%        echelon=corps,
%        faction=friendly,
%        command=land},
%      factors={chit/2 factors={4,3}},
%      parent={chit/small identifier={II}},
%      unique={chit/small identifier={4}},
%      turn={chit/small identifier={2}},
%      hex={chit/small identifier={0120}},
%      kriegspiel,
%      color=black,
%      fill=hostile](0,0);
%   \chit[symbol={
%        main={[fill=pgfstrokecolor]artillery},%
%        echelon=corps,
%        faction=friendly,
%        command=land},
%      factors={chit/2 factors artillery={4,3,2}},
%      parent={chit/small identifier={II}},
%      unique={chit/small identifier={4}},
%      turn={chit/small identifier={2}},
%      hex={chit/small identifier={0120}},
%      kriegspiel,
%      color=black,
%      fill=friendly,
%      kriegspiel
%    ](2.5,0);
%    \chit[
%       frame={black},
%       symbol={
%         main=reconnaissance,
%         echelon=corps,
%         command=land,
%         faction=friendly,
%         color=black,
%         fill=hostile,
%       },
%       factors={chit/2 factors={4,3}},
%       parent={chit/small identifier={II}},
%       unique={chit/small identifier={4}},
%       turn={chit/small identifier={2}},
%       hex={chit/small identifier={0120}},
%       color=white,
%       fill=unknown!50!black,
%       kriegspiel](5,0);
%   \chit[
%       frame={black},
%       symbol={
%         main={reconnaissance artillery},
%         echelon=corps,
%         command=land,
%         faction=friendly,
%         fill=friendly,
%       },
%       factors={chit/2 factors artillery={4,3,2}},
%       parent={chit/small identifier={II}},
%       unique={chit/small identifier={4}},
%       turn={chit/small identifier={2}},
%       color=white,
%       fill=neutral!50!black,
%       kriegspiel](7.5,0);
% \end{tikzpicture}
%
%
% These are produced by
%
% \begin{verbatim}
% \begin{tikzpicture}[
%   chit/factor/.append style={font=\sffamily\bfseries\small},
%    /chit/.cd,
%    hex/.style={lower right={#1}},
%    turn/.style={lower left={#1}}]
%    \chit[symbol={main=infantry,echelon=corps,faction=friendly,command=land},
%      factors={chit/2 factors={4,3}},
%      parent={chit/small identifier={II}},
%      unique={chit/small identifier={4}},
%      turn={chit/small identifier={2}},
%      hex={chit/small identifier={0120}},
%      kriegspiel,
%      color=black,
%      fill=hostile](0,0);
%   \chit[symbol={
%        main={[fill=pgfstrokecolor]artillery},%
%        echelon=corps,faction=friendly,command=land},
%      factors={chit/2 factors artillery={4,3,2}},
%      parent={chit/small identifier={II}},
%      unique={chit/small identifier={4}},
%      turn={chit/small identifier={2}},
%      hex={chit/small identifier={0120}},
%      kriegspiel,
%      color=black,
%      fill=friendly,
%      kriegspiel
%    ](2.5,0);
%    \chit[
%       frame={black},
%       symbol={
%         main=reconnaissance, echelon=corps,command=land,faction=friendly,
%         color=black,
%         fill=hostile,
%       },
%       factors={chit/2 factors={4,3}},
%       parent={chit/small identifier={II}},
%       unique={chit/small identifier={4}},
%       turn={chit/small identifier={2}},
%       hex={chit/small identifier={0120}},
%       color=white,
%       fill=unknown!50!black,
%       kriegspiel](5,0);
%   \chit[
%       frame={black},
%       symbol={
%         main={reconnaissance artillery},
%         echelon=corps,command=land,faction=friendly,fill=friendly,
%       },
%       factors={chit/2 factors artillery={4,3,2}},
%       parent={chit/small identifier={II}},
%       unique={chit/small identifier={4}},
%       turn={chit/small identifier={2}},
%       color=white,
%       fill=neutral!50!black,
%       kriegspiel](7.5,0);
% \end{tikzpicture}
% \end{verbatim}
% 
% \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~\ref{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,dismounted}{%
%   \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}
%
%
% See \tablename~\ref{tab:natoapp6c:abbr}.
%
% \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\footnote{Sometimes just `I'}\\
%       \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\footnote{Sometimes `DIV'}\\
%       \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/}.  See
%   also implementation using this package at
%   \url{https://gitlab.com/wargames_tex/firstblood_tex}. 
% \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


