texlive[74591] Master/texmf-dist: chess-problem-diagrams (12mar25)
commits+karl at tug.org
commits+karl at tug.org
Wed Mar 12 20:34:05 CET 2025
Revision: 74591
https://tug.org/svn/texlive?view=revision&revision=74591
Author: karl
Date: 2025-03-12 20:34:04 +0100 (Wed, 12 Mar 2025)
Log Message:
-----------
chess-problem-diagrams (12mar25)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/latex/chess-problem-diagrams/README
trunk/Master/texmf-dist/doc/latex/chess-problem-diagrams/diagram.pdf
trunk/Master/texmf-dist/source/latex/chess-problem-diagrams/diagram.dtx
trunk/Master/texmf-dist/tex/latex/chess-problem-diagrams/diagram.sty
Modified: trunk/Master/texmf-dist/doc/latex/chess-problem-diagrams/README
===================================================================
--- trunk/Master/texmf-dist/doc/latex/chess-problem-diagrams/README 2025-03-12 19:33:53 UTC (rev 74590)
+++ trunk/Master/texmf-dist/doc/latex/chess-problem-diagrams/README 2025-03-12 19:34:04 UTC (rev 74591)
@@ -1,5 +1,5 @@
diagram --- A package for typesetting chessproblems
-Version v1.22 / Stefan Hoening 1994-2024
+Version v1.23 / Stefan Hoening 1994-2025
CONTENTS
Modified: trunk/Master/texmf-dist/doc/latex/chess-problem-diagrams/diagram.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/source/latex/chess-problem-diagrams/diagram.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/chess-problem-diagrams/diagram.dtx 2025-03-12 19:33:53 UTC (rev 74590)
+++ trunk/Master/texmf-dist/source/latex/chess-problem-diagrams/diagram.dtx 2025-03-12 19:34:04 UTC (rev 74591)
@@ -13,9 +13,9 @@
%%
%%
% \fi
-% \def\fileversion{v1.22}
-% \def\docdate{2024/06/13}
-% \CheckSum{4611}
+% \def\fileversion{v1.23}
+% \def\docdate{2025/03/12}
+% \CheckSum{4227}
% \changes{v0.1}{15 Februar 2004}{First Version}
% \changes{v0.2}{23 Februar 2004}{Added the documentation for the
% {\itshape information collecting} macros which may be used
@@ -100,6 +100,12 @@
% diagrams.\\
% Fixed numbering when creating empty diagram numbering via
% speciadiagram.}
+% \changes{v1.23}{2025/03/12}{%
+% Fixed pdflatex/Acrobat-Reader issue by using tikz in put at row.
+% Removed dependency to pstricks.
+% Switched to LaTeX counters from TeX counters.
+% Fixed spacing issue when using fen notation.
+% }
%
% \DoNotIndex{\@arabic,\def,\@idxitem,\@ifnextchar,\@ifstar,
% \@ne,\@ptsize,\ ,\advance,\AtEndOfPackage,\begin,\begingroup,
@@ -1053,7 +1059,7 @@
% Specifies the preamble of our style file.
% \begin{macrocode}
%<*style>
-\ProvidesPackage{diagram}[2024/10/14]
+\ProvidesPackage{diagram}[2025/02/21-tikz]
% \end{macrocode}
%
% \begin{macro}{\DefaultDiagramSize}
@@ -1077,7 +1083,8 @@
% \begin{macrocode}
\RequirePackage{ifthen}
\RequirePackage{calc}
-\RequirePackage{pstricks}
+\RequirePackage{tikz}
+\RequirePackage{xstring}
% \end{macrocode}
%%
%%
@@ -1118,14 +1125,9 @@
\renewcommand{\theboard at nr}{\thediag}
% \newif\iffigcnt
\newboolean{piececounter}
-\newcount\r at w
-\newcount\lin@
-\newcount\pl at ne
-\newcount\current at plane
-\newcount\w at cnt
-\newcount\b at cnt
-\newcount\n at cnt
+\newcounter{cpd at piece@index}
+
\newboolean{showcity}
\setboolean{showcity}{false}
\newboolean{showacademictitle}
@@ -1156,9 +1158,6 @@
\newcounter{cpd at blackPieces}
\newcounter{cpd at neutralPieces}
-\newcounter{cpd at row}
-\newcounter{cpd at line}
-
\newcommand{\cpd at stepcounterWhite}{\stepcounter{cpd at whitePieces}}
\newcommand{\cpd at stepcounterBlack}{\stepcounter{cpd at blackPieces}}
\newcommand{\cpd at stepcounterNeutral}{\stepcounter{cpd at neutralPieces}}
@@ -1165,7 +1164,6 @@
\global\let\cpd at stepcounterPieces\relax
\newcount\help at a
-\newcount\help at b
\newbox\dia at box
\newbox\@cnt at box
@@ -1177,8 +1175,6 @@
\newdimen\@test at dimen
\newif\if at left
-\newcount\brd at ff
-
\newdimen\dia at lineskip
\newdimen\board at width
@@ -1303,20 +1299,21 @@
\newwrite\s at lfd
\let\below at newline=\relax
% These are used by the ``old'' board creating mechanism
-\newcount\@lines
-\newcount\@rows
-\newcount\lines at max
-\newcount\rows at max
-\newcount\planes at max
% \end{macrocode}
%
% The following counters are used when creating the diagram
% itself.
% \begin{macrocode}
-\newcounter{cpd at rowsmax}
-\newcounter{cpd at linesmax}
-\newcounter{cpd at current@row}
-\newcounter{cpd at current@line}
+\newcounter{cpd at planes}
+\newcounter{cpd at rows}
+\newcounter{cpd at lines}
+\newcounter{cpd at plane}
+\newcounter{cpd at current@plane}
+\newcounter{cpd at current@plane at display}
+\newcounter{cpd at row}
+\newcounter{cpd at line}
+\newcounter{cpd at row@display}
+\newcounter{cpd at line@display}
\newcounter{cpd at maxsquare}
\newcounter{cpd at helper}
\newcounter{cpd at current@square at index}
@@ -1361,17 +1358,15 @@
}
\def\@cpd at initsize#1#2{%
- \setcounter{cpd at linesmax}{#1}%
- \setcounter{cpd at rowsmax}{#2}%
- \setcounter{cpd at maxsquare}{\value{cpd at rowsmax}*\value{cpd at linesmax}}%
+ \setcounter{cpd at lines}{#1}%
+ \setcounter{cpd at rows}{#2}%
+ \setcounter{cpd at maxsquare}{\value{cpd at rows}*\value{cpd at lines}}%
}
\def\@diagram[#1x#2]{%
- \lines at max=#1%
- \rows at max=#2%
\@cpd at initsize{#1}{#2}%
- \pl at ne=\z@%
- \current at plane=\z@%
+ \setcounter{cpd at plane}{0}%
+ \setcounter{cpd at current@plane}{0}%
\let\put at sqs=\put at sqs@normal%
\let\read at plane=\read at plane@normal%
\@start at diagram%
@@ -1399,9 +1394,7 @@
}
\def\@spacediagram[#1x#2x#3]{%
- \lines at max=#1%
- \rows at max=#2%
- \planes at max=#3%
+ \setcounter{cpd at planes}{#3}%
\@cpd at initsize{#1}{#2}%
\let\put at sqs=\put at sqs@space%
\let\read at plane=\read at plane@space%
@@ -1484,7 +1477,7 @@
\outer at frame=\space at frame%
\fi%
\ifspace at vertical%
- \bd at width=\lines at max\sq at width%
+ \bd at width=\value{cpd at lines}\sq at width%
\board at width\bd at width%
\advance\bd at width\tw@\inner at frame%
\advance\board at width\tw@\inner at frame%
@@ -1491,7 +1484,7 @@
\advance\board at width\tw@\h at frame@dist%
\advance\board at width\tw@\outer at frame%
\else%
- \bd at width=\lines at max\sq at width%
+ \bd at width=\value{cpd at lines}\sq at width%
\advance\bd at width\tw@\inner at frame%
\ifdim\h at space@dist<1.5\sq at width%
\h at space@dist=1.5\sq at width%
@@ -1500,20 +1493,20 @@
% Now we can compute the width of the complete board
\board at width\bd at width%
\advance\board at width\h at space@dist%
- \multiply\board at width\planes at max%
+ \multiply\board at width\value{cpd at planes}%
\advance\board at width\h at space@dist%
\advance\board at width\tw@\outer at frame%
\fi%
\else%
\ifthenelse{\boolean{legend}}{\v at frame@dist=1.5em\h at frame@dist=1.5em}{}%
- \bd at width=\lines at max\sq at width%
- \ifnum\lines at max>\@ight%
+ \bd at width=\value{cpd at lines}\sq at width%
+ \ifthenelse{\value{cpd at lines} > 8}{%
% Make the board wider
- \board at width=\lines at max\sq at width%
- \else%
+ \board at width=\value{cpd at lines}\sq at width%
+ }{%
% Make a normal width
\board at width=\@ight\sq at width%
- \fi%
+ }%
\advance\bd at width\tw@\inner at frame%
\advance\board at width\tw@\inner at frame%
\advance\board at width\tw@\h at frame@dist%
@@ -1711,6 +1704,7 @@
% \begin{macro}{\diagramxi}
% \begin{macro}{\diagramxii}
% \begin{macrocode}
+\newcounter{cpd at chessfontsize}
\newcommand*{\diagramx}{
\ifcase\elchfont\relax%
\font\chessfont=pkelch12
@@ -1721,6 +1715,7 @@
\fi%
\dia at lineskip\z@
\dia at type\z@
+ \setcounter{cpd at chessfontsize}{12}%
}
\newcommand*{\diagramxi}{
@@ -1733,6 +1728,7 @@
\fi%
\dia at lineskip\@ne\p@
\dia at type\@ne
+ \setcounter{cpd at chessfontsize}{14}%
}
\newcommand*{\diagramxii}{
@@ -1745,6 +1741,7 @@
\fi%
\dia at lineskip\tw@\p@
\dia at type\tw@
+ \setcounter{cpd at chessfontsize}{16}%
}
% \end{macrocode}
% \end{macro}
@@ -2027,7 +2024,7 @@
{}% Do nothing
{%
\setboolean{cpd at checkPieceCounts}{true}%
- \@parseWhiteAndBlackCount#1+\e at list
+ \@parseWhiteAndBlackCount#1+\e at list%
}%
\fen at tk={#2}\setboolean{@cpd at fen}{true}%
\ignorespaces%
@@ -2197,7 +2194,7 @@
\def\themeindex{\printindex[theme]}
\def\DefinePieces#1#2#3{%
\@setPieceColor#1\@setPieceSpec#2\@setPieceRotation#3%
- \loop at rotation%
+ \cpd at piecedef@rotations%
\expandafter\xdef\csname\ds at black\ds at white\ds at bishop\endcsname{%
\noexpand\ch at fig{20}%
}%
@@ -2241,6 +2238,8 @@
\def\wX{\ch at fig{180}}
\def\nX{\ch at fig{186}}
\def\sX{\ch at fig{192}}
+\def\cpd at whiteField{{\chessfont\ }}
+\def\cpd at blackField{{\chessfont\char144}}
% \end{macrocode}
%
@@ -2851,31 +2850,44 @@
\def\get at text#1{\text at tk={#1}\read at square}
-\def\getpi at ce#1{\if#1B\relax\else
- \if#1\ds at knight\advance\help at a\@ne%
- \else\if#1\ds at bishop\advance\help at a\tw@%
- \else\if#1\ds at rook\advance\help at a\thr@@%
- \else\if#1\ds at queen\advance\help at a\f at ur%
- \else\if#1\ds at king\advance\help at a 5%
- \else\if#1C%
- % An imitator should not count for any color.
- \let\cpd at stepcounterPieces\relax
- \advance\help at a 145%
- \else\if#1E% Equihopper
- \advance\help at a 216%
- \else\if#1X% Equihopper senkrecht
- \advance\help at a 180%
- \else%
- \errmessage{invalid piece!}%
- \fi\fi\fi\fi\fi\fi\fi\fi\fi%
+\def\getpi at ce#1{%
+ \IfStrEqCase{#1}{%
+ {\ds at pawn}{}%
+ {\ds at knight}{\advance\help at a\@ne}%
+ {\ds at bishop}{\advance\help at a\tw@}%
+ {\ds at rook}{\advance\help at a\thr@@}%
+ {\ds at queen}{\advance\help at a\f at ur}%
+ {\ds at king}{\advance\help at a 5}%
+ {C}{%
+ \let\cpd at stepcounterPieces\relax
+ \advance\help at a 145%
+ }%
+ {E}{\advance\help at a 216}%
+ {X}{\advance\help at a 180}%
+ }[\errmessage{invalid piece!}]%
\futurelet\r at tate\chkr at tate%
}
\def\chkr at tate{%
+% \IfStrEqCase{\r at tate}{%
+% {\ds at rotation@upsidedown}{%
+% \advance\help at a 108%
+% \let\nextpr at c=\skipr at t%
+% }%
+% {\ds at rotation@left}{%
+% \advance\help at a 36%
+% \let\nextpr at c=\skipr at t%
+% }%
+% {\ds at rotation@right}{%
+% \advance\help at a 72%
+% \let\nextpr at c=\skipr at t%
+% }%
+% }[\let\nextpr at c\piece at job]%
\if\r at tate \ds at rotation@upsidedown\advance\help at a 108\let\nextpr at c=\skipr at t\else%
\if\r at tate \ds at rotation@left\advance\help at a 36\let\nextpr at c=\skipr at t\else%
\if\r at tate \ds at rotation@right\advance\help at a 72\let\nextpr at c=\skipr at t\else%
- \let\nextpr at c\piece at job\fi\fi\fi\nextpr at c%
+ \let\nextpr at c\piece at job\fi\fi\fi%
+ \nextpr at c%
}
\def\skipr at t#1{\piece at job}
\def\l@@k{\futurelet\whatsnext\parsefi at lds}
@@ -2889,7 +2901,7 @@
}
\def\set at current@square at index#1#2{%
- \setcounter{cpd at current@square at index}{#1+\value{cpd at linesmax}*#2}%
+ \setcounter{cpd at current@square at index}{#1+\value{cpd at lines}*#2}%
}
\def\set at current@square at value#1{%
\expandafter%
@@ -2899,34 +2911,25 @@
\setcounter{cpd at current@square at value}%
{\csname cpd at square@\roman{cpd at current@square at index}\endcsname}%
}
-\def\set at piece{%
- \ifnum\pl at ne=\current at plane%
+\def\@cpd at setpiece{%
+ \ifthenelse{\value{cpd at plane}=\value{cpd at current@plane}}{%
\cpd at stepcounterPieces%
- \set at current@square at index\lin@\r at w%
- \get at current@square at value%
- \ifthenelse{\value{cpd at current@square at value}=\m at ne}
- {\set at current@square at value{\the\help at a}}%
- {\ifthenelse{\value{cpd at current@square at value}=144}%
- {\set at current@square at value{\the\help at a+18}}%
- {\errmessage{Trying to set a piece to an occupied square}}}%
- \fi%
- \l@@k%
-}
-\def\cpd at fen@setpiece{%
- \ifnum\pl at ne=\current at plane%
- \cpd at stepcounterPieces%
\set at current@square at index{\value{cpd at line}}{\value{cpd at row}}%
\get at current@square at value%
- \ifthenelse{\value{cpd at current@square at value}=\m at ne}
+ \ifthenelse{\value{cpd at current@square at value}=\m at ne}%
{\set at current@square at value{\the\help at a}}%
{\ifthenelse{\value{cpd at current@square at value}=144}%
{\set at current@square at value{\the\help at a+18}}%
- {\errmessage{Trying to set a piece to an occupied square}}}%
- \fi%
+ {\errmessage{Trying to set a piece to an occupied square.}}}%
+ }{}%
}
+\def\set at piece{%
+ \@cpd at setpiece%
+ \l@@k%
+}
\def\set at nofield, {%
- \ifnum\pl at ne=\current at plane%
- \set at current@square at index\lin@\r at w%
+ \ifthenelse{\value{cpd at plane}=\value{cpd at current@plane}}{%
+ \set at current@square at index{\value{cpd at line}}{\value{cpd at row}}%
\get at current@square at value%
\ifthenelse{\value{cpd at current@square at value}=\m at ne}%
{}% This is an empty white square, nothing to do
@@ -2933,19 +2936,20 @@
{\ifthenelse{\value{cpd at current@square at value}=144}%
{\set at current@square at value{\m at ne}}%
{\errmessage{Trying to set a piece to an occupied square}}}%
- \fi%
- \l@@klist%
+ }{}%
+ \l@@klist%
}
\def\set at frame, {%
- \ifnum\pl at ne=\current at plane%
- \@vGrid{\the\lin@}{\the\r at w}\@ne%
- \@hGrid{\the\lin@}{\the\r at w}\@ne%
- \advance\lin@\@ne%
- \@vGrid{\the\lin@}{\the\r at w}\@ne%
- \advance\lin@\m at ne\advance\r at w\@ne%
- \@hGrid{\the\lin@}{\the\r at w}\@ne%
- \fi%
- \l@@klist%
+ \ifthenelse{\value{cpd at plane}=\value{cpd at current@plane}}{%
+ \@vGrid{\value{cpd at line}}{\value{cpd at row}}\@ne%
+ \@hGrid{\value{cpd at line}}{\value{cpd at row}}\@ne%
+ \addtocounter{cpd at line}{1}%
+ \@vGrid{\value{cpd at line}}{\value{cpd at row}}\@ne%
+ \addtocounter{cpd at line}{-1}%
+ \addtocounter{cpd at row}{1}%
+ \@hGrid{\value{cpd at line}}{\value{cpd at row}}\@ne%
+ }{}%
+ \l@@klist%
}
\def\e at list{\relax}
\def\l@@klist{\futurelet\nextlist\ch at cklst}
@@ -2965,93 +2969,46 @@
\addtocounter{cpd at row}{\m at ne}%
}%
{%
- \errmessage{FEN: there is now row to end here}%
+ \errmessage{FEN: there is now row to end here.}%
}%
- \else\ifx#1K\relax%
+ \fi% FEN space issue
+ \IfSubStr{12345678}{#1}{%
+ \addtocounter{cpd at line}{#1}%
+ }{}%
+ \IfSubStr{KQRBNP}{#1}{%
\let\cpd at stepcounterPieces\cpd at stepcounterWhite%
- \help at a=5%
- \cpd at fen@setpiece%
+ \IfStrEqCase{#1}{%
+ {K}{\help at a=5}%
+ {Q}{\help at a=4}%
+ {R}{\help at a=3}%
+ {B}{\help at a=2}%
+ {N}{\help at a=1}%
+ {P}{\help at a=0}%
+ }
+ \@cpd at setpiece%
\addtocounter{cpd at line}{\@ne}%
- \else\ifx#1Q\relax%
- \let\cpd at stepcounterPieces\cpd at stepcounterWhite%
- \help at a=4%
- \cpd at fen@setpiece%
- \addtocounter{cpd at line}{\@ne}%
- \else\ifx#1R\relax%
- \let\cpd at stepcounterPieces\cpd at stepcounterWhite%
- \help at a=3%
- \cpd at fen@setpiece%
- \addtocounter{cpd at line}{\@ne}%
- \else\ifx#1B\relax%
- \let\cpd at stepcounterPieces\cpd at stepcounterWhite%
- \help at a=2%
- \cpd at fen@setpiece%
- \addtocounter{cpd at line}{\@ne}%
- \else\ifx#1N\relax%
- \let\cpd at stepcounterPieces\cpd at stepcounterWhite%
- \help at a=1%
- \cpd at fen@setpiece%
- \addtocounter{cpd at line}{\@ne}%
- \else\ifx#1P\relax%
- \let\cpd at stepcounterPieces\cpd at stepcounterWhite%
- \help at a=0%
- \cpd at fen@setpiece%
- \addtocounter{cpd at line}{\@ne}%
- \else\ifx#1k\relax%
+ }{}%
+ \IfSubStr{kqrbnp}{#1}{%
\let\cpd at stepcounterPieces\cpd at stepcounterBlack%
- \help at a=17%
- \cpd at fen@setpiece%
+ \IfStrEqCase{#1}{%
+ {k}{\help at a=17}%
+ {q}{\help at a=16}%
+ {r}{\help at a=15}%
+ {b}{\help at a=14}%
+ {n}{\help at a=13}%
+ {p}{\help at a=12}%
+ }
+ \@cpd at setpiece%
\addtocounter{cpd at line}{\@ne}%
- \else\ifx#1q\relax%
- \let\cpd at stepcounterPieces\cpd at stepcounterBlack%
- \help at a=16%
- \cpd at fen@setpiece%
- \addtocounter{cpd at line}{\@ne}%
- \else\ifx#1r\relax%
- \let\cpd at stepcounterPieces\cpd at stepcounterBlack%
- \help at a=15%
- \cpd at fen@setpiece%
- \addtocounter{cpd at line}{\@ne}%
- \else\ifx#1b\relax%
- \let\cpd at stepcounterPieces\cpd at stepcounterBlack%
- \help at a=14%
- \cpd at fen@setpiece%
- \addtocounter{cpd at line}{\@ne}%
- \else\ifx#1n\relax%
- \let\cpd at stepcounterPieces\cpd at stepcounterBlack%
- \help at a=13%
- \cpd at fen@setpiece%
- \addtocounter{cpd at line}{\@ne}%
- \else\ifx#1p\relax%
- \let\cpd at stepcounterPieces\cpd at stepcounterBlack%
- \help at a=12%
- \cpd at fen@setpiece%
- \addtocounter{cpd at line}{\@ne}%
- \else\ifx1#1\relax%
- \addtocounter{cpd at line}{1}%
- \else\ifx2#1\relax%
- \addtocounter{cpd at line}{2}%
- \else\ifx3#1\relax%
- \addtocounter{cpd at line}{3}%
- \else\ifx4#1\relax%
- \addtocounter{cpd at line}{4}%
- \else\ifx5#1\relax%
- \addtocounter{cpd at line}{5}%
- \else\ifx6#1\relax%
- \addtocounter{cpd at line}{6}%
- \else\ifx7#1\relax%
- \addtocounter{cpd at line}{7}%
- \else\ifx8#1\relax%
- \addtocounter{cpd at line}{8}%
- \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
+ }{}%
}
\def\@cpd at parse@fen#1{\@cpd at handle@fen#1\l@@klist}
\def\p at rsepieces#1, {\getc at lor#1\e at list\l@@klist}
\def\p at rsetext#1, {\get at text#1\e at list\l@@klist}
\def\set at text{%
- \ifnum\pl at ne=\current at plane%
- \raise\r at w\sq at width\hbox to \z@{%
- \hskip\lin@\sq at width%
+ \ifthenelse{\value{cpd at plane}=\value{cpd at current@plane}}{%
+ \raise\value{cpd at row}\sq at width\hbox to \z@{%
+ \hskip\value{cpd at line}\sq at width%
\vbox to \sq at width{\vss%
\hbox to \sq at width{%
\hss%
@@ -3060,13 +3017,13 @@
}\vss}%
\hss%
}%
- \fi%
- \l@@klist%
+ }{}%
+ \l@@klist%
}
\def\p at rseauthor#1; {\sh at wauthor#1;\l@@klist}
\def\read at square#1#2{%
- \lin@=`#1\advance\lin@ by -`a\relax%
- \r at w=#2\advance\r at w by \m at ne%
+ \setcounter{cpd at line}{`#1-`a}%
+ \setcounter{cpd at row}{#2-1}%
\read at plane%
}
\def\read at plane@normal{\plane at job}
@@ -3075,19 +3032,28 @@
\def\get at plane@stereo{%
\if\plane at char A%
- \pl at ne=\@ne\advance\r at w-\tw@\advance\lin at -\tw@%
+ \setcounter{cpd at plane}{1}%
+ \addtocounter{cpd at row}{-2}%
+ \addtocounter{cpd at line}{-2}%
\let\@plane at job=\skip at plane%
\else\if\plane at char B%
- \pl at ne=\tw@\advance\r at w-\tw@\advance\lin at -\tw@%
+ \setcounter{cpd at plane}{2}%
+ \addtocounter{cpd at row}{-2}%
+ \addtocounter{cpd at line}{-2}%
\let\@plane at job=\skip at plane%
\else\if\plane at char C%
- \pl at ne=\thr@@\advance\r at w-\tw@\advance\lin at -\tw@%
+ \setcounter{cpd at plane}{3}%
+ \addtocounter{cpd at row}{-2}%
+ \addtocounter{cpd at line}{-2}%
\let\@plane at job=\skip at plane%
\else\if\plane at char D%
- \pl at ne=\f at ur\advance\r at w-\tw@\advance\lin at -\tw@%
+ \setcounter{cpd at plane}{4}%
+ \addtocounter{cpd at row}{-2}%
+ \addtocounter{cpd at line}{-2}%
\let\@plane at job=\skip at plane%
\else%
- \pl at ne=\z@\let\@plane at job=\plane at job%
+ \setcounter{cpd at plane}{0}%
+ \let\@plane at job=\plane at job%
\fi\fi\fi\fi%
\@plane at job%
}
@@ -3094,7 +3060,10 @@
\def\skip at plane#1{\plane at job}
-\def\read at plane@space#1{\pl at ne=`#1\advance\pl at ne by -`A\relax\plane at job}
+\def\read at plane@space#1{%
+ \setcounter{cpd at plane}{`#1-`A}%
+ \plane at job%
+}
\def\@vGrid#1#2#3{%
\raise#2\sq at width\hbox to \z@{%
\hskip#1\sq at width\hskip-.5\grid at width%
@@ -3110,7 +3079,7 @@
}%
}
\def\@selGrid#1#2, {%
- \ifnum\pl at ne=\current at plane%
+ \ifthenelse{\value{cpd at plane}=\value{cpd at current@plane}}{%
\if#1h%
\@hGrid#2%
\else\if#1v%
@@ -3118,23 +3087,21 @@
\else%
\errmessage{Wrong GridSelector #1}%
\fi\fi%
- \fi%
- \l@@klist%
+ }{}%
+ \l@@klist%
}
\def\@stdgrid{%
\setbox\plane at box=\vbox{\hbox{%
\help at a=\tw@%
- \loop%
- \ifnum\help at a<\lines at max%
- \@vGrid{\the\help at a}{0}{\the\rows at max}%
+ \whiledo{\help at a<\value{cpd at lines}}{%
+ \@vGrid{\the\help at a}{0}{\value{cpd at rows}}%
\advance\help at a\tw@%
- \repeat%
+ }%
\help at a=\tw@%
- \loop%
- \ifnum\help at a<\rows at max%
- \@hGrid{0}{\the\help at a}{\the\lines at max}%
+ \whiledo{\help at a<\value{cpd at rows}}{%
+ \@hGrid{0}{\the\help at a}{\value{cpd at lines}}%
\advance\help at a\tw@%
- \repeat%
+ }%
\box\plane at box
}}%
}
@@ -3157,7 +3124,7 @@
\setcounter{cpd at whitePieces}{\z@}%
\setcounter{cpd at blackPieces}{\z@}%
\setcounter{cpd at neutralPieces}{\z@}%
- \lin@\z@
+ \setcounter{cpd at line}{0}%
}
\def\clear at board{%
@@ -3166,72 +3133,61 @@
{\@whitefield=\m at ne\@blackfield=144}%
\ifthenelse{\boolean{allwhite}}{\@blackfield=\m at ne}{}%
\ifthenelse{\boolean{switchcolors}}{\@whitefield=144\@blackfield=\m at ne}{}%
- \setcounter{cpd at current@row}{0}%
- \whiledo{\value{cpd at current@row}<\value{cpd at rowsmax}}{%
- \setcounter{cpd at current@line}{0}%
- \whiledo{\value{cpd at current@line}<\value{cpd at linesmax}}{%
- \set at current@square at index{\value{cpd at current@line}}{\value{cpd at current@row}}%
- \setcounter{cpd at helper}{\the\current at plane+\value{cpd at current@line}+\value{cpd at current@row}}%
+ \setcounter{cpd at row}{0}%
+ \whiledo{\value{cpd at row}<\value{cpd at rows}}{%
+ \setcounter{cpd at line}{0}%
+ \whiledo{\value{cpd at line}<\value{cpd at lines}}{%
+ \set at current@square at index{\value{cpd at line}}{\value{cpd at row}}%
+ \setcounter{cpd at helper}{%
+ \value{cpd at current@plane}%
+ +\value{cpd at line}%
+ +\value{cpd at row}}%
\ifthenelse{\isodd{\value{cpd at helper}}}%
{\set at current@square at value{\@whitefield}}%
{\set at current@square at value{\@blackfield}}%
- \addtocounter{cpd at current@line}{\@ne}%
+ \addtocounter{cpd at line}{\@ne}%
}%
- \addtocounter{cpd at current@row}{\@ne}%
+ \addtocounter{cpd at row}{\@ne}%
}%
}
+
\def\put at row#1{%
- \lin@\z@%
- \help at b=#1%
- \advance\help at b\brd at ff%
+ \setcounter{cpd at row}{#1}%
+ \setcounter{cpd at row@display}{#1 + 1}%
+ \setcounter{cpd at line}{0}%
\hbox{%
\ifthenelse{\boolean{legend}}{{%
- \advance\@rows`1%
- \llap{\raise .25\sq at width\hbox{\legendfont \char\@rows\ \ }}%
+ \llap{\raise .1\sq at width\hbox{\legendfont\arabic{cpd at row@display}\ \ }}%
}}{}%
\if at stereo%
- \ifnum\current at plane>\z@%
- \ifnum\@rows=12%
- \llap{\raise .5\sq at width\hbox{\cpd at boardfont c6\ }}%
- \fi%
- \fi%
+ \ifthenelse{\value{cpd at current@plane}>0}{%
+ \ifthenelse{\value{cpd at row} = 3}{%
+ \llap{\cpd at boardfont c6\ }%
+ }{}%
+ % \fi%
+ }{}%
+ % \fi%
\fi%
- \hbox to \z@{\vbox to \sq at width{}}%
- \set at current@square at index{\lin@}{#1}%
- \loop%
- \get at current@square at value%
- \ifthenelse{\value{cpd at current@square at value}=\m at ne}%
- {\wF}%
- {\char\value{cpd at current@square at value}}%
- % \ifnum\count\help at b=\m at ne\wF%
- % \else\char\count\help at b\fi%
- \advance\lin@\@ne%
- \addtocounter{cpd at current@square at index}{1}%
- % \advance\help at b\@ne%
- \ifnum\lin@<\lines at max\repeat%
+ % \hbox to \z@{\vbox to \sq at width{}}%
+ \set at current@square at index{\value{cpd at line}}{#1}%
+ \begin{tikzpicture}[x=\sq at width,y=\sq at width]%
+ \useasboundingbox (0, 0) rectangle (\value{cpd at lines}, 1);%
+ \whiledo{\value{cpd at line} < \value{cpd at lines}}{%
+ \get at current@square at value%
+ \ifthenelse{\value{cpd at current@square at value}=\m at ne}%
+ {}%
+ {%
+ \draw (\value{cpd at line}+.5, .5)%
+ node {{\chessfont\char\value{cpd at current@square at value}}};%
+ }%
+ \addtocounter{cpd at line}{1}%
+ \addtocounter{cpd at current@square at index}{1}%
+ }%
+ \end{tikzpicture}%
}%
}
-% \def\put at line#1{%
-% \lin@\z@%
-% \help at b=#1%
-% \advance\help at b\brd at ff%
-% \hbox{%
-% \if at stereo%
-% \ifnum\current at plane>\z@%
-% \ifnum\@rows=12%
-% \llap{\raise .5\sq at width\hbox{\cpd at boardfont c6\ }}%
-% \fi%
-% \fi%
-% \fi%
-% \hbox to \z@{\vbox to \sq at width{}}%
-% \loop%
-% \ifnum\count\help at b=\m at ne\wF%
-% \else\char\count\help at b\fi%
-% \advance\lin@\@ne\advance\help at b\@ne%
-% \ifnum\lin@<\lines at max\repeat%
-% }%
-% }
+\def\cpd at fen@parseTokenlist#1{\expandafter\l@@klist\the#1\e at list}
\def\@parseTokenlist#1#2{\expandafter\l@@klist\the#1#2 \e at list}
\def\@addToPlane#1{%
\setbox\plane at box=\vbox{\hbox{%
@@ -3240,97 +3196,110 @@
}}%
}
\def\put at plane{%
- % We might want gridchess
- \if at stdgrid%
+ % We might want gridchess
+ \if at stdgrid%
\@stdgrid%
- \fi%
- % Let us first set the fieldframes
- \if at fieldframe%
- \let\@action\read at square%
- \let\plane at job\set at frame%
- \@addToPlane\fieldframe at tk%
- \fi%
- % Now we set text to all squares which are given using \fieldtext
- \if at fieldtext%
- \let\@action\p at rsetext%
- \let\plane at job\set at text%
- \@addToPlane\fieldtext at tk%
- \fi%
- % Then we should add the gridlines
- \if at gridlines%
- \let\@action\read at plane%
- \let\plane at job\@selGrid%
- \@addToPlane\gridlines at tk%
- \else%
- \if at stereo%
- \stereo at center%
- \fi%
- \fi%
- % In an 'allwhite' diagram we display dotted lines
- \ifthenelse{\boolean{allwhite}}{%
- \setbox\plane at box=\vbox{\hbox{%
- \psset{unit=\sq at width,linewidth=.4pt,linestyle=dotted,dotsep=.125}%
- \setcounter{field at border}{1}%
- \whiledo{\value{field at border}<\lines at max}{%
- \psline(\value{field at border},0)(\value{field at border},\rows at max)%
- \addtocounter{field at border}{\@ne}%
+ \fi%
+ % Let us first set the fieldframes
+ \if at fieldframe%
+ \let\@action\read at square%
+ \let\plane at job\set at frame%
+ \@addToPlane\fieldframe at tk%
+ \fi%
+ % Now we set text to all squares which are given using \fieldtext
+ \if at fieldtext%
+ \let\@action\p at rsetext%
+ \let\plane at job\set at text%
+ \@addToPlane\fieldtext at tk%
+ \fi%
+ % Then we should add the gridlines
+ \if at gridlines%
+ \let\@action\read at plane%
+ \let\plane at job\@selGrid%
+ \@addToPlane\gridlines at tk%
+ \else%
+ \if at stereo%
+ \stereo at center%
+ \fi%
+ \fi%
+ % In an 'allwhite' diagram we display dotted lines
+ \ifthenelse{\boolean{allwhite}}{%
+ \setbox\plane at box=\vbox{\hbox{%
+ \begin{tikzpicture}[x=\sq at width,y=\sq at width]%
+ \useasboundingbox
+ (0, 0) rectangle (\value{cpd at lines}, \value{cpd at rows});
+ \setcounter{field at border}{1}%
+ \whiledo{\value{field at border}<\value{cpd at lines}}{%
+ \draw[densely dotted]
+ (\value{field at border},0)
+ --
+ (\value{field at border},\value{cpd at rows});
+ \addtocounter{field at border}{\@ne}%
+ }%
+ \setcounter{field at border}{1}%
+ \whiledo{\value{field at border}<\value{cpd at rows}}{%
+ \draw[densely dotted]
+ (0, \value{field at border})
+ --
+ (\value{cpd at lines}, \value{field at border});
+ \addtocounter{field at border}{\@ne}%
+ }%
+ \end{tikzpicture}%
+ \box\plane at box%
+ }}%
+ }{}%
+ % Now we should clear the board
+ \clear at board%
+ % Let us now parse the list of pieces
+ \ifthenelse{\boolean{@cpd at fen}}{%
+ \ifthenelse{\value{cpd at rows}=8}{}{\errmessage{FEN is only allowed for 8x8 boards.}}% FEN space issue
+ \ifthenelse{\value{cpd at lines}=8}{}{\errmessage{FEN is only allowed for 8x8 boards.}}% FEN space issue
+ \setcounter{cpd at row}{7}%
+ \setcounter{cpd at line}{0}%
+ \let\@action\@cpd at parse@fen%
+ \cpd at fen@parseTokenlist\fen at tk\e at list% FEN space issue
+ }{}%
+ \if at pieces%
+ \let\@action\p at rsepieces%
+ \let\piece at job\l@@k\let\plane at job\set at piece%
+ \@parseTokenlist\pieces at tk,%
+ \fi%
+ % Now we clear all fields, which are given using \nofields
+ \if at nofields%
+ \let\@action\read at square%
+ \let\plane at job\set at nofield%
+ \@parseTokenlist\nofields at tk,%
+ \fi%
+ % Now we can put the pieces to the board
+ \global\setbox\plane at box=\hbox{%
+ \vbox{\rlap{\box\plane at box}}%
+ \vbox{%
+ \chessfont%
+ \baselineskip=\z@\lineskip=\z@%
+ \setcounter{cpd at row}{\value{cpd at rows} - 1}%
+ \whiledo{\value{cpd at row} > -1}{%
+ \put at row{\value{cpd at row}}%
+ \addtocounter{cpd at row}{-1}%
}%
- \setcounter{field at border}{1}%
- \whiledo{\value{field at border}<\rows at max}{%
- \psline(0,\value{field at border})(\lines at max,\value{field at border})%
- \addtocounter{field at border}{\@ne}%
- }%
- \box\plane at box%
- }}%
- }{}%
- % Now we should clear the board
- \clear at board%
- % Let us now parse the list of pieces
- \ifthenelse{\boolean{@cpd at fen}}{%
- \ifthenelse{\value{cpd at rowsmax}=8}{}{\errmessage{FEN is only allowed for 8x8 boards.}}
- \ifthenelse{\value{cpd at linesmax}=8}{}{\errmessage{FEN is only allowed for 8x8 boards.}}
- \setcounter{cpd at row}{7}%
- \setcounter{cpd at line}{0}%
- \let\@action\@cpd at parse@fen%
- \@parseTokenlist\fen at tk\e at list%
- }{}%
- \if at pieces%
- \let\@action\p at rsepieces%
- \let\piece at job\l@@k\let\plane at job\set at piece%
- \@parseTokenlist\pieces at tk,%
- \fi%
- % Now we clear all fields, which are given using \nofields
- \if at nofields%
- \let\@action\read at square%
- \let\plane at job\set at nofield%
- \@parseTokenlist\nofields at tk,%
- \fi%
- % Now we can put the pieces to the board
- \global\setbox\plane at box=\hbox{%
- \vbox{\rlap{\box\plane at box}}%
- \vbox{%
- \chessfont%
- \baselineskip=\z@\lineskip=\z@%
- \@rows=\rows at max%
- % \multiply\@rows by \lines at max%
- \loop%
- \advance\@rows \m at ne%
- \put at row\@rows%
- \ifnum\@rows>\z@\repeat%
- }%
- % Put a legend if wanted
- \ifthenelse{\boolean{legend}}{%
- \vbox to \z@{%
- \vbox to \z@{\vss}%
- \llap{\hbox{\hspace*{\inner at frame}%
- \lin@\z@%
- \loop%
- \hbox to \sq at width{\hfill{\advance\lin@`a\legendfont\char\lin@}\hfill}%
- \advance\lin@\@ne%
- \ifnum\lin@<\lines at max\repeat%
- }}\vss}%
- }{}%
- }%
+ }%
+ % Put a legend if wanted
+ \ifthenelse{\boolean{legend}}{%
+ \vbox to \z@{%
+ \vbox to \z@{\vss}%
+ \llap{\hbox{\hspace*{\inner at frame}%
+ \setcounter{cpd at line}{0}%
+ \setcounter{cpd at line@display}{`a}%
+ \whiledo{\value{cpd at line}<\value{cpd at lines}}{%
+ \hbox to \sq at width{\hfill%
+ {\legendfont\char\value{cpd at line@display}}%
+ \hfill}%
+ \addtocounter{cpd at line}{1}%
+ \addtocounter{cpd at line@display}{1}%
+ }
+ }}%
+ \vss}%
+ }{}%
+ }%
}
\def\put at sqs@normal{%
\put at plane%
@@ -3340,17 +3309,16 @@
}
\def\put at sqs@stereo{%
\setbox\sq at box=\hbox{\hfil\vbox{%
- \current at plane=5%
\vskip\v at space@dist%
- \loop%
- \advance\current at plane\m at ne%
- \ifnum\current at plane=\z@%
- \lines at max=\@ight%
- \rows at max=\@ight%
- \else%
- \lines at max=\f at ur%
- \rows at max=\f at ur%
- \fi%
+ \setcounter{cpd at current@plane}{4}%
+ \whiledo{\value{cpd at current@plane}>-1}{%
+ \ifthenelse{\value{cpd at current@plane}=0}{%
+ \setcounter{cpd at lines}{8}%
+ \setcounter{cpd at rows}{8}%
+ }{%
+ \setcounter{cpd at lines}{4}%
+ \setcounter{cpd at rows}{4}%
+ }%
% Now we should clear the board
\begingroup% We need this for inner loops!
\clear at board%
@@ -3359,7 +3327,7 @@
\hbox to \bd at width{%
\hfil%
\inner at henbox{\box\plane at box}%
- \ifcase\current at plane\or%
+ \ifcase\value{cpd at current@plane}\or%
\rlap{{\cpd at boardfont\ A}}\or%
\rlap{{\cpd at boardfont\ B}}\or%
\rlap{{\cpd at boardfont\ C}}\or%
@@ -3368,45 +3336,45 @@
\hfil%
}%
\vskip\v at space@dist%
- \ifnum\z@<\current at plane\repeat%
+ \addtocounter{cpd at current@plane}{-1}%
+ }%
}\hfil}%
}
\def\stereo at center{%
- \ifnum\current at plane=\z@%
+ \ifthenelse{\value{cpd at current@plane}=0}{%
\setbox\plane at box=\vbox{\hbox{%
\@hGrid\tw@\tw@\f at ur\@hGrid\tw@ 6\f at ur%
\@vGrid\tw@\tw@\f at ur\@vGrid6\tw@\f at ur%
\box\plane at box%
}}%
- \fi%
+ }{}%
}
\def\put at sqs@space at vertical{%
- \setbox\sq at box=\hbox{\hfil\vbox{%
- \current at plane=\planes at max%
- \vskip\v at space@dist%
- \loop%
- \advance\current at plane\m at ne%
- % Now we should clear the board
- \begingroup% We use inner loops!
- \clear at board%
- \put at plane%
- \hbox to \bd at width{%
- \inner at henbox{\box\plane at box}%
- \advance\current at plane`A%
- \rlap{{\cpd at boardfont\ \char\current at plane}}%
- }%
- \endgroup%
- \vskip\v at space@dist%
- \ifnum\z@<\current at plane\repeat%
- }\hfil}%
+ \setbox\sq at box=\hbox{\hfil\vbox{%
+ \setcounter{cpd at current@plane}{\value{cpd at planes}-1}%
+ \vskip\v at space@dist%
+ \whiledo{\value{cpd at current@plane}>-1}{%
+ \begingroup% We use inner loops!
+ \clear at board%
+ \put at plane%
+ \hbox to \bd at width{%
+ \inner at henbox{\box\plane at box}%
+ \setcounter{cpd at current@plane at display}{`A+\value{cpd at current@plane}}%
+ \rlap{{\cpd at boardfont\ \char\value{cpd at current@plane at display}}}%
+ }%
+ \endgroup%
+ \vskip\v at space@dist%
+ \addtocounter{cpd at current@plane}{-1}%
+ }%
+ }\hfil}%
}
\def\put at sqs@space at horizontal{%
\setbox\sq at box=\hbox{%
- \current at plane=\z@%
+ \setcounter{cpd at current@plane}{0}%
\hskip\h at space@dist%
- \loop%
+ \whiledo{\value{cpd at current@plane}<\value{cpd at planes}}{%
% Now we should clear the board
\begingroup% We use inner loops!
\clear at board%
@@ -3413,14 +3381,13 @@
\put at plane%
\hbox to \bd at width{%
\inner at henbox{\box\plane at box}%
- \advance\current at plane`A%
- \rlap{{\cpd at boardfont\ \char\current at plane}}%
+ \setcounter{cpd at current@plane at display}{`A+\value{cpd at current@plane}}%
+ \rlap{{\cpd at boardfont\ \char\value{cpd at current@plane at display}}}%
}%
\endgroup%
\hskip\h at space@dist%
- \advance\current at plane\@ne%
- \ifnum\planes at max>\current at plane%
- \repeat%
+ \addtocounter{cpd at current@plane}{1}%
+ }%
}%
}
@@ -3595,71 +3562,34 @@
\def\@setPieceRotation#1#2#3{%
\gdef\ds at rotation@left{#1}\gdef\ds at rotation@right{#2}\gdef\ds at rotation@upsidedown{#3}%
}
-\def\loop at rotation{%
- \bgroup%
- \n at cnt\z@%
- \help at a\z@%
- \loop%
- \ifcase\n at cnt%
- \def\@theRotation{}%
- \or%
- \def\@theRotation{\ds at rotation@left}%
- \or%
- \def\@theRotation{\ds at rotation@right}%
- \or%
- \def\@theRotation{\ds at rotation@upsidedown}%
- \fi%
- \loop at color%
- \advance\n at cnt\@ne%
- \advance\help at a by 36\relax%
- \ifnum\n at cnt<\f at ur\repeat%
- \egroup%
+\newcommand{\cpd at piecedef@rotations}{%
+ \def\@theRotation{}\cpd at piecedef@colors{0}%
+ \def\@theRotation{\ds at rotation@left}\cpd at piecedef@colors{36}%
+ \def\@theRotation{\ds at rotation@right}\cpd at piecedef@colors{72}%
+ \def\@theRotation{\ds at rotation@upsidedown}\cpd at piecedef@colors{108}%
}
-
-\def\loop at color{%
- \bgroup%
- \w at cnt\z@%
- \loop%
- \ifcase\w at cnt%
- \def\@theColor{\ds at white}%
- \or%
- \def\@theColor{\ds at neutral}%
- \or%
- \def\@theColor{\ds at black}%
- \fi%
- \loop at piece%
- \advance\w at cnt\@ne%
- \advance\help at a by 6%
- \ifnum\w at cnt<\thr@@\repeat%
- \egroup%
+\newcommand{\cpd at piecedef@colors}[1]{%
+ \def\@theColor{\ds at white}\cpd at piecedef@types{#1}{0}%
+ \def\@theColor{\ds at neutral}\cpd at piecedef@types{#1}{6}%
+ \def\@theColor{\ds at black}\cpd at piecedef@types{#1}{12}%
}
+\newcommand{\cpd at piecedef@types}[2]{%
+ \def\@thePiece{\ds at pawn}\cpd at piecedef{#1}{#2}{0}%
+ \def\@thePiece{\ds at knight}\cpd at piecedef{#1}{#2}{1}%
+ \def\@thePiece{\ds at bishop}\cpd at piecedef{#1}{#2}{2}%
+ \def\@thePiece{\ds at rook}\cpd at piecedef{#1}{#2}{3}%
+ \def\@thePiece{\ds at queen}\cpd at piecedef{#1}{#2}{4}%
+ \def\@thePiece{\ds at king}\cpd at piecedef{#1}{#2}{5}%
+}
+\newcommand{\cpd at piecedef}[3]{%
+ \setcounter{cpd at piece@index}{#1+#2+#3}%
+ \edef\cpd at piecedef@index{\arabic{cpd at piece@index}}%
+ \expandafter\xdef%
+ \csname\@theColor\@thePiece\@theRotation\endcsname{%
+ \ch at fig{\cpd at piecedef@index}%
+ }
+}
-\def\loop at piece{%
- \bgroup%
- \b at cnt\z@%
- \loop%
- \ifcase\b at cnt%
- \def\@thePiece{\ds at pawn}%
- \or%
- \def\@thePiece{\ds at knight}%
- \or%
- \def\@thePiece{\ds at bishop}%
- \or%
- \def\@thePiece{\ds at rook}%
- \or%
- \def\@thePiece{\ds at queen}%
- \or%
- \def\@thePiece{\ds at king}%
- \fi%
- \expandafter\xdef\csname%
- \@theColor\@thePiece\@theRotation\endcsname{%
- \noexpand\ch at fig{\the\help at a}%
- }
- \advance\b at cnt\@ne%
- \advance\help at a by \@ne%
- \ifnum\b at cnt<6\repeat%
- \egroup%
-}
\elchfont\@fselch
\defaultelchfont%
Modified: trunk/Master/texmf-dist/tex/latex/chess-problem-diagrams/diagram.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/chess-problem-diagrams/diagram.sty 2025-03-12 19:33:53 UTC (rev 74590)
+++ trunk/Master/texmf-dist/tex/latex/chess-problem-diagrams/diagram.sty 2025-03-12 19:34:04 UTC (rev 74591)
@@ -36,7 +36,7 @@
%%
%%
-\ProvidesPackage{diagram}[2024/10/14]
+\ProvidesPackage{diagram}[2025/02/21-tikz]
\newcommand*{\DefaultDiagramSize}{}
\DeclareOption{10pt}{\renewcommand*{\DefaultDiagramSize}{\diagramx}}
\DeclareOption{11pt}{\renewcommand*{\DefaultDiagramSize}{\diagramxi}}
@@ -47,7 +47,8 @@
\AtBeginDocument{\DefaultDiagramSize}
\RequirePackage{ifthen}
\RequirePackage{calc}
-\RequirePackage{pstricks}
+\RequirePackage{tikz}
+\RequirePackage{xstring}
%%
%%
%%
@@ -82,14 +83,9 @@
\newcounter{board at nr}
\renewcommand{\theboard at nr}{\thediag}
\newboolean{piececounter}
-\newcount\r at w
-\newcount\lin@
-\newcount\pl at ne
-\newcount\current at plane
-\newcount\w at cnt
-\newcount\b at cnt
-\newcount\n at cnt
+\newcounter{cpd at piece@index}
+
\newboolean{showcity}
\setboolean{showcity}{false}
\newboolean{showacademictitle}
@@ -115,9 +111,6 @@
\newcounter{cpd at blackPieces}
\newcounter{cpd at neutralPieces}
-\newcounter{cpd at row}
-\newcounter{cpd at line}
-
\newcommand{\cpd at stepcounterWhite}{\stepcounter{cpd at whitePieces}}
\newcommand{\cpd at stepcounterBlack}{\stepcounter{cpd at blackPieces}}
\newcommand{\cpd at stepcounterNeutral}{\stepcounter{cpd at neutralPieces}}
@@ -124,7 +117,6 @@
\global\let\cpd at stepcounterPieces\relax
\newcount\help at a
-\newcount\help at b
\newbox\dia at box
\newbox\@cnt at box
@@ -136,8 +128,6 @@
\newdimen\@test at dimen
\newif\if at left
-\newcount\brd at ff
-
\newdimen\dia at lineskip
\newdimen\board at width
@@ -245,15 +235,16 @@
\newif\if at first
\newwrite\s at lfd
\let\below at newline=\relax
-\newcount\@lines
-\newcount\@rows
-\newcount\lines at max
-\newcount\rows at max
-\newcount\planes at max
-\newcounter{cpd at rowsmax}
-\newcounter{cpd at linesmax}
-\newcounter{cpd at current@row}
-\newcounter{cpd at current@line}
+\newcounter{cpd at planes}
+\newcounter{cpd at rows}
+\newcounter{cpd at lines}
+\newcounter{cpd at plane}
+\newcounter{cpd at current@plane}
+\newcounter{cpd at current@plane at display}
+\newcounter{cpd at row}
+\newcounter{cpd at line}
+\newcounter{cpd at row@display}
+\newcounter{cpd at line@display}
\newcounter{cpd at maxsquare}
\newcounter{cpd at helper}
\newcounter{cpd at current@square at index}
@@ -272,17 +263,15 @@
}
\def\@cpd at initsize#1#2{%
- \setcounter{cpd at linesmax}{#1}%
- \setcounter{cpd at rowsmax}{#2}%
- \setcounter{cpd at maxsquare}{\value{cpd at rowsmax}*\value{cpd at linesmax}}%
+ \setcounter{cpd at lines}{#1}%
+ \setcounter{cpd at rows}{#2}%
+ \setcounter{cpd at maxsquare}{\value{cpd at rows}*\value{cpd at lines}}%
}
\def\@diagram[#1x#2]{%
- \lines at max=#1%
- \rows at max=#2%
\@cpd at initsize{#1}{#2}%
- \pl at ne=\z@%
- \current at plane=\z@%
+ \setcounter{cpd at plane}{0}%
+ \setcounter{cpd at current@plane}{0}%
\let\put at sqs=\put at sqs@normal%
\let\read at plane=\read at plane@normal%
\@start at diagram%
@@ -304,9 +293,7 @@
}
\def\@spacediagram[#1x#2x#3]{%
- \lines at max=#1%
- \rows at max=#2%
- \planes at max=#3%
+ \setcounter{cpd at planes}{#3}%
\@cpd at initsize{#1}{#2}%
\let\put at sqs=\put at sqs@space%
\let\read at plane=\read at plane@space%
@@ -388,7 +375,7 @@
\outer at frame=\space at frame%
\fi%
\ifspace at vertical%
- \bd at width=\lines at max\sq at width%
+ \bd at width=\value{cpd at lines}\sq at width%
\board at width\bd at width%
\advance\bd at width\tw@\inner at frame%
\advance\board at width\tw@\inner at frame%
@@ -395,7 +382,7 @@
\advance\board at width\tw@\h at frame@dist%
\advance\board at width\tw@\outer at frame%
\else%
- \bd at width=\lines at max\sq at width%
+ \bd at width=\value{cpd at lines}\sq at width%
\advance\bd at width\tw@\inner at frame%
\ifdim\h at space@dist<1.5\sq at width%
\h at space@dist=1.5\sq at width%
@@ -404,20 +391,20 @@
% Now we can compute the width of the complete board
\board at width\bd at width%
\advance\board at width\h at space@dist%
- \multiply\board at width\planes at max%
+ \multiply\board at width\value{cpd at planes}%
\advance\board at width\h at space@dist%
\advance\board at width\tw@\outer at frame%
\fi%
\else%
\ifthenelse{\boolean{legend}}{\v at frame@dist=1.5em\h at frame@dist=1.5em}{}%
- \bd at width=\lines at max\sq at width%
- \ifnum\lines at max>\@ight%
+ \bd at width=\value{cpd at lines}\sq at width%
+ \ifthenelse{\value{cpd at lines} > 8}{%
% Make the board wider
- \board at width=\lines at max\sq at width%
- \else%
+ \board at width=\value{cpd at lines}\sq at width%
+ }{%
% Make a normal width
\board at width=\@ight\sq at width%
- \fi%
+ }%
\advance\bd at width\tw@\inner at frame%
\advance\board at width\tw@\inner at frame%
\advance\board at width\tw@\h at frame@dist%
@@ -579,6 +566,7 @@
\newcommand*{\labelfont}{\rmfamily}
\newcommand*{\cpd at boardfont}{\rmfamily}
\newcommand*{\legendfont}{\sffamily}
+\newcounter{cpd at chessfontsize}
\newcommand*{\diagramx}{
\ifcase\elchfont\relax%
\font\chessfont=pkelch12
@@ -589,6 +577,7 @@
\fi%
\dia at lineskip\z@
\dia at type\z@
+ \setcounter{cpd at chessfontsize}{12}%
}
\newcommand*{\diagramxi}{
@@ -601,6 +590,7 @@
\fi%
\dia at lineskip\@ne\p@
\dia at type\@ne
+ \setcounter{cpd at chessfontsize}{14}%
}
\newcommand*{\diagramxii}{
@@ -613,6 +603,7 @@
\fi%
\dia at lineskip\tw@\p@
\dia at type\tw@
+ \setcounter{cpd at chessfontsize}{16}%
}
\def\defaultelchfont{%
\ifcase\@ptsize\relax%
@@ -801,7 +792,7 @@
{}% Do nothing
{%
\setboolean{cpd at checkPieceCounts}{true}%
- \@parseWhiteAndBlackCount#1+\e at list
+ \@parseWhiteAndBlackCount#1+\e at list%
}%
\fen at tk={#2}\setboolean{@cpd at fen}{true}%
\ignorespaces%
@@ -940,7 +931,7 @@
\def\themeindex{\printindex[theme]}
\def\DefinePieces#1#2#3{%
\@setPieceColor#1\@setPieceSpec#2\@setPieceRotation#3%
- \loop at rotation%
+ \cpd at piecedef@rotations%
\expandafter\xdef\csname\ds at black\ds at white\ds at bishop\endcsname{%
\noexpand\ch at fig{20}%
}%
@@ -984,6 +975,8 @@
\def\wX{\ch at fig{180}}
\def\nX{\ch at fig{186}}
\def\sX{\ch at fig{192}}
+\def\cpd at whiteField{{\chessfont\ }}
+\def\cpd at blackField{{\chessfont\char144}}
\newboolean{above at newline}
\newcommand{\above at newline}{\ifthenelse{\boolean{above at newline}}{\linebreak}{\setboolean{above at newline}{true}}}
@@ -1557,23 +1550,21 @@
\def\get at text#1{\text at tk={#1}\read at square}
-\def\getpi at ce#1{\if#1B\relax\else
- \if#1\ds at knight\advance\help at a\@ne%
- \else\if#1\ds at bishop\advance\help at a\tw@%
- \else\if#1\ds at rook\advance\help at a\thr@@%
- \else\if#1\ds at queen\advance\help at a\f at ur%
- \else\if#1\ds at king\advance\help at a 5%
- \else\if#1C%
- % An imitator should not count for any color.
- \let\cpd at stepcounterPieces\relax
- \advance\help at a 145%
- \else\if#1E% Equihopper
- \advance\help at a 216%
- \else\if#1X% Equihopper senkrecht
- \advance\help at a 180%
- \else%
- \errmessage{invalid piece!}%
- \fi\fi\fi\fi\fi\fi\fi\fi\fi%
+\def\getpi at ce#1{%
+ \IfStrEqCase{#1}{%
+ {\ds at pawn}{}%
+ {\ds at knight}{\advance\help at a\@ne}%
+ {\ds at bishop}{\advance\help at a\tw@}%
+ {\ds at rook}{\advance\help at a\thr@@}%
+ {\ds at queen}{\advance\help at a\f at ur}%
+ {\ds at king}{\advance\help at a 5}%
+ {C}{%
+ \let\cpd at stepcounterPieces\relax
+ \advance\help at a 145%
+ }%
+ {E}{\advance\help at a 216}%
+ {X}{\advance\help at a 180}%
+ }[\errmessage{invalid piece!}]%
\futurelet\r at tate\chkr at tate%
}
@@ -1581,7 +1572,8 @@
\if\r at tate \ds at rotation@upsidedown\advance\help at a 108\let\nextpr at c=\skipr at t\else%
\if\r at tate \ds at rotation@left\advance\help at a 36\let\nextpr at c=\skipr at t\else%
\if\r at tate \ds at rotation@right\advance\help at a 72\let\nextpr at c=\skipr at t\else%
- \let\nextpr at c\piece at job\fi\fi\fi\nextpr at c%
+ \let\nextpr at c\piece at job\fi\fi\fi%
+ \nextpr at c%
}
\def\skipr at t#1{\piece at job}
\def\l@@k{\futurelet\whatsnext\parsefi at lds}
@@ -1595,7 +1587,7 @@
}
\def\set at current@square at index#1#2{%
- \setcounter{cpd at current@square at index}{#1+\value{cpd at linesmax}*#2}%
+ \setcounter{cpd at current@square at index}{#1+\value{cpd at lines}*#2}%
}
\def\set at current@square at value#1{%
\expandafter%
@@ -1605,34 +1597,25 @@
\setcounter{cpd at current@square at value}%
{\csname cpd at square@\roman{cpd at current@square at index}\endcsname}%
}
-\def\set at piece{%
- \ifnum\pl at ne=\current at plane%
+\def\@cpd at setpiece{%
+ \ifthenelse{\value{cpd at plane}=\value{cpd at current@plane}}{%
\cpd at stepcounterPieces%
- \set at current@square at index\lin@\r at w%
- \get at current@square at value%
- \ifthenelse{\value{cpd at current@square at value}=\m at ne}
- {\set at current@square at value{\the\help at a}}%
- {\ifthenelse{\value{cpd at current@square at value}=144}%
- {\set at current@square at value{\the\help at a+18}}%
- {\errmessage{Trying to set a piece to an occupied square}}}%
- \fi%
- \l@@k%
-}
-\def\cpd at fen@setpiece{%
- \ifnum\pl at ne=\current at plane%
- \cpd at stepcounterPieces%
\set at current@square at index{\value{cpd at line}}{\value{cpd at row}}%
\get at current@square at value%
- \ifthenelse{\value{cpd at current@square at value}=\m at ne}
+ \ifthenelse{\value{cpd at current@square at value}=\m at ne}%
{\set at current@square at value{\the\help at a}}%
{\ifthenelse{\value{cpd at current@square at value}=144}%
{\set at current@square at value{\the\help at a+18}}%
- {\errmessage{Trying to set a piece to an occupied square}}}%
- \fi%
+ {\errmessage{Trying to set a piece to an occupied square.}}}%
+ }{}%
}
+\def\set at piece{%
+ \@cpd at setpiece%
+ \l@@k%
+}
\def\set at nofield, {%
- \ifnum\pl at ne=\current at plane%
- \set at current@square at index\lin@\r at w%
+ \ifthenelse{\value{cpd at plane}=\value{cpd at current@plane}}{%
+ \set at current@square at index{\value{cpd at line}}{\value{cpd at row}}%
\get at current@square at value%
\ifthenelse{\value{cpd at current@square at value}=\m at ne}%
{}% This is an empty white square, nothing to do
@@ -1639,19 +1622,20 @@
{\ifthenelse{\value{cpd at current@square at value}=144}%
{\set at current@square at value{\m at ne}}%
{\errmessage{Trying to set a piece to an occupied square}}}%
- \fi%
- \l@@klist%
+ }{}%
+ \l@@klist%
}
\def\set at frame, {%
- \ifnum\pl at ne=\current at plane%
- \@vGrid{\the\lin@}{\the\r at w}\@ne%
- \@hGrid{\the\lin@}{\the\r at w}\@ne%
- \advance\lin@\@ne%
- \@vGrid{\the\lin@}{\the\r at w}\@ne%
- \advance\lin@\m at ne\advance\r at w\@ne%
- \@hGrid{\the\lin@}{\the\r at w}\@ne%
- \fi%
- \l@@klist%
+ \ifthenelse{\value{cpd at plane}=\value{cpd at current@plane}}{%
+ \@vGrid{\value{cpd at line}}{\value{cpd at row}}\@ne%
+ \@hGrid{\value{cpd at line}}{\value{cpd at row}}\@ne%
+ \addtocounter{cpd at line}{1}%
+ \@vGrid{\value{cpd at line}}{\value{cpd at row}}\@ne%
+ \addtocounter{cpd at line}{-1}%
+ \addtocounter{cpd at row}{1}%
+ \@hGrid{\value{cpd at line}}{\value{cpd at row}}\@ne%
+ }{}%
+ \l@@klist%
}
\def\e at list{\relax}
\def\l@@klist{\futurelet\nextlist\ch at cklst}
@@ -1671,93 +1655,46 @@
\addtocounter{cpd at row}{\m at ne}%
}%
{%
- \errmessage{FEN: there is now row to end here}%
+ \errmessage{FEN: there is now row to end here.}%
}%
- \else\ifx#1K\relax%
+ \fi% FEN space issue
+ \IfSubStr{12345678}{#1}{%
+ \addtocounter{cpd at line}{#1}%
+ }{}%
+ \IfSubStr{KQRBNP}{#1}{%
\let\cpd at stepcounterPieces\cpd at stepcounterWhite%
- \help at a=5%
- \cpd at fen@setpiece%
+ \IfStrEqCase{#1}{%
+ {K}{\help at a=5}%
+ {Q}{\help at a=4}%
+ {R}{\help at a=3}%
+ {B}{\help at a=2}%
+ {N}{\help at a=1}%
+ {P}{\help at a=0}%
+ }
+ \@cpd at setpiece%
\addtocounter{cpd at line}{\@ne}%
- \else\ifx#1Q\relax%
- \let\cpd at stepcounterPieces\cpd at stepcounterWhite%
- \help at a=4%
- \cpd at fen@setpiece%
- \addtocounter{cpd at line}{\@ne}%
- \else\ifx#1R\relax%
- \let\cpd at stepcounterPieces\cpd at stepcounterWhite%
- \help at a=3%
- \cpd at fen@setpiece%
- \addtocounter{cpd at line}{\@ne}%
- \else\ifx#1B\relax%
- \let\cpd at stepcounterPieces\cpd at stepcounterWhite%
- \help at a=2%
- \cpd at fen@setpiece%
- \addtocounter{cpd at line}{\@ne}%
- \else\ifx#1N\relax%
- \let\cpd at stepcounterPieces\cpd at stepcounterWhite%
- \help at a=1%
- \cpd at fen@setpiece%
- \addtocounter{cpd at line}{\@ne}%
- \else\ifx#1P\relax%
- \let\cpd at stepcounterPieces\cpd at stepcounterWhite%
- \help at a=0%
- \cpd at fen@setpiece%
- \addtocounter{cpd at line}{\@ne}%
- \else\ifx#1k\relax%
+ }{}%
+ \IfSubStr{kqrbnp}{#1}{%
\let\cpd at stepcounterPieces\cpd at stepcounterBlack%
- \help at a=17%
- \cpd at fen@setpiece%
+ \IfStrEqCase{#1}{%
+ {k}{\help at a=17}%
+ {q}{\help at a=16}%
+ {r}{\help at a=15}%
+ {b}{\help at a=14}%
+ {n}{\help at a=13}%
+ {p}{\help at a=12}%
+ }
+ \@cpd at setpiece%
\addtocounter{cpd at line}{\@ne}%
- \else\ifx#1q\relax%
- \let\cpd at stepcounterPieces\cpd at stepcounterBlack%
- \help at a=16%
- \cpd at fen@setpiece%
- \addtocounter{cpd at line}{\@ne}%
- \else\ifx#1r\relax%
- \let\cpd at stepcounterPieces\cpd at stepcounterBlack%
- \help at a=15%
- \cpd at fen@setpiece%
- \addtocounter{cpd at line}{\@ne}%
- \else\ifx#1b\relax%
- \let\cpd at stepcounterPieces\cpd at stepcounterBlack%
- \help at a=14%
- \cpd at fen@setpiece%
- \addtocounter{cpd at line}{\@ne}%
- \else\ifx#1n\relax%
- \let\cpd at stepcounterPieces\cpd at stepcounterBlack%
- \help at a=13%
- \cpd at fen@setpiece%
- \addtocounter{cpd at line}{\@ne}%
- \else\ifx#1p\relax%
- \let\cpd at stepcounterPieces\cpd at stepcounterBlack%
- \help at a=12%
- \cpd at fen@setpiece%
- \addtocounter{cpd at line}{\@ne}%
- \else\ifx1#1\relax%
- \addtocounter{cpd at line}{1}%
- \else\ifx2#1\relax%
- \addtocounter{cpd at line}{2}%
- \else\ifx3#1\relax%
- \addtocounter{cpd at line}{3}%
- \else\ifx4#1\relax%
- \addtocounter{cpd at line}{4}%
- \else\ifx5#1\relax%
- \addtocounter{cpd at line}{5}%
- \else\ifx6#1\relax%
- \addtocounter{cpd at line}{6}%
- \else\ifx7#1\relax%
- \addtocounter{cpd at line}{7}%
- \else\ifx8#1\relax%
- \addtocounter{cpd at line}{8}%
- \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
+ }{}%
}
\def\@cpd at parse@fen#1{\@cpd at handle@fen#1\l@@klist}
\def\p at rsepieces#1, {\getc at lor#1\e at list\l@@klist}
\def\p at rsetext#1, {\get at text#1\e at list\l@@klist}
\def\set at text{%
- \ifnum\pl at ne=\current at plane%
- \raise\r at w\sq at width\hbox to \z@{%
- \hskip\lin@\sq at width%
+ \ifthenelse{\value{cpd at plane}=\value{cpd at current@plane}}{%
+ \raise\value{cpd at row}\sq at width\hbox to \z@{%
+ \hskip\value{cpd at line}\sq at width%
\vbox to \sq at width{\vss%
\hbox to \sq at width{%
\hss%
@@ -1766,13 +1703,13 @@
}\vss}%
\hss%
}%
- \fi%
- \l@@klist%
+ }{}%
+ \l@@klist%
}
\def\p at rseauthor#1; {\sh at wauthor#1;\l@@klist}
\def\read at square#1#2{%
- \lin@=`#1\advance\lin@ by -`a\relax%
- \r at w=#2\advance\r at w by \m at ne%
+ \setcounter{cpd at line}{`#1-`a}%
+ \setcounter{cpd at row}{#2-1}%
\read at plane%
}
\def\read at plane@normal{\plane at job}
@@ -1781,19 +1718,28 @@
\def\get at plane@stereo{%
\if\plane at char A%
- \pl at ne=\@ne\advance\r at w-\tw@\advance\lin at -\tw@%
+ \setcounter{cpd at plane}{1}%
+ \addtocounter{cpd at row}{-2}%
+ \addtocounter{cpd at line}{-2}%
\let\@plane at job=\skip at plane%
\else\if\plane at char B%
- \pl at ne=\tw@\advance\r at w-\tw@\advance\lin at -\tw@%
+ \setcounter{cpd at plane}{2}%
+ \addtocounter{cpd at row}{-2}%
+ \addtocounter{cpd at line}{-2}%
\let\@plane at job=\skip at plane%
\else\if\plane at char C%
- \pl at ne=\thr@@\advance\r at w-\tw@\advance\lin at -\tw@%
+ \setcounter{cpd at plane}{3}%
+ \addtocounter{cpd at row}{-2}%
+ \addtocounter{cpd at line}{-2}%
\let\@plane at job=\skip at plane%
\else\if\plane at char D%
- \pl at ne=\f at ur\advance\r at w-\tw@\advance\lin at -\tw@%
+ \setcounter{cpd at plane}{4}%
+ \addtocounter{cpd at row}{-2}%
+ \addtocounter{cpd at line}{-2}%
\let\@plane at job=\skip at plane%
\else%
- \pl at ne=\z@\let\@plane at job=\plane at job%
+ \setcounter{cpd at plane}{0}%
+ \let\@plane at job=\plane at job%
\fi\fi\fi\fi%
\@plane at job%
}
@@ -1800,7 +1746,10 @@
\def\skip at plane#1{\plane at job}
-\def\read at plane@space#1{\pl at ne=`#1\advance\pl at ne by -`A\relax\plane at job}
+\def\read at plane@space#1{%
+ \setcounter{cpd at plane}{`#1-`A}%
+ \plane at job%
+}
\def\@vGrid#1#2#3{%
\raise#2\sq at width\hbox to \z@{%
\hskip#1\sq at width\hskip-.5\grid at width%
@@ -1816,7 +1765,7 @@
}%
}
\def\@selGrid#1#2, {%
- \ifnum\pl at ne=\current at plane%
+ \ifthenelse{\value{cpd at plane}=\value{cpd at current@plane}}{%
\if#1h%
\@hGrid#2%
\else\if#1v%
@@ -1824,23 +1773,21 @@
\else%
\errmessage{Wrong GridSelector #1}%
\fi\fi%
- \fi%
- \l@@klist%
+ }{}%
+ \l@@klist%
}
\def\@stdgrid{%
\setbox\plane at box=\vbox{\hbox{%
\help at a=\tw@%
- \loop%
- \ifnum\help at a<\lines at max%
- \@vGrid{\the\help at a}{0}{\the\rows at max}%
+ \whiledo{\help at a<\value{cpd at lines}}{%
+ \@vGrid{\the\help at a}{0}{\value{cpd at rows}}%
\advance\help at a\tw@%
- \repeat%
+ }%
\help at a=\tw@%
- \loop%
- \ifnum\help at a<\rows at max%
- \@hGrid{0}{\the\help at a}{\the\lines at max}%
+ \whiledo{\help at a<\value{cpd at rows}}{%
+ \@hGrid{0}{\the\help at a}{\value{cpd at lines}}%
\advance\help at a\tw@%
- \repeat%
+ }%
\box\plane at box
}}%
}
@@ -1863,7 +1810,7 @@
\setcounter{cpd at whitePieces}{\z@}%
\setcounter{cpd at blackPieces}{\z@}%
\setcounter{cpd at neutralPieces}{\z@}%
- \lin@\z@
+ \setcounter{cpd at line}{0}%
}
\def\clear at board{%
@@ -1872,52 +1819,60 @@
{\@whitefield=\m at ne\@blackfield=144}%
\ifthenelse{\boolean{allwhite}}{\@blackfield=\m at ne}{}%
\ifthenelse{\boolean{switchcolors}}{\@whitefield=144\@blackfield=\m at ne}{}%
- \setcounter{cpd at current@row}{0}%
- \whiledo{\value{cpd at current@row}<\value{cpd at rowsmax}}{%
- \setcounter{cpd at current@line}{0}%
- \whiledo{\value{cpd at current@line}<\value{cpd at linesmax}}{%
- \set at current@square at index{\value{cpd at current@line}}{\value{cpd at current@row}}%
- \setcounter{cpd at helper}{\the\current at plane+\value{cpd at current@line}+\value{cpd at current@row}}%
+ \setcounter{cpd at row}{0}%
+ \whiledo{\value{cpd at row}<\value{cpd at rows}}{%
+ \setcounter{cpd at line}{0}%
+ \whiledo{\value{cpd at line}<\value{cpd at lines}}{%
+ \set at current@square at index{\value{cpd at line}}{\value{cpd at row}}%
+ \setcounter{cpd at helper}{%
+ \value{cpd at current@plane}%
+ +\value{cpd at line}%
+ +\value{cpd at row}}%
\ifthenelse{\isodd{\value{cpd at helper}}}%
{\set at current@square at value{\@whitefield}}%
{\set at current@square at value{\@blackfield}}%
- \addtocounter{cpd at current@line}{\@ne}%
+ \addtocounter{cpd at line}{\@ne}%
}%
- \addtocounter{cpd at current@row}{\@ne}%
+ \addtocounter{cpd at row}{\@ne}%
}%
}
\def\put at row#1{%
- \lin@\z@%
- \help at b=#1%
- \advance\help at b\brd at ff%
+ \setcounter{cpd at row}{#1}%
+ \setcounter{cpd at row@display}{#1 + 1}%
+ \setcounter{cpd at line}{0}%
\hbox{%
\ifthenelse{\boolean{legend}}{{%
- \advance\@rows`1%
- \llap{\raise .25\sq at width\hbox{\legendfont \char\@rows\ \ }}%
+ \llap{\raise .1\sq at width\hbox{\legendfont\arabic{cpd at row@display}\ \ }}%
}}{}%
\if at stereo%
- \ifnum\current at plane>\z@%
- \ifnum\@rows=12%
- \llap{\raise .5\sq at width\hbox{\cpd at boardfont c6\ }}%
- \fi%
- \fi%
+ \ifthenelse{\value{cpd at current@plane}>0}{%
+ \ifthenelse{\value{cpd at row} = 3}{%
+ \llap{\cpd at boardfont c6\ }%
+ }{}%
+ % \fi%
+ }{}%
+ % \fi%
\fi%
- \hbox to \z@{\vbox to \sq at width{}}%
- \set at current@square at index{\lin@}{#1}%
- \loop%
- \get at current@square at value%
- \ifthenelse{\value{cpd at current@square at value}=\m at ne}%
- {\wF}%
- {\char\value{cpd at current@square at value}}%
- % \ifnum\count\help at b=\m at ne\wF%
- % \else\char\count\help at b\fi%
- \advance\lin@\@ne%
- \addtocounter{cpd at current@square at index}{1}%
- % \advance\help at b\@ne%
- \ifnum\lin@<\lines at max\repeat%
+ % \hbox to \z@{\vbox to \sq at width{}}%
+ \set at current@square at index{\value{cpd at line}}{#1}%
+ \begin{tikzpicture}[x=\sq at width,y=\sq at width]%
+ \useasboundingbox (0, 0) rectangle (\value{cpd at lines}, 1);%
+ \whiledo{\value{cpd at line} < \value{cpd at lines}}{%
+ \get at current@square at value%
+ \ifthenelse{\value{cpd at current@square at value}=\m at ne}%
+ {}%
+ {%
+ \draw (\value{cpd at line}+.5, .5)%
+ node {{\chessfont\char\value{cpd at current@square at value}}};%
+ }%
+ \addtocounter{cpd at line}{1}%
+ \addtocounter{cpd at current@square at index}{1}%
+ }%
+ \end{tikzpicture}%
}%
}
+\def\cpd at fen@parseTokenlist#1{\expandafter\l@@klist\the#1\e at list}
\def\@parseTokenlist#1#2{\expandafter\l@@klist\the#1#2 \e at list}
\def\@addToPlane#1{%
\setbox\plane at box=\vbox{\hbox{%
@@ -1926,97 +1881,110 @@
}}%
}
\def\put at plane{%
- % We might want gridchess
- \if at stdgrid%
+ % We might want gridchess
+ \if at stdgrid%
\@stdgrid%
- \fi%
- % Let us first set the fieldframes
- \if at fieldframe%
- \let\@action\read at square%
- \let\plane at job\set at frame%
- \@addToPlane\fieldframe at tk%
- \fi%
- % Now we set text to all squares which are given using \fieldtext
- \if at fieldtext%
- \let\@action\p at rsetext%
- \let\plane at job\set at text%
- \@addToPlane\fieldtext at tk%
- \fi%
- % Then we should add the gridlines
- \if at gridlines%
- \let\@action\read at plane%
- \let\plane at job\@selGrid%
- \@addToPlane\gridlines at tk%
- \else%
- \if at stereo%
- \stereo at center%
- \fi%
- \fi%
- % In an 'allwhite' diagram we display dotted lines
- \ifthenelse{\boolean{allwhite}}{%
- \setbox\plane at box=\vbox{\hbox{%
- \psset{unit=\sq at width,linewidth=.4pt,linestyle=dotted,dotsep=.125}%
- \setcounter{field at border}{1}%
- \whiledo{\value{field at border}<\lines at max}{%
- \psline(\value{field at border},0)(\value{field at border},\rows at max)%
- \addtocounter{field at border}{\@ne}%
+ \fi%
+ % Let us first set the fieldframes
+ \if at fieldframe%
+ \let\@action\read at square%
+ \let\plane at job\set at frame%
+ \@addToPlane\fieldframe at tk%
+ \fi%
+ % Now we set text to all squares which are given using \fieldtext
+ \if at fieldtext%
+ \let\@action\p at rsetext%
+ \let\plane at job\set at text%
+ \@addToPlane\fieldtext at tk%
+ \fi%
+ % Then we should add the gridlines
+ \if at gridlines%
+ \let\@action\read at plane%
+ \let\plane at job\@selGrid%
+ \@addToPlane\gridlines at tk%
+ \else%
+ \if at stereo%
+ \stereo at center%
+ \fi%
+ \fi%
+ % In an 'allwhite' diagram we display dotted lines
+ \ifthenelse{\boolean{allwhite}}{%
+ \setbox\plane at box=\vbox{\hbox{%
+ \begin{tikzpicture}[x=\sq at width,y=\sq at width]%
+ \useasboundingbox
+ (0, 0) rectangle (\value{cpd at lines}, \value{cpd at rows});
+ \setcounter{field at border}{1}%
+ \whiledo{\value{field at border}<\value{cpd at lines}}{%
+ \draw[densely dotted]
+ (\value{field at border},0)
+ --
+ (\value{field at border},\value{cpd at rows});
+ \addtocounter{field at border}{\@ne}%
+ }%
+ \setcounter{field at border}{1}%
+ \whiledo{\value{field at border}<\value{cpd at rows}}{%
+ \draw[densely dotted]
+ (0, \value{field at border})
+ --
+ (\value{cpd at lines}, \value{field at border});
+ \addtocounter{field at border}{\@ne}%
+ }%
+ \end{tikzpicture}%
+ \box\plane at box%
+ }}%
+ }{}%
+ % Now we should clear the board
+ \clear at board%
+ % Let us now parse the list of pieces
+ \ifthenelse{\boolean{@cpd at fen}}{%
+ \ifthenelse{\value{cpd at rows}=8}{}{\errmessage{FEN is only allowed for 8x8 boards.}}% FEN space issue
+ \ifthenelse{\value{cpd at lines}=8}{}{\errmessage{FEN is only allowed for 8x8 boards.}}% FEN space issue
+ \setcounter{cpd at row}{7}%
+ \setcounter{cpd at line}{0}%
+ \let\@action\@cpd at parse@fen%
+ \cpd at fen@parseTokenlist\fen at tk\e at list% FEN space issue
+ }{}%
+ \if at pieces%
+ \let\@action\p at rsepieces%
+ \let\piece at job\l@@k\let\plane at job\set at piece%
+ \@parseTokenlist\pieces at tk,%
+ \fi%
+ % Now we clear all fields, which are given using \nofields
+ \if at nofields%
+ \let\@action\read at square%
+ \let\plane at job\set at nofield%
+ \@parseTokenlist\nofields at tk,%
+ \fi%
+ % Now we can put the pieces to the board
+ \global\setbox\plane at box=\hbox{%
+ \vbox{\rlap{\box\plane at box}}%
+ \vbox{%
+ \chessfont%
+ \baselineskip=\z@\lineskip=\z@%
+ \setcounter{cpd at row}{\value{cpd at rows} - 1}%
+ \whiledo{\value{cpd at row} > -1}{%
+ \put at row{\value{cpd at row}}%
+ \addtocounter{cpd at row}{-1}%
}%
- \setcounter{field at border}{1}%
- \whiledo{\value{field at border}<\rows at max}{%
- \psline(0,\value{field at border})(\lines at max,\value{field at border})%
- \addtocounter{field at border}{\@ne}%
- }%
- \box\plane at box%
- }}%
- }{}%
- % Now we should clear the board
- \clear at board%
- % Let us now parse the list of pieces
- \ifthenelse{\boolean{@cpd at fen}}{%
- \ifthenelse{\value{cpd at rowsmax}=8}{}{\errmessage{FEN is only allowed for 8x8 boards.}}
- \ifthenelse{\value{cpd at linesmax}=8}{}{\errmessage{FEN is only allowed for 8x8 boards.}}
- \setcounter{cpd at row}{7}%
- \setcounter{cpd at line}{0}%
- \let\@action\@cpd at parse@fen%
- \@parseTokenlist\fen at tk\e at list%
- }{}%
- \if at pieces%
- \let\@action\p at rsepieces%
- \let\piece at job\l@@k\let\plane at job\set at piece%
- \@parseTokenlist\pieces at tk,%
- \fi%
- % Now we clear all fields, which are given using \nofields
- \if at nofields%
- \let\@action\read at square%
- \let\plane at job\set at nofield%
- \@parseTokenlist\nofields at tk,%
- \fi%
- % Now we can put the pieces to the board
- \global\setbox\plane at box=\hbox{%
- \vbox{\rlap{\box\plane at box}}%
- \vbox{%
- \chessfont%
- \baselineskip=\z@\lineskip=\z@%
- \@rows=\rows at max%
- % \multiply\@rows by \lines at max%
- \loop%
- \advance\@rows \m at ne%
- \put at row\@rows%
- \ifnum\@rows>\z@\repeat%
- }%
- % Put a legend if wanted
- \ifthenelse{\boolean{legend}}{%
- \vbox to \z@{%
- \vbox to \z@{\vss}%
- \llap{\hbox{\hspace*{\inner at frame}%
- \lin@\z@%
- \loop%
- \hbox to \sq at width{\hfill{\advance\lin@`a\legendfont\char\lin@}\hfill}%
- \advance\lin@\@ne%
- \ifnum\lin@<\lines at max\repeat%
- }}\vss}%
- }{}%
- }%
+ }%
+ % Put a legend if wanted
+ \ifthenelse{\boolean{legend}}{%
+ \vbox to \z@{%
+ \vbox to \z@{\vss}%
+ \llap{\hbox{\hspace*{\inner at frame}%
+ \setcounter{cpd at line}{0}%
+ \setcounter{cpd at line@display}{`a}%
+ \whiledo{\value{cpd at line}<\value{cpd at lines}}{%
+ \hbox to \sq at width{\hfill%
+ {\legendfont\char\value{cpd at line@display}}%
+ \hfill}%
+ \addtocounter{cpd at line}{1}%
+ \addtocounter{cpd at line@display}{1}%
+ }
+ }}%
+ \vss}%
+ }{}%
+ }%
}
\def\put at sqs@normal{%
\put at plane%
@@ -2026,17 +1994,16 @@
}
\def\put at sqs@stereo{%
\setbox\sq at box=\hbox{\hfil\vbox{%
- \current at plane=5%
\vskip\v at space@dist%
- \loop%
- \advance\current at plane\m at ne%
- \ifnum\current at plane=\z@%
- \lines at max=\@ight%
- \rows at max=\@ight%
- \else%
- \lines at max=\f at ur%
- \rows at max=\f at ur%
- \fi%
+ \setcounter{cpd at current@plane}{4}%
+ \whiledo{\value{cpd at current@plane}>-1}{%
+ \ifthenelse{\value{cpd at current@plane}=0}{%
+ \setcounter{cpd at lines}{8}%
+ \setcounter{cpd at rows}{8}%
+ }{%
+ \setcounter{cpd at lines}{4}%
+ \setcounter{cpd at rows}{4}%
+ }%
% Now we should clear the board
\begingroup% We need this for inner loops!
\clear at board%
@@ -2045,7 +2012,7 @@
\hbox to \bd at width{%
\hfil%
\inner at henbox{\box\plane at box}%
- \ifcase\current at plane\or%
+ \ifcase\value{cpd at current@plane}\or%
\rlap{{\cpd at boardfont\ A}}\or%
\rlap{{\cpd at boardfont\ B}}\or%
\rlap{{\cpd at boardfont\ C}}\or%
@@ -2054,45 +2021,45 @@
\hfil%
}%
\vskip\v at space@dist%
- \ifnum\z@<\current at plane\repeat%
+ \addtocounter{cpd at current@plane}{-1}%
+ }%
}\hfil}%
}
\def\stereo at center{%
- \ifnum\current at plane=\z@%
+ \ifthenelse{\value{cpd at current@plane}=0}{%
\setbox\plane at box=\vbox{\hbox{%
\@hGrid\tw@\tw@\f at ur\@hGrid\tw@ 6\f at ur%
\@vGrid\tw@\tw@\f at ur\@vGrid6\tw@\f at ur%
\box\plane at box%
}}%
- \fi%
+ }{}%
}
\def\put at sqs@space at vertical{%
- \setbox\sq at box=\hbox{\hfil\vbox{%
- \current at plane=\planes at max%
- \vskip\v at space@dist%
- \loop%
- \advance\current at plane\m at ne%
- % Now we should clear the board
- \begingroup% We use inner loops!
- \clear at board%
- \put at plane%
- \hbox to \bd at width{%
- \inner at henbox{\box\plane at box}%
- \advance\current at plane`A%
- \rlap{{\cpd at boardfont\ \char\current at plane}}%
- }%
- \endgroup%
- \vskip\v at space@dist%
- \ifnum\z@<\current at plane\repeat%
- }\hfil}%
+ \setbox\sq at box=\hbox{\hfil\vbox{%
+ \setcounter{cpd at current@plane}{\value{cpd at planes}-1}%
+ \vskip\v at space@dist%
+ \whiledo{\value{cpd at current@plane}>-1}{%
+ \begingroup% We use inner loops!
+ \clear at board%
+ \put at plane%
+ \hbox to \bd at width{%
+ \inner at henbox{\box\plane at box}%
+ \setcounter{cpd at current@plane at display}{`A+\value{cpd at current@plane}}%
+ \rlap{{\cpd at boardfont\ \char\value{cpd at current@plane at display}}}%
+ }%
+ \endgroup%
+ \vskip\v at space@dist%
+ \addtocounter{cpd at current@plane}{-1}%
+ }%
+ }\hfil}%
}
\def\put at sqs@space at horizontal{%
\setbox\sq at box=\hbox{%
- \current at plane=\z@%
+ \setcounter{cpd at current@plane}{0}%
\hskip\h at space@dist%
- \loop%
+ \whiledo{\value{cpd at current@plane}<\value{cpd at planes}}{%
% Now we should clear the board
\begingroup% We use inner loops!
\clear at board%
@@ -2099,14 +2066,13 @@
\put at plane%
\hbox to \bd at width{%
\inner at henbox{\box\plane at box}%
- \advance\current at plane`A%
- \rlap{{\cpd at boardfont\ \char\current at plane}}%
+ \setcounter{cpd at current@plane at display}{`A+\value{cpd at current@plane}}%
+ \rlap{{\cpd at boardfont\ \char\value{cpd at current@plane at display}}}%
}%
\endgroup%
\hskip\h at space@dist%
- \advance\current at plane\@ne%
- \ifnum\planes at max>\current at plane%
- \repeat%
+ \addtocounter{cpd at current@plane}{1}%
+ }%
}%
}
@@ -2281,71 +2247,34 @@
\def\@setPieceRotation#1#2#3{%
\gdef\ds at rotation@left{#1}\gdef\ds at rotation@right{#2}\gdef\ds at rotation@upsidedown{#3}%
}
-\def\loop at rotation{%
- \bgroup%
- \n at cnt\z@%
- \help at a\z@%
- \loop%
- \ifcase\n at cnt%
- \def\@theRotation{}%
- \or%
- \def\@theRotation{\ds at rotation@left}%
- \or%
- \def\@theRotation{\ds at rotation@right}%
- \or%
- \def\@theRotation{\ds at rotation@upsidedown}%
- \fi%
- \loop at color%
- \advance\n at cnt\@ne%
- \advance\help at a by 36\relax%
- \ifnum\n at cnt<\f at ur\repeat%
- \egroup%
+\newcommand{\cpd at piecedef@rotations}{%
+ \def\@theRotation{}\cpd at piecedef@colors{0}%
+ \def\@theRotation{\ds at rotation@left}\cpd at piecedef@colors{36}%
+ \def\@theRotation{\ds at rotation@right}\cpd at piecedef@colors{72}%
+ \def\@theRotation{\ds at rotation@upsidedown}\cpd at piecedef@colors{108}%
}
-
-\def\loop at color{%
- \bgroup%
- \w at cnt\z@%
- \loop%
- \ifcase\w at cnt%
- \def\@theColor{\ds at white}%
- \or%
- \def\@theColor{\ds at neutral}%
- \or%
- \def\@theColor{\ds at black}%
- \fi%
- \loop at piece%
- \advance\w at cnt\@ne%
- \advance\help at a by 6%
- \ifnum\w at cnt<\thr@@\repeat%
- \egroup%
+\newcommand{\cpd at piecedef@colors}[1]{%
+ \def\@theColor{\ds at white}\cpd at piecedef@types{#1}{0}%
+ \def\@theColor{\ds at neutral}\cpd at piecedef@types{#1}{6}%
+ \def\@theColor{\ds at black}\cpd at piecedef@types{#1}{12}%
}
+\newcommand{\cpd at piecedef@types}[2]{%
+ \def\@thePiece{\ds at pawn}\cpd at piecedef{#1}{#2}{0}%
+ \def\@thePiece{\ds at knight}\cpd at piecedef{#1}{#2}{1}%
+ \def\@thePiece{\ds at bishop}\cpd at piecedef{#1}{#2}{2}%
+ \def\@thePiece{\ds at rook}\cpd at piecedef{#1}{#2}{3}%
+ \def\@thePiece{\ds at queen}\cpd at piecedef{#1}{#2}{4}%
+ \def\@thePiece{\ds at king}\cpd at piecedef{#1}{#2}{5}%
+}
+\newcommand{\cpd at piecedef}[3]{%
+ \setcounter{cpd at piece@index}{#1+#2+#3}%
+ \edef\cpd at piecedef@index{\arabic{cpd at piece@index}}%
+ \expandafter\xdef%
+ \csname\@theColor\@thePiece\@theRotation\endcsname{%
+ \ch at fig{\cpd at piecedef@index}%
+ }
+}
-\def\loop at piece{%
- \bgroup%
- \b at cnt\z@%
- \loop%
- \ifcase\b at cnt%
- \def\@thePiece{\ds at pawn}%
- \or%
- \def\@thePiece{\ds at knight}%
- \or%
- \def\@thePiece{\ds at bishop}%
- \or%
- \def\@thePiece{\ds at rook}%
- \or%
- \def\@thePiece{\ds at queen}%
- \or%
- \def\@thePiece{\ds at king}%
- \fi%
- \expandafter\xdef\csname%
- \@theColor\@thePiece\@theRotation\endcsname{%
- \noexpand\ch at fig{\the\help at a}%
- }
- \advance\b at cnt\@ne%
- \advance\help at a by \@ne%
- \ifnum\b at cnt<6\repeat%
- \egroup%
-}
\elchfont\@fselch
\defaultelchfont%
More information about the tex-live-commits
mailing list.