summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/chess-problem-diagrams
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-01-11 22:25:14 +0000
committerKarl Berry <karl@freefriends.org>2015-01-11 22:25:14 +0000
commitffc578485f0573fbef95749a3b239380be42da87 (patch)
tree76c2ef5b80f81151132fb873781039b5e2e3cce1 /Master/texmf-dist/source/latex/chess-problem-diagrams
parented0cfbb5582f3534884edd499c2d7bd38611bd9a (diff)
chess-problem-diagrams (11jan15)
git-svn-id: svn://tug.org/texlive/trunk@36024 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/chess-problem-diagrams')
-rw-r--r--Master/texmf-dist/source/latex/chess-problem-diagrams/diagram.dtx222
1 files changed, 138 insertions, 84 deletions
diff --git a/Master/texmf-dist/source/latex/chess-problem-diagrams/diagram.dtx b/Master/texmf-dist/source/latex/chess-problem-diagrams/diagram.dtx
index 3f359c20add..5ed17ca94da 100644
--- a/Master/texmf-dist/source/latex/chess-problem-diagrams/diagram.dtx
+++ b/Master/texmf-dist/source/latex/chess-problem-diagrams/diagram.dtx
@@ -13,9 +13,9 @@
%%
%%
% \fi
-% \def\fileversion{1.6.5}
-% \def\docdate{2013/06/21}
-% \CheckSum{4220}
+% \def\fileversion{1.9}
+% \def\docdate{2015/1/10}
+% \CheckSum{4281}
% \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
@@ -59,6 +59,12 @@
% \changes{v1.6.3}{12 November 2012}{Added boolean for board with switched field colors.}
% \changes{v1.6.4}{12 November 2012}{Added convenience command for 'allwhite' and 'switchcolors' booleans.}
% \changes{v1.6.5}{21 June 2013}{As suggested by Torsten Lin{\ss} and Thomas Brand added support for Equihopper and turned Equihopper (X)}
+% \changes{v1.6.6}{06 July 2013}{Introduced new command to switch to the default diagram size.}
+% \changes{v1.6.7}{17 August 2013}{Fixed issue '19a' with allwhite on quadratic fields.}
+% \changes{v1.7.0}{17 August 2013}{Implemented Issue '32c': the command diagnum now allows to specify a prefix to be used for the following diagrams.}
+% \changes{v1.8.0}{27 November 2013}{Implemented issue '03f/f2a': Added code to display a legend around the board, controlled by the boolean 'legend'.}
+% \changes{v1.8.1}{17 August 2014}{Implemented issue '03f/83c': changed tex boolean solafterdiagram to latex boolean.}
+% \changes{v1.9}{10 Januar 2015}{Implemented issue '03f/932': Renamed boardfont to cpd@boardfont due to a naming collision with another chess package. Changed all font definitions to newcommand instead of def.}
%
% \DoNotIndex{\@arabic,\def,\@idxitem,\@ifnextchar,\@ifstar,
% \@ne,\@ptsize,\ ,\advance,\AtEndOfPackage,\begin,\begingroup,
@@ -131,6 +137,7 @@
% \hfill
% \begin{diagram}
% \label{BSP2}
+% \setboolean{legend}{true}
% \author{Brand, Thomas}
% \source{Problemkiste} \year{1992}
% \pieces[3+2]{wKa4, wLb5, wSh3, sKb7, sBh4}
@@ -162,6 +169,7 @@
% \hfill
%%
% \begin{diagram}
+% \setboolean{legend}{true}
% \author{Brand, Thomas}
% \source{Problemkiste} \year{1992}
% \pieces[3+2]{wKa4, wLb5, wSh3, sKb7, sBh4}
@@ -435,6 +443,10 @@
% This is a boolean switch, which controls whether academic
% titles |\Dr|, |\Prof| or |\ProfDr| --- typically used within
% the |\author| command --- are displayed. The default is |true|.
+% \item \DescribeMacro{legend}
+% This boolean controls whether a legend is displayed. The default
+% value of this value is |false|. When legends are displayed the
+% distance between inner and outer frame is automatically adjusted.
% \end{itemize}
%
% \DescribeMacro{\notcomputerproofedsymbol}
@@ -475,10 +487,13 @@
% diagram number is displayed when using |\ref| instead of the
% page number.
% \item \DescribeMacro{\diagnum}
-% This macro expects a number as a parameter. The number will be
-% used to (re-)initialize the diagram number counter. With this
-% command the output of diagram numbers also is switched on. It
-% must be used outside the {\ttfamily diagram} environment.
+% This macro expects a number as a parameter. The number will be used to
+% (re-)initialize the diagram number counter. With this command the output of
+% diagram numbers also is switched on. It must be used outside the {\ttfamily
+% diagram} environment. As an optional parameter you may specify something,
+% which will be used as prefix before the automatically updated diagram numbers.
+% E.\,g.\ the command \verb+\diagnum[T-]{4}+ will produce the following diagram numbers for the
+% following diagrams: \textbf{T-4}, \textbf{T-5}, \textbf{T-6}, \dots{}
% \end{itemize}
%
%
@@ -948,10 +963,10 @@
% Specifies the preamble of our style file.
% \begin{macrocode}
%<*style>
-\ProvidesPackage{diagram}[2012/11/18]
-\DeclareOption{10pt}{\AtBeginDocument{\diagramx}}
-\DeclareOption{11pt}{\AtBeginDocument{\diagramxi}}
-\DeclareOption{12pt}{\AtBeginDocument{\diagramxii}}
+\ProvidesPackage{diagram}[2015/01/10]
+\DeclareOption{10pt}{\AtBeginDocument{}}
+\DeclareOption{11pt}{\AtBeginDocument{\renewcommand{\DefaultDiagramSize}{\diagramxi}}}
+\DeclareOption{12pt}{\AtBeginDocument{\renewcommand{\DefaultDiagramSize}{\diagramxii}}}
\ExecuteOptions{10pt}
\ProcessOptions
\RequirePackage{ifthen}
@@ -973,11 +988,13 @@
\newcount\dia@type
-\newif\if@textproblem\@textproblemfalse
-\def\textproblem{\@textproblemtrue\let\@dia@stipulation=\relax}
+\newboolean{@textproblem}
+\setboolean{@textproblem}{false}
+\def\textproblem{\setboolean{@textproblem}{true}\let\@dia@stipulation=\relax}
-\newif\if@solafterdiagram\@solafterdiagramfalse
-\def\solafterdiagram{\@solafterdiagramtrue\ignorespaces}
+\newboolean{@solafterdiagram}
+\setboolean{@solafterdiagram}{false}
+\def\solafterdiagram{\setboolean{@solafterdiagram}{true}\ignorespaces}
\newif\if@vframe\@vframetrue
\newif\if@hframe\@hframetrue
@@ -1004,6 +1021,8 @@
\setboolean{showcity}{false}
\newboolean{showacademictitle}
\setboolean{showacademictitle}{true}
+\newboolean{legend}
+\setboolean{legend}{false}
\newcount\@blackfield
\newboolean{allwhite}
@@ -1345,6 +1364,7 @@
\advance\board@width\tw@\outer@frame%
\fi%
\else%
+ \ifthenelse{\boolean{legend}}{\v@frame@dist=1.5em\h@frame@dist=1.5em}{}%
\bd@width=\lines@max\sq@width%
\ifnum\lines@max>\@ight%
% Make the board wider
@@ -1366,7 +1386,7 @@
%
% Now we should build the diagram itself
%
- \if@textproblem%
+ \ifthenelse{\boolean{@textproblem}}{%
% Put the stipulation into the \sq@box
\setbox\sq@box=\hbox{\vbox to \board@width{\hsize\board@width%
\stipfont%
@@ -1375,7 +1395,7 @@
\the\stipulation@tk%
\vfil%
}}%
- \else%
+ }{%
\put@sqs% This builds up the \sq@box
% Check, if the given number of pieces is reached
\ifthenelse{\boolean{cpd@checkPieceCounts}}{%
@@ -1386,7 +1406,7 @@
\ifthenelse{\value{cpd@defNeutralPieces}=\value{cpd@neutralPieces}}{}%
{\errmessage{Wrong number of neutral pieces}}%
}{}%
- \fi%
+ }%
%
\global\setbox\dia@box=\hbox{\vbox{%
\parindent\z@%
@@ -1409,11 +1429,11 @@
\vtop{\hsize\board@width%
\hbox to \head@width{\hss\vbox{%
\hsize\board@width%
- \if@textproblem%
+ \ifthenelse{\boolean{@textproblem}}{%
\box\sq@box%
- \else%
+ }{%
\outer@henbox{\box\sq@box}%
- \fi%
+ }%
}\hss}%
% diagram trailer
\hbox to \head@width{\hss\vtop{%
@@ -1429,6 +1449,11 @@
\endgroup%
}
+\def\do@put@count{%
+ \ \ (\arabic{cpd@whitePieces}+\arabic{cpd@blackPieces}%
+ \ifthenelse{\value{cpd@neutralPieces}>0}{+\arabic{cpd@neutralPieces}}{})%
+}
+
\def\put@count{%
% First we build the box with the figure count
\ifthenelse{\boolean{showcomputer}\OR\boolean{piececounter}}{%
@@ -1438,8 +1463,7 @@
\ \ \if@computer\computerproofedsymbol\else\notcomputerproofedsymbol\fi%
}{}%
\ifthenelse{\boolean{piececounter}}{%
- \ \ (\arabic{cpd@whitePieces}+\arabic{cpd@blackPieces}%
- \ifthenelse{\value{cpd@neutralPieces}>0}{+\arabic{cpd@neutralPieces}}{})%
+ \do@put@count%
}{}%
}%
\@cnt@wd=\wd\@cnt@box%
@@ -1509,7 +1533,8 @@
% \begin{macro}{\stipfont}
% \begin{macro}{\remfont}
% \begin{macro}{\labelfont}
-% \begin{macro}{\boardfont}
+% \begin{macro}{\cpd@boardfont}
+% \begin{macro}{\legendfont}
% \begin{macrocode}
\newcommand*{\authorfont}{\bfseries}
\newcommand*{\cityfont}{\slshape}
@@ -1519,7 +1544,8 @@
\newcommand*{\stipfont}{\rmfamily}
\newcommand*{\remfont}{\rmfamily}
\newcommand*{\labelfont}{\rmfamily}
-\newcommand*{\boardfont}{\rmfamily}
+\newcommand*{\cpd@boardfont}{\rmfamily}
+\newcommand*{\legendfont}{\sffamily}
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -1530,6 +1556,7 @@
% \end{macro}
% \end{macro}
% \end{macro}
+% \end{macro}
%
% We have three different default sizes for diagrams.
% The following commands switch fontsizes used for the chessfonts
@@ -1578,6 +1605,15 @@
% \end{macro}
% \end{macro}
%
+% To switch to the default diagram size we have the following command. This
+% macro is executed in \verb+\begin{document}+ and is redefined when using
+% document options \verb+11pt+ or \verb+12pt+.
+% \begin{macro}{\DefaultDiagramSize}
+% \begin{macrocode}
+\newcommand{\DefaultDiagramSize}{\diagramx}
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\defaultelchfont}
% |\defaultelchfont| is used to define the fontsize used to
% typeset the diagrams depending on the documentsize.
@@ -1595,7 +1631,10 @@
% \begin{macrocode}
\def\dianamestyle#1{\def\@dianame{\csname @#1\endcsname}}
\def\solnamestyle#1{\def\@solname{\csname @#1\endcsname}}
-\def\diagnum#1{\c@board@nr=#1\advance\c@board@nr\m@ne}
+\newcommand*{\diagnum}[2][]{%
+ \renewcommand*{\@dianumber@prefix}{#1}%
+ \setcounter{board@nr}{#2}%
+ \addtocounter{board@nr}{\m@ne}}
% \end{macrocode}
%
% \begin{macro}{\ra}
@@ -1634,9 +1673,10 @@
% \begin{macrocode}
\def\spacelayout#1{\csname space@#1\endcsname}
\def\nodiagnumbering{\global\di@nofalse}
+\newcommand*{\@dianumber@prefix}{}
\def\diagnumbering#1{%
\di@notrue\diagnum{\@ne}%
- \gdef\thediag{\csname @#1\endcsname\c@board@nr}%
+ \gdef\thediag{\@dianumber@prefix\csname @#1\endcsname\c@board@nr}%
}
% \end{macrocode}
%
@@ -2016,7 +2056,10 @@
% couple of other macros, which then generate the displayed
% information above the diagram.
% \begin{macrocode}
+\newboolean{above@newline}
+\newcommand{\above@newline}{\ifthenelse{\boolean{above@newline}}{\linebreak}{\setboolean{above@newline}{true}}}
\def\dia@above{%
+ \setboolean{above@newline}{false}%
\@dia@number%
\@dia@authors%
\@dia@city%
@@ -2049,10 +2092,10 @@
\@dia@twins%
\fi%
\@dia@remark%
- \if@solafterdiagram%
+ \ifthenelse{\boolean{@solafterdiagram}}{%
\below@newline%
\the\sol@tk%
- \fi%
+ }{}%
\noindent\hbox{}\newline\hbox{}%
\egroup%
}
@@ -2064,7 +2107,7 @@
% single paragraph.
% \begin{macrocode}
\def\@dia@number{%
- {\authorfont\thediag\par}%
+ \ifdi@no\above@newline{\authorfont\thediag}\fi%
}
% \end{macrocode}
% \end{macro}
@@ -2078,17 +2121,13 @@
% \begin{macrocode}
\def\@dia@authors{%
\ifauth@r%
- \bgroup%
- \authorfont%
\ifnormal@names%
- \the\aut@tk%
+ \above@newline
+ {\authorfont\the\aut@tk}%
\else%
- {\def\name@sep{\par}%
- \@notfirstfalse%
\let\@action=\@dia@writename% Parse the list of authors
- \@parseTokenlist\aut@tk;}
+ \@parseTokenlist\aut@tk;
\fi%
- \egroup%
\fi%
}
% \end{macrocode}
@@ -2102,10 +2141,10 @@
\def\@dia@city{%
\ifthenelse{\boolean{showcity}}{%
\if@city%
+ \above@newline%
\bgroup%
\cityfont\@notfirstfalse%
\let\@action=\p@rsecity\@parseTokenlist\city@tk;%
- \par%
\egroup%
\fi%
}{}%
@@ -2114,15 +2153,17 @@
\def\@dia@after{%
\if@after%
\bgroup%
- \dedicfont\the\after@tk\par%
+ \above@newline%
+ \dedicfont\the\after@tk%
\egroup%
\fi%
}
\def\@dia@version{%
\if@version%
+ \above@newline%
\bgroup%
- \dedicfont\the\version@tk\par%
+ \dedicfont\the\version@tk%
\egroup%
\fi%
}
@@ -2142,6 +2183,7 @@
\def\@dia@source{%
\if@source%
+ \above@newline%
\bgroup%
\sourcefont%
\if@sourcenr\the\sourcenr@tk\ \fi
@@ -2149,14 +2191,13 @@
\if@date\ \ \fi\@dia@date%
\if@issue\ \ \the\issue@tk\fi%
\if@pages ,\ \the\pages@tk\fi%
- \par%
\egroup%
\else%
\if@tournament\else\if@date%
+ \above@newline%
\bgroup%
\sourcefont%
\@dia@date%
- \par%
\egroup%
\fi\fi%
\fi%
@@ -2164,40 +2205,40 @@
\def\@dia@correction{%
\if@correction%
+ \above@newline%
\bgroup%
\dedicfont\the\correction@tk%
- \par%
\egroup%
\fi%
}
\def\@dia@tournament{%
\if@tournament
+ \above@newline%
\bgroup%
\awardfont%
\the\tournament@tk
\if@source\else\if@date%
\ \ \@dia@date%
\fi\fi%
- \par%
\egroup%
\fi%
}
\def\@dia@award{%
\if@award%
+ \above@newline%
\bgroup%
\awardfont\the\award@tk%
- \par%
\egroup%
\fi%
}
\def\@dia@dedic{%
\if@dedication%
+ \above@newline%
\bgroup%
\dedicfont\the\dedic@tk%
- \par%
\egroup%
\fi%
}
@@ -2205,10 +2246,10 @@
\def\@show@album#1/#2;{#1 FIDE-Album #2}
\def\@dia@fidealbum{%
- \if@fidealbum{%
- \expandafter\@show@album\the\fidealbum@tk;%
- \par%
- }\fi%
+ \if@fidealbum%
+ \above@newlne%
+ {\expandafter\@show@album\the\fidealbum@tk;}%
+ \fi%
}
\def\@twinskip{\ \ }
@@ -2570,7 +2611,7 @@
\fi
}
\def\@months#1-#2;{\from@month=#1\to@month=#2\@datetrue}
-\def\@dia@writename#1; {\sep@names\@dianame#1; \l@@klist}
+\def\@dia@writename#1; {\above@newline{\authorfont\@dianame#1; }\l@@klist}
\def\@sol@writename#1; {\sep@names\@dianame#1; \l@@klist}
\def\name@sep{,\ }
\def\sep@names{\if@notfirst\name@sep\else\@notfirsttrue\fi}
@@ -2603,7 +2644,7 @@
{\@notfirstfalse\let\@action\short@christian\l@@klist#1-\e@list}%
\fi%
}
-\def\@fullname#1, #2; {\hbox{\write@christian#2; #1}}
+\def\@fullname#1, #2; {\write@christian#2; #1}
\def\@sirname#1, #2; {#1}
\def\@short#1, #2; {\write@short#2;\ #1}
\def\@noname#1, #2; {}
@@ -2857,10 +2898,14 @@
\help@b=#1%
\advance\help@b\brd@ff%
\hbox{%
+ \ifthenelse{\boolean{legend}}{{%
+ \advance\@rows`1%
+ \llap{\raise .25\sq@width\hbox{\legendfont \char\@rows\ \ }}%
+ }}{}%
\if@stereo%
\ifnum\current@plane>\z@%
\ifnum\@rows=12%
- \llap{\raise .5\sq@width\hbox{\boardfont c6\ }}%
+ \llap{\raise .5\sq@width\hbox{\cpd@boardfont c6\ }}%
\fi%
\fi%
\fi%
@@ -2879,26 +2924,26 @@
\ifnum\lin@<\lines@max\repeat%
}%
}
-\def\put@line#1{%
- \lin@\z@%
- \help@b=#1%
- \advance\help@b\brd@ff%
- \hbox{%
- \if@stereo%
- \ifnum\current@plane>\z@%
- \ifnum\@rows=12%
- \llap{\raise .5\sq@width\hbox{\boardfont c6\ }}%
- \fi%
- \fi%
- \fi%
- \hbox to \z@{\vbox to \sq@width{}}%
- \loop%
- \ifnum\count\help@b=\m@ne\wF%
- \else\char\count\help@b\fi%
- \advance\lin@\@ne\advance\help@b\@ne%
- \ifnum\lin@<\lines@max\repeat%
- }%
-}
+% \def\put@line#1{%
+% \lin@\z@%
+% \help@b=#1%
+% \advance\help@b\brd@ff%
+% \hbox{%
+% \if@stereo%
+% \ifnum\current@plane>\z@%
+% \ifnum\@rows=12%
+% \llap{\raise .5\sq@width\hbox{\cpd@boardfont c6\ }}%
+% \fi%
+% \fi%
+% \fi%
+% \hbox to \z@{\vbox to \sq@width{}}%
+% \loop%
+% \ifnum\count\help@b=\m@ne\wF%
+% \else\char\count\help@b\fi%
+% \advance\lin@\@ne\advance\help@b\@ne%
+% \ifnum\lin@<\lines@max\repeat%
+% }%
+% }
\def\@parseTokenlist#1#2{\expandafter\l@@klist\the#1#2 \e@list}
\def\@addToPlane#1{%
\setbox\plane@box=\vbox{\hbox{%
@@ -2939,12 +2984,12 @@
\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})%
+ \psline(\value{field@border},0)(\value{field@border},\rows@max)%
\addtocounter{field@border}{\@ne}%
}%
\setcounter{field@border}{1}%
\whiledo{\value{field@border}<\rows@max}{%
- \psline(\value{field@border},0)(\value{field@border},\lines@max)%
+ \psline(0,\value{field@border})(\lines@max,\value{field@border})%
\addtocounter{field@border}{\@ne}%
}%
\box\plane@box%
@@ -2973,13 +3018,22 @@
\@rows=\rows@max%
% \multiply\@rows by \lines@max%
\loop%
- % \advance\@rows -\lines@max%
- % \put@line\@rows%
- % Remove \put@line in future versions
\advance\@rows \m@ne%
\put@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@frame}%
+ \lin@\z@%
+ \loop%
+ \hbox to \sq@width{\hfill{\advance\lin@`a\legendfont\char\lin@}\hfill}%
+ \advance\lin@\@ne%
+ \ifnum\lin@<\lines@max\repeat%
+ }}\vss}%
+ }{}%
}%
}
\def\put@sqs@normal{%
@@ -3010,10 +3064,10 @@
\hfil%
\inner@henbox{\box\plane@box}%
\ifcase\current@plane\or%
- \rlap{{\boardfont\ A}}\or%
- \rlap{{\boardfont\ B}}\or%
- \rlap{{\boardfont\ C}}\or%
- \rlap{{\boardfont\ D}}%
+ \rlap{{\cpd@boardfont\ A}}\or%
+ \rlap{{\cpd@boardfont\ B}}\or%
+ \rlap{{\cpd@boardfont\ C}}\or%
+ \rlap{{\cpd@boardfont\ D}}%
\fi%
\hfil%
}%
@@ -3044,7 +3098,7 @@
\hbox to \bd@width{%
\inner@henbox{\box\plane@box}%
\advance\current@plane`A%
- \rlap{{\boardfont\ \char\current@plane}}%
+ \rlap{{\cpd@boardfont\ \char\current@plane}}%
}%
\endgroup%
\vskip\v@space@dist%
@@ -3064,7 +3118,7 @@
\hbox to \bd@width{%
\inner@henbox{\box\plane@box}%
\advance\current@plane`A%
- \rlap{{\boardfont\ \char\current@plane}}%
+ \rlap{{\cpd@boardfont\ \char\current@plane}}%
}%
\endgroup%
\hskip\h@space@dist%