diff options
author | Norbert Preining <preining@logic.at> | 2007-11-15 13:44:03 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2007-11-15 13:44:03 +0000 |
commit | aeb985d233fd72659294d6c217b205f641a7f3b4 (patch) | |
tree | 91f6178acde7aace897994c52fd75391c6c43082 /Master/texmf-dist/tex/latex/skak/skak.sty | |
parent | 9344b2c4650e32dbce0f1e30a22150c8428ddf2a (diff) |
update skak from CTAN
git-svn-id: svn://tug.org/texlive/trunk@5426 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/skak/skak.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/skak/skak.sty | 666 |
1 files changed, 407 insertions, 259 deletions
diff --git a/Master/texmf-dist/tex/latex/skak/skak.sty b/Master/texmf-dist/tex/latex/skak/skak.sty index a9dad163ccb..895af5ef79f 100644 --- a/Master/texmf-dist/tex/latex/skak/skak.sty +++ b/Master/texmf-dist/tex/latex/skak/skak.sty @@ -5,7 +5,7 @@ % - extension of the \highlight command % - unwanted generation of spaces removed % - a set of informator symbols added -% - the fonts have been improved +% - the fonts have been improved % Fixed a bug in \ParseCoordinates (fix provided by % Ulrike Fischer). % Fixed the bug with opening spaces in the SAN input. @@ -19,13 +19,17 @@ % The check for trailing spaces in the ``typeset@cmoves'' % command has been removed due to problems at the end of a % ``mainline'' or ``variation'' env when an additional -% Informator symbol was involved.. +% Informator symbol was involved.. +% 1.4 2004-12-30 Incorporation of changes made by Ulrike Fischer that +% makes it easy to use different fonts. +% New engine for parsing and typesetting moves: +% the functionality is now shared between the two. +% Joao Nabais reported a problem related to switching +% back and forth from styleC - this has been fixed using +% \leavestylec command complex. - - -% skak.sty \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{skak}[2003/09/27 v1.3 Chess typesetting] +\ProvidesPackage{skak}[2005/06/29 v1.4a Chess typesetting] \DeclareOption{tiny}{\AtEndOfClass{\tinyboard}} \DeclareOption{small}{\AtEndOfClass{\smallboard}} @@ -41,15 +45,35 @@ \DeclareOption{styleA}{\AtEndOfClass{\styleA}} \DeclareOption{styleB}{\AtEndOfClass{\styleB}} \DeclareOption{styleC}{\AtEndOfClass{\styleC}} +\DeclareOption{skaknew}{% + \PassOptionsToPackage{skaknew}{chessfss}} \ExecuteOptions{notation,normal,psoff,english,moveroff,styleB} \ProcessOptions -\RequirePackage{lambda,ifthen,calc} +\RequirePackage{chessfss} + +%% changed by UF to stop a clash with \And of amsmath, +%% also changed every occurance of \And to +%% \LambdaAnd in this sty-file. +\let\Ori@nd\And +\RequirePackage{lambda,ifthen,calc,textcomp} +\let\LambdaAnd\And +\let\And\Ori@nd +%% end of change \ps@on{\RequirePackage{pstricks,pst-node}\SpecialCoor% \newpsstyle{psskak}{arrowinset=0,nodesep=.25,armA=.75,arrowsize=.2 1, linearc=.2,arrowlength=1.25,linewidth=0.04, doubleline=true,doublesep=.06}}{} +% to avoid problems when switching back from styleC +\def\normalstyles{% + \def\mainlinestyle{\bfseries}% could also contain + % definitions of the + % various style options + \def\variationstyle{}% as with mainlinestyle +} +\def\styleC@on{\False} + % list related functions \def\IsNil#1{#1{\False}{\True}} @@ -58,7 +82,7 @@ \def\MemberA#1#2#3#4% {#1{#2}{#3}% {\True}% - {\Member{#1}{#2}{#4}}} + {\Member{#1}{#2}{#4}}} % Explode: string -> char list \def\Explode#1{\EqStr{Z}{#1}{\Nil}{\ExplodeA#1Z}} @@ -70,7 +94,7 @@ #1{True}{False}} % the basic manipulation of the board -\def\Set#1#2{% square -> piece -> unit +\def\Set#1#2{% square -> piece -> unit \expandafter\xdef\csname#1\endcsname{#2}} \def\Get#1{% square -> piece \csname#1\endcsname} @@ -81,7 +105,7 @@ \csname#1\endcsname} -\def\PieceNames{\Listize[K,Q,R,B,N]} +\def\PieceNames{\Listize[K,Q,R,B,N,p]} \def\FileNames{\Listize[a,b,c,d,e,f,g,h]} \def\RankNames{\Listize[1,2,3,4,5,6,7,8]} @@ -93,6 +117,15 @@ \def\showonlyblack{\showonly{k,q,r,b,n,p}} \def\showonlypawns{\showonly{p,P}} + +\def\NotMember#1#2{% a list -> a -> bool + \Not{\Member{\EqStr}{#2}{#1}}} + +\def\showallbut#1{% + \expandafter\def\csname ShowOnlyList\endcsname{% + \Filter{\NotMember{\Listize[#1]}}% + {\Listize[K,Q,R,B,N,P,k,q,r,b,n,p]}}} + %%% \def\TeXifx#1#2#3% {#1\def\next{#2}\else\def\next{#3}\fi @@ -144,19 +177,19 @@ \edef\pst@arrowtable{\pst@arrowtable,<|-|>} \def\tx@ArrowTriangleA{ArrowTriangleA } \def\tx@ArrowTriangleB{ArrowTriangleB } -\@namedef{psas@|>}{% - /ArrowTriangleA { CLW dup 3.5 div SLW mul add dup 2 div /w ED mul dup - /h ED mul /a ED - 0 h a sub moveto w h L 0 0 L w neg h L 0 h a sub L +\@namedef{psas@|>}{% + /ArrowTriangleA { CLW dup 3.5 div SLW mul add dup 2 div /w ED mul dup + /h ED mul /a ED + 0 h a sub moveto w h L 0 0 L w neg h L 0 h a sub L gsave 1 setgray fill grestore gsave - stroke grestore } def + stroke grestore } def \psk@arrowinset \psk@arrowlength \psk@arrowsize \tx@ArrowTriangleA} \@namedef{psas@<|}{% - /ArrowTriangle { CLW dup 2 div SLW mul add dup 2 div - /w ED mul dup /h ED mul /a ED + /ArrowTriangle { CLW dup 2 div SLW mul add dup 2 div + /w ED mul dup /h ED mul /a ED { 0 h T 1 -1 scale } if w neg h moveto 0 0 L w h L w neg a neg - rlineto w neg a rlineto w 0 rmoveto gsave stroke grestore } def + rlineto w neg a rlineto w 0 rmoveto gsave stroke grestore } def true \psk@arrowinset \psk@arrowlength \psk@arrowsize \tx@ArrowTriangleB} % end of PSTricks addon @@ -283,7 +316,7 @@ \multiply@by@sqlength{fileFrom}% \multiply@by@sqlength{rankFrom}% \multiply@by@sqlength{fileTo}% - \multiply@by@sqlength{rankTo}} + \multiply@by@sqlength{rankTo}} %% Sets the special markers ``From'' and ``To'' by %% directly outputting PS commands. @@ -304,7 +337,7 @@ %% Outputs a ``knight move'' arrow from the first %% square to the second. -\def\printknightmove#1#2{% +\def\printknightmove#1#2{% \setcounter{ps@knightangle}{0}% \add@fileangle{\First#1}{\First#2}% \add@rankangle{\Second#1}{\Second#2}% @@ -357,7 +390,7 @@ {\EqStr{#1}{o}{\Apply{\ps@markero}{\Listize[#2]}}% {\EqStr{#1}{X}{\Apply{\ps@markerX}{\Listize[#2]}}% {\EqStr{#1}{O}{\Apply{\ps@markerO}{\Listize[#2]}}% - {\Apply{\ps@markersquare}{\Listize[#2]}}}}} + {\Apply{\ps@markersquare}{\Listize[#2]}}}}}% } \def\highlight@NoOpt#1{\Apply{\ps@markersquare}{\Listize[#1]}} @@ -393,7 +426,9 @@ {B}% {\EqPiece{#1}{\uc@knight}% {N}% - {\errmessage{not a valid piece name in the current language:#1}}}}}}} + {\EqPiece{#1}{\uc@pawn}% added 2005.03.30 UF + {p}% + {\errmessage{not a valid piece name in the current language:#1}}}}}}}} \def\skak@englishToEnglish#1{#1} @@ -412,14 +447,14 @@ \def\currentlanguage{#1}% \ifthenelse{\equal{#1}{english}}% {\let\skak@pieceToEnglish=\skak@englishToEnglish% - \def\PieceNames{\Listize[K,Q,R,B,N]}} + \def\PieceNames{\Listize[K,Q,R,B,N,p]}} {\edef\temp@lang{\csname skaklanguage.#1\endcsname} \expandafter\skak@definepieces\temp@lang% \let\skak@pieceToEnglish=\skak@piece@toEnglish% \def\PieceNames{% - \Listize[\uc@king,\uc@queen,\uc@rook,\uc@bishop,\uc@knight]}}} + \Listize[\uc@king,\uc@queen,\uc@rook,\uc@bishop,\uc@knight,\uc@pawn]}}} + - \def\showskaklanguage{% (\uc@king)(\uc@queen)(\uc@rook)(\uc@bishop)(\uc@knight)(\uc@pawn)} @@ -444,7 +479,7 @@ {\EqStr{#1}{O}} \def\File#1% file -> square list, eg. a -> [a1,a2,...,a8] -{\Map{\Glue{#1}}{\RankNames}} +{\Map{\Glue{#1}}{\RankNames}} \def\Rank#1% rank -> square list, eg. 1 -> [a1,b1,...,h1] {\Map{\Twiddle\Glue{#1}}{\FileNames}} @@ -452,7 +487,7 @@ % Compose: ('b -> 'c) -> ('a -> 'b) -> ('a -> c') % Second: 'a -> 'b -> 'b % f: 'a -> unit -% Compose Second f: 'a -> ('a -> 'b -> unit) +% Compose Second f: 'a -> ('a -> 'b -> unit) % \def\Apply#1#2% ('a -> unit) -> ('a list -> unit) % {\Force{\Map{#1}{#2}}} % \def\Force#1{#1\ForceA{}} @@ -495,7 +530,7 @@ {\EqStr{1}{#1}% {E}% {#1}}}}}}}}} - + \def\ParseFenRank#1{\ParseFenRankA(#1Z)} \def\ParseFenRankA(#1#2){% @@ -524,7 +559,7 @@ \def\SetRank#1#2{% rank -> fenrank -> unit \edef\pap{\ParseFenRank{#2}}% \expandafter\InitRank\pap#1} - + \def\InitBoard(#1/#2/#3/#4/#5/#6/#7/#8){% \SetRank{8}{#1}% @@ -656,7 +691,7 @@ \def\GetNeighbour#1#2% direction -> square -> square {\csname#1.#2\endcsname} % all the hard work: -% first we deal with the board border +% first we deal with the board border \def\FF#1#2{\SetNeighbour{#1}{#2}{Offboard}} \def\ForwardDirection#1% bool -> direction; up for white, down for black @@ -806,13 +841,13 @@ \SetKnightSquares{a6}{\Listize[b8,c7,c5,b4]} \SetKnightSquares{a7}{\Listize[c8,c6,b5]} \SetKnightSquares{a8}{\Listize[c7,b6]} -% b file +% b file %Typo corrected at b6 \SetKnightSquares{b1}{\Listize[a3,c3,d2]} \SetKnightSquares{b2}{\Listize[a4,c4,d3,d1]} \SetKnightSquares{b3}{\Listize[a5,c5,d4,d2,a1,c1]} \SetKnightSquares{b4}{\Listize[a6,c6,d5,d3,a2,c2]} \SetKnightSquares{b5}{\Listize[a7,c7,d6,d4,a3,c3]} -\SetKnightSquares{b6}{\Listize[a8,c8,d7,d5,a5,c5]} +\SetKnightSquares{b6}{\Listize[a8,c8,d7,d5,a4,c4]} \SetKnightSquares{b7}{\Listize[d8,d6,a5,c5]} \SetKnightSquares{b8}{\Listize[d7,a6,c6]} % c file @@ -875,7 +910,7 @@ \def\StringToTokens#1% {\ifthenelse{\equal{#1}{}}{\Nil}{\StrToTokens(#1 )}} \def\StrToTokens (#1 #2){% - \EqStr{#1}{}% + \EqStr{#1}{}% {\Nil}% \Cons{#1}{\EqStr{#2}{} {\Nil} {\StrToTokens(#2)}}} @@ -902,12 +937,25 @@ \gdef\PieceNameToMove{Z}% \gdef\Capture{\False}% \gdef\Promotion{\False}\gdef\PromotionPieceName{Z}% - \gdef\Castling{\False}\gdef\LongCastling{\False}} + \gdef\Castling{\False}\gdef\LongCastling{\False}% + \gdef\CheckTest{}% + \gdef\MateTest{}% + \gdef\MoveRest{}} \def\ParseMove#1{% string -> unit + \StoreLastMove{\gdef\LastMoveString{#1}}{}% usualy only done for mainline. \ParseMoveA(#1)} -\def\ParseMoveA(#1#2){% char -> string -> unit + +\DeclareRobustCommand{\lastmove}{{\def\variationstyle{}% + \WhiteToMove{% + \addtocounter{move}{-1}% + \beforenumber\arabic{move}\blackopen\beforeblack% + \addtocounter{move}{1}}% + {\beforenumber\arabic{move}\whiteopen\beforewhite}% + \expandafter\wmove\expandafter{\LastMoveString}}} + +\def\ParseMoveA(#1#2){% char -> string -> unit \IsPieceName{#1}% {\gdef\PieceNameToMove{\skak@pieceToEnglish{#1}}% \gdef\PieceToMove{\PieceNameToPiece{\PieceNameToMove}{\WhiteToMove}}% @@ -920,6 +968,8 @@ \gdef\MoveTo{\MoveToFile\MoveToRank}}}} \def\FirstChar(#1#2){#1} +\def\FirstChar(#1#2){#1} +\def\RestChars(#1#2){\gdef\@restchars{#2}} \def\ParseCoordinates(#1#2){% char -> string -> unit \EqStr{Z}{#1}% @@ -940,10 +990,18 @@ {\gdef\Capture{\True}% \ParseCoordinates(#2)}% {\IsPromotion{#1}% - {\def\Promotion{\True}% - \gdef\PromotionPieceName{\skak@pieceToEnglish{\FirstChar(#2)}}}}% - {}% no more information is of interest - }}}} + {\gdef\Promotion{\True}% + \gdef\PromotionPieceName{\skak@pieceToEnglish{\FirstChar(#2)}}% + \RestChars(#2)% sets \@restchars + \expandafter\ParseCoordinates\expandafter(\@restchars)}% + {\EqStr{#1}{+}% + {\protected@xdef\CheckTest{\checksymbol}\ParseCoordinates(#2)}% + {\EqStr{#1}{##}% + {\protected@xdef\MateTest{\mate}\ParseCoordinates(#2)}% + {\@setmoverest(#1#2)}}}}}}}} + +\def\@setmoverest(#1Z){\gdef\MoveRest{#1}} + % help for \ParseCastling \def\ParseCastlingA(#1#2#3){% @@ -1025,7 +1083,7 @@ % relies on the info gathered by ParseMove -\def\FindPieceSquares#1#2{% bool -> square -> square list +\def\FindPieceSquares#1#2{% bool -> square -> square list \EqPiece{\PieceNameToMove}{R}% {\ScanDirections% {\EqPiece{\PieceToMove}}{#2}{\Listize[up,down,left,right]}}% @@ -1040,7 +1098,7 @@ {\Filter{\IsRightPiece{\PieceToMove}}{\KnightSquares{#2}}}}}} \def\UniqueMove% bool, if the descriminators <> Z -{\And% +{\LambdaAnd% {\Not{\EqStr{\RankDiscriminator}{Z}}}% {\Not{\EqStr{\FileDiscriminator}}{Z}}} @@ -1076,7 +1134,7 @@ % relies on \ParseMove \def\TrimMoveList#1{% square -> bool \gdef\trimhelp{#1}%( -\And{\RightRank(\trimhelp)}{\And{\RightFile(\trimhelp)}{\LegalMove{\trimhelp}}}} +\LambdaAnd{\RightRank(\trimhelp)}{\LambdaAnd{\RightFile(\trimhelp)}{\LegalMove{\trimhelp}}}} \def\ExecuteKingMove{% relies on ParseMove, WhiteToMove \DoTheMove{\KingSquare{\WhiteToMove}}% @@ -1168,12 +1226,13 @@ {\Set{\MoveToFile\FromRank}{E}}% {}% \DoTheMove{\FileDiscriminator\FromRank}% - \def\EnPassantSquare{-}}% + \xdef\EnPassantSquare{-}}% {\EqPiece{E}{\Get{\MoveToFile\FromRank}}% - {\edef\EnPassantSquare{\MoveToFile\FromRank}% two square move + {\xdef\EnPassantSquare{\MoveToFile\FromRank}% two square move \DoTheMove{\MoveToFile\InitialRank}}% - {\DoTheMove{\MoveToFile\FromRank}% one square move - \def\EnPassantSquare{-}}}% + {\xdef\EnPassantSquare{-}% + \DoTheMove{\MoveToFile\FromRank}% one square move + }}% \Promotion% {\Set{\MoveTo}{\PieceNameToPiece{\PromotionPieceName}{\WhiteToMove}}}% {}} @@ -1182,26 +1241,41 @@ \def\MakeMove#1{% string -> unit \ParseMoveInit% \ParseMove{#1}% - \EqPiece{Z}{\PieceNameToMove}% - {\Castling% - {\gdef\EnPassantSquare{-}\ExecuteCastling}% - {\ExecutePawnMove}}% - {\gdef\EnPassantSquare{-}% - \ExecutePieceMove}% - \WhiteToMove% - {\gdef\WhiteToMove{\False}}% - {\gdef\WhiteToMove{\True}\addtocounter{move}{1}}% + % check if there is a piece of own colour on \MoveToFile\MoveToRank + % THIS CHECK HAS TO BE IMPLEMENTED! + \ExecuteMoves% + {\EqPiece{Z}{\PieceNameToMove}% + {\Castling% + {\gdef\EnPassantSquare{-}\ExecuteCastling}% + {\ExecutePawnMove}}% + {\gdef\EnPassantSquare{-}% + \ExecutePieceMove}% + \WhiteToMove% + {\gdef\WhiteToMove{\False}}% + {\gdef\WhiteToMove{\True}\addtocounter{move}{1}}}% + {}% moves are not executed + \printmove% } \def\mainline{\begingroup\catcode`\#=12 \@mainline} \def\@mainline#1{\endgroup\gdef\NumberNext{\True}% - \Mainline(#1 Z ){\mainlinestyle\typeset@A{#1}}} - + \gdef\AfterBlack{\False}% + \gdef\PrintMoves{\True}% + \gdef\ExecuteMoves{\True}% + \gdef\StoreLastMove{\True}% + {\mainlinestyle\opencommands% + \Mainline(#1 Z )% + \closecommands}} \def\hidemoves{\begingroup\catcode`\#=12 \@hidemoves} -\def\@hidemoves#1{\endgroup\def\NumberNext{\True}% - \Mainline(#1 Z )} +\def\@hidemoves#1{\endgroup\gdef\NumberNext{\True}% + \gdef\AfterBlack{\False}% + \gdef\PrintMoves{\False}% + \gdef\ExecuteMoves{\True}% + \gdef\StoreLastMove{\True}% just in case you want to refer to the last move. + {\relax@typesetting% + \Mainline(#1 Z )}} \newcounter{helpnumber} @@ -1209,20 +1283,32 @@ \def\EatNumber#1{% \setcounter{helpnumberMove}{\arabic{move}}% - \setcounter{helpnumber}{0}\EatNumberA(#1WXYZ)} + \setcounter{helpnumber}{0}% + \AfterBlack{\afterblack}{}% + \gdef\AfterBlack{\True}% + \beforenumber\EatNumberA(#1WXYZ)} \def\EatNumberA(#1.#2){% - \setcounter{helpnumber}{#1}% - \ifthenelse{\value{helpnumberMove}=\value{helpnumber}}% - {\LookForMove(.#2)}% sets \ExpectedColour and \CurrentMove - {\errmessage{mainline: not the correct move number}}} + \PrintMoves{#1}{}% + \ExecuteMoves% + {\setcounter{helpnumber}{#1}% + \ifthenelse{\value{helpnumberMove}=\value{helpnumber}}% + {\LookForMove(.#2)}% sets \ExpectedColour and \CurrentMove + {\errmessage{mainline: not the correct move number}}}% + {\LookForMove(.#2)}% +} + \def\LookForMove(#1#2#3#4){% \EqStr{.}{#2}% ... after the move number - {\gdef\ExpectedColour{\False}% + {\blackopen% + \gdef\AfterWhite{\False}% + \gdef\ExpectedColour{\False}% \HandleMove(#4)}% - {\gdef\ExpectedColour{\True}% + {\whiteopen% + \gdef\AfterWhite{\True}% + \gdef\ExpectedColour{\True}% \HandleMove(#2#3#4)}}% @@ -1233,7 +1319,7 @@ \def\StripMove(#1W){% handles things like 1.e4 \MakeMoveMainline{#1}} - +% The tricky part! Has to integrate \typeset@A@move \def\MakeMoveMainline#1{% {\ExpectedColour% {\WhiteToMove% @@ -1244,7 +1330,21 @@ {\WhiteToMove% {\errmessage{mainline: white, not black, to move (#1)}}% {\MakeMove{#1}\gdef\NumberNext{\True}}}}} - + +\def\MakeMoveMainline#1{% + \ExecuteMoves% + {\ExpectedColour% + {\WhiteToMove{}{\errmessage{mainline: black, not white, to move (#1)}}}% + {\WhiteToMove{\errmessage{mainline: white, not black, to move (#1)}}{}}} + {}% + % regardless of the moves are executed or not: + \ExpectedColour% + {\beforewhite\MakeMove{#1}% + \gdef\ExpectedColour{\False}% + \gdef\NumberNext{\False}}% + {\AfterWhite{\afterwhite}{}% + \beforeblack\MakeMove{#1}\gdef\NumberNext{\True}}} + \def\Mainline(#1 #2){% \EqStr{ }{#1}% @@ -1254,7 +1354,7 @@ {}% {\NumberNext% {\EatNumber{#1}% sets \NumberOK, \ExpectedColour - % executes a move not separated from the + % executes a move not separated from the % number with a space, eg, 1.e4 %{\gdef\NumberNext{\False}\Mainline(#2)}% %\gdef\NumberNext{\False}% @@ -1264,22 +1364,70 @@ %%%%% typesetting -%%% figurine notation -%\input{fig1\@ptsize.clo} -\newcommand{\skakfamily}{\usefont{U}{skak}{m}{n}} -\DeclareTextFontCommand{\textskak}{\skakfamily} -\DeclareTextFontCommand{\textskakbf}{\skakfamily\bfseries} - -\def\liftfig#1{{\fontfamily{skak}\fontencoding{U}\selectfont #1}} -%%\def\liftfig#1{{\skakfamily#1}} - -% -% The symbol used for indicating a "check" -% -\def\checksymbol{\liftfig{+}} - -\def\styleA@opentypesetting{} -\def\styleA@closetypesetting{} + +% depends on the info gathered by \ParseMove +\def\printmove@san{% + \EqPiece{Z}{\PieceNameToMove}% + {\Castling% + {\LongCastling{\castlingchar\castlinghyphen}{}% + \castlingchar\castlinghyphen\castlingchar}% + {%pawn move + \Capture{\FileDiscriminator\capturesymbol}{}% + \MoveToFile\MoveToRank% + \Promotion{\cfss@textsymfigsymbol{\PromotionPieceName}}{}}}% + {% piece move + \cfss@textsymfigsymbol{\PieceNameToMove}% + \EqStr{Z}{\FileDiscriminator}{}{\FileDiscriminator}% + \EqStr{Z}{\RankDiscriminator}{}{\RankDiscriminator}% + \Capture{\capturesymbol}{}% + \MoveToFile\MoveToRank}% + % for all moves: + \CheckTest\MateTest\MoveRest} + +\DeclareRobustCommand{\movehyphen}{-} + +% depends on the info gathered by \ParseMove +\def\printmove@algebraic{% + \EqPiece{Z}{\PieceNameToMove}% + {\Castling% + {\LongCastling{\castlingchar\castlinghyphen}{}% + \castlingchar\castlinghyphen\castlingchar}% + {%pawn move + \MoveFrom% + \Capture{\capturesymbol}{\movehyphen}% + \MoveToFile\MoveToRank% + \Promotion{\cfss@textsymfigsymbol{\PromotionPieceName}}{}}}% + {% piece move + \cfss@textsymfigsymbol{\PieceNameToMove}% + \MoveFrom% + \Capture{\capturesymbol}{\movehyphen}% + \MoveToFile\MoveToRank}% + % for all moves: + \CheckTest\MateTest\MoveRest} + +\def\longmoves{% +\let\printmove=\printmove@algebraic} + +\def\shortmoves{% +\let\printmove=\printmove@san} + +\shortmoves% this is default + +\def\relax@typesetting{% +\let\opencommands=\relax +\let\closecommands=\relax +\let\whiteopen=\relax +\let\blackopen=\relax +\let\beforenumber=\relax +\let\beforewhite=\relax +\let\afterwhite=\relax +\let\beforeblack=\relax +\let\afterblack=\relax +\let\printmove=\relax +} + +\def\styleA@opencommands{} +\def\styleA@closecommands{} \def\styleA@whiteopen{.} \def\styleA@blackopen{. -} \def\styleA@beforenumber{} @@ -1289,8 +1437,8 @@ \def\styleA@afterblack{ } \def\styleA{% -\let\opentypesetting=\styleA@opentypesetting -\let\closetypesetting=\styleA@closetypesetting +\let\opencommands=\styleA@opencommands +\let\closecommands=\styleA@closecommands \let\whiteopen=\styleA@whiteopen \let\blackopen=\styleA@blackopen \let\beforenumber=\styleA@beforenumber @@ -1298,12 +1446,12 @@ \let\afterwhite=\styleA@afterwhite \let\beforeblack=\styleA@beforeblack \let\afterblack=\styleA@afterblack +\leavestylec } -%%%% the default style -\styleA -\def\styleB@opentypesetting{} -\def\styleB@closetypesetting{} + +\def\styleB@opencommands{} +\def\styleB@closecommands{} \def\styleB@whiteopen{ } \def\styleB@blackopen{\ldots} \def\styleB@beforenumber{} @@ -1312,9 +1460,10 @@ \def\styleB@beforeblack{} \def\styleB@afterblack{ } + \def\styleB{% -\let\opentypesetting=\styleB@opentypesetting -\let\closetypesetting=\styleB@closetypesetting +\let\opencommands=\styleB@opencommands +\let\closecommands=\styleB@closecommands \let\whiteopen=\styleB@whiteopen \let\blackopen=\styleB@blackopen \let\beforenumber=\styleB@beforenumber @@ -1322,13 +1471,21 @@ \let\afterwhite=\styleB@afterwhite \let\beforeblack=\styleB@beforeblack \let\afterblack=\styleB@afterblack +\leavestylec +} + +% avoiding problems with switch from styleC to other styles +% problem reported by Joao Nabais +\newcommand{\leavestylec}{% + \styleC@on{\normalstyles}{\relax}% + \def\styleC@on{\False}% } -\def\styleC@opentypesetting{% +\def\styleC@opencommands{% \begin{tabbing}% \hspace{.2\linewidth}\=\hspace{.2\linewidth}\=% \hspace{.2\linewidth}\= \kill} -\def\styleC@closetypesetting{\end{tabbing}} +\def\styleC@closecommands{\end{tabbing}} \def\styleC@whiteopen{} \def\styleC@blackopen{\>\ldots} \def\styleC@beforenumber{\>} @@ -1337,9 +1494,10 @@ \def\styleC@beforeblack{\>} \def\styleC@afterblack{\\} + \def\styleC{% -\let\opentypesetting=\styleC@opentypesetting -\let\closetypesetting=\styleC@closetypesetting +\let\opencommands=\styleC@opencommands +\let\closecommands=\styleC@closecommands \let\whiteopen=\styleC@whiteopen \let\blackopen=\styleC@blackopen \let\beforenumber=\styleC@beforenumber @@ -1349,10 +1507,11 @@ \let\afterblack=\styleC@afterblack \def\mainlinestyle{\styleC\bfseries} \def\variationstyle{\styleB} +\def\styleC@on{\True} } \def\mainlinestyle{\bfseries}% could also contain - % definitions of the + % definitions of the % various style options \def\variationstyle{}% as with mainlinestyle @@ -1374,7 +1533,7 @@ {\typeset@numberStripMove(#1)}} \def\typeset@numberStripMove(#1W){% \typeset@A@move{#1}} - + \def\typeset@A@move#1{% \TypeSetColour% {\beforewhite\mbox{\typeset@A@moveA(#1Z)}% @@ -1383,32 +1542,36 @@ {\TypeSetAfterWhite{\afterwhite}{}% \beforeblack\mbox{\typeset@A@moveA(#1Z)}% \gdef\TypeSetColour{\True}\gdef\TypeSetNumberNext{\True}}} + \def\typeset@A@moveA(#1#2){% \EqStr{Z}{#1}% {}% {\IsPieceName{#1}% {\xdef\temp@piece{\skak@pieceToEnglish{#1}}% - \expandafter\liftfig\temp@piece}% + \expandafter\cfss@textsymfigsymbol\temp@piece}% {\EqStr{=}{#1}% {}% {\EqStr{x}{#1}% - {\liftfig{X}}% the ``capture'' symbol + {\capturesymbol}% %%changed UF {\EqStr{+}{#1}% {\checksymbol}% was "\ensuremath{\dagger}" before {\EqStr{-}{#1}% {\LastCharWasCastle - {\liftfig{-}}% short dash for castlings + {\castlinghyphen}% %%changed UF, dash from Textfont short dash for castlings {\hbox{--}}}% longer dash for moves - {#1}}}}}% - \EqStr{O}{#1}% Check if we encountered the ``castling'' char... - {\gdef\LastCharWasCastle{\True}}% - {\gdef\LastCharWasCastle{\False}}% + {\EqStr{O}{#1}% + {\gdef\LastCharWasCastle{\True}% + \castlingchar}% %% UF added to be able to change from O to 0 + {\gdef\LastCharWasCastle{\False}% + \EqStr{##}{#1}%added 2004.04.14 for \mate + {\mate} + {#1}}}}}}}% \typeset@A@moveA(#2)}} \def\typeset@A#1{\gdef\TypeSetNumberNext{\True}% - \gdef\TypeSetAfterBlack{\False}\opentypesetting\typeset@AA(#1 Z )% - \closetypesetting} + \gdef\TypeSetAfterBlack{\False}\opencommands\typeset@AA(#1 Z )% + \closecommands} %\typeset@AA is isomorf with \Mainline \def\typeset@AA(#1 #2){% \EqStr{ }{#1}% @@ -1421,7 +1584,7 @@ \typeset@AA(#2)}% {\typeset@A@move{#1}% \typeset@AA(#2)}}}} - + %\typeset@cmoves and \typeset@comment added by db <2002-01-06> \def\movewhite{ } @@ -1432,11 +1595,21 @@ {}% {\typeset@A@moveA(#1Z)\movewhite\typeset@cmoves(#2)}}} -\def\typeset@comment#1{\opentypesetting\typeset@cmoves(#1 Y )% - \closetypesetting} +\def\typeset@comment#1{\opencommands\typeset@cmoves(#1 Y )% + \closecommands} + +%\def\variation{\begingroup\catcode`\#=12 \@variation} +\DeclareRobustCommand{\variation}{\begingroup\catcode`\#=12 \@variation} +%\def\@variation#1{\endgroup{\variationstyle\typeset@A{#1}}} -\def\variation{\begingroup\catcode`\#=12 \@variation} -\def\@variation#1{\endgroup{\variationstyle\typeset@A{#1}}} +\def\@variation#1{\endgroup\gdef\NumberNext{\True}% + \gdef\AfterBlack{\False}% + \gdef\PrintMoves{\True}% + \gdef\ExecuteMoves{\False}% + \gdef\StoreLastMove{\False}% + {\variationstyle\opencommands% + \Mainline(#1 Z )% + \closecommands}} % typesetting moves without move number \def\wmove{\begingroup\catcode`\#=12 \@wmove} @@ -1453,23 +1626,35 @@ \newlength{\squarelength} %% Multiplier for the special PS markers, see set@special@psmarkers \newcount\square@multiplier -\newlength{\showlength} \newlength{\ranklift} -\def\setup@showboard#1{\font\Skak=skak#1% - \setlength{\squarelength}{#1pt}% - \square@multiplier=#1 + + +%%% 2004.04.09 UF: removed pt so bigger board are possible +%%% 2004.04.05 UF: group around the font-changing-command +%%% UF 2005.03.24 changes to use chessfss size changing commands +\def\setup@showboard{% UF 2005.03.24 don't need argument. Sizes should be set before. + \settowidth\squarelength{\BlackEmptySquare}% + \square@multiplier=\squarelength% in sp + \divide\square@multiplier by 65536% in pt % ps setup \ps@on{\psset{unit=\the\squarelength}}{} + %% put a group around font-changing-command UF: + {\sidefont\setlength{\@tempdima}{.5\squarelength-0.8ex} + \xdef\aftergrouplength{\the\@tempdima}% + \aftergroup\setlength\aftergroup\ranklift% + \aftergroup{\aftergroup\aftergrouplength\aftergroup}}} - \notationfont\setlength{\ranklift}{.5\squarelength-.8ex}\normalsize} +\def\tinyboard{\cfss@setupboardsize{10pt}{6pt}\setup@showboard} +\def\smallboard{\cfss@setupboardsize{15pt}{8pt}\setup@showboard} +\def\normalboard{\cfss@setupboardsize{20pt}{10pt}\setup@showboard} +\def\largeboard{\cfss@setupboardsize{30pt}{12pt}\setup@showboard} - -\def\tinyboard{\font\notationfont=cmss6\setup@showboard{10}} -\def\smallboard{\font\notationfont=cmss8\setup@showboard{15}} -\def\normalboard{\font\notationfont=cmss10\setup@showboard{20}} -\def\largeboard{\font\notationfont=cmss12\setup@showboard{30}} +%new 2005.06.29 UF +\newcommand\setupboard[2]{% + \cfss@setupboardsize{#1}{#2}%#1 board, #2 notation + \setup@showboard} % the default \normalboard @@ -1477,8 +1662,17 @@ \def\ToggleWhiteSquare{% \WhiteSquare{\def\WhiteSquare{\False}}{\def\WhiteSquare{\True}}} +%\def\WhiteSquarePiece#1{% +% \EqPiece{E}{#1}{0}{#1}} + +% getting around deficiencies in some fonts \def\WhiteSquarePiece#1{% - \EqPiece{E}{#1}{0}{#1}} + \EqPiece{E}{#1}{\WhiteEmptySquare}{#1}} + + +% for fonts without an empty square one can use +%\renewcommand\WhiteEmptySquare}{{\rule{\squarelength}{0pt}}} + \def\BlackSquarePiece#1{% \EqPiece{E}{#1}{Z}% @@ -1493,7 +1687,7 @@ {\EqPiece{Q}{#1}{L}% {\EqPiece{q}{#1}{l}% {\EqPiece{K}{#1}{J}{j}}}}}}}}}}}}} - + \def\FilterShowOnly#1{% piece -> piece, shows only the pieces in % ShowOnlyList \Member{\EqStr}{#1}{\ShowOnlyList}% @@ -1507,11 +1701,11 @@ \ToggleWhiteSquare} \def\Showrank#1{% rank -> drawn rank - \Skak\Apply{\Showchar}{\Rank{#1}}% + \boardfont\Apply{\Showchar}{\Rank{#1}}% \ifnum#1=1\ps@on{\pnode(-.5,.5){BM}}{}\fi} \def\ShowrankInverse#1{% rank -> drawn rank - \Skak\Apply{\Showchar}{\Reverse{\Rank{#1}}}% + \boardfont\Apply{\Showchar}{\Reverse{\Rank{#1}}}% \ifnum#1=8\ps@on{\pnode(-.5,.5){BM}}{}\fi} \def\ShowMoverWhiteNormal{\pscustom{\skak@translate{h}{1}% @@ -1533,55 +1727,57 @@ \psframe(0.84,-0.16)(1.16,0.16)}} \def\show@board{% - \def\WhiteSquare{\True} - \vbox{\offinterlineskip - \hrule height1pt - \hbox{\vrule width1pt - \vbox{\hbox{\Showrank{8}}\ToggleWhiteSquare - \hbox{\Showrank{7}}\ToggleWhiteSquare - \hbox{\Showrank{6}}\ToggleWhiteSquare - \hbox{\Showrank{5}}\ToggleWhiteSquare - \hbox{\Showrank{4}}\ToggleWhiteSquare - \hbox{\Showrank{3}}\ToggleWhiteSquare - \hbox{\Showrank{2}}\ToggleWhiteSquare + \def\WhiteSquare{\True}% + \leavevmode% + \vbox{\offinterlineskip% + \hrule height1pt% + \hbox{\vrule width1pt% + \vbox{\hbox{\Showrank{8}}\ToggleWhiteSquare% + \hbox{\Showrank{7}}\ToggleWhiteSquare% + \hbox{\Showrank{6}}\ToggleWhiteSquare% + \hbox{\Showrank{5}}\ToggleWhiteSquare% + \hbox{\Showrank{4}}\ToggleWhiteSquare% + \hbox{\Showrank{3}}\ToggleWhiteSquare% + \hbox{\Showrank{2}}\ToggleWhiteSquare% \hbox{\Showrank{1}}}% - \vrule width1pt} - \hrule height1pt} - \setcounter{ps@inverse}{0} - \ShowMover - {\WhiteToMove - {\ShowMoverWhiteNormal} - {\ShowMoverBlackNormal}} - {} + \vrule width1pt}% + \hrule height1pt}% + \setcounter{ps@inverse}{0}% + \ShowMover% + {\WhiteToMove% + {\ShowMoverWhiteNormal}% + {\ShowMoverBlackNormal}}% + {}% } \def\show@board@inverse{% - \def\WhiteSquare{\True} - \vbox{\offinterlineskip - \hrule height1pt - \hbox{\vrule width1pt - \vbox{\hbox{\ShowrankInverse{1}}\ToggleWhiteSquare - \hbox{\ShowrankInverse{2}}\ToggleWhiteSquare - \hbox{\ShowrankInverse{3}}\ToggleWhiteSquare - \hbox{\ShowrankInverse{4}}\ToggleWhiteSquare - \hbox{\ShowrankInverse{5}}\ToggleWhiteSquare - \hbox{\ShowrankInverse{6}}\ToggleWhiteSquare - \hbox{\ShowrankInverse{7}}\ToggleWhiteSquare + \leavevmode% + \def\WhiteSquare{\True}% + \vbox{\offinterlineskip% + \hrule height1pt% + \hbox{\vrule width1pt% + \vbox{\hbox{\ShowrankInverse{1}}\ToggleWhiteSquare% + \hbox{\ShowrankInverse{2}}\ToggleWhiteSquare% + \hbox{\ShowrankInverse{3}}\ToggleWhiteSquare% + \hbox{\ShowrankInverse{4}}\ToggleWhiteSquare% + \hbox{\ShowrankInverse{5}}\ToggleWhiteSquare% + \hbox{\ShowrankInverse{6}}\ToggleWhiteSquare% + \hbox{\ShowrankInverse{7}}\ToggleWhiteSquare% \hbox{\ShowrankInverse{8}}}% - \vrule width1pt} - \hrule height1pt} - \setcounter{ps@inverse}{180} - \ShowMover - {\WhiteToMove - {\ShowMoverWhiteInverse} - {\ShowMoverBlackInverse}} - {} + \vrule width1pt}% + \hrule height1pt}% + \setcounter{ps@inverse}{180}% + \ShowMover% + {\WhiteToMove% + {\ShowMoverWhiteInverse}% + {\ShowMoverBlackInverse}}% + {}% } \def\ShowrankNumber#1{% \makebox[0pt][r]{% \raisebox{\ranklift}[0cm][0cm]{% - \makebox[\squarelength][r]{\notationfont#1\hspace*{.1\squarelength}}}}} + \makebox[\squarelength][r]{\sidefont#1\hspace*{.1\squarelength}}}}} \def\ShowrankWithNumber#1{\ShowrankNumber{#1}% \vrule width1pt \Showrank{#1}\vrule width1pt} @@ -1590,56 +1786,59 @@ \vrule width1pt\ShowrankInverse{#1}\vrule width1pt} -\def\Showfile#1{\hbox to \squarelength{\hfil\notationfont#1\hfil}} +\def\Showfile#1{\hbox to \squarelength{\hfil\sidefont#1\hfil}} \def\Showfiles{\hfil\Showfile{a}\Showfile{b}\Showfile{c}\Showfile{d}% \Showfile{e}\Showfile{f}\Showfile{g}\Showfile{h}\hfil} \def\Showfiles@inverse{\hfil\Showfile{h}\Showfile{g}\Showfile{f}\Showfile{e}% \Showfile{d}\Showfile{c}\Showfile{b}\Showfile{a}\hfil} +%%% changed \def\show@board@notation{% \def\WhiteSquare{\True}% + \leavevmode% \vbox{\offinterlineskip% - \hrule height1pt - \hbox{\ShowrankWithNumber{8}}\ToggleWhiteSquare - \hbox{\ShowrankWithNumber{7}}\ToggleWhiteSquare - \hbox{\ShowrankWithNumber{6}}\ToggleWhiteSquare - \hbox{\ShowrankWithNumber{5}}\ToggleWhiteSquare - \hbox{\ShowrankWithNumber{4}}\ToggleWhiteSquare - \hbox{\ShowrankWithNumber{3}}\ToggleWhiteSquare - \hbox{\ShowrankWithNumber{2}}\ToggleWhiteSquare - \hbox{\ShowrankWithNumber{1}}\ToggleWhiteSquare - \hrule height1pt - \vspace*{.1\squarelength} - \hbox{\Showfiles}} - \setcounter{ps@inverse}{0} - \ShowMover - {\WhiteToMove - {\ShowMoverWhiteNormal} - {\ShowMoverBlackNormal}} - {} + \hrule height1pt% + \hbox{\ShowrankWithNumber{8}}\ToggleWhiteSquare% + \hbox{\ShowrankWithNumber{7}}\ToggleWhiteSquare% + \hbox{\ShowrankWithNumber{6}}\ToggleWhiteSquare% + \hbox{\ShowrankWithNumber{5}}\ToggleWhiteSquare% + \hbox{\ShowrankWithNumber{4}}\ToggleWhiteSquare% + \hbox{\ShowrankWithNumber{3}}\ToggleWhiteSquare% + \hbox{\ShowrankWithNumber{2}}\ToggleWhiteSquare% + \hbox{\ShowrankWithNumber{1}}\ToggleWhiteSquare% + \hrule height1pt% + \vspace*{.1\squarelength}% + \hbox{\Showfiles}}% + \setcounter{ps@inverse}{0}% + \ShowMover% + {\WhiteToMove% + {\ShowMoverWhiteNormal}% + {\ShowMoverBlackNormal}}% + {}% } \def\show@board@notation@inverse{% \def\WhiteSquare{\True}% + \leavevmode%\rule{\squarelength}{0pt}%\hspace*{-\squarelength}% \vbox{\offinterlineskip% - \hrule height1pt - \hbox{\ShowrankInverseWithNumber{1}}\ToggleWhiteSquare - \hbox{\ShowrankInverseWithNumber{2}}\ToggleWhiteSquare - \hbox{\ShowrankInverseWithNumber{3}}\ToggleWhiteSquare - \hbox{\ShowrankInverseWithNumber{4}}\ToggleWhiteSquare - \hbox{\ShowrankInverseWithNumber{5}}\ToggleWhiteSquare - \hbox{\ShowrankInverseWithNumber{6}}\ToggleWhiteSquare - \hbox{\ShowrankInverseWithNumber{7}}\ToggleWhiteSquare - \hbox{\ShowrankInverseWithNumber{8}}\ToggleWhiteSquare - \hrule height1pt - \vspace*{.1\squarelength} - \hbox{\Showfiles@inverse}} - \setcounter{ps@inverse}{180} - \ShowMover - {\WhiteToMove - {\ShowMoverWhiteInverse} - {\ShowMoverBlackInverse}} - {} + \hrule height1pt% + \hbox{\ShowrankInverseWithNumber{1}}\ToggleWhiteSquare% + \hbox{\ShowrankInverseWithNumber{2}}\ToggleWhiteSquare% + \hbox{\ShowrankInverseWithNumber{3}}\ToggleWhiteSquare% + \hbox{\ShowrankInverseWithNumber{4}}\ToggleWhiteSquare% + \hbox{\ShowrankInverseWithNumber{5}}\ToggleWhiteSquare% + \hbox{\ShowrankInverseWithNumber{6}}\ToggleWhiteSquare% + \hbox{\ShowrankInverseWithNumber{7}}\ToggleWhiteSquare% + \hbox{\ShowrankInverseWithNumber{8}}\ToggleWhiteSquare% + \hrule height1pt% + \vspace*{.1\squarelength}% + \hbox{\Showfiles@inverse}}% + \setcounter{ps@inverse}{180}% + \ShowMover% + {\WhiteToMove% + {\ShowMoverWhiteInverse}% + {\ShowMoverBlackInverse}}% + {}% } % on the fly configuration @@ -1648,9 +1847,14 @@ \def\notationOff{\let\showboard=\show@board% \let\showinverseboard=\show@board@inverse} +\def\notationon{\notationOn} +\def\notationoff{\notationOff} + \def\showmoverOn{\def\ShowMover{\True}} \def\showmoverOff{\def\ShowMover{\False}} +\def\showmoveron{\showmoverOn} +\def\showmoveroff{\showmoverOff} \def\newgame{% \fenboard{rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1}} @@ -1686,60 +1890,4 @@ \edef\restore@temp{\csname chessgame.#1\endcsname} \expandafter\FenBoard\restore@temp)} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%% support for informator symbols (db <2002-11-06>) %%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\def\wbetter{\liftfig{f}} -\def\bbetter{\liftfig{g}} -\def\wupperhand{\liftfig{c}} -\def\bupperhand{\liftfig{e}} -\def\wdecisive{\liftfig{h}} -\def\bdecisive{\liftfig{i}} -\def\equal{\liftfig{j}} -\def\unclear{\liftfig{k}} -\def\compensation{\liftfig{n}} -\def\devadvantage{\liftfig{t}} -\def\moreroom{\liftfig{U}} -\def\withattack{\liftfig{A}} -\def\withinit{\liftfig{C}} -\def\counterplay{\liftfig{V}} -\def\zugzwang{\liftfig{D}} -\def\mate{\liftfig{m}} -\def\withidea{\liftfig{E}} -\def\onlymove{\liftfig{F}} -\def\betteris{\liftfig{b}} -\def\file{\liftfig{H}} -\def\diagonal{\liftfig{G}} -\def\centre{\liftfig{I}} -\def\kside{\liftfig{O}} -\def\qside{\liftfig{M}} -\def\weakpt{\liftfig{J}} -\def\ending{\liftfig{L}} - -\def\bishoppair{\liftfig{a}} -\def\opposbishops{\liftfig{o}} -\def\samebishops{\liftfig{s}} - -\def\unitedpawns{\liftfig{u}} -\def\seppawns{\liftfig{q}} -\def\doublepawns{\liftfig{d}} -\def\passedpawn{\liftfig{r}} -\def\morepawns{\liftfig{S}} -\def\timelimit{\liftfig{T}} -\def\novelty{{\textsf{N}}} -\def\comment{{\textsf{\mbox{RR}}}} -\def\various{{\textsf{R}}} -\def\without{\liftfig{v}} -\def\with{\liftfig{w}} -\def\etc{\liftfig{P}} -\def\see{\liftfig{l}} - -\def\markera{\liftfig{x}} -\def\markerb{\liftfig{y}} % end skak.sty - - - - |