diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/chess-problem-diagrams/diagram.sty | 77 |
1 files changed, 73 insertions, 4 deletions
diff --git a/Master/texmf-dist/tex/latex/chess-problem-diagrams/diagram.sty b/Master/texmf-dist/tex/latex/chess-problem-diagrams/diagram.sty index 434fc40c7f6..57f66bee0c7 100644 --- a/Master/texmf-dist/tex/latex/chess-problem-diagrams/diagram.sty +++ b/Master/texmf-dist/tex/latex/chess-problem-diagrams/diagram.sty @@ -36,7 +36,7 @@ %% %% -\ProvidesPackage{diagram}[2011/06/04] +\ProvidesPackage{diagram}[2012/11/12] \DeclareOption{10pt}{\AtBeginDocument{\diagramx}} \DeclareOption{11pt}{\AtBeginDocument{\diagramxi}} \DeclareOption{12pt}{\AtBeginDocument{\diagramxii}} @@ -44,6 +44,7 @@ \ProcessOptions \RequirePackage{ifthen} \RequirePackage{calc} +\RequirePackage{pstricks} %% %% %% @@ -86,6 +87,14 @@ \setboolean{showcity}{false} \newboolean{showacademictitle} \setboolean{showacademictitle}{true} + +\newcount\@blackfield +\newboolean{allwhite} +\setboolean{allwhite}{false} +\newcounter{field@border} +\newcount\@whitefield +\newboolean{switchcolors} +\setboolean{switchcolors}{false} \newboolean{cpd@checkPieceCounts} \newcounter{cpd@defWhitePieces} \newcounter{cpd@defBlackPieces} @@ -169,6 +178,7 @@ \newtoks\stipulation@tk\stipulation@tk={\relax} \newtoks\condition@tk\condition@tk={\relax} \newtoks\remark@tk\remark@tk={\relax} +\newtoks\piecedefs@tk\piecedefs@tk={\relax} \newif\if@label\@labelfalse \newif\if@number\@numberfalse \newif\if@special\@specialfalse @@ -205,6 +215,7 @@ \newif\if@stipulation\@stipulationfalse \newif\if@condition\@conditionfalse \newif\if@remark\@remarkfalse +\newif\if@piecedefs\@piecedefsfalse \newif\if@typis\@typisfalse \newif\if@widedias\@widediasfalse \newif\ifx@twins\x@twinsfalse @@ -740,6 +751,10 @@ \remark@tk={#1}\@remarktrue% \ignorespaces% } +\def\piecedefs#1{% + \piecedefs@tk={#1}\@piecedefstrue% + \ignorespaces% +} \def\Co#1{% \ifx#1+\@computertrue\computer@tk={+}\fi% \ignorespaces% @@ -1115,6 +1130,31 @@ \fi% } +\def\check@piecedef{% + \ifx\next@piecedef\relax% + \let\col@action=\relax% + \else% + \let\col@action=\@@piecedef% + \fi% + \col@action% +} +\def\@@piecedef#1{\csname#1\x@piecedef\endcsname\parse@piecedef} + +\def\parse@piecedef{\futurelet\next@piecedef\check@piecedef} + +\def\@piecedef#1#2#3{% + \def\x@piecedef{#2}% + \below@newline% + \hbox{% + \parse@piecedef#1\relax% + \ = #3}% +} + +\def\write@piecedefs#1; {% + \@piecedef#1% + \l@@klist% +} + \def\@dia@remark{% \if@remark% \bgroup% @@ -1124,6 +1164,14 @@ \egroup% \let\below@newline\newline% \fi% + \if@piecedefs% + \bgroup% + \@lefttrue% + \let\below@newline\newline% + \remfont\let\@action=\write@piecedefs% + \@parseTokenlist\piecedefs@tk;% + \egroup% + \fi% } \def\parse@params#1{% @@ -1616,7 +1664,11 @@ } \def\clear@board{% - % Now the new style + \ifthenelse{\boolean{allwhite}\and\boolean{switchcolors}}% + {\errmessage{'allwhite' and 'switchcolors' do not make sense used together.}}% + {\@whitefield=\m@ne\@blackfield=144}% + \ifthenelse{\boolean{allwhite}}{\@blackfield=\m@ne}{}% + \ifthenelse{\boolean{switchcolors}}{\@whitefield=144\@blackfield=\m@ne}{}% \setcounter{cpd@current@row}{0}% \whiledo{\value{cpd@current@row}<\value{cpd@rowsmax}}{% \setcounter{cpd@current@line}{0}% @@ -1624,8 +1676,8 @@ \set@current@square@index{\value{cpd@current@line}}{\value{cpd@current@row}}% \setcounter{cpd@helper}{\the\current@plane+\value{cpd@current@line}+\value{cpd@current@row}}% \ifthenelse{\isodd{\value{cpd@helper}}}% - {\set@current@square@value{-1}}% - {\set@current@square@value{144}}% + {\set@current@square@value{\@whitefield}}% + {\set@current@square@value{\@blackfield}}% \addtocounter{cpd@current@line}{\@ne}% }% \addtocounter{cpd@current@row}{\@ne}% @@ -1713,6 +1765,23 @@ \stereo@center% \fi% \fi% + % In an 'allwhite' diagram we display dotted lines + \ifthenelse{\boolean{allwhite}}{% + \setbox\plane@box=\vbox{\hbox{% + \psset{unit=\sq@width,linewidth=.4pt,linestyle=dotted,dotsep=.125}% + \setcounter{field@border}{1}% + \whiledo{\value{field@border}<\lines@max}{% + \psline(0,\value{field@border})(\rows@max,\value{field@border})% + \addtocounter{field@border}{\@ne}% + }% + \setcounter{field@border}{1}% + \whiledo{\value{field@border}<\rows@max}{% + \psline(\value{field@border},0)(\value{field@border},\lines@max)% + \addtocounter{field@border}{\@ne}% + }% + \box\plane@box% + }}% + }{}% % Now we should clear the board \clear@board% % Let us now parse the list of pieces |