diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/chess-problem-diagrams/diagram.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/chess-problem-diagrams/diagram.sty | 161 |
1 files changed, 85 insertions, 76 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 5e9eec6cd73..c72486da10e 100644 --- a/Master/texmf-dist/tex/latex/chess-problem-diagrams/diagram.sty +++ b/Master/texmf-dist/tex/latex/chess-problem-diagrams/diagram.sty @@ -36,10 +36,10 @@ %% %% -\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} @@ -57,11 +57,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 @@ -87,6 +89,8 @@ \setboolean{showcity}{false} \newboolean{showacademictitle} \setboolean{showacademictitle}{true} +\newboolean{legend} +\setboolean{legend}{false} \newcount\@blackfield \newboolean{allwhite} @@ -378,6 +382,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 @@ -399,7 +404,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% @@ -408,7 +413,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}}{% @@ -419,7 +424,7 @@ \ifthenelse{\value{cpd@defNeutralPieces}=\value{cpd@neutralPieces}}{}% {\errmessage{Wrong number of neutral pieces}}% }{}% - \fi% + }% % \global\setbox\dia@box=\hbox{\vbox{% \parindent\z@% @@ -442,11 +447,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{% @@ -462,6 +467,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}}{% @@ -471,8 +481,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% @@ -536,7 +545,8 @@ \newcommand*{\stipfont}{\rmfamily} \newcommand*{\remfont}{\rmfamily} \newcommand*{\labelfont}{\rmfamily} -\newcommand*{\boardfont}{\rmfamily} +\newcommand*{\cpd@boardfont}{\rmfamily} +\newcommand*{\legendfont}{\sffamily} \newcommand*{\diagramx}{ \ifcase\elchfont\relax% \font\chessfont=pkelch12 @@ -572,6 +582,7 @@ \dia@lineskip\tw@\p@ \dia@type\tw@ } +\newcommand{\DefaultDiagramSize}{\diagramx} \def\defaultelchfont{% \ifcase\@ptsize\relax% \diagramx\or% @@ -581,7 +592,10 @@ } \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}} \def\ra{\mbox{$\rightarrow$}} \def\lra{\mbox{$\leftrightarrow$}} \let\rla=\lra @@ -594,9 +608,10 @@ \def\further{\ifmmode\Rightarrow\else$\Rightarrow$\fi\ \ignorespaces} \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}% } \def\diagcenter{\def\he@dpos{\centering}} \def\diagleft{\def\he@dpos{\raggedright}} @@ -890,7 +905,10 @@ \def\nX{\ch@fig{186}} \def\sX{\ch@fig{192}} +\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% @@ -915,29 +933,25 @@ \@dia@twins% \fi% \@dia@remark% - \if@solafterdiagram% + \ifthenelse{\boolean{@solafterdiagram}}{% \below@newline% \the\sol@tk% - \fi% + }{}% \noindent\hbox{}\newline\hbox{}% \egroup% } \def\@dia@number{% - {\authorfont\thediag\par}% + \ifdi@no\above@newline{\authorfont\thediag}\fi% } \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% } \def\@show@city#1;{\if@notfirst\ \slash\ \else\@notfirsttrue\fi#1} @@ -947,10 +961,10 @@ \def\@dia@city{% \ifthenelse{\boolean{showcity}}{% \if@city% + \above@newline% \bgroup% \cityfont\@notfirstfalse% \let\@action=\p@rsecity\@parseTokenlist\city@tk;% - \par% \egroup% \fi% }{}% @@ -959,15 +973,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% } @@ -987,6 +1003,7 @@ \def\@dia@source{% \if@source% + \above@newline% \bgroup% \sourcefont% \if@sourcenr\the\sourcenr@tk\ \fi @@ -994,14 +1011,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% @@ -1009,40 +1025,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% } @@ -1050,10 +1066,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{\ \ } @@ -1415,7 +1431,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} @@ -1448,7 +1464,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; {} @@ -1702,10 +1718,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% @@ -1724,26 +1744,6 @@ \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\@parseTokenlist#1#2{\expandafter\l@@klist\the#1#2 \e@list} \def\@addToPlane#1{% \setbox\plane@box=\vbox{\hbox{% @@ -1784,12 +1784,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% @@ -1818,13 +1818,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{% @@ -1855,10 +1864,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% }% @@ -1889,7 +1898,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% @@ -1909,7 +1918,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% |