%%
%% This is file `texmate.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% texmate.dtx  (with options: `package')
%% 
%% Copyright 2005 Federico Garcia
%% 
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{texmate}[2005/03/12 v1 Chess typesetting (Federico Garcia)]
\newif\if@filling\@fillingfalse
\DeclareOption{filling}{\@fillingtrue}
\DeclareOption{notfilling}{\@fillingfalse}
\DeclareOption*{\typeout{Unknown option (`\CurrentOption')}}
\ExecuteOptions{filling}
\ProcessOptions
\def\pieceinitials#1{\@initials#1}
\def\@initials#1#2#3#4#5#6{%
    \def\@Pawn{#1}\def\@Rook{#2}\def\@Knight{#3}%
    \def\@Bishop{#4}\def\@Queen{#5}\def\@King{#6}%
    \lowercase{\def\@pawn{#1}\def\@rook{#2}\def\@knight{#3}%
    \def\@bishop{#4}\def\@queen{#5}\def\@king{#6}}}
\newlength\diagramsize
\newcount\SquareNo
\newcount\@squarecount
\newif\if@blacksq\@blacksqfalse
\def\@togglesq{\if@blacksq\@blacksqfalse\else\@blacksqtrue\fi}
\newcount\@piececode
\def\diagram#1{\font\diagramfont=skak10 at \the\diagramsize
    \@squarecount\SquareNo
    \bgroup
    \setlength\fboxsep{.8pt}%
    \fbox{\parbox{\the\SquareNo\diagramsize}{%
        \baselineskip\diagramsize\diagramfont\@diagline#1.}}\egroup}
\def\@diagpiece#1{\def\temp{#1}\symbol{%
        \ifx\temp\@pawn\if@blacksq'157\else'160\fi\else
        \ifx\temp\@rook\if@blacksq'163\else'162\fi\else
        \ifx\temp\@knight\if@blacksq'155\else'156\fi\else
        \ifx\temp\@bishop\if@blacksq'141\else'142\fi\else
        \ifx\temp\@queen\if@blacksq'154\else'161\fi\else
        \ifx\temp\@king\if@blacksq'152\else'153\fi\else
        \ifx\temp\@Pawn\if@blacksq'117\else'120\fi\else
        \ifx\temp\@Rook\if@blacksq'123\else'122\fi\else
        \ifx\temp\@Knight\if@blacksq'115\else'116\fi\else
        \ifx\temp\@Bishop\if@blacksq'101\else'102\fi\else
        \ifx\temp\@Queen\if@blacksq'114\else'121\fi\else
        \ifx\temp\@King\if@blacksq'112\else'113\fi\else
        \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}}
\def\@diagline#1{\@tempcnta0 \let\next\@diagline
    \ifx#1.\let\next\relax\if@filling\@dospaces{\@squarecount}\fi
    \else\ifx#1/\def\next{\if@filling\@dospaces{\@squarecount}\fi
        \newline\@togglesq\@squarecount\SquareNo\relax
        \@diagline}%
    \else\ifcat1#12\@dospaces{#1}%
    \else\@diagpiece#1\advance\@squarecount-1 \@togglesq
    \fi\fi\fi
    \next}
\def\@dospaces#1{\ifnum#1>0
    \if@blacksq\symbol{'132}\else\hphantom{\symbol{'132}}\fi
    \@togglesq\@tempcntb#1 \advance\@tempcnta1 \advance\@squarecount-1
    \ifnum\@tempcnta<\@tempcntb\let\@next\@dospaces\else
        \let\@next\@gobble\fi
    \@next\@tempcntb\fi}
\newcommand{\skakfamily}{\usefont{U}{skak}{m}{n}}
\DeclareTextFontCommand{\textskakbf}{\skakfamily\bfseries}
\DeclareTextFontCommand{\textskak}{\skakfamily}
\newcount\@rk\@rk'122
\newcount\@kt\@kt'116
\newcount\@bp\@bp'102
\newcount\@qn\@qn'121
\newcount\@kg\@kg'113
\DeclareRobustCommand\rook{\@piece\@rk }
\DeclareRobustCommand\knight{\@piece\@kt }
\DeclareRobustCommand\bishop{\@piece\@bp }
\DeclareRobustCommand\queen{\@piece\@qn }
\DeclareRobustCommand\king{\@piece\@kg }
\def\@piece#1{\bgroup\catcode`\x=11 \textpiece{\symbol{#1}}\egroup}
\def\@@piece#1{\def\temp{#1}%
    \ifx\temp\@Rook\rook\else
    \ifx\temp\@Knight\knight\else
    \ifx\temp\@Bishop\bishop\else
    \ifx\temp\@Queen\queen\else
    \ifx\temp\@King\king\else
    #1\fi\fi\fi\fi\fi}
\DeclareRobustCommand\takes{\makebox[1.2ex][c]{$\times$}}
{\catcode`\x=13 \gdefx{\takes}}
\def\@chesssymbol#1{\bgroup\catcode`\x=11
    \smash{\textskak{\symbol{#1}}}\egroup }
\DeclareRobustCommand\checksign{\smash{\@piece{'053}}}
\DeclareRobustCommand\mate{\smash{\@piece{'155}}}
\DeclareRobustCommand\wbetter{\raisebox{-.1ex}{\@chesssymbol{'146}}}
\DeclareRobustCommand\bbetter{\raisebox{-.1ex}{\@chesssymbol{'147}}}
\DeclareRobustCommand\wBetter{\raisebox{-.35ex}{\@chesssymbol{'143}}}
\DeclareRobustCommand\bBetter{\@chesssymbol{'145}}
\DeclareRobustCommand\WBetter{{\large\@chesssymbol{'150}}}
\DeclareRobustCommand\BBetter{{\large\@chesssymbol{'151}}}
\DeclareRobustCommand\equal{=}
\DeclareRobustCommand\unclear{\raisebox{-.5ex}{{\Large\@chesssymbol{'153}}}}
\DeclareRobustCommand\compensation{{\large\@chesssymbol{'156}}}
\DeclareRobustCommand\development{{\footnotesize\@chesssymbol{'164}}}
\DeclareRobustCommand\spaceadv{{\footnotesize\@chesssymbol{'171}}}
\DeclareRobustCommand\attack{\raisebox{-.3ex}{{\large\@chesssymbol{'101}}}}
\DeclareRobustCommand\initiative{\raisebox{-.2ex}{{\large\@chesssymbol{'103}}}}
\DeclareRobustCommand\counterplay{{\large\@chesssymbol{'126}}}
\DeclareRobustCommand\zugzwang{{\small\@chesssymbol{'104}}}
\DeclareRobustCommand\withidea{{\footnotesize\@chesssymbol{'105}}}
\DeclareRobustCommand\onlymove{{\footnotesize\@chesssymbol{'106}}}
\DeclareRobustCommand\betteris{{\footnotesize\@chesssymbol{'142}}}
\DeclareRobustCommand\boardfile{\@chesssymbol{'110}}
\DeclareRobustCommand\boarddiagonal{{\small\@chesssymbol{'107}}}
\DeclareRobustCommand\boardcenter{{\small\@chesssymbol{'111}}}
\DeclareRobustCommand\kingside{\@chesssymbol{'117}}
\DeclareRobustCommand\queenside{\@chesssymbol{'115}}
\DeclareRobustCommand\weak{{\small\@chesssymbol{'170}}}
\DeclareRobustCommand\ending{{\footnotesize\@chesssymbol{'114}}}
\DeclareRobustCommand\bishops{\@chesssymbol{'141}}
\DeclareRobustCommand\oppositebishops{\@chesssymbol{'157}}
\DeclareRobustCommand\samebishops{\@chesssymbol{'163}}
\DeclareRobustCommand\unitedpawns{\@chesssymbol{'153}}
\DeclareRobustCommand\separatedpawns{\@chesssymbol{'161}}
\DeclareRobustCommand\doubledpawns{\@chesssymbol{'144}}
\DeclareRobustCommand\passedpawn{\@chesssymbol{'162}}
\DeclareRobustCommand\pawnsno{{\small\@chesssymbol{'123}}}
\DeclareRobustCommand\timetrouble{{\small\@chesssymbol{124}}}
\DeclareRobustCommand\with{{\small\@chesssymbol{'166}}}
\DeclareRobustCommand\without{{\small\@chesssymbol{'167}}}
\DeclareRobustCommand\chessetc{\@chesssymbol{'120}}
\DeclareRobustCommand\chesssee{\@chesssymbol{'154}}
\def\ifont{\bfseries\let\textpiece\textskakbf}
\def\iifont{\normalfont\let\textpiece\textskak}
\def\iiifont{\normalfont}
\def\ivfont{\itshape}
\newcount\@commlevel
\let\iopen\relax\let\iclose\relax
\DeclareRobustCommand\iopent{\par\noindent }
\DeclareRobustCommand\icloset{\par}
\DeclareRobustCommand\iiopen{ [}
\DeclareRobustCommand\iiclose{\leavevmode\unskip]\textbf{;} }
\DeclareRobustCommand\iiiopen{ (}
\DeclareRobustCommand\iiiclose{\leavevmode\unskip) }
\DeclareRobustCommand\ivopen{ (}
\DeclareRobustCommand\ivclose{\leavevmode\unskip) }
\DeclareRobustCommand\iiopent{}
\DeclareRobustCommand\iicloset{}
\DeclareRobustCommand\iiiopent{}
\DeclareRobustCommand\iiicloset{}
\DeclareRobustCommand\ivopent{}
\DeclareRobustCommand\ivcloset{}
\def\makebarother{\catcode`\|=12 }
\def\makebarchess{\catcode`\|=13 }
\makebarchess
\def\@chesscodes{\catcode`\ =\active \catcode`\.=\active
    \catcode`\;=\active \catcode`\[=\active \catcode`\]=\active
    \catcode`\>=\active \catcode`\+=\active }
\def\@restorecodes{\catcode`\ =10 \catcode`\.=12
    \catcode`\;=12 \catcode`\]=12 \catcode`\[=12
    \catcode`\>=12 \catcode`\x=11 \catcode`\+=12 }
\newif\if@white
\newif\if@resuming
\newif\if@delimited
\def\@turn{\@delimitedtrue\if@white\@whitefalse\else\@whitetrue\fi}
\long\def\@execute#1{\let\next\relax
    \ifcat1\noexpand#1%
        \ifnum0=#1
            \if@white
                \if@resuming
                    \def\next{\beforeno\the\move\afterno
                        \catcode`\x=\active\@@piece}%
                \else
                    \def\next{\afterb\beforeno\the\move\afterno
                        \catcode`\x=\active\@@piece}%
                \fi
            \else
                \if@resuming
                    \def\next{\beforeb
                        \advance\move1
                        \catcode`\x=\active\@@piece}%
                \else
                    \def\next{\afterw
                        \advance\move1
                        \catcode`\x=\active\@@piece}%
                \fi
            \fi
            \@delimitedfalse
            \@resumingfalse
        \else
            \def\next{\move}%
        \fi
    \else
    \ifcat a\noexpand#1%
        \if@white
            \if@resuming
                \def\next{\beforeno\the\move\afterno
                    \catcode`\x=\active\@@piece}%
            \else
                \def\next{\afterb\beforeno\the\move\afterno
                    \catcode`\x=\active\@@piece}%
            \fi
        \else
            \if@resuming
                \def\next{\beforeb
                    \advance\move1
                    \catcode`\x=\active\@@piece}%
            \else
                \def\next{\afterw
                    \advance\move1
                    \catcode`\x=\active\@@piece}%
            \fi
        \fi
        \@delimitedfalse
        \@resumingfalse
    \fi\fi
    \next#1}
\newcount\move
\DeclareRobustCommand\afterno{.~}
\DeclareRobustCommand\afterw{ }
\DeclareRobustCommand\afterb{; }
\DeclareRobustCommand\beforeb{\the\move.~\dots\ }
\DeclareRobustCommand\beforeno{}
\def\@openchess{\let|\@closechess
    \advance\@commlevel-1\relax
    \csname\@roman{\the\@commlevel}font\endcsname
    \@chesscodes
    \@execute}
\let|\@openchess
\def\@closechess{\let|\@openchess
    \if@delimited\else\@turn\fi
    \@restorecodes\normalfont
    \@resumingtrue\advance\@commlevel1\relax}
\def\@opencomm#1{%
    \@resumingtrue
    \catcode`\x=11
    \bgroup
    \if@delimited
        \@turn
    \fi
    \@delimitedtrue
    \if@white\else\advance\move-1\fi
    \advance\@commlevel1\relax
    \csname\@roman{\the\@commlevel}font\endcsname
    \csname\@roman{\the\@commlevel}#1\endcsname
    \@execute}
\def\@closecomm#1{\csname\@roman{\the\@commlevel}#1\endcsname
    \egroup}
\def\dummy{\@turn
    \if@white\advance\move1\relax\fi\@execute}
\def\ddummy{\advance\move1\relax\@execute}
\def\black{\@whitefalse\@execute}
\def\white{\@whitetrue\@execute}
\def\steplevel{\advance\@commlevel1\relax\csname
    \@roman{\the\@commlevel}font\endcsname}
\def\backlevel{\advance\@commlevel-1\relax\csname
    \@roman{\the\@commlevel}font\endcsname}
\def\newgame{\@whitetrue\@resumingtrue\@commlevel2 \move1 \@delimitedtrue}
\long\def\threat#1{\bgroup\ifcase\@commlevel\or
    \iifont\or\iiifont\or\ivfont\or\ivfont\fi\
    \@restorecodes\catcode`\>\active\withidea}
\def\@chessperiod{. }
\def\@chesssemicolon{; }
{\@chesscodes\iffalse
\fi\global\let\.\@chessperiod\iffalse
\fi\global\let\;\@chesssemicolon\iffalse
\fi\gdef+{\checksign}\iffalse
\fi\gdef\#{\mate}\iffalse
\fi\long\gdef #1{\ifx #1\else\iffalse
    \fi\if@delimited\else\@turn\fi\expandafter\@execute\fi#1}\iffalse
\fi\gdef.#1{ }\gdef;{ }\iffalse
\fi\global\let>\egroup\iffalse
\fi\gdef[{\@opencomm{open}}\iffalse
\fi\gdef\[{\@opencomm{opent}}\iffalse
\fi\gdef]{\@closecomm{close} }\iffalse
\fi\gdef\]{\@closecomm{closet} }}
\setlength\diagramsize{18pt}
\SquareNo8
\pieceinitials{PRNBQK}
\let\textpiece\textskak
\newgame
\endinput
%%
%% End of file `texmate.sty'.
