| 1 |
% !Mode:: "TeX:DE:UTF-8:Main" |
| 2 |
% -*- mode: TeX -*- -*- coding: UTF-8 -*- |
| 3 |
\def\UFcurrentpackage{xskak} |
| 4 |
\newcommand\UFcurrentversion{1.5} |
| 5 |
|
| 6 |
\RequirePackage{fix-cm} |
| 7 |
|
| 8 |
\documentclass[pagesize,parskip=half-,fontsize=12pt]{scrartcl} |
| 9 |
\usepackage[utf8]{inputenc} |
| 10 |
|
| 11 |
%% xskak specific commands |
| 12 |
\usepackage[LSB1,LSB2, LSB3,LSBC2,LSBC3,LSBC4,LSBC5, T1]{fontenc} |
| 13 |
\usepackage{xskak} |
| 14 |
%\usepackage{eqparbox} |
| 15 |
\usepackage{tabularx} |
| 16 |
|
| 17 |
\usepackage{framed} |
| 18 |
\colorlet{shadecolor}{lightgray!25} |
| 19 |
|
| 20 |
|
| 21 |
\makeatletter |
| 22 |
\newcommand\Describefillkey[4][]{\par\index{#2 (\textbackslash chessboard key)}% |
| 23 |
\makebox[0pt][r]{\tiny #1\hspace{1em}}% |
| 24 |
\colorbox{green!25}{\makebox[\dimexpr\textwidth-2\fboxsep\relax]{\ttfamily% |
| 25 |
\eqparbox{fillkey}{#2=\meta{#3}}\hfill |
| 26 |
\eqparbox{fillexample}{% |
| 27 |
\ifthenelse{\equal{#4}{}}% |
| 28 |
{#2} |
| 29 |
{#2={#4}}}}}% |
| 30 |
\par\nobreak\@afterheading} |
| 31 |
\makeatother |
| 32 |
|
| 33 |
\usepackage{filecontents} |
| 34 |
\usepackage{UF-xskak-documentation} |
| 35 |
|
| 36 |
\setchessboard{smallboard, showmover=false} |
| 37 |
\xskakset{style=UF} |
| 38 |
|
| 39 |
\usepackage{showexpl} |
| 40 |
\makeatletter |
| 41 |
\renewcommand\board@pgf@extractangle[2]{%#1 command, #2 pgfpoint |
| 42 |
\pgfextracty{\len@board@tempy}{#2}% |
| 43 |
\pgfextractx{\len@board@tempx}{#2}% |
| 44 |
\ifdim\len@board@tempx=0pt\relax |
| 45 |
%\len@board@tempy= 1 or unchanged? |
| 46 |
\else |
| 47 |
%\divide \len@board@tempy by \strip@pt\len@board@tempx\relax |
| 48 |
\pgfmathsetlength{\len@board@tempy}{\len@board@tempy/\len@board@tempx}% |
| 49 |
\fi |
| 50 |
\ifdim\len@board@tempx=0pt\relax |
| 51 |
\ifdim\len@board@tempy=0pt\relax |
| 52 |
\def#1{0}% |
| 53 |
\else |
| 54 |
\ifdim\len@board@tempy>0pt\relax |
| 55 |
\def#1{90}% |
| 56 |
\else |
| 57 |
\def#1{-90}% |
| 58 |
\fi |
| 59 |
\fi |
| 60 |
\fi |
| 61 |
\ifdim\len@board@tempy=0pt\relax |
| 62 |
\ifdim\len@board@tempx=0pt\relax |
| 63 |
\def#1{0}% |
| 64 |
\else |
| 65 |
\ifdim\len@board@tempx>0pt\relax |
| 66 |
\def#1{0}% |
| 67 |
\else |
| 68 |
\def#1{180}% |
| 69 |
\fi |
| 70 |
\fi |
| 71 |
\fi |
| 72 |
\ifdim\len@board@tempx>0pt\relax |
| 73 |
\ifdim\len@board@tempy>0pt\relax |
| 74 |
\pgfmathatan{\len@board@tempy}% |
| 75 |
\edef#1{\pgfmathresult}% |
| 76 |
\fi |
| 77 |
\ifdim\len@board@tempy<0pt\relax |
| 78 |
\pgfmathatan{\len@board@tempy}% |
| 79 |
\edef#1{\pgfmathresult}% |
| 80 |
\fi |
| 81 |
\fi |
| 82 |
\ifdim\len@board@tempx<0pt\relax |
| 83 |
\ifdim\len@board@tempy>0pt\relax |
| 84 |
\pgfmathatan{-\len@board@tempy}% |
| 85 |
\pgfmathadd{-\pgfmathresult}{180}% |
| 86 |
\edef#1{\pgfmathresult}% |
| 87 |
\fi |
| 88 |
\ifdim\len@board@tempy<0pt\relax |
| 89 |
\pgfmathatan{\len@board@tempy}% |
| 90 |
\pgfmathadd{\pgfmathresult}{180}% |
| 91 |
\edef#1{\pgfmathresult}% |
| 92 |
\fi |
| 93 |
\fi |
| 94 |
} |
| 95 |
|
| 96 |
\makeatother |
| 97 |
|
| 98 |
\begin{document} |
| 99 |
|
| 100 |
\title{\packagename{xskak}: An extension to \skaksty} |
| 101 |
\author{Ulrike Fischer} |
| 102 |
\maketitle |
| 103 |
|
| 104 |
\tableofcontents |
| 105 |
|
| 106 |
\section{Changes} |
| 107 |
\begin{description} |
| 108 |
\item[2019-06-23] (Version 1.5)] Corrected a bug: \cs{xskak@beforecomment}{} was not defined. styleA was missing a space. Improved the documentation and added the source to the ctan upload. |
| 109 |
|
| 110 |
\item[2015-01-02] (Version 1.4)] Corrected a bug: After a promotion the promotionpiece and the fen position were wrong. |
| 111 |
\item[2014-04-19] (Version 1.3)] Corrected a bug: enpassant test didn't check the piece and so other figures than a pawn could make an enpassant move. |
| 112 |
\item[2012-08-24 (Version 1.2b)] |
| 113 |
Corrected a small bug -- \cs{printchessgame} doesn't wrap around a wrapfigure. |
| 114 |
|
| 115 |
|
| 116 |
\item[2012-08-24 (Version 1.2a)] |
| 117 |
Corrected a small bug -- \cs{hidemoves} printed comment signs. |
| 118 |
|
| 119 |
\item[2008-10-10 (Version 1.2)] |
| 120 |
Made some changes to make \xskak compatible to the version 1.5 of |
| 121 |
\skaksty. See below for details. |
| 122 |
|
| 123 |
Changed Code: As \cs{longmoves} doesn't work with \cs{variation} |
| 124 |
anyway \cs{variation} now use always \cs{shortmoves}. |
| 125 |
|
| 126 |
Bug correction: \skaksty forgets to store comments after castling |
| 127 |
moves. Code to correct this has been added to \xskak. |
| 128 |
|
| 129 |
Bug correction: \xskak didn't print check and mate symbol after |
| 130 |
castling moves due to wrong position of braces. |
| 131 |
|
| 132 |
\item[2008-07-28 (Version 1.1)] |
| 133 |
Bug correction: Added the code for the promotion piece to the SAN and |
| 134 |
LAN notation. |
| 135 |
|
| 136 |
Bug correction: Remove some spurious spaces. |
| 137 |
|
| 138 |
\end{description} |
| 139 |
|
| 140 |
|
| 141 |
\section{Introduction} |
| 142 |
|
| 143 |
\Xskak\footnote{License: \LaTeX\ Project Public License} is an extension for \skaksty -- and as \xskak is an extension |
| 144 |
(and not a replacement) the main work is still done by \skaksty so |
| 145 |
please read first the documentation of \skaksty as I'm not explaining |
| 146 |
the \packagename{skak} commands in this documentation. |
| 147 |
|
| 148 |
|
| 149 |
\Skaksty is a package from Torben Hoffmann which can parse and print |
| 150 |
chess games given in (a subset of) the PGN notation. |
| 151 |
|
| 152 |
The main features of \packagename{xskak} are: |
| 153 |
|
| 154 |
\begin{itemize} |
| 155 |
\item \packagename{xskak} can handle an extended set of PGN. |
| 156 |
|
| 157 |
\item \packagename{xskak} |
| 158 |
can parse and store an arbitrary number of chess games in PGN. The |
| 159 |
games can be exported and imported and all positions and moves can be |
| 160 |
retrieved at anytime. |
| 161 |
|
| 162 |
\item \packagename{xskak} can |
| 163 |
handle an arbitrary number of printing styles to distinguish |
| 164 |
the different variations levels. |
| 165 |
|
| 166 |
\end{itemize} |
| 167 |
|
| 168 |
\minisec{Extended PGN handling} |
| 169 |
|
| 170 |
When handling a PGN chess parsers at first have to split the notation |
| 171 |
in different chunks. I will call this step the \emph{PGN parser}. |
| 172 |
As an example\\[1ex]\mbox{}\quad {\ttfamily 15.Ne5!+ |
| 173 |
\$3 \{This breaks the black defense\} (15.Re1? Kg8!)}\\[1ex] contains as |
| 174 |
chunks a \emph{move number} (\texttt{15.}), a \emph{move} |
| 175 |
(\texttt{Ne5}), \emph{short move comments} (\texttt{!+}), a |
| 176 |
\emph{NAG} (\texttt{\$3}), a \emph{comment} (\texttt{\{This breaks |
| 177 |
the black defense\}}) and a \emph{variation} (\texttt{(15.Re1? |
| 178 |
Kg8!)}). |
| 179 |
|
| 180 |
Neither \packagename{skak} nor \packagename{xskak} can handle all |
| 181 |
legal PGN's. \Skaksty can only handle PGN's which contains move |
| 182 |
numbers, moves and short comments. \packagename{xskak} can |
| 183 |
additionally handle NAG's and a special form of comments. None of the |
| 184 |
packages can currently parse PGN's with variations. |
| 185 |
|
| 186 |
|
| 187 |
\minisec{Storing moves} |
| 188 |
|
| 189 |
After the splitting of the PGN the chunks are processed further. |
| 190 |
Depending on the type of the chunk different actions are taken. The |
| 191 |
most important subprocess is the \emph{move parser}. It takes the |
| 192 |
move, retrieves from somewhere the current (FEN-)position of the game |
| 193 |
and tries to figure out what the move is exactly doing. |
| 194 |
|
| 195 |
In \packagename{xskak} only the commands \cs{mainline} and |
| 196 |
\cs{hidemoves} calls the move parser, \cs{variation} uses only the |
| 197 |
PGN parser. |
| 198 |
|
| 199 |
The main difference between \packagename{xskak} and |
| 200 |
\packagename{skak} is how they handle the information gathered by |
| 201 |
the move parser: \Skaksty uses the results of the move parser mainly |
| 202 |
to update the board and after the move throws almost all other |
| 203 |
information away -- including previous positions. \xskak saves all |
| 204 |
information about the moves for later use. Here a simple example: |
| 205 |
|
| 206 |
\begin{LTXexample} |
| 207 |
\newchessgame |
| 208 |
\mainline{1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 4. Ba4 Nf6} |
| 209 |
|
| 210 |
\xskakset{moveid=2w}% |
| 211 |
\chessboard[setfen=\xskakget{nextfen}]\\[1ex] |
| 212 |
Position after 2.\,\xskakget{lan} |
| 213 |
\end{LTXexample} |
| 214 |
|
| 215 |
So in short you start a game with \cs{newchessgame}, you enter moves |
| 216 |
with \cs{mainline} (or \cs{hidemoves}), you set the move for which |
| 217 |
you want to retrieve data with \cs{xskakset}, and then you retrieve |
| 218 |
the data with \cs{xskakget}. |
| 219 |
|
| 220 |
|
| 221 |
The storing of the moves and positions is not restricted to the main |
| 222 |
game. You can store and retrieve as much variation levels you want. |
| 223 |
|
| 224 |
|
| 225 |
\minisec{Printing styles} |
| 226 |
|
| 227 |
The following example shows how to use different styles for different |
| 228 |
variation levels. But it also shows the problems: It can be quite |
| 229 |
tiresome to get a good printing result. You must pay attention to the |
| 230 |
levels and the spaces after commands, and for each variation you have |
| 231 |
to start a new game and resume older games if you go back to them. |
| 232 |
|
| 233 |
\begin{LTXexample} |
| 234 |
\longmoves \xskakset{style=UF} |
| 235 |
\newchessgame[id=main] |
| 236 |
\mainline{1.e4 e5} |
| 237 |
% |
| 238 |
(Alternatives are |
| 239 |
\newchessgame[newvar=main,id=var1]% |
| 240 |
\mainline[invar]{1... d5} which is answered by |
| 241 |
\mainline{2. exd5 Qxd5} |
| 242 |
% |
| 243 |
\newchessgame[newvar=var1,id=var1-1] |
| 244 |
(\mainline[invar]{2... Nf6}) |
| 245 |
% |
| 246 |
or |
| 247 |
\newchessgame[newvar=main,id=var2] |
| 248 |
\mainline[outvar]{1... e6 2. d4}) |
| 249 |
% |
| 250 |
\resumechessgame[id=main]% |
| 251 |
\mainline[outvar]{2.Nf3} |
| 252 |
|
| 253 |
\chessboard |
| 254 |
\end{LTXexample} |
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
\bigskip |
| 259 |
|
| 260 |
In the following sections I will describe the finer points. This |
| 261 |
includes |
| 262 |
\begin{itemize} |
| 263 |
\item how to handle more than one game at a time, |
| 264 |
\item how to retrieve the data faster, |
| 265 |
\item what data you can retrieve, |
| 266 |
\item how to loop through a game, |
| 267 |
\item how to export the data, |
| 268 |
\item how to improve the printing of the games, |
| 269 |
\item and some other changes/additions I made to \packagename{skak}. |
| 270 |
\end{itemize} |
| 271 |
|
| 272 |
|
| 273 |
\subsection{Warnings} |
| 274 |
|
| 275 |
\minisec{\packagename{xskak} and \packagename{skak}} |
| 276 |
|
| 277 |
\Xskak doesn't only define some new commands, it also changes some |
| 278 |
quite central internal commands of \skaksty. This means |
| 279 |
\begin{itemize} |
| 280 |
\item it can break standard commands of \skaksty, |
| 281 |
|
| 282 |
\item it will possibly not work together with future versions of |
| 283 |
\skaksty, |
| 284 |
|
| 285 |
\item loading \packagename{xskak.sty} can lead to problems with |
| 286 |
packages like \packagename{texmate} which use internally |
| 287 |
\packagename{skak}. |
| 288 |
\end{itemize} |
| 289 |
|
| 290 |
\minisec{Local and global commands} |
| 291 |
|
| 292 |
In the package \packagename{chessboard} almost every setting is local |
| 293 |
to the board. This was a quite natural decision as a board is a |
| 294 |
confined space. In \packagename{xskak} the situation is quite |
| 295 |
different: As a start \packagename{skak} already sets and saves some |
| 296 |
information globally and the data saved by \packagename{xskak} |
| 297 |
during the parsing must be saved globally or they wouldn't never |
| 298 |
escape the \cs{mainline}. And secondly, as I wanted to use |
| 299 |
\packagename{beamer} and \packagename{animate} a lot of data |
| 300 |
must be preserved from one frame/picture to the next. So I decided to |
| 301 |
use in most cases global commands unless -- like in the cases of |
| 302 |
styles -- I could see a real advantage in keeping a setting local. |
| 303 |
|
| 304 |
So please be aware that settings made e.g. in a figure environment |
| 305 |
can affect the following text. |
| 306 |
|
| 307 |
|
| 308 |
\subsection{Some history} |
| 309 |
|
| 310 |
While the commands \cs{mainline} and \cs{hidemoves} parse a chess |
| 311 |
game \skaksty updates an internal board and so can always show the |
| 312 |
current position. Sadly a lot of the data gathered during the |
| 313 |
parsing are thrown away after \packagename{skak} has updated the |
| 314 |
board and has go on to the next move and so can not be used by the |
| 315 |
user. E.g. there is no way to get the field a piece came from or to |
| 316 |
store easily all positions of a game. |
| 317 |
|
| 318 |
Some years ago I tried to find out how to print a game in long |
| 319 |
algebraic notation and I realized quite fast that I need some of |
| 320 |
these lost data to be able to do it, and that it would be necessary |
| 321 |
to patch some internal commands of \skaksty to save the data. At the |
| 322 |
same time I also tried to insert some code that allows the parsing of |
| 323 |
standard PGN-comment signs. Due to lack of time the whole project |
| 324 |
didn't got very far but I had a working beta. Then a new version of |
| 325 |
\skaksty came. It had even a -- sadly at the time not fully working -- command \cs{longmoves}% |
| 326 |
\index{longmoves=\verb!*+\longmoves+>}% |
| 327 |
\index{shortmoves=\verb!*+\shortmoves+>} |
| 328 |
(and the counterpart \cs{shortmoves}) to switch to the long algebraic |
| 329 |
notation. But I hadn't the time to test and adjust my package. |
| 330 |
|
| 331 |
\index{longmoves=\verb!*+\longmoves+>}% |
| 332 |
\index{shortmoves=\verb!*+\shortmoves+>}% |
| 333 |
|
| 334 |
Then in 2006 I wrote \pchessboard and during the tests also tried to |
| 335 |
make animated pdf's which show all positions of a game. That worked |
| 336 |
fine but the input was so tiresome that I restarted the |
| 337 |
\packagename{xskak}-project: Like in the case of the long algebraic |
| 338 |
notation the main problem was the loss of previous positions. |
| 339 |
|
| 340 |
|
| 341 |
\subsection{Bugs and errors} |
| 342 |
|
| 343 |
I'm quite sure that they are bugs and errors in the package. |
| 344 |
|
| 345 |
If you have questions ask them in the newsgroups |
| 346 |
\nolinkurl{comp.text.tex}, \nolinkurl{de.comp.text.tex} or |
| 347 |
\nolinkurl{fr.comp.text.tex} or at \url{http://tex.stackexchange.com/}. |
| 348 |
I'm reading these groups regularly and |
| 349 |
I'm much better in answering there than in answering e-mails. |
| 350 |
|
| 351 |
If you find errors in this text (this includes wrong english) or in |
| 352 |
the package, you can write me a bugreport at |
| 353 |
\nolinkurl{[email protected]} or -- better -- add an issue to the github site |
| 354 |
\url{https://github.com/u-fischer/xskak/issues/}. A bugreport should contain a complete, |
| 355 |
running, \emph{minimal} example and the log-file of the pdf\LaTeX\ |
| 356 |
run (that means the engine that makes a pdf!). |
| 357 |
|
| 358 |
|
| 359 |
\subsection{Requirements} |
| 360 |
|
| 361 |
\Xskak uses some primitives of e\TeX. It needs version 1.4 or version |
| 362 |
1.5 of \skaksty, a recent version of \chessfss (chess font selection) |
| 363 |
and \packagename{xkeyval} (\textit{key=value}-syntax), version 1.5 of |
| 364 |
\packagename{chessboard} (which in turns needs \packagename{pgf}) and |
| 365 |
\packagename{xifthen}. |
| 366 |
|
| 367 |
|
| 368 |
\subsection{Installation} |
| 369 |
|
| 370 |
Run \filetype{xskak.ins} through \LaTeX\ and then put the |
| 371 |
\filetype{*.sty} where \LaTeX\ finds them. |
| 372 |
(\path{<texmf>/tex/latex/xskak/} is a good place.) Update the |
| 373 |
filename database. |
| 374 |
|
| 375 |
|
| 376 |
\subsection{Loading and package options} |
| 377 |
|
| 378 |
Loading of the package is done with \verb+\usepackage{xskak}+. |
| 379 |
Currently the package has only one option: \texttt{nopdfmatch}.% |
| 380 |
\index{nopdfmatch (package option)} |
| 381 |
The option will disable the use of the experimental \cs{pdfmatch} |
| 382 |
used in the processing of the style levels (see section |
| 383 |
\ref{sec:usestyles}). \packagename{xskak} will load \skaksty without |
| 384 |
option (and won't pass options to it). So, if you want to load |
| 385 |
\packagename{skak} with options, you must do it before loading |
| 386 |
\xskak. |
| 387 |
|
| 388 |
\subsection{Adaption to \skaksty version 1.5} |
| 389 |
|
| 390 |
Above I warned that \xskak can break with newer versions of \skaksty. |
| 391 |
When the version 1.5 of \packagename{skak} appeared |
| 392 |
promptly a lot of things broke so I had to adapt and change my code. |
| 393 |
Version 1.2 of \xskak will work with both versions of |
| 394 |
\skaksty. |
| 395 |
|
| 396 |
In version 1.5 of \skaksty some fundamental things have changed. At |
| 397 |
first \cs{longmoves} works now correctly, even as you can see for the |
| 398 |
\cs{variation} command: |
| 399 |
|
| 400 |
|
| 401 |
\LTXinputExample[label=ex:longmovesnew, |
| 402 |
graphic={[trim=3cm 24cm 9cm |
| 403 |
4cm,clip]{skak-longmoves-test-new}}, |
| 404 |
caption={The new |
| 405 |
longmoves implementation of |
| 406 |
\skaksty}]{skak-longmoves-test-new} |
| 407 |
|
| 408 |
|
| 409 |
The more important change (from the point of my package) is that |
| 410 |
\cs{variation} now parse the moves too (that's why it can show the |
| 411 |
long algebraic notation). To achieve this the author of \skaksty, |
| 412 |
Torben Hoffman, stores now the position before a move so that he can |
| 413 |
go back to this position and start the variation from there. |
| 414 |
|
| 415 |
The main problem with this approach is that it imposes restrictions |
| 416 |
on the move numbers of variations: All variations must start with the |
| 417 |
move number of the last move in a \cs{mainline} command. So |
| 418 |
separating two moves of a variation by some text is no longer |
| 419 |
possible: |
| 420 |
|
| 421 |
\begin{lstlisting} |
| 422 |
\documentclass{article} |
| 423 |
\usepackage{skak} %=skak version 1.5 |
| 424 |
\begin{document} |
| 425 |
\newgame |
| 426 |
\mainline{1.e4 e5 2. Nf3} |
| 427 |
\variation{2. d3 d6} %works |
| 428 |
\variation{2. c3} %works |
| 429 |
and then |
| 430 |
\variation{2...c6} %error |
| 431 |
\end{document} |
| 432 |
\end{lstlisting} |
| 433 |
|
| 434 |
To tell the truth, I'm not sure that this a very good idea. In any |
| 435 |
case: \xskak overwrites the responsable definitions of \skaksty. With |
| 436 |
\xskak \cs{variation} currently doesn't parse games (and so also |
| 437 |
can't show moves in long algebraic notation -- if you want this you |
| 438 |
will have to start with the commands described later in this |
| 439 |
documentation a new game with another id). So the above example works |
| 440 |
fine with \xskak. |
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
\subsection{The example} |
| 447 |
|
| 448 |
Almost all examples use as starting point a new game. But in some |
| 449 |
cases the following position is used, which allows to show almost all |
| 450 |
special cases (like enpassant, promotion, capture, castling, |
| 451 |
ambiguous moves). The position is stored under the name «example» and |
| 452 |
so can be retrieved e.g. with the key \key{restorefen=example} from |
| 453 |
\packagename{chessboard} or the command |
| 454 |
\lstinline+\restoregame{example}+ of the package |
| 455 |
\packagename{skak}\footnote{One could also use key \key{tag} to |
| 456 |
store the position and key \key{reffen} to retrieve it.}: |
| 457 |
|
| 458 |
\begin{LTXexample}[caption={The standard example position},width=.7\textwidth] |
| 459 |
\newchessgame[id=example, |
| 460 |
castling=Q, |
| 461 |
setwhite={pa2,pc7,pg5,ph2,pe4, |
| 462 |
ke1,ra1,bg4}, |
| 463 |
addblack={pb4,ph7,pd5, |
| 464 |
ke8,rh8,bh3,nf6,ne5}, |
| 465 |
storefen=example]% |
| 466 |
|
| 467 |
\mbox{\Xskakexampleinitfen} |
| 468 |
|
| 469 |
\chessboard |
| 470 |
\end{LTXexample} |
| 471 |
|
| 472 |
|
| 473 |
\section{Improved parsing of comments}\label{sec:diagrams} |
| 474 |
|
| 475 |
\Skaksty can handle comments in the input if they follow |
| 476 |
directly the move, if the commands are robust and if the spaces that |
| 477 |
separate moves and numbers are not swallowed by a command. |
| 478 |
|
| 479 |
\LTXinputExample[label=ex:comments, |
| 480 |
graphic={[trim=3cm 24cm 9cm |
| 481 |
4cm,clip]{skak-comment-test}}, |
| 482 |
caption={comments in \skaksty}]{skak-comment-test} |
| 483 |
|
| 484 |
|
| 485 |
This is quite okay for a few small comments in a small number of |
| 486 |
games, but a bit tiresome if you want to handle a lot of games that |
| 487 |
you have annotated with a chess application. The PGN export of such |
| 488 |
games uses NAG's for short comments and curly braces for longer |
| 489 |
comments. |
| 490 |
|
| 491 |
|
| 492 |
With \xskak the commands \cs{mainline}, \cs{hidemoves} and |
| 493 |
\cs{variation} now can parse NAG's and longer comments if the input |
| 494 |
meet the following conditions: |
| 495 |
%\end{document} |
| 496 |
\begin{itemize} |
| 497 |
\item There must be spaces between the moves, each NAG and the |
| 498 |
comments. |
| 499 |
|
| 500 |
\item Text comments must be written as |
| 501 |
\verb+\xskakcomment{+\meta{Text}\verb+}+% |
| 502 |
\footnote{Braces are so frequent in \TeX\ that is simply not |
| 503 |
possible to identify the comments simply by looking for a brace |
| 504 |
-- at least not without a lot of complicated hacks.} |
| 505 |
|
| 506 |
\end{itemize} |
| 507 |
|
| 508 |
While parsing the comments the spaces before and between them will be |
| 509 |
swallowed. If you want a space you must add it to the text. The |
| 510 |
NAG's (\$1, \$2 etc) are translated following the definitions in |
| 511 |
\filetype{xskak-nagdef.sty}. The list there is neither complete nor |
| 512 |
definite. For quite a lot NAG's I hadn't the faintest idea what do. |
| 513 |
I'm open for suggestions/corrections. |
| 514 |
|
| 515 |
There exist two «fake» NAG's: \$d and \$D. If used in a \cs{mainline} |
| 516 |
or \cs{hidemoves} both will save the identification of the current |
| 517 |
move in an internal list and print whatever they have been defined |
| 518 |
to. (Currently \$D will print \cs{chessdiagramname} which is defined |
| 519 |
as \verb+\ (Diagram)\ +, \$d is |
| 520 |
empty). This can be used to refer to diagrams printed later.% |
| 521 |
\footnote{It is not a accidental that there is a similar command |
| 522 |
«\cs{toD}» in \packagename{texmate}. That's where I got the idea |
| 523 |
from.} |
| 524 |
|
| 525 |
|
| 526 |
|
| 527 |
\begin{LTXexample}[caption={NAG's, comments and diagram references in the input}] |
| 528 |
\newchessgame[id=GameA] |
| 529 |
\mainline{1.e4! $2 e5 $D 2.Nf3 Nf6 \xskakcomment{ What's that? }} |
| 530 |
|
| 531 |
\renewcommand\xskakcomment[1]{{\itshape #1}}% |
| 532 |
\mainline{3. Nxe5 |
| 533 |
\xskakcomment{ I took a pawn! } $D } |
| 534 |
\variation[invar]{3. Nc3 $4 |
| 535 |
\xskakcomment{ (boring) }} |
| 536 |
|
| 537 |
\makeatletter |
| 538 |
\@for\mymoveid:=\XskakGameAdiagramlist\do{% |
| 539 |
\xskakset{moveid=\mymoveid}% |
| 540 |
\begin{tabular}{c} |
| 541 |
\chessboard[tinyboard, |
| 542 |
setfen=\xskakget{nextfen}]\\ |
| 543 |
After move \xskakget{opennr}\xskakget{lan} |
| 544 |
\end{tabular} } |
| 545 |
\end{LTXexample} |
| 546 |
|
| 547 |
|
| 548 |
\section{The core of \xskak: Saving games.} |
| 549 |
|
| 550 |
\Xskak redefines some internal commands of \skaksty to enable |
| 551 |
\cs{mainline} and \cs{hidemoves} to store quite a lot% |
| 552 |
\footnote{\textbf{Attention:} When I say «a lot» I really mean it. Currently |
| 553 |
about 30 commands for each halfmove is saved plus about 30 commands |
| 554 |
for each game. A lot of games with individual game identifications |
| 555 |
can use a lot of memory. But in practice that shouldn't be a problem |
| 556 |
as it is seldom necessary to use a lot of different game |
| 557 |
identifications.} |
| 558 |
data about the moves and the state of the game while parsing |
| 559 |
the game. |
| 560 |
|
| 561 |
There are two sorts of data: Information related to the game as a |
| 562 |
whole (e.g. the names of the players and the start position) and |
| 563 |
information related to the moves. Both type of information use a |
| 564 |
\meta{GameId} in the names of the commands to identify the game they |
| 565 |
are referring to, the move data use additionally a \meta{MoveId}. |
| 566 |
|
| 567 |
\begin{shaded} |
| 568 |
\minisec{Exkurs 1} |
| 569 |
|
| 570 |
It is important to understand one difference between the use of |
| 571 |
\meta{GameId} and \meta{MoveId}: There is only \emph{one} command |
| 572 |
that holds the current \meta{GameId}. The \meta{GameId} is a concept |
| 573 |
specific to \xskak. The current value \meta{GameId} is stored in a |
| 574 |
command and will be used (and can be changed) by all the commands |
| 575 |
that store information \emph{and} by all the commands that retrieve |
| 576 |
information. So if you are parsing a game in bits you should be |
| 577 |
careful to use the same \meta{GameId} for each part. |
| 578 |
|
| 579 |
On the other sides there are \emph{three} different places where move |
| 580 |
data are set or used: \skaksty uses in \cs{mainline} and |
| 581 |
\cs{hidemoves} a counter called «\texttt{move}» and a boolean to keep |
| 582 |
track of the current move and player. \Xskak has two internal |
| 583 |
commands which are used to set up the start moves of games and to |
| 584 |
retrieve the stored move data, and \cs{chessboard} has two keys that |
| 585 |
set move data in FEN's. This can be sometimes a bit |
| 586 |
confusing. \Skaksty will not like it if its move counter is changed |
| 587 |
while parsing a game, but it is normally not a problem to change the |
| 588 |
\packagename{xskak} move commands e.g. to retrieve data about |
| 589 |
previous moves -- as long as you don't use commands like |
| 590 |
\cs{newchessgame} that affects also the \packagename{skak} move |
| 591 |
counter. |
| 592 |
\end{shaded} |
| 593 |
|
| 594 |
|
| 595 |
\begin{shaded} |
| 596 |
\minisec{Exkurs 2} |
| 597 |
|
| 598 |
In chess we speak quite as often about the last move and the last |
| 599 |
position than about the next move and the next position: A position |
| 600 |
can be described as the one \emph{after} the \emph{last} move, the |
| 601 |
result of a move. But it can also be described as the one |
| 602 |
\emph{before} the \emph{next} move. |
| 603 |
|
| 604 |
The keys and commands described later reflect this: Given a move |
| 605 |
number you can access e.g. the position \emph{before} the move |
| 606 |
through the key word \key{pastfen} and the position \emph{after} the |
| 607 |
move through the key word \key{nextfen}. Given a \emph{tag} -- that |
| 608 |
is a label between two moves, you can refer to the move |
| 609 |
\textit{before} the tag through keys with the prefix \key{past} and |
| 610 |
to the move \emph{after} the tag through keys with the prefix |
| 611 |
\key{next}. |
| 612 |
|
| 613 |
In short: \key{past} looks back and \key{next} looks forward. |
| 614 |
|
| 615 |
The first position of a game and the first move have the prefix |
| 616 |
\key{init}. The last position (after the last move) and the last move |
| 617 |
have the prefix \key{last}. |
| 618 |
|
| 619 |
\end{shaded} |
| 620 |
|
| 621 |
|
| 622 |
\subsection{Initialization of the game} |
| 623 |
|
| 624 |
\DescribeMacro{\newchessgame}% |
| 625 |
When using \xskak you should start a new game with |
| 626 |
\cs{newchessgame}\keyoarg{} instead of \cs{newgame}. It will set the |
| 627 |
identification \meta{GameId} of the game, the start position, start |
| 628 |
move and quite a lot of other variables to sensible values. |
| 629 |
|
| 630 |
In the optional argument you can use the following keys: |
| 631 |
|
| 632 |
\begin{description} |
| 633 |
\item[\key{id=}\meta{GameId}] |
| 634 |
\index{newchessgame=\verb!*+\newchessgame+>id (key)}% |
| 635 |
\index{id (\texttt{\textbackslash newchessgame} key)}% |
| 636 |
This key sets the string that identifies the game and is used in |
| 637 |
the following parsing commands to store the data. |
| 638 |
It is possible to use commands and counters e.g. for automatic numbering of |
| 639 |
the games. |
| 640 |
If you don't use the key or if you use the key without |
| 641 |
argument (\verb+\newchessgame[id]+) a default is used. |
| 642 |
The initial value of this default is \texttt{game}, but it can be changed with |
| 643 |
\cs{xskakset}. |
| 644 |
You can use the key \key{id} in each \cs{newchessgame} only once. |
| 645 |
|
| 646 |
\begin{LTXexample}[varwidth=false,width=0.3\textwidth] |
| 647 |
\newchessgame[white=Bob]% |
| 648 |
\mainline{1. e4 e5} |
| 649 |
|
| 650 |
\newchessgame[id=MY,white=Bill]% |
| 651 |
\mainline{1. e4 e5} |
| 652 |
|
| 653 |
\newcounter{gamecounter}% |
| 654 |
\stepcounter{gamecounter}% |
| 655 |
\xskakset{defaultid=Game\Alph{gamecounter}}% |
| 656 |
|
| 657 |
\newchessgame[white=Harry]% |
| 658 |
\mainline{1. e4 e5} |
| 659 |
|
| 660 |
\stepcounter{gamecounter}% |
| 661 |
\newchessgame[white=Thomas]% |
| 662 |
\mainline{1. d4 d5} |
| 663 |
|
| 664 |
\Xskakgamewhite, \XskakMYwhite, |
| 665 |
\XskakGameAwhite, \XskakGameBwhite% |
| 666 |
\end{LTXexample} |
| 667 |
|
| 668 |
\item[\key{movenr=}\meta{number}, \key{player=}\meta{«w» or «b»}, \key{moveid=}\meta{number + «w» or «b»}] |
| 669 |
\index{newchessgame=\verb!*+\newchessgame+>movenr (key)}% |
| 670 |
\index{movenr (\texttt{\textbackslash newchessgame} key)}% |
| 671 |
\index{newchessgame=\verb!*+\newchessgame+>player (key)}% |
| 672 |
\index{player (\texttt{\textbackslash newchessgame} key)}% |
| 673 |
\index{newchessgame=\verb!*+\newchessgame+>moveid (key)}% |
| 674 |
\index{moveid (\texttt{\textbackslash newchessgame} key)}% |
| 675 |
With this keys you can change the start move for the parsing |
| 676 |
commands \cs{mainline} and \cs{hidemoves}. |
| 677 |
Setting this keys will change the counter and boolean |
| 678 |
of \packagename{skak} \emph{and} the internal commands of |
| 679 |
\packagename{xskak}. |
| 680 |
The changes are global. |
| 681 |
Default is \texttt{moveid=1w}, this default can be changed with |
| 682 |
\cs{xskakset}. |
| 683 |
Move number and player given through one of the FEN-keys of \cs{chessboard} |
| 684 |
will not affect the move counter of \packagename{skak}! |
| 685 |
|
| 686 |
|
| 687 |
\begin{LTXexample}[varwidth=false,width=0.3\textwidth] |
| 688 |
\newchessgame |
| 689 |
\mainline{1. e4} |
| 690 |
|
| 691 |
\newchessgame[moveid=4w] |
| 692 |
\mainline{4. e4 e5} |
| 693 |
|
| 694 |
\xskakset{defaultmoveid=5b} |
| 695 |
\newchessgame |
| 696 |
\mainline{5... c4} |
| 697 |
\xskakset{defaultmoveid=1w} %back to normal |
| 698 |
\end{LTXexample} |
| 699 |
|
| 700 |
\item[\key{newvar=}\meta{GameId}] |
| 701 |
\index{newchessgame=\verb!*+\newchessgame+>newvar (key)}% |
| 702 |
\index{newvar (\texttt{\textbackslash newchessgame} key)}% |
| 703 |
|
| 704 |
If you use this key \cs{newchessgame} will use the position |
| 705 |
and the \meta{moveid} \emph{before} the last |
| 706 |
move of the game \meta{GameId} as start position. If you don't |
| 707 |
give a value the current meaning of \meta{GameId} is used. This |
| 708 |
can be used to start variations. The new game inherits only the |
| 709 |
start position of the reference game! |
| 710 |
|
| 711 |
|
| 712 |
\item[\key{ref\ldots=}\meta{tag}] |
| 713 |
|
| 714 |
The \meta{GameId} and the start move can also be set with keys which |
| 715 |
use values saved with a \key{tag}. The keys are described in section |
| 716 |
\ref{sec:labeling}. |
| 717 |
|
| 718 |
|
| 719 |
\item[keys to set PGN-infos] |
| 720 |
\index{newchessgame=\verb!*+\newchessgame+>result (key)}% |
| 721 |
\index{result (\texttt{\textbackslash newchessgame} key)}% |
| 722 |
\index{newchessgame=\verb!*+\newchessgame+>white (key)}% |
| 723 |
\index{white (\texttt{\textbackslash newchessgame} key)}% |
| 724 |
\index{newchessgame=\verb!*+\newchessgame+>black (key)}% |
| 725 |
\index{black (\texttt{\textbackslash newchessgame} key)}% |
| 726 |
\index{newchessgame=\verb!*+\newchessgame+>whiteelo (key)}% |
| 727 |
\index{whiteelo (\texttt{\textbackslash newchessgame} key)}% |
| 728 |
\index{newchessgame=\verb!*+\newchessgame+>blackelo (key)}% |
| 729 |
\index{blackelo (\texttt{\textbackslash newchessgame} key)}% |
| 730 |
\index{newchessgame=\verb!*+\newchessgame+>site (key)}% |
| 731 |
\index{site (\texttt{\textbackslash newchessgame} key)}% |
| 732 |
\index{newchessgame=\verb!*+\newchessgame+>date (key)}% |
| 733 |
\index{date (\texttt{\textbackslash newchessgame} key)}% |
| 734 |
\index{newchessgame=\verb!*+\newchessgame+>event (key)}% |
| 735 |
\index{event (\texttt{\textbackslash newchessgame} key)}% |
| 736 |
\index{newchessgame=\verb!*+\newchessgame+>round (key)}% |
| 737 |
\index{round (\texttt{\textbackslash newchessgame} key)}% |
| 738 |
\index{PGN-infos |see (\texttt{\textbackslash newchessgame} keys)}% |
| 739 |
With the keys \key{result}, \key{white}, \key{black}, |
| 740 |
\key{whiteelo}, \key{blackelo}, \key{site}, \key{date}, |
| 741 |
\key{event} and \key{round} you can store the content of the |
| 742 |
PGN-infos. Unused keys are set to default values. These defaults |
| 743 |
can be changed with \cs{xskakset}. |
| 744 |
|
| 745 |
\DescribeMacro{\xskaknewpgninfo}% |
| 746 |
With \cs{xskaknewpgninfo}\oarg{default value}\marg{keyname} you can define a own PGN-info key. This |
| 747 |
will also define a key \key{default\meta{name}} to change the default value later. |
| 748 |
|
| 749 |
\begin{LTXexample}[varwidth=false,width=0.3\textwidth] |
| 750 |
\xskaknewpgninfo[Tom]{commentary} |
| 751 |
|
| 752 |
\newchessgame[white=Harry,date=2007] |
| 753 |
\xskakgetgame{white}, \xskakgetgame{date}, |
| 754 |
\xskakgetgame{event}, |
| 755 |
\xskakgetgame{commentary} |
| 756 |
|
| 757 |
\xskakset{defaultevent=My open} |
| 758 |
|
| 759 |
\newchessgame[commentary=Müller] |
| 760 |
\xskakgetgame{commentary}, |
| 761 |
\xskakgetgame{event} |
| 762 |
|
| 763 |
\end{LTXexample} |
| 764 |
|
| 765 |
|
| 766 |
\item[using chessboard keys] |
| 767 |
\index{newchessgame=\verb!*+\newchessgame+>using chessboard keys}% |
| 768 |
You can use any key that can be used in the optional argument of |
| 769 |
\cs{chessboard} from the package \packagename{chessboard}. |
| 770 |
\cs{newchessgame} will pass all keys to an internal |
| 771 |
\cs{chessboard}% |
| 772 |
\footnote{That's why you will get an error from \cs{chessboard} if you use an unknown key.}. |
| 773 |
\cs{chessboard} will set a position and give it back as the start position for the |
| 774 |
game. |
| 775 |
All \packagename{chessboard} keys are processed normally. |
| 776 |
You can even print directly the board by using the key \key{print}. |
| 777 |
The only exceptions\footnote{They don't gives |
| 778 |
error but they will have no effect.} are the keys \key{maxfield} |
| 779 |
and \key{zero} that change the size of the board -- |
| 780 |
\packagename{skak} doesn't like unusual sizes of the board -- |
| 781 |
and the keys \key{mover} and \key{fullmove} which are overwritten |
| 782 |
by the (eventually default) value of key \key{moveid}. The castling |
| 783 |
possibilities and the enpassant field are set accordingly the |
| 784 |
values in the default fen, you only need to set them if you want |
| 785 |
to use other values. |
| 786 |
Read the documentation of \packagename{chessboard} for more information. |
| 787 |
|
| 788 |
|
| 789 |
\begin{LTXexample} |
| 790 |
\newchessgame[ |
| 791 |
moveid=4b,print, |
| 792 |
showmover, |
| 793 |
mover=w,% has no effect |
| 794 |
castling=Q,enpassant=a3, |
| 795 |
setwhite={pa4,pc7,pg5,ph2,pe4,ke1,ra1,bg4}, |
| 796 |
addblack={pb4,ph7,pd5,ke8,rh8,bh3,nf6,ne5}]% |
| 797 |
|
| 798 |
\mainline{4... bxa3} |
| 799 |
\chessboard |
| 800 |
\end{LTXexample} |
| 801 |
\end{description} |
| 802 |
|
| 803 |
To use a position of another game as a start position you can use |
| 804 |
e.g. this sequence of keys |
| 805 |
(a shorter method that use a label/ref-method will |
| 806 |
be described in the section \ref{sec:labeling}): |
| 807 |
|
| 808 |
\cs{newchessgame}\verb+[id=+\meta{old id}% |
| 809 |
\verb+, moveid=+\meta{old move id}% |
| 810 |
\verb+,+\\\phantom{(newchessgame[}% |
| 811 |
\verb+setfen=\xskakget{+\meta{\ttfamily\upshape nextfen|pastfen}\verb+}+% |
| 812 |
\verb+,+\\\phantom{(newchessgame[}% |
| 813 |
\verb+id=+\meta{new id}\verb+, moveid=+\meta{new initmove id}% |
| 814 |
\verb+]+ |
| 815 |
|
| 816 |
\textbf{Attention:} A new game is a \emph{new} game. It doesn't inherit moves of |
| 817 |
another game -- it only reuses a position. |
| 818 |
So if the new and the old game have identical \meta{GameId} |
| 819 |
then the old game will be more or less lost. |
| 820 |
|
| 821 |
In case that you want to go one half move back and start a new |
| 822 |
game from there you can use the key \key{newvar}: |
| 823 |
|
| 824 |
\cs{newchessgame}\verb+[newvar=+\meta{old id}% |
| 825 |
\verb+, id=+\meta{new id}\verb+]+ |
| 826 |
|
| 827 |
|
| 828 |
\begin{LTXexample} |
| 829 |
\newchessgame[id=A]% |
| 830 |
\mainline{1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 4. Ba4 Nf6 5. O-O} |
| 831 |
|
| 832 |
\newchessgame[ |
| 833 |
id=A,moveid=3w,print, |
| 834 |
setfen=\xskakget{nextfen}, |
| 835 |
%fen after move 3w |
| 836 |
id=B,moveid=1b] |
| 837 |
|
| 838 |
\mainline{1... Nf6} |
| 839 |
|
| 840 |
\newchessgame[id=C] |
| 841 |
\mainline{1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 4. Ba4 Nf6 5. O-O} |
| 842 |
|
| 843 |
\newchessgame[print, |
| 844 |
id=C, |
| 845 |
% we retrieve the number of the last move |
| 846 |
% of game C and set it as first number |
| 847 |
% of the new game B at the same time: |
| 848 |
moveid=\xskakgetgame{lastmoveid}, |
| 849 |
setfen=\xskakget{pastfen}, |
| 850 |
id=B] |
| 851 |
|
| 852 |
\mainline{5. d3} |
| 853 |
\end{LTXexample} |
| 854 |
|
| 855 |
|
| 856 |
\subsection{Continuing a game} |
| 857 |
|
| 858 |
\DescribeMacro{\resumechessgame}% |
| 859 |
\Skaksty doesn't have a problem if you split a game in pieces. |
| 860 |
You can use as many \cs{mainline} commands as you want. It even |
| 861 |
doesn't matter if you started the game in another group. But if |
| 862 |
you mix two games you must first reset the |
| 863 |
position and the move counter to the end position of the old game |
| 864 |
before you can continue it. This is possible with |
| 865 |
\cs{resumechessgame}\keyoarg. You can use |
| 866 |
\cs{chessboard}-keys in the optional argument but all the keys |
| 867 |
that tries to change the position will have no effect. It is also |
| 868 |
not possible to store the new moves under a new game identification or |
| 869 |
to renumber the moves. |
| 870 |
|
| 871 |
The command accepts the following additional keys in the optional |
| 872 |
argument: |
| 873 |
|
| 874 |
\begin{description} |
| 875 |
\item[\key{id=}\meta{GameId}] |
| 876 |
\index{resumechessgame=\verb!*+\resumechessgame+>id (key)}% |
| 877 |
\index{id (\texttt{\textbackslash resumechessgame} key)}% |
| 878 |
This key identifies the game that should be continued (as a |
| 879 |
default the currently active identification is used). The key |
| 880 |
changes \meta{GameId} globally! |
| 881 |
|
| 882 |
|
| 883 |
\item[\key{movenr=}\meta{number}, \key{player=}\meta{«w» or «b»}, \key{moveid}\meta{number + «w» or «b»}] |
| 884 |
\index{resumechessgame=\verb!*+\resumechessgame+>movenr (key)}% |
| 885 |
\index{movenr (\texttt{\textbackslash resumechessgame} key)}% |
| 886 |
\index{resumechessgame=\verb!*+\resumechessgame+>player (key)}% |
| 887 |
\index{player (\texttt{\textbackslash resumechessgame} key)}% |
| 888 |
\index{resumechessgame=\verb!*+\resumechessgame+>moveid (key)}% |
| 889 |
\index{moveid (\texttt{\textbackslash resumechessgame} key)}% |
| 890 |
This keys set the move from which on the game should be |
| 891 |
restarted. With the keys it is possible to go back and then |
| 892 |
continue the game along another variation (in this case the moves |
| 893 |
of the first variation will be lost). |
| 894 |
The values describes the \emph{next} move that means the position \emph{before} the move is |
| 895 |
used. |
| 896 |
As a default \cs{resumechessgame} continues the game. |
| 897 |
|
| 898 |
\begin{LTXexample}[width=0.5\textwidth,preset=\parskip1ex] |
| 899 |
\newchessgame[id=main] |
| 900 |
\mainline{1. e4 e5 2. Nf3 Nc6 3. Bb5} |
| 901 |
|
| 902 |
That reminds me another game |
| 903 |
some years ago where I played |
| 904 |
\newchessgame[id=exkurs] |
| 905 |
\mainline{1. d4 Nf6 2. c4 e6} |
| 906 |
\ldots\ lots of text \ldots\ |
| 907 |
|
| 908 |
Let's continue the second game with -- |
| 909 |
as a reminder -- the last move of |
| 910 |
black |
| 911 |
\resumechessgame[id=exkurs,moveid=2b]% |
| 912 |
\mainline{2... e6 3. Nc3} |
| 913 |
|
| 914 |
Let us now go back to the first game\\ |
| 915 |
\resumechessgame[id=main,print, |
| 916 |
tinyboard,showmover]% |
| 917 |
\mainline{3... a6} |
| 918 |
\end{LTXexample} |
| 919 |
|
| 920 |
\item[\key{newvar=}\meta{GameId}] |
| 921 |
\index{resumechessgame=\verb!*+\resumechessgame+>newvar (key)}% |
| 922 |
\index{newvar (\texttt{\textbackslash resumechessgame} key)}% |
| 923 |
|
| 924 |
This key moves you one halfmove back. |
| 925 |
This can be used to write down a lot of variations. With the |
| 926 |
(optional) value of the key you set the \meta{GameId}. If you don't |
| 927 |
give a value the current meaning of \meta{GameId} is used. |
| 928 |
|
| 929 |
\begin{LTXexample}[width=0.5\textwidth,preset=\parskip1ex] |
| 930 |
\newchessgame[id=main] |
| 931 |
\mainline{1. e4 e5 2. Nf3 Nc6 3. Bb5} |
| 932 |
|
| 933 |
|
| 934 |
\newchessgame[id=exkurs] |
| 935 |
\mainline{1. d4 Nf6 2. c4 e6} |
| 936 |
|
| 937 |
\resumechessgame[newvar=main] |
| 938 |
\mainline{3. Bc4} |
| 939 |
|
| 940 |
|
| 941 |
\resumechessgame[newvar] |
| 942 |
\mainline{3. Nc3} |
| 943 |
\chessboard |
| 944 |
|
| 945 |
\xskakset{id=exkurs} |
| 946 |
\resumechessgame[newvar] |
| 947 |
\mainline{2... c5} |
| 948 |
\chessboard |
| 949 |
|
| 950 |
\end{LTXexample} |
| 951 |
|
| 952 |
\item[\key{ref\ldots=}\meta{tag}] |
| 953 |
The \meta{GameId} and start move can also be set with this keys which |
| 954 |
use values saved with a \key{tag}. The keys are described in section |
| 955 |
\ref{sec:labeling}. |
| 956 |
|
| 957 |
\end{description} |
| 958 |
|
| 959 |
\subsection{The stored information} |
| 960 |
|
| 961 |
The following lists describes all the types of information stored |
| 962 |
during the parsing of a game. As you will see some data are stored |
| 963 |
more than once with only slight differences. I did it because it is |
| 964 |
easier to store the redundant data than to have to convert them |
| 965 |
later. |
| 966 |
|
| 967 |
There are also commands which contains the \meta{GameId} and the |
| 968 |
\meta{MoveId}. That looks a bit senseless as you need to know this |
| 969 |
values to be able to retrieve them but they allow easy access to the |
| 970 |
values without having to know or use the internal command names. |
| 971 |
|
| 972 |
|
| 973 |
\subsubsection{Essential game related information} |
| 974 |
|
| 975 |
\begin{description} |
| 976 |
|
| 977 |
\item[\textbackslash Xskak\meta{GameId}initfen]% |
| 978 |
\index{game data >Xskakinitfen=\textbackslash Xskak\meta{GameId}initfen}% |
| 979 |
\index{Xskakinitfen=\textbackslash Xskak\meta{GameId}initfen}% |
| 980 |
The position before the first move. Set by \cs{newchessgame}. |
| 981 |
|
| 982 |
|
| 983 |
\item[\textbackslash Xskak\meta{GameId}initplayer]% |
| 984 |
\index{game data >Xskakinitplayer=\textbackslash Xskak\meta{GameId}initplayer}% |
| 985 |
\index{Xskakinitplayer=\textbackslash Xskak\meta{GameId}initplayer}% |
| 986 |
«w» or «b». The color of the next (first) player, (must be identical |
| 987 |
to the color in the initfen). Also set by \cs{newchessgame}. |
| 988 |
|
| 989 |
\item[\textbackslash Xskak\meta{GameId}initmovenr]% |
| 990 |
\index{game data >Xskakinitmovenr=\textbackslash Xskak\meta{GameId}initmovenr}% |
| 991 |
\index{Xskakinitmovenr=\textbackslash Xskak\meta{GameId}initmovenr}% |
| 992 |
The number of the first move (must be identical to the fullmove |
| 993 |
number in the initfen). Also set by \cs{newchessgame}. |
| 994 |
|
| 995 |
\item[\textbackslash Xskak\meta{GameId}initmoveid]% |
| 996 |
\index{game data >Xskakinitmoveid=\textbackslash Xskak\meta{GameId}initmoveid}% |
| 997 |
\index{Xskakinitmoveid=\textbackslash Xskak\meta{GameId}initmoveid}% |
| 998 |
Combination of \key{initmovenr} and \key{initplayer}. |
| 999 |
|
| 1000 |
\begin{LTXexample} |
| 1001 |
\newchessgame[id=show, |
| 1002 |
setfen=2K/k/7R, |
| 1003 |
moveid=10b, |
| 1004 |
print] |
| 1005 |
|
| 1006 |
\mbox{\xskakgetgame{initfen}},\\ |
| 1007 |
\xskakgetgame{initplayer}, |
| 1008 |
\xskakgetgame{initmovenr}, |
| 1009 |
\xskakgetgame{initmoveid} |
| 1010 |
\end{LTXexample} |
| 1011 |
|
| 1012 |
|
| 1013 |
|
| 1014 |
\item[\textbackslash Xskak\meta{GameId}lastfen]% |
| 1015 |
\index{game data >Xskaklastfen=\textbackslash Xskak\meta{GameId}lastfen}% |
| 1016 |
\index{Xskaklastfen=\textbackslash Xskak\meta{GameId}lastfen}% |
| 1017 |
The fen \emph{after} the last move, set during parsing. |
| 1018 |
|
| 1019 |
\item[\textbackslash Xskak\meta{GameId}lastplayer]% |
| 1020 |
\index{game data >Xskaklastplayer=\textbackslash Xskak\meta{GameId}lastplayer}% |
| 1021 |
\index{Xskaklastplayer=\textbackslash Xskak\meta{GameId}lastplayer}% |
| 1022 |
«w» or «b». The player which made the last move, set by |
| 1023 |
\cs{newchessgame}, by \cs{resumechessgame} and during |
| 1024 |
parsing. Identical to color in the fen \emph{before} the last |
| 1025 |
move! \emph{Not} identical to the color in {\texttt\textbackslash |
| 1026 |
Xskak\meta{GameId}lastfen}! |
| 1027 |
|
| 1028 |
\item[\textbackslash Xskak\meta{GameId}lastmovenr]% |
| 1029 |
\index{game data >Xskaklastmovenr=\textbackslash Xskak\meta{GameId}lastmovenr}% |
| 1030 |
\index{Xskaklastmovenr=\textbackslash Xskak\meta{GameId}lastmovenr}% |
| 1031 |
The number of the last move, set during parsing. Identical to |
| 1032 |
fullmove in the fen \emph{before} the last move! \emph{Not} |
| 1033 |
necessarily identical to the number in {\texttt\textbackslash |
| 1034 |
Xskak\meta{GameId}lastfen}! |
| 1035 |
|
| 1036 |
\item[\textbackslash Xskak\meta{GameId}lastmoveid]% |
| 1037 |
\index{game data >Xskaklastmoveid=\textbackslash Xskak\meta{GameId}lastmoveid}% |
| 1038 |
\index{Xskaklastmoveid=\textbackslash Xskak\meta{GameId}lastmoveid}% |
| 1039 |
Combination of \key{lastmovenr} and \key{lastplayer}. |
| 1040 |
|
| 1041 |
\begin{LTXexample} |
| 1042 |
\newchessgame[id=show, |
| 1043 |
setfen=2K/k/7R, |
| 1044 |
castling={}, |
| 1045 |
% sets correct castling in the FEN |
| 1046 |
moveid=10b] |
| 1047 |
\mainline{10... Ka8} |
| 1048 |
|
| 1049 |
\chessboard |
| 1050 |
|
| 1051 |
\mbox{\xskakgetgame{lastfen}},\\ |
| 1052 |
\xskakgetgame{lastplayer}, |
| 1053 |
\xskakgetgame{lastmovenr}, |
| 1054 |
\xskakgetgame{lastmoveid} |
| 1055 |
\end{LTXexample} |
| 1056 |
|
| 1057 |
|
| 1058 |
\item[\textbackslash Xskak\meta{GameId}nextplayer]% |
| 1059 |
\index{game data >Xskaknextplayer=\textbackslash Xskak\meta{GameId}nextplayer}% |
| 1060 |
\index{Xskaknextplayer=\textbackslash Xskak\meta{GameId}nextplayer}% |
| 1061 |
«w» or «b». The player which will make the next move, set by |
| 1062 |
\cs{newchessgame}, by \cs{resumechessgame} and during parsing. |
| 1063 |
Identical to the color in {\texttt\textbackslash Xskak\meta{GameId}lastfen}. |
| 1064 |
|
| 1065 |
\item[\textbackslash Xskak\meta{GameId}nextmovenr]% |
| 1066 |
\index{game data >Xskaknextmovenr=\textbackslash Xskak\meta{GameId}nextmovenr}% |
| 1067 |
\index{Xskaknextmovenr=\textbackslash Xskak\meta{GameId}nextmovenr}% |
| 1068 |
The number of the next move, set during parsing. Identical to |
| 1069 |
fullmove in {\texttt\textbackslash Xskak\meta{GameId}lastfen}. |
| 1070 |
|
| 1071 |
\item[\textbackslash Xskak\meta{GameId}nextmoveid]% |
| 1072 |
\index{game data >Xskaknextmoveid=\textbackslash Xskak\meta{GameId}nextmoveid}% |
| 1073 |
\index{Xskaknextmoveid=\textbackslash Xskak\meta{GameId}nextmoveid}% |
| 1074 |
Combination of \key{nextmovenr} and \key{nextplayer}. |
| 1075 |
|
| 1076 |
\begin{LTXexample}[width=0.5\textwidth] |
| 1077 |
\newchessgame[id=show, |
| 1078 |
setfen=2K/k/7R, |
| 1079 |
moveid=10b] |
| 1080 |
\mainline{10... Ka8} |
| 1081 |
|
| 1082 |
\chessboard |
| 1083 |
|
| 1084 |
\xskakgetgame{nextplayer}, |
| 1085 |
\xskakgetgame{nextmovenr}, |
| 1086 |
\xskakgetgame{nextmoveid} |
| 1087 |
\end{LTXexample} |
| 1088 |
|
| 1089 |
|
| 1090 |
\item[\textbackslash Xskak\meta{GameId}diagramlist]% |
| 1091 |
\index{game data >Xskakdiagramlist=\textbackslash Xskak\meta{GameId}diagramlist}% |
| 1092 |
\index{Xskakdiagramlist=\textbackslash Xskak\meta{GameId}diagramlist}% |
| 1093 |
A comma separated list of moves (a combination of movenr and |
| 1094 |
player), (e.g. 3b,20w). Records the moves with an \$d or \$D |
| 1095 |
after the move. See section \ref{sec:diagrams}. |
| 1096 |
|
| 1097 |
|
| 1098 |
\item[\textbackslash Xskak\meta{GameId}gameid]% |
| 1099 |
\index{game data >Xskakgameid=\textbackslash Xskak\meta{GameId}gameid}% |
| 1100 |
\index{Xskakgameid=\textbackslash Xskak\meta{GameId}gameid}% |
| 1101 |
This command holds the game identification (the value is equal to the value of \meta{GameId}). |
| 1102 |
|
| 1103 |
\begin{LTXexample} |
| 1104 |
\newchessgame[id=game\arabic{section}] |
| 1105 |
The id of the current game is \xskakgetgame{gameid} |
| 1106 |
\end{LTXexample} |
| 1107 |
|
| 1108 |
|
| 1109 |
\end{description} |
| 1110 |
|
| 1111 |
|
| 1112 |
\subsubsection{Optional game information: PGN-infos} |
| 1113 |
|
| 1114 |
\DescribeMacro{\xskaknewpgninfo}% |
| 1115 |
The following commands store various optional information which are |
| 1116 |
normally stored in the so-called PGN-infos. You can set them in |
| 1117 |
\cs{newchessgame} and retrieve them later. New PGN-infos can be |
| 1118 |
defined with the \cs{xskaknewpgninfo}\oarg{default}\marg{name}. With |
| 1119 |
the exception of «result» all currently defined commands are empty |
| 1120 |
by default. |
| 1121 |
|
| 1122 |
\begin{description} |
| 1123 |
\item[\textbackslash Xskak\meta{GameId}result]% |
| 1124 |
\index{PGN-info data >Xskakresult=\textbackslash Xskak\meta{GameId}result}% |
| 1125 |
\index{Xskakresult=\textbackslash Xskak\meta{GameId}result}% |
| 1126 |
Default is \verb+*+, value should be 1-0, or 1/2-1/2, 0-1 or |
| 1127 |
something like that. |
| 1128 |
|
| 1129 |
\item[\textbackslash Xskak\meta{GameId}white]% |
| 1130 |
\index{PGN-info data >Xskakwhite=\textbackslash Xskak\meta{GameId}white}% |
| 1131 |
\index{Xskakwhite=\textbackslash Xskak\meta{GameId}white}% |
| 1132 |
The name of the white player. |
| 1133 |
|
| 1134 |
\item[\textbackslash Xskak\meta{GameId}black]% |
| 1135 |
\index{PGN-info data >Xskakblack=\textbackslash Xskak\meta{GameId}black}% |
| 1136 |
\index{Xskakblack=\textbackslash Xskak\meta{GameId}black}% |
| 1137 |
The name of the black player. |
| 1138 |
|
| 1139 |
|
| 1140 |
\item[\textbackslash Xskak\meta{GameId}whiteelo]% |
| 1141 |
\index{PGN-info data >Xskakwhiteelo=\textbackslash Xskak\meta{GameId}whiteelo}% |
| 1142 |
\index{Xskakwhiteelo=\textbackslash Xskak\meta{GameId}whiteelo}% |
| 1143 |
The elo of the white player. |
| 1144 |
|
| 1145 |
\item[\textbackslash Xskak\meta{GameId}blackelo]% |
| 1146 |
\index{PGN-info data >Xskakblackelo=\textbackslash Xskak\meta{GameId}blackelo}% |
| 1147 |
\index{Xskakblackelo=\textbackslash Xskak\meta{GameId}blackelo}% |
| 1148 |
The elo of the black player. |
| 1149 |
|
| 1150 |
|
| 1151 |
\item[\textbackslash Xskak\meta{GameId}site]% |
| 1152 |
\index{PGN-info data >Xskaksite=\textbackslash Xskak\meta{GameId}site}% |
| 1153 |
\index{Xskaksite=\textbackslash Xskak\meta{GameId}site}% |
| 1154 |
The site of the tournament. |
| 1155 |
|
| 1156 |
\item[\textbackslash Xskak\meta{GameId}event]% |
| 1157 |
\index{PGN-info data >Xskakevent=\textbackslash Xskak\meta{GameId}event}% |
| 1158 |
\index{Xskakevent=\textbackslash Xskak\meta{GameId}event}% |
| 1159 |
The name of the tournament. |
| 1160 |
|
| 1161 |
|
| 1162 |
|
| 1163 |
\item[\textbackslash Xskak\meta{GameId}date]% |
| 1164 |
\index{PGN-info data >Xskakdate=\textbackslash Xskak\meta{GameId}date}% |
| 1165 |
\index{Xskakdate=\textbackslash Xskak\meta{GameId}date}% |
| 1166 |
The date of the game. |
| 1167 |
|
| 1168 |
\item[\textbackslash Xskak\meta{GameId}round]% |
| 1169 |
\index{PGN-info data >Xskakround=\textbackslash Xskak\meta{GameId}round}% |
| 1170 |
\index{Xskakround=\textbackslash Xskak\meta{GameId}round}% |
| 1171 |
The round of game. |
| 1172 |
|
| 1173 |
\end{description} |
| 1174 |
|
| 1175 |
\subsubsection{The move related data}\label{sec:movedata} |
| 1176 |
|
| 1177 |
The move data are stored during the parsing of a game with |
| 1178 |
\cs{mainline} and/or \cs{hidemoves}. You can split the game in as |
| 1179 |
much pieces as you want but {\bfseries you must start a game with |
| 1180 |
\cs{newchessgame} and you must use the same game identification for |
| 1181 |
each piece} if you don't want to end with broken games. |
| 1182 |
|
| 1183 |
All values depends on the parsing from \skaksty which in turn depends |
| 1184 |
heavily on the correct input: \skaksty knows a bit about the position |
| 1185 |
of the game (it needs it e.g. to find out where a piece came from) |
| 1186 |
but doesn't analyze it thoroughly. The main work is done by analyzing |
| 1187 |
the \emph{notation} e.g. \skaksty will recognize a check by the |
| 1188 |
+-sign. Quite often \skaksty doesn't recognize illegal moves or wrong |
| 1189 |
input syntax (e.g. \texttt{0-0} for casting instead the correct |
| 1190 |
\texttt{O-O}) but fails some moves later or shows a wrong position: |
| 1191 |
|
| 1192 |
\begin{LTXexample} |
| 1193 |
\newchessgame |
| 1194 |
\mainline{1.d4 e5 2.Bc4} |
| 1195 |
\chessboard |
| 1196 |
\end{LTXexample} |
| 1197 |
|
| 1198 |
\paragraph{Piece data} |
| 1199 |
|
| 1200 |
The following types store the piece which was moved and the piece |
| 1201 |
that was perhaps captured. The variants differ in the storing of |
| 1202 |
black pieces and pawns: |
| 1203 |
|
| 1204 |
\begin{description} |
| 1205 |
\item[pgnpiece] |
| 1206 |
\index{Move data >pgnpiece}% |
| 1207 |
\index{pgnpiece (move data type)}% |
| 1208 |
K,Q,R,B or N. Is empty for pawn and |
| 1209 |
castling moves. |
| 1210 |
|
| 1211 |
\item[piecechar] |
| 1212 |
\index{Move data >piecechar}% |
| 1213 |
\index{piecechar (move data type)}% |
| 1214 |
K,Q,R,B,N or p. Is empty for castling. |
| 1215 |
|
| 1216 |
|
| 1217 |
\item[piece] |
| 1218 |
\index{Move data >piece}% |
| 1219 |
\index{piece (move data type)}% |
| 1220 |
K,Q,R,B,N or P or k,q,r,b,n or p (for black). Is empty for castling. |
| 1221 |
|
| 1222 |
|
| 1223 |
\item[pgnlostpiece] |
| 1224 |
\index{Move data >pgnlostpiece}% |
| 1225 |
\index{pgnlostpiece (move data type)}% |
| 1226 |
In case of a capture move: K,Q,R,B, or N. |
| 1227 |
|
| 1228 |
\item[lostpiecechar] |
| 1229 |
\index{Move data >lostpiecechar}% |
| 1230 |
\index{lostpiecechar (move data type)}% |
| 1231 |
In case of a capture move: K,Q,R,B,N or p, empty |
| 1232 |
else. |
| 1233 |
|
| 1234 |
|
| 1235 |
\item[lostpiece] |
| 1236 |
\index{Move data >lostpiece}% |
| 1237 |
\index{lostpiece (move data type)}% |
| 1238 |
In case of a capture move it stores the lost piece as K,Q,R,B,N or P or |
| 1239 |
k,q,r,b,n or p. |
| 1240 |
|
| 1241 |
\end{description} |
| 1242 |
|
| 1243 |
|
| 1244 |
\paragraph{Move data} |
| 1245 |
|
| 1246 |
\begin{description} |
| 1247 |
\item[movefrom] |
| 1248 |
\index{Move data >movefrom}% |
| 1249 |
\index{movefrom (move data type)}% |
| 1250 |
The field were the piece came from. Two fields in case of castling moves e.g. «e1,h1». |
| 1251 |
|
| 1252 |
\item[pgnmovefrom] |
| 1253 |
\index{Move data >pgnmovefrom}% |
| 1254 |
\index{pgnmovefrom (move data type)}% |
| 1255 |
This contains the additional «movefrom» information in the PGN |
| 1256 |
for ambiguous moves or pawn captures. |
| 1257 |
E.g. In case of \wmove{exd5} the value is |
| 1258 |
«e», in case of \wmove{Nbd2} it is «b». |
| 1259 |
|
| 1260 |
\item[moveto] |
| 1261 |
\index{Move data >moveto}% |
| 1262 |
\index{moveto (move data type)}% |
| 1263 |
The field were the piece move to. Two fields in case of castling moves e.g. «g1,f1». |
| 1264 |
|
| 1265 |
\item[enpassant] |
| 1266 |
\index{Move data >enpassant}% |
| 1267 |
\index{enpassant (move data type)}% |
| 1268 |
Sets the boolean \texttt{xskakboolenpassant} to true if the move |
| 1269 |
was an enpassant capture. |
| 1270 |
|
| 1271 |
\item[enpassantsquare] |
| 1272 |
\index{Move data >enpassantsquare}% |
| 1273 |
\index{enpassantsquare (move data type)}% |
| 1274 |
A field, after e.g. e4 the value is e3. Indicates if the next |
| 1275 |
pawn move can be an enpassant capture. |
| 1276 |
|
| 1277 |
\begin{LTXexample} |
| 1278 |
\newchessgame[restorefen=example] |
| 1279 |
\mainline{1. a4 h5} |
| 1280 |
\chessboard[lastmoveid, |
| 1281 |
pgfstyle=border, |
| 1282 |
color=red, |
| 1283 |
markfield=\xskakget{enpassantsquare}, |
| 1284 |
moveid=1w, color=blue, |
| 1285 |
markfield=\xskakget{enpassantsquare}] |
| 1286 |
\end{LTXexample} |
| 1287 |
|
| 1288 |
\item[castling] |
| 1289 |
\index{Move data >castling}% |
| 1290 |
\index{castling (move data type)}% |
| 1291 |
Sets the boolean \texttt{xskakboolcastling}, is true for short |
| 1292 |
*and* long castling! |
| 1293 |
|
| 1294 |
|
| 1295 |
\item[longcastling] |
| 1296 |
\index{Move data >longcastling}% |
| 1297 |
\index{longcastling (move data type)}% |
| 1298 |
Sets the boolean \texttt{xskakboollongcastling}. |
| 1299 |
|
| 1300 |
\item[capture] |
| 1301 |
\index{Move data >capture}% |
| 1302 |
\index{capture (move data type)}% |
| 1303 |
Sets the boolean \texttt{xskakboolcapture}. |
| 1304 |
|
| 1305 |
|
| 1306 |
\item[promotion] |
| 1307 |
\index{Move data >promotion}% |
| 1308 |
\index{promotion (move data type)}% |
| 1309 |
Sets the boolean \texttt{xskakboolpromotion}. |
| 1310 |
|
| 1311 |
|
| 1312 |
\item[promotionpiece] |
| 1313 |
\index{Move data >promotionpiece}% |
| 1314 |
\index{promotionpiece (move data type)}% |
| 1315 |
Q,R,B or N or q,r,b or n or empty. |
| 1316 |
|
| 1317 |
\item[promotionpiecechar] |
| 1318 |
\index{Move data >promotionpiecechar}% |
| 1319 |
\index{promotionpiecechar (move data type)}% |
| 1320 |
Q,R,B or N or empty. |
| 1321 |
|
| 1322 |
\begin{LTXexample} |
| 1323 |
\newcommand\testpromotion{% |
| 1324 |
\xskakget{promotion}% |
| 1325 |
\ifthenelse{\boolean{xskakboolpromotion}} |
| 1326 |
{A pawn promoted to |
| 1327 |
\figsymbol{\xskakget{promotionpiecechar}}} |
| 1328 |
{No promotion in this move}} |
| 1329 |
\newchessgame[restorefen=example] |
| 1330 |
\mainline{1. c8=Q+ Ke7} |
| 1331 |
|
| 1332 |
\xskakset{moveid=1w} |
| 1333 |
\testpromotion |
| 1334 |
|
| 1335 |
\xskakset{moveid=1b} |
| 1336 |
\testpromotion |
| 1337 |
\end{LTXexample} |
| 1338 |
|
| 1339 |
|
| 1340 |
\end{description} |
| 1341 |
|
| 1342 |
\paragraph{Other data/combinations} |
| 1343 |
|
| 1344 |
\begin{description} |
| 1345 |
\item[addpieces] |
| 1346 |
\index{Move data >addpieces}% |
| 1347 |
\index{addpieces (move data type)}% |
| 1348 |
contains the (list of) piece(s) that should be put on the |
| 1349 |
board.\\ E.g. \verb+{kg8,rf8}+ in case of black short castling. |
| 1350 |
|
| 1351 |
\item[clearfields] |
| 1352 |
\index{Move data >clearfields}% |
| 1353 |
\index{clearfields (move data type)}% |
| 1354 |
The list of fields that should be emptied on the board (equal |
| 1355 |
to the movefrom field with the exception of enpassant moves). |
| 1356 |
|
| 1357 |
\item[nextfen] |
| 1358 |
\index{Move data >nextfen}% |
| 1359 |
\index{nextfen (move data type)}% |
| 1360 |
The fen position \emph{after} the current move. |
| 1361 |
|
| 1362 |
\item[pastfen] |
| 1363 |
\index{Move data >pastfen}% |
| 1364 |
\index{pastfen (move data type)}% |
| 1365 |
The fen position \emph{before} the current move (identical to |
| 1366 |
the fen \emph{after} the previous move). |
| 1367 |
|
| 1368 |
\item[san] |
| 1369 |
\index{Move data >san}% |
| 1370 |
\index{san (move data type)}% |
| 1371 |
The standard algebraic notation of the move. It use chess |
| 1372 |
commands: E.g. |
| 1373 |
\\\verb+\textsymfigsymbol{R}a2+ for \textsymfigsymbol{R}a2 |
| 1374 |
\\\verb+e\capturesymbol d5+ for e\capturesymbol d5, |
| 1375 |
\\\verb+\castlingchar\castlinghyphen\castlingchar+ for |
| 1376 |
\castlingchar\castlinghyphen\castlingchar\\ |
| 1377 |
It contains also the signs for chess and mate, but not the |
| 1378 |
comments. |
| 1379 |
|
| 1380 |
\item[lan] |
| 1381 |
\index{Move data >lan}% |
| 1382 |
\index{lan (move data type)}% |
| 1383 |
Long algebraic notation of the move, similar to \texttt{san}. |
| 1384 |
|
| 1385 |
\medskip |
| 1386 |
\begin{LTXexample}[varwidth=false,width=0.3\textwidth] |
| 1387 |
\newchessgame |
| 1388 |
\mainline{1.f3 e5 2. g4?? Qh4+#!} |
| 1389 |
|
| 1390 |
\xskakset{moveid=2w}% |
| 1391 |
\xskakget{san}, \xskakget{lan} |
| 1392 |
|
| 1393 |
\xskakset{moveid=2b}% |
| 1394 |
\xskakget{san}, \xskakget{lan} |
| 1395 |
\end{LTXexample} |
| 1396 |
|
| 1397 |
|
| 1398 |
|
| 1399 |
\item[opennr] |
| 1400 |
\index{Move data >opennr}% |
| 1401 |
\index{opennr (move data type)}% |
| 1402 |
This contains the code to print the number like \skaksty would do |
| 1403 |
it if you start or continue a game with this move. The style must be set independantly either with |
| 1404 |
a \cs{styleX} of \packagename{skak} or -- if you use the new interface of |
| 1405 |
\packagename{xskak} to set a style -- with \cs{xskakset} and \cs{mainlinestyle} or \cs{variationstyle}. |
| 1406 |
|
| 1407 |
\medskip |
| 1408 |
\begin{LTXexample}[varwidth=false,width=0.3\textwidth] |
| 1409 |
\newchessgame |
| 1410 |
\mainline{1.e4 e5} |
| 1411 |
|
| 1412 |
\xskakset{moveid=1w}% |
| 1413 |
\xskakget{opennr}\xskakget{lan}, |
| 1414 |
{\styleB\mainlinestyle |
| 1415 |
\xskakget{opennr}\xskakget{lan}} |
| 1416 |
|
| 1417 |
|
| 1418 |
\xskakset{moveid=1b}% |
| 1419 |
\xskakget{opennr}\xskakget{lan} |
| 1420 |
\xskakset{style=styleA,level=1} |
| 1421 |
{\mainlinestyle |
| 1422 |
\xskakget{opennr}\xskakget{lan}} |
| 1423 |
|
| 1424 |
\xskakset{style=UF}%return to my style |
| 1425 |
\end{LTXexample} |
| 1426 |
|
| 1427 |
\item[comments]% |
| 1428 |
\index{Move data >comments}% |
| 1429 |
\index{comments (move data type)}% |
| 1430 |
contains the short comments after a move (!,? \withattack{} etc) |
| 1431 |
|
| 1432 |
\medskip |
| 1433 |
\begin{LTXexample}[varwidth=false,width=0.3\textwidth] |
| 1434 |
\newchessgame |
| 1435 |
\mainline{1.f3 e5 2. g4?? Qh4+#!} |
| 1436 |
|
| 1437 |
\xskakset{moveid=2w}% |
| 1438 |
\xskakget{comments} |
| 1439 |
|
| 1440 |
\xskakset{moveid=2b}% |
| 1441 |
\xskakget{comments} |
| 1442 |
\end{LTXexample} |
| 1443 |
|
| 1444 |
|
| 1445 |
\item[nag] |
| 1446 |
\index{Move data >nag}% |
| 1447 |
\index{nag (move data type)} |
| 1448 |
NAG's and comments inputed with \cs{xskakcomment}. |
| 1449 |
|
| 1450 |
\begin{LTXexample}[varwidth=false,width=0.3\textwidth] |
| 1451 |
\newchessgame |
| 1452 |
\mainline{1.f3 e5 2. g4 |
| 1453 |
$4 \xskakcomment{ Why this? } Qh4+#!} |
| 1454 |
|
| 1455 |
\xskakset{moveid=2w}% |
| 1456 |
\xskakget{nag} |
| 1457 |
\end{LTXexample} |
| 1458 |
|
| 1459 |
\end{description} |
| 1460 |
|
| 1461 |
\subsection{Exporting the games} |
| 1462 |
|
| 1463 |
\DescribeMacro{\xskakexportgames}% |
| 1464 |
With \cs{xskakexportgames}\keyoarg{} you can export games to a file. |
| 1465 |
As default the command exports the game data of the game with the |
| 1466 |
default \meta{GameId} to the file \texttt{xskakgames.xsk}\footnote{I |
| 1467 |
didn't find any other application that use this extension. So I think |
| 1468 |
it is quite safe.}. |
| 1469 |
|
| 1470 |
The command accept the following keys: |
| 1471 |
\begin{description} |
| 1472 |
\item[\key{file=}\meta{string}] |
| 1473 |
\index{xskakexportgames=\verb!*+\xskakexportgames+>file (key)}% |
| 1474 |
\index{file (\texttt{\textbackslash xskakexportgames} key)} |
| 1475 |
This changes the name of the file. The extension can not be changed. |
| 1476 |
\item[\key{games=\{}\meta{comma separated list of games}\texttt{\}}] |
| 1477 |
\index{xskakexportgames=\verb!*+\xskakexportgames+>games (key)}% |
| 1478 |
\index{games (\texttt{\textbackslash xskakexportgames} key)}% |
| 1479 |
With this key you can chose the games that should be exported. |
| 1480 |
\end{description} |
| 1481 |
|
| 1482 |
|
| 1483 |
You can then input the games in other document and use there the game |
| 1484 |
data without have to do all the parsing with \cs{mainline} again |
| 1485 |
(which can be quite slow). The export file is also quite handy to |
| 1486 |
debug the game parsing and saving. |
| 1487 |
|
| 1488 |
As an example I exported in another document the following two games |
| 1489 |
which I will use later in this documentation: |
| 1490 |
|
| 1491 |
\begin{lstlisting} |
| 1492 |
\newchessgame[id=export,white=Deep Blue, black=Kasparov,result=1-0] |
| 1493 |
\mainline{1.e4 c6 2.d4 d5 3.Nc3 dxe4 4.Nxe4 Nd7 5.Ng5 Ngf6 6.Bd3 e6 |
| 1494 |
7.N1f3 h6 8.Nxe6 Qe7 9.O-O fxe6 10.Bg6+ Kd8 \xskakcomment{Kasparov |
| 1495 |
schüttelt kurz den Kopf} 11.Bf4 b5 12.a4 Bb7 13.Re1 Nd5 14.Bg3 Kc8 |
| 1496 |
15.axb5 cxb5 16.Qd3 Bc6 17.Bf5 exf5 18.Rxe7 Bxe7 19.c4} |
| 1497 |
|
| 1498 |
\newchessgame[white=none,black=none,id=exportb] |
| 1499 |
\mainline{1. e4 e5} |
| 1500 |
|
| 1501 |
\xskakexportgames[games={export,exportb}] |
| 1502 |
\end{lstlisting} |
| 1503 |
|
| 1504 |
\DescribeMacro{\xskakendgamedata}% |
| 1505 |
\DescribeMacro{\xskakcurrentgameid}% |
| 1506 |
The export consists more or less of a long list of definitions with |
| 1507 |
one notable exception: At the end of each game there is the command |
| 1508 |
\cs{xskakendgamedata}. As a default the command does nothing but if |
| 1509 |
you redefine it e.g. to \cs{printchessgame} (see section |
| 1510 |
\ref{sec:print}), it can be used to print all games during the input. |
| 1511 |
\cs{xskakcurrentgameid} holds the \meta{GameId} of the previous game. |
| 1512 |
|
| 1513 |
\begin{LTXexample} |
| 1514 |
\renewcommand\xskakendgamedata |
| 1515 |
{\xskakset{id=\xskakcurrentgameid}% |
| 1516 |
\xskakgetgame{white}--\xskakgetgame{black}: |
| 1517 |
\printchessgame[style=styleB,level=1] |
| 1518 |
\par\bigskip} |
| 1519 |
\input{xskakgames.xsk} |
| 1520 |
\end{LTXexample} |
| 1521 |
|
| 1522 |
|
| 1523 |
|
| 1524 |
\subsection{The inner technique: how the data are stored} |
| 1525 |
|
| 1526 |
The game related data are stored in commands with names of |
| 1527 |
the following structure:\\[0.5ex] |
| 1528 |
% |
| 1529 |
\indent{\ttfamily Xskak\meta{GameId}\meta{type of Information}}\\[0.5ex] |
| 1530 |
% |
| 1531 |
If \meta{GameId} is a simple string of characters you can use the |
| 1532 |
command by putting a backslash before the name, in other case you |
| 1533 |
will have to use \cs{csname}\ldots\cs{endcsname}. |
| 1534 |
|
| 1535 |
The move related data are stored in commands with names that |
| 1536 |
have the following structure:\\[0.5ex] |
| 1537 |
{\ttfamily Xskak.\meta{GameId}.\meta{movenr}.\meta{player}.\meta{type |
| 1538 |
of Information}}\\[0.5ex] |
| 1539 |
As the names contain points and a number it is not possible to |
| 1540 |
execute the commands by putting a backslash before the name. If you |
| 1541 |
want to use them you will have to surround the name by |
| 1542 |
\cs{csname}\ldots\cs{endcsname} |
| 1543 |
-- something that probably will not be necessary in normal cases as |
| 1544 |
there are user commands that allows «normal» access. |
| 1545 |
|
| 1546 |
During storing the data \meta{movenr} and \meta{player} are taken |
| 1547 |
from the current move as processed by \skaksty, that is |
| 1548 |
\verb+\mainline{15... Nf3}+ will store the data in \\{\ttfamily |
| 1549 |
Xskak.\meta{GameId}.15.b.\meta{type of Information}}. \\Renumbering |
| 1550 |
the moves during storing is not possible\footnote{But it would be |
| 1551 |
probably not difficult to implement. So if you need it badly, sent me |
| 1552 |
a feature request.}. |
| 1553 |
|
| 1554 |
Example \ref{ex:internal} on page \pageref{ex:internal} shows an |
| 1555 |
example that use the internal commands. As you can see, the |
| 1556 |
\cs{csname}--\cs{endcsname}-input is quite powerful: You can |
| 1557 |
construct a command with the help of other (expandable) commands or |
| 1558 |
use the value of counters. |
| 1559 |
|
| 1560 |
\minisec{Warning!} \verb+\csname whatever\endcsname+ doesn't give an |
| 1561 |
error if the command isn't defined. It simply defines \cs{whatever} |
| 1562 |
as \cs{relax} and then executes it. So it is easy to overlook typing |
| 1563 |
errors -- and then to wonder why one doesn't get the expected output. |
| 1564 |
|
| 1565 |
|
| 1566 |
\begin{LTXexample}[pos=t, |
| 1567 |
width=\textwidth, |
| 1568 |
float,caption=Using the internal commands, |
| 1569 |
label=ex:internal, |
| 1570 |
language=TeX, |
| 1571 |
texcs={mainline,figsymbol,xskakgameAlastmovenr, |
| 1572 |
xskakgameinitmovenr,xskakgameinitmovenr, |
| 1573 |
newchessgame,xskakgameinitmovenr,chessboard}, |
| 1574 |
texcsstyle=*\color{blue}, |
| 1575 |
texcs={[2]{ifthenelse,boolean,csname,endcsname,the,value,numexpr,relax}}, |
| 1576 |
texcsstyle={*[2]{\color{red}}}] |
| 1577 |
\begin{multicols}{2} |
| 1578 |
\minisec{Game 1}\newchessgame[id=gameA]% |
| 1579 |
\mainline{1. e4 e5 2. Nf3 Nc6 3. Bb5 Nf6 4. O-O Nxe4 5.Bxc6 bxc6} |
| 1580 |
|
| 1581 |
\minisec{Game 2}\newchessgame[id=game,restorefen=example,moveid=15w]% |
| 1582 |
\mainline{15. c8=Q+ Ke7 16. Rd1} |
| 1583 |
|
| 1584 |
\minisec{Comments}\setcounter{enumi}{1}% |
| 1585 |
In the first game, white moved at first a |
| 1586 |
\figsymbol{\csname Xskak.gameA.\the\value{enumi}.w.piecechar\endcsname}, |
| 1587 |
then a \figsymbol{% |
| 1588 |
\csname Xskak.gameA.\the\numexpr\the\value{enumi}+1\relax.w.piecechar\endcsname} |
| 1589 |
and a \figsymbol{% |
| 1590 |
\csname Xskak.gameA.\the\numexpr\the\value{enumi}+2\relax.w.piecechar\endcsname}. |
| 1591 |
In his last move black took a |
| 1592 |
\figsymbol{\csname Xskak.gameA.\XskakgameAlastmovenr.b.lostpiecechar\endcsname}, |
| 1593 |
white took a \figsymbol{\csname |
| 1594 |
Xskak.gameA.5.w.lostpiecechar\endcsname}. |
| 1595 |
|
| 1596 |
In the second game the second move of white was |
| 1597 |
\figsymbol{% |
| 1598 |
\csname Xskak.game.\the\numexpr \Xskakgameinitmovenr +1\relax.w.piece\endcsname}% |
| 1599 |
\csname Xskak.game.16.w.movefrom\endcsname--% |
| 1600 |
\csname Xskak.game.16.w.moveto\endcsname. |
| 1601 |
|
| 1602 |
The position in the first game after the third move of black was: |
| 1603 |
|
| 1604 |
\chessboard[tinyboard, setfen=\csname Xskak.gameA.3.b.nextfen\endcsname] |
| 1605 |
The fourth move of white was\csname |
| 1606 |
Xskak.gameA.4.w.castling\endcsname |
| 1607 |
\ifthenelse{\boolean{xskakboolcastling}}{}{not} a castling move. |
| 1608 |
\end{multicols} |
| 1609 |
\end{LTXexample} |
| 1610 |
|
| 1611 |
\clearpage |
| 1612 |
|
| 1613 |
|
| 1614 |
\section{Retrieving the stored information} |
| 1615 |
|
| 1616 |
\subsection{Setting the variables} |
| 1617 |
|
| 1618 |
\DescribeMacro{\xskakset}% |
| 1619 |
It should be clear that to retrieve the information you must tell |
| 1620 |
\packagename{xskak} the game and the move for which you want to get |
| 1621 |
data. This is done with \cs{xskakset}\keymarg{} which will set the |
| 1622 |
variables \meta{GameId} and/or \meta{MoveId} to the values listed in |
| 1623 |
the \keylist. |
| 1624 |
|
| 1625 |
Some possible\footnote{More keys are described later.} keys are: |
| 1626 |
\begin{description} |
| 1627 |
\item[\key{id=}\meta{name}] |
| 1628 |
\index{xskakset=\verb!*+\xskakset+>id (key)}% |
| 1629 |
\index{id (\texttt{\textbackslash xskakset} key)}% |
| 1630 |
The key will set/change globally the active game identification, the |
| 1631 |
\meta{GameId}. This will also affect the storing of the following |
| 1632 |
moves! So if you change the \meta{GameId} in the middle of the |
| 1633 |
parsing of a game, don't forget to reset it to the old value before |
| 1634 |
continuing! |
| 1635 |
|
| 1636 |
|
| 1637 |
\item[\key{movenr=}\meta{number}, \key{player=}\meta{«w» or «b»}, |
| 1638 |
\key{moveid=}\meta{number + «w» or «b»}] |
| 1639 |
\index{xskakset=\verb!*+\xskakset+>movenr (key)}% |
| 1640 |
\index{movenr (\texttt{\textbackslash xskakset} key)}% |
| 1641 |
\index{xskakset=\verb!*+\xskakset+>player (key)}% |
| 1642 |
\index{player (\texttt{\textbackslash xskakset} key)}% |
| 1643 |
\index{xskakset=\verb!*+\xskakset+>moveid (key)}% |
| 1644 |
\index{moveid (\texttt{\textbackslash xskakset} key)}% |
| 1645 |
The keys will set the move number and the player. The values are global but |
| 1646 |
the values of \key{movenr} and \key{player} are not expanded |
| 1647 |
directly while the value of \key{moveid} is. The keys change only |
| 1648 |
the internal commands that are used to retrieve information, the |
| 1649 |
move counter and the boolean of \cs{mainline} are not affected by this keys. |
| 1650 |
|
| 1651 |
\item[\key{stepmoveid=}\meta{number}] |
| 1652 |
\index{xskakset=\verb!*+\xskakset+>stepmoveid (key)}% |
| 1653 |
\index{stepmoveid (\texttt{\textbackslash xskakset} key)}% |
| 1654 |
\key{stepmoveid} picks up the current value of the move variables of |
| 1655 |
\packagename{xskak} and «adds» the given number of halfmoves. When no |
| 1656 |
number is given the value 1 is used and this gives the next move. |
| 1657 |
E.g. if the current move is \texttt{10w} and you use |
| 1658 |
\texttt{stepmoveid=3} then you get \texttt{11b}. Negative numbers can |
| 1659 |
be used, if this results in a move number smaller than 1, a warning |
| 1660 |
is given but not an error: This gives you the possibility e.g. in |
| 1661 |
loops to handle the case yourself. |
| 1662 |
|
| 1663 |
|
| 1664 |
|
| 1665 |
\item[\key{lastmoveid=}\meta{GameId}] |
| 1666 |
\index{xskakset=\verb!*+\xskakset+>lastmoveid (key)}% |
| 1667 |
\index{lastmoveid (\texttt{\textbackslash xskakset} key)}% |
| 1668 |
This key sets the \packagename{xskak} move identification |
| 1669 |
commands |
| 1670 |
to the number/color of the last move |
| 1671 |
of the game \meta{GameId}. \meta{GameId} is optional. |
| 1672 |
\texttt{lastmoveid=A} ist equivalent to |
| 1673 |
\texttt{id=A,lastmoveid}. |
| 1674 |
|
| 1675 |
|
| 1676 |
|
| 1677 |
|
| 1678 |
\item[\key{tag=}\meta{name}, \key{ref\ldots=}\meta{name}] |
| 1679 |
\index{xskakset=\verb!*+\xskakset+>tag (key)}% |
| 1680 |
\index{tag (\texttt{\textbackslash xskakset} key)}% |
| 1681 |
\index{xskakset=\verb!*+\xskakset+>refid (key)}% |
| 1682 |
\index{refid (\texttt{\textbackslash xskakset} key)}% |
| 1683 |
\index{xskakset=\verb!*+\xskakset+>refnextmoveid(key)}% |
| 1684 |
\index{refnextmoveid (\texttt{\textbackslash xskakset} key)}% |
| 1685 |
\index{xskakset=\verb!*+\xskakset+>refpastmoveid(key)}% |
| 1686 |
\index{refpastmoveid (\texttt{\textbackslash xskakset} key)}% |
| 1687 |
\index{xskakset=\verb!*+\xskakset+>refpastmovenr (key)}% |
| 1688 |
\index{refpastmovenr (\texttt{\textbackslash xskakset} key)}% |
| 1689 |
\index{xskakset=\verb!*+\xskakset+>refpastplayer (key)}% |
| 1690 |
\index{refpastplayer (\texttt{\textbackslash xskakset} key)}% |
| 1691 |
\index{xskakset=\verb!*+\xskakset+>refnextmovenr (key)}% |
| 1692 |
\index{refnextmovenr (\texttt{\textbackslash xskakset} key)}% |
| 1693 |
\index{xskakset=\verb!*+\xskakset+>refnextplayer (key)}% |
| 1694 |
\index{refnextplayer (\texttt{\textbackslash xskakset} key)}% |
| 1695 |
\index{xskakset=\verb!*+\xskakset+>refpast (key)}% |
| 1696 |
\index{refpast (\texttt{\textbackslash xskakset} key)}% |
| 1697 |
\index{xskakset=\verb!*+\xskakset+>refnext (key)}% |
| 1698 |
\index{refnext (\texttt{\textbackslash xskakset} key)}% |
| 1699 |
|
| 1700 |
|
| 1701 |
\key{tag} saves the current values of \meta{GameId} and the move in |
| 1702 |
internal commands. They can then later be retrieved by the keys of |
| 1703 |
type \key{ref}. |
| 1704 |
|
| 1705 |
For more information on the labeling and referencing see section |
| 1706 |
\ref{sec:labeling}. |
| 1707 |
|
| 1708 |
\item[\key{defaultid=}\meta{name}] |
| 1709 |
\index{xskakset=\verb!*+\xskakset+>defaultid (key)}% |
| 1710 |
\index{defaultid (\texttt{\textbackslash xskakset} key)}% |
| 1711 |
With this key you can change the default game identification. |
| 1712 |
The change is global. |
| 1713 |
|
| 1714 |
\begin{LTXexample} |
| 1715 |
\setcounter{gamecounter}{4} |
| 1716 |
\xskakset{defaultid=game\Alph{gamecounter}} |
| 1717 |
|
| 1718 |
\newchessgame[white=John] |
| 1719 |
\mainline{1. e4 e5} |
| 1720 |
|
| 1721 |
\stepcounter{gamecounter} |
| 1722 |
\newchessgame[white=Jack] |
| 1723 |
\mainline{1. d4 d5} |
| 1724 |
|
| 1725 |
The white players were \XskakgameDwhite\ and \XskakgameEwhite. |
| 1726 |
\end{LTXexample} |
| 1727 |
|
| 1728 |
|
| 1729 |
\item[\key{defaultmovenr=}\meta{number}, |
| 1730 |
\key{defaultplayer=}\meta{«w» or «b»},] |
| 1731 |
\item[\key{defaultmoveid=}\meta{number}\meta{«w» or «b»}] |
| 1732 |
\index{xskakset=\verb!*+\xskakset+>defaultmoveid (key)}% |
| 1733 |
\index{defaultmoveid (\texttt{\textbackslash xskakset} key)}% |
| 1734 |
\index{xskakset=\verb!*+\xskakset+>defaultmovenr (key)}% |
| 1735 |
\index{defaultmovenr (\texttt{\textbackslash xskakset} key)}% |
| 1736 |
\index{xskakset=\verb!*+\xskakset+>defaultplayer (key)}% |
| 1737 |
\index{defaultplayer (\texttt{\textbackslash xskakset} key)}% |
| 1738 |
With this keys you can change the default start move for the |
| 1739 |
subsequent games. The change is global. |
| 1740 |
|
| 1741 |
\item[\key{defaultfen=}\meta{FEN}] |
| 1742 |
\index{xskakset=\verb!*+\xskakset+>defaultfen (key)}% |
| 1743 |
\index{defaultfen (\texttt{\textbackslash xskakset} key)}% |
| 1744 |
As a default \cs{newchessgame} sets the start position to a new |
| 1745 |
game. You can change this default with this key. The change is |
| 1746 |
global. |
| 1747 |
|
| 1748 |
\end{description} |
| 1749 |
|
| 1750 |
|
| 1751 |
|
| 1752 |
\subsection{Getting the game information} |
| 1753 |
|
| 1754 |
\DescribeMacro{\xskakgetgame}% |
| 1755 |
With \cs{xskakgetgame}\marg{type} you can retrieve game data |
| 1756 |
for the currently active \meta{GameId} (which can be set/changed with |
| 1757 |
the commands \cs{newchessgame}, \cs{resumechessgame} and |
| 1758 |
\cs{xskakset}). |
| 1759 |
|
| 1760 |
\begin{LTXexample}[width=0.5\textwidth] |
| 1761 |
\newchessgame[id=A,white=John White, |
| 1762 |
black=Jack Black, |
| 1763 |
result=1--0] |
| 1764 |
\minisec{\xskakgetgame{white}-- |
| 1765 |
\xskakgetgame{black}} |
| 1766 |
\mainline{1.e4 e5 2.Bc4 Nc6 3. Qh5 Nf6 4.Qxf7#} |
| 1767 |
\mbox{\xskakgetgame{result}} |
| 1768 |
|
| 1769 |
|
| 1770 |
\newchessgame[id=B, |
| 1771 |
white=Harry Red, |
| 1772 |
black=Tom Green, |
| 1773 |
result=0--1, |
| 1774 |
setwhite={kd1}, |
| 1775 |
addblack={kd3,rc5}] |
| 1776 |
\chessboard[setfen={\xskakgetgame{initfen}}] |
| 1777 |
\minisec{\xskakgetgame{white} -- |
| 1778 |
\xskakgetgame{black}} |
| 1779 |
\mainline{1. Ke1 Rf5 2. Kd1 Rf1#} \mbox{\xskakgetgame{result}} |
| 1780 |
\end{LTXexample} |
| 1781 |
|
| 1782 |
It is also possible to get the stored information by simply calling |
| 1783 |
the command\\ \cs{xskak}\meta{gameid}\meta{type} (if \meta{gameid} |
| 1784 |
consists of letters). |
| 1785 |
|
| 1786 |
\begin{LTXexample}[width=0.5\textwidth] |
| 1787 |
\newchessgame[id=A,white=John White, |
| 1788 |
black=Jack Black, result=1--0] |
| 1789 |
\minisec{\XskakAwhite\ -- \XskakAblack} |
| 1790 |
\mainline{1.e4 e5 2.Bc4 Nc6 3. Qh5 Nf6 4.Qxf7#} |
| 1791 |
\mbox{\XskakAresult} |
| 1792 |
\newchessgame[id=B,white=Harry Red, |
| 1793 |
black=Tom Green, result=0--1] |
| 1794 |
\minisec{\XskakBwhite\ -- \XskakBblack} |
| 1795 |
\mainline{1.f3 e5 2.g4 Qh4#} |
| 1796 |
\mbox{\XskakBresult} |
| 1797 |
|
| 1798 |
\minisec{List of Results} |
| 1799 |
\begin{tabular}[t]{l@{\,--\,}lr} |
| 1800 |
\XskakAwhite&\XskakAblack&\XskakAresult\\ |
| 1801 |
\XskakBwhite&\XskakBblack&\XskakBresult |
| 1802 |
\end{tabular} |
| 1803 |
|
| 1804 |
\minisec{Final positions} |
| 1805 |
\chessboard[tinyboard,lastmoveid=A, |
| 1806 |
setfen=\xskakget{nextfen}] |
| 1807 |
\chessboard[tinyboard,lastmoveid=B, |
| 1808 |
setfen=\xskakget{nextfen}] |
| 1809 |
\end{LTXexample} |
| 1810 |
|
| 1811 |
%If \meta{gameid} contains non-letter chars (e.g. a number) you must |
| 1812 |
%use\\ |
| 1813 |
%\cs{csname}\texttt{~xskak}\meta{gameid}\meta{type}\cs{endcsname}. |
| 1814 |
% |
| 1815 |
%If the \meta{gameid} or the \meta{type} are stored in commands you |
| 1816 |
%can use this commands in \cs{csname}\texttt{\ldots}\cs{endcsname}: |
| 1817 |
%\cs{csname}\texttt{~xskak}\cs{mygameid}\cs{mygametype}\cs{endcsname} |
| 1818 |
|
| 1819 |
|
| 1820 |
|
| 1821 |
\subsection{Getting the move information} |
| 1822 |
|
| 1823 |
Move data are bit more difficult as they depend on more |
| 1824 |
variables. |
| 1825 |
|
| 1826 |
At first, you can naturally use a |
| 1827 |
\cs{csname}\texttt{\ldots}\cs{endcsname}:\\ |
| 1828 |
\cs{csname}\texttt{~xskak}.\meta{gameid}.\meta{movenr}.\meta{player}.\meta{type}\cs{endcsname}. |
| 1829 |
|
| 1830 |
|
| 1831 |
But normally you should use a |
| 1832 |
\cs{xskakset}/\cs{xskakget}-combination% |
| 1833 |
\footnote{I had to implement the retrieving as a two-step-method to |
| 1834 |
be able to use the retrieving command in the \keylist of |
| 1835 |
\cs{chessboard}. As the values are expanded during |
| 1836 |
the processing complicated commands which use internally \cs{def} |
| 1837 |
and \cs{setkeys} can not be used as values.}. |
| 1838 |
|
| 1839 |
|
| 1840 |
\DescribeMacro{\xskakget}% |
| 1841 |
\cs{xskakget}\marg{type} will pick up the current values of the |
| 1842 |
variables for the \meta{GameId} and the \meta{MoveId} and then |
| 1843 |
retrieve/print the content of type \meta{type}. |
| 1844 |
|
| 1845 |
\index{Move data >movenr (virtual type)}% |
| 1846 |
\index{movenr (virtual move data type)}% |
| 1847 |
\index{Move data >moveid (virtual type)}% |
| 1848 |
\index{moveid (virtual move data type)}% |
| 1849 |
\index{Move data >player (virtual type)}% |
| 1850 |
\index{player (virtual move data type)}% |
| 1851 |
\meta{type} can be any of the types described in \ref{sec:movedata} |
| 1852 |
and additionally the three virtual types \textsf{movenr}, |
| 1853 |
\textsf{player} and \textsf{moveid} can be used which will output the |
| 1854 |
current move identification. This allows easier retrieving of the |
| 1855 |
current value of the internal variables e.g. in loops and tests. |
| 1856 |
|
| 1857 |
\textbf{Attention:} The move variables are not changed by the parsing |
| 1858 |
command of \skaksty. And they are not stored like the other types -- |
| 1859 |
you can't retrieve them with a |
| 1860 |
\cs{csname}\texttt{\ldots}\cs{endcsname} construction. |
| 1861 |
|
| 1862 |
\begin{LTXexample} |
| 1863 |
\newchessgame[moveid=10b] |
| 1864 |
\mainline{10... e5} |
| 1865 |
|
| 1866 |
The game started with move \xskakget{moveid}. |
| 1867 |
|
| 1868 |
\xskakset{moveid=5w} |
| 1869 |
Now the moveid has value \xskakget{movenr}\xskakget{player}. |
| 1870 |
\end{LTXexample} |
| 1871 |
|
| 1872 |
|
| 1873 |
|
| 1874 |
\subsection{Using the data with \texttt{\textbackslash chessboard}} |
| 1875 |
|
| 1876 |
The move data can naturally be used with \cs{chessboard} e.g. to |
| 1877 |
highlight the last move with an arrow. The \meta{MoveId} you want to |
| 1878 |
refer to can be set before the board with \cs{xskakset} but if this |
| 1879 |
were the sole possibility this would mean that you couldn't get data |
| 1880 |
from other moves. So I defined a bunch of new keys for |
| 1881 |
\cs{chessboard} (and changed some existing keys) which allows to |
| 1882 |
retrieve during building the board all available move datas. The most |
| 1883 |
important ones are keys that tells \cs{chessboard} the \meta{GameId} |
| 1884 |
and the \meta{MoveId} for which you want to retrieve datas: |
| 1885 |
|
| 1886 |
\begin{description} |
| 1887 |
\item[\key{id=}\meta{name}] |
| 1888 |
\index{chessboard=\verb!*+\chessboard+>id (key)}% |
| 1889 |
\index{movenr (\texttt{\textbackslash chessboard} key)}% |
| 1890 |
Like the other \key{id}-keys this one sets the variable that |
| 1891 |
identifies the game. But setting this key will \emph{not} affect |
| 1892 |
the value of the game identification outside the board, any |
| 1893 |
change is local to the board. |
| 1894 |
|
| 1895 |
\textbf{Attention:} Setting this key will \emph{not} change the |
| 1896 |
default position shown by \cs{chessboard}. This is always the |
| 1897 |
«current» game. |
| 1898 |
|
| 1899 |
\item[\key{movenr=}\meta{number}, \key{player=}\meta{«w» or «b»}, \key{moveid=}\meta{number + «w» or «b»}] |
| 1900 |
\index{chessboard=\verb!*+\chessboard+>movenr (key)}% |
| 1901 |
\index{movenr (\texttt{\textbackslash chessboard} key)}% |
| 1902 |
\index{chessboard=\verb!*+\chessboard+>player (key)}% |
| 1903 |
\index{player (\texttt{\textbackslash chessboard} key)}% |
| 1904 |
\index{chessboard=\verb!*+\chessboard+>moveid (key)}% |
| 1905 |
\index{moveid (\texttt{\textbackslash chessboard} key)}% |
| 1906 |
This keys stores the number and player for which you want to retrieve |
| 1907 |
move related information. Again any setting is local to the board. |
| 1908 |
|
| 1909 |
|
| 1910 |
|
| 1911 |
\item[\key{stepmoveid=}\meta{number}] |
| 1912 |
\index{xskakset=\verb!*+\chessboard+>stepmoveid (key)}% |
| 1913 |
\index{stepmoveid (\texttt{\textbackslash chessboard} key)}% |
| 1914 |
Like the similar key of \cs{xskakset} \key{stepmoveid} picks up the |
| 1915 |
current value of the move variables of \packagename{xskak} and «adds» |
| 1916 |
the given number of halfmoves. But again when you use the key in the |
| 1917 |
argument of \cs{chessboard} the change is local to the board. |
| 1918 |
|
| 1919 |
\textbf{Attention:} If you set the \meta{MoveId} with the above keys |
| 1920 |
to a value «outside» the game and then try to retrieve a data you |
| 1921 |
will probably get horrible errors. |
| 1922 |
|
| 1923 |
|
| 1924 |
\item[\key{lastmoveid=}\meta{gameid}] |
| 1925 |
\index{chessboard=\verb!*+\chessboard+>lastmoveid (key)}% |
| 1926 |
\index{lastmoveid (\texttt{\textbackslash chessboard} key)} |
| 1927 |
The usual case is probably that you want to use the (currently) last |
| 1928 |
move of a game. This can be done with this key. The (optional) value |
| 1929 |
lets you specify a game identification. \texttt{lastmoveid=A} ist |
| 1930 |
equivalent to \texttt{id=A,lastmoveid}. Again the setting is local to |
| 1931 |
the board. |
| 1932 |
|
| 1933 |
\end{description} |
| 1934 |
|
| 1935 |
\index{xskakget=\verb!*+\xskakget+ (with \texttt{\textbackslash chessboard})}% |
| 1936 |
After you have set the move variables, you can use the command |
| 1937 |
\cs{xskakget}\marg{type} described above used without |
| 1938 |
problems\footnote{I hope but I haven't tested any possible usage.} |
| 1939 |
inside \cs{chessboard} as long as the value expands to something the |
| 1940 |
keys can handle (\key{markmove} e.g. will not like it if you ask it |
| 1941 |
to process a fen). |
| 1942 |
|
| 1943 |
\begin{LTXexample}[width=0.4\textwidth] |
| 1944 |
\newchessgame[id=A,white=John White, |
| 1945 |
black=Jack Black, result=1--0] |
| 1946 |
\mainline{1.e4 e5 2.Bc4 Nc6 3. Qh5 Nf6 4.Qxf7#} |
| 1947 |
|
| 1948 |
\newchessgame % a game between A and the board |
| 1949 |
\mainline{1.e4} |
| 1950 |
|
| 1951 |
\setchessboard{shortenend=5pt,color=red}% |
| 1952 |
\chessboard[lastmoveid=A,setfen=\xskakget{nextfen}, |
| 1953 |
pgfstyle=border,color=red, |
| 1954 |
markfields={\xskakget{moveto},\xskakget{movefrom}}, |
| 1955 |
pgfstyle=straightmove, |
| 1956 |
markmove=\xskakget{movefrom}-\xskakget{moveto}] |
| 1957 |
\end{LTXexample} |
| 1958 |
|
| 1959 |
|
| 1960 |
\begin{LTXexample}[width=0.4\textwidth,escapechar=/] |
| 1961 |
\newchessgame[id=A] |
| 1962 |
\mainline{1.e4 e5 2.Bc4 Nc6 3. Qh5 Nf6 4.Qxf7#} |
| 1963 |
|
| 1964 |
\xskakget{moveid}% to show /\meta{MoveId} is still 1w/ |
| 1965 |
|
| 1966 |
\setchessboard{shortenend=5pt,color=red}% |
| 1967 |
\chessboard[lastmoveid=A,setfen=\xskakget{nextfen}, |
| 1968 |
moveid=1w, |
| 1969 |
pgfstyle=straightmove, |
| 1970 |
markmove=\xskakget{movefrom}-\xskakget{moveto}, |
| 1971 |
stepmoveid=2,color=green, |
| 1972 |
markmove=\xskakget{movefrom}-\xskakget{moveto}, |
| 1973 |
stepmoveid=2,color=blue, |
| 1974 |
markmove=\xskakget{movefrom}-\xskakget{moveto}, |
| 1975 |
stepmoveid=2,color=yellow, |
| 1976 |
markmove=\xskakget{movefrom}-\xskakget{moveto}] |
| 1977 |
|
| 1978 |
\xskakget{moveid}% to show that /\meta{MoveId} is again 1w/ |
| 1979 |
\end{LTXexample} |
| 1980 |
|
| 1981 |
|
| 1982 |
\subsection{Labeling a game}\label{sec:labeling} |
| 1983 |
|
| 1984 |
It is a bit tedious to have to remember the number and the color of |
| 1985 |
the moves when you want to start or to continue a game, or for which |
| 1986 |
you want to draw a diagram or retrieve another move information. So |
| 1987 |
there is a sort of labeling system. In difference to the labeling in |
| 1988 |
normal \LaTeX\ it doesn't write the values to auxiliary files. That |
| 1989 |
means that you can't reference labels which come later in the |
| 1990 |
document (at my opinion this would lead to chaos anyway). |
| 1991 |
|
| 1992 |
|
| 1993 |
|
| 1994 |
To set a label you use the command \cs{xskakset} with the key |
| 1995 |
\key{tag}\footnote{The name «label» is used by \cs{chessboard} to set |
| 1996 |
the labels of the boards.}.% |
| 1997 |
\index{xskakset=\verb!*+\xskakset+>tag (key)}% |
| 1998 |
\index{tag (\texttt{\textbackslash xskakset} key)} |
| 1999 |
It saves the current value of the move counter (the |
| 2000 |
\packagename{skak} counter!), the value of the (\packagename{skak}!) |
| 2001 |
boolean that holds the player and the \meta{GameId}. If you haven't |
| 2002 |
started any game yet (more precisely: if the move counter has value |
| 2003 |
0) then \xskak will issue a warning and do nothing. |
| 2004 |
|
| 2005 |
You can set the tag between two \cs{mainline} (or \cs{hidemoves}) |
| 2006 |
commands, but it works also if you put them directly in the argument |
| 2007 |
of \cs{mainline}: |
| 2008 |
|
| 2009 |
\begin{LTXexample} |
| 2010 |
\newchessgame% |
| 2011 |
\mainline{1. e4 e5\xskakset{tag=A} |
| 2012 |
2. Nf3\xskakset{tag=B} Nc6 |
| 2013 |
3. Bb5 Nf6 |
| 2014 |
4. O-O Nxe4 |
| 2015 |
5.Bxc6 bxc6} |
| 2016 |
|
| 2017 |
\end{LTXexample} |
| 2018 |
|
| 2019 |
|
| 2020 |
The saved values can be retrieved with various keys of type \key{ref} |
| 2021 |
(e.g. \key{refpastmoveid}, \key{refnextplayer}), or by the command |
| 2022 |
\cs{xskakget}. |
| 2023 |
|
| 2024 |
The label is set in most cases between two moves. There probably will |
| 2025 |
be cases when you need the \meta{MoveId} of the move \emph{before} |
| 2026 |
the tag e.g. to show the position or to comment on the last move, and |
| 2027 |
there will be cases when you will need the \meta{MoveId} of the move |
| 2028 |
\emph{after} the tag e.g. to continue the game. So there are ref-keys |
| 2029 |
for both cases. |
| 2030 |
|
| 2031 |
\subsubsection{Retrieving the tagged values with \texttt{\textbackslash |
| 2032 |
xskakget}} |
| 2033 |
|
| 2034 |
Retrieving the \meta{GameId} and/or \meta{MoveId} values stored by a |
| 2035 |
\key{tag} is again a more-than-one-step procedure: At first you must |
| 2036 |
tell \packagename{xskak} the tag name you want to use, and then use a |
| 2037 |
\cs{xskakget}\marg{list of ref types}, where \meta{ref type} is one |
| 2038 |
of the following keywords: {\ttfamily refid, refpastmoveid, |
| 2039 |
refnextmoveid, refpastmovenr, refnextmovenr, refpastplayer, |
| 2040 |
refnextplayer}. |
| 2041 |
|
| 2042 |
|
| 2043 |
\index{resumechessgame=\verb!*+\resumechessgame+>reftag (key)}% |
| 2044 |
\index{reftag (\texttt{\textbackslash resumechessgame} key)}% |
| 2045 |
\index{newchessgame=\verb!*+\newchessgame+>reftag (key)}% |
| 2046 |
\index{reftag (\texttt{\textbackslash newchessgame} key)}% |
| 2047 |
\index{xskakset=\verb!*+\xskakset+>reftag (key)}% |
| 2048 |
\index{reftag (\texttt{\textbackslash xskakset} key)}% |
| 2049 |
\index{xskakloop=\verb!*+\xskakloop+>reftag (key)}% |
| 2050 |
\index{reftag (\texttt{\textbackslash xskakloop} key)}% |
| 2051 |
\index{printchessgame=\verb!*+\xskakloop+>reftag (key)}% |
| 2052 |
\index{reftag (\texttt{\textbackslash printchessgame} key)}% |
| 2053 |
\index{chessboard=\verb!*+\chessboard+>reftag (key)}% |
| 2054 |
\index{reftag (\texttt{\textbackslash chessboard} key)}% |
| 2055 |
Setting the tag name is done with the key \key{reftag}, which you can |
| 2056 |
use with all commands that accept the key \key{id}. If you use the |
| 2057 |
key in the optional argument of \cs{chessboard} it will change the |
| 2058 |
tag name locally for the board. In all other cases the tag name is |
| 2059 |
set globally. |
| 2060 |
|
| 2061 |
\begin{LTXexample}[escapechar=/] |
| 2062 |
\newchessgame[id=new] % to set a new id |
| 2063 |
\chessboard[ |
| 2064 |
reftag=B,%from previous example |
| 2065 |
id=\xskakget{refid}, |
| 2066 |
%retrieves and sets the /\meta{Gameid}/ from tag B |
| 2067 |
moveid=\xskakget{refnextmoveid}, |
| 2068 |
%retrieves and sets the /\meta{Moveid}/ from tag B |
| 2069 |
setfen=\xskakget{pastfen}] |
| 2070 |
\end{LTXexample} |
| 2071 |
|
| 2072 |
|
| 2073 |
\subsubsection{The \key{ref}-keys} |
| 2074 |
|
| 2075 |
As the more-step-procedure to use the tags is a bit longuish there |
| 2076 |
exist keys that shorten the procedure. This keys too work in the |
| 2077 |
arguments of all commands that can also handle the correspondant keys |
| 2078 |
\key{id}, \key{moveid} etc. The effect will be identical to setting |
| 2079 |
the values directly: Keys used in the optional argument of |
| 2080 |
\cs{chessboard} will set their values only local to the board, in the |
| 2081 |
other cases the values are set globally. |
| 2082 |
|
| 2083 |
\begin{description} |
| 2084 |
\item[\key{refid=}\meta{tag}] |
| 2085 |
\index{resumechessgame=\verb!*+\resumechessgame+>refid (key)}% |
| 2086 |
\index{refid (\texttt{\textbackslash resumechessgame} key)}% |
| 2087 |
\index{newchessgame=\verb!*+\newchessgame+>refid (key)}% |
| 2088 |
\index{refid (\texttt{\textbackslash newchessgame} key)}% |
| 2089 |
\index{xskakset=\verb!*+\xskakset+>refid (key)}% |
| 2090 |
\index{refid (\texttt{\textbackslash xskakset} key)}% |
| 2091 |
\index{xskakloop=\verb!*+\xskakloop+>refid (key)}% |
| 2092 |
\index{refid (\texttt{\textbackslash xskakloop} key)}% |
| 2093 |
\index{chessboard=\verb!*+\chessboard+>refid (key)}% |
| 2094 |
\index{refid (\texttt{\textbackslash chessboard} key)}% |
| 2095 |
|
| 2096 |
This key will set the \meta{GameId} to the value stored in the tag. |
| 2097 |
It is a shortcut for\\ |
| 2098 |
\key{reftag=}\meta{tag},\key{id=}\cs{xskakget}verb+{refid}+ |
| 2099 |
|
| 2100 |
|
| 2101 |
\item[\key{refpastmoveid=}\meta{tag}, \key{refpastmovenr=}\meta{tag}, \key{refpastplayer=}\meta{tag} ] |
| 2102 |
\index{resumechessgame=\verb!*+\resumechessgame+>refpastmoveid (key)}% |
| 2103 |
\index{refpastmoveid (\texttt{\textbackslash resumechessgame} key)}% |
| 2104 |
\index{resumechessgame=\verb!*+\resumechessgame+>refpastmovenr (key)}% |
| 2105 |
\index{refpastmovenr (\texttt{\textbackslash resumechessgame} key)}% |
| 2106 |
\index{resumechessgame=\verb!*+\resumechessgame+>refpastplayer (key)}% |
| 2107 |
\index{refpastplayer (\texttt{\textbackslash resumechessgame} key)}% |
| 2108 |
% |
| 2109 |
\index{newchessgame=\verb!*+\newchessgame+>refpastmovenr (key)}% |
| 2110 |
\index{refpastmovenr (\texttt{\textbackslash newchessgame} key)}% |
| 2111 |
\index{newchessgame=\verb!*+\newchessgame+>refpastmoveid (key)}% |
| 2112 |
\index{refpastmoveid (\texttt{\textbackslash newchessgame} key)}% |
| 2113 |
\index{newchessgame=\verb!*+\newchessgame+>refpastplayer (key)}% |
| 2114 |
\index{refpastplayer (\texttt{\textbackslash newchessgame} key)}% |
| 2115 |
% |
| 2116 |
\index{xskakset=\verb!*+\xskakset+>refpastmoveid (key)}% |
| 2117 |
\index{refpastmoveid (\texttt{\textbackslash xskakset} key)}% |
| 2118 |
\index{xskakset=\verb!*+\xskakset+>refpastmovenr (key)}% |
| 2119 |
\index{refpastmovenr (\texttt{\textbackslash xskakset} key)}% |
| 2120 |
\index{xskakset=\verb!*+\xskakset+>refpastplayer (key)}% |
| 2121 |
\index{refpastplayer (\texttt{\textbackslash xskakset} key)}% |
| 2122 |
% |
| 2123 |
\index{chessboard=\verb!*+\chessboard+>refpastmoveid (key)}% |
| 2124 |
\index{refpastmoveid (\texttt{\textbackslash chessboard} key)}% |
| 2125 |
\index{chessboard=\verb!*+\chessboard+>refpastmovenr (key)}% |
| 2126 |
\index{refpastmovenr (\texttt{\textbackslash chessboard} key)}% |
| 2127 |
\index{chessboard=\verb!*+\chessboard+>refpastplayer (key)}% |
| 2128 |
\index{refpastplayer (\texttt{\textbackslash chessboard} key)}% |
| 2129 |
|
| 2130 |
|
| 2131 |
This keys will set the respective move information to the value of |
| 2132 |
the move before the tag. If the tag is before the move 1w, then the |
| 2133 |
value 0b is used. |
| 2134 |
|
| 2135 |
\item[\key{refnextmoveid=}\meta{tag}, \key{refnextmovenr=}\meta{tag}, \key{refnextplayer=}\meta{tag} ] |
| 2136 |
\index{resumechessgame=\verb!*+\resumechessgame+>refnextmoveid (key)}% |
| 2137 |
\index{refnextmoveid (\texttt{\textbackslash resumechessgame} key)}% |
| 2138 |
\index{resumechessgame=\verb!*+\resumechessgame+>refnextmovenr (key)}% |
| 2139 |
\index{refnextmovenr (\texttt{\textbackslash resumechessgame} key)}% |
| 2140 |
\index{resumechessgame=\verb!*+\resumechessgame+>refnextplayer (key)}% |
| 2141 |
\index{refnextplayer (\texttt{\textbackslash resumechessgame} key)}% |
| 2142 |
% |
| 2143 |
\index{newchessgame=\verb!*+\newchessgame+>refnextmovenr (key)}% |
| 2144 |
\index{refnextmovenr (\texttt{\textbackslash newchessgame} key)}% |
| 2145 |
\index{newchessgame=\verb!*+\newchessgame+>refnextmoveid (key)}% |
| 2146 |
\index{refnextmoveid (\texttt{\textbackslash newchessgame} key)}% |
| 2147 |
\index{newchessgame=\verb!*+\newchessgame+>refnextplayer (key)}% |
| 2148 |
\index{refnextplayer (\texttt{\textbackslash newchessgame} key)}% |
| 2149 |
% |
| 2150 |
\index{xskakset=\verb!*+\xskakset+>refnextmoveid (key)}% |
| 2151 |
\index{refnextmoveid (\texttt{\textbackslash xskakset} key)}% |
| 2152 |
\index{xskakset=\verb!*+\xskakset+>refnextmovenr (key)}% |
| 2153 |
\index{refnextmovenr (\texttt{\textbackslash xskakset} key)}% |
| 2154 |
\index{xskakset=\verb!*+\xskakset+>refnextplayer (key)}% |
| 2155 |
\index{refnextplayer (\texttt{\textbackslash xskakset} key)}% |
| 2156 |
% |
| 2157 |
\index{chessboard=\verb!*+\chessboard+>refnextmoveid (key)}% |
| 2158 |
\index{refnextmoveid (\texttt{\textbackslash chessboard} key)}% |
| 2159 |
\index{chessboard=\verb!*+\chessboard+>refnextmovenr (key)}% |
| 2160 |
\index{refnextmovenr (\texttt{\textbackslash chessboard} key)}% |
| 2161 |
\index{chessboard=\verb!*+\chessboard+>refnextplayer (key)}% |
| 2162 |
\index{refnextplayer (\texttt{\textbackslash chessboard} key)}% |
| 2163 |
|
| 2164 |
|
| 2165 |
This keys will set the respective move information to the value of |
| 2166 |
the move after the tag. |
| 2167 |
|
| 2168 |
\item[\key{refpast=}\meta{tag}, \key{refnext=}\meta{tag}] |
| 2169 |
\index{resumechessgame=\verb!*+\resumechessgame+>refpast (key)}% |
| 2170 |
\index{refpast (\texttt{\textbackslash resumechessgame} key)}% |
| 2171 |
\index{newchessgame=\verb!*+\newchessgame+>refpast (key)}% |
| 2172 |
\index{refpast (\texttt{\textbackslash newchessgame} key)}% |
| 2173 |
\index{xskakset=\verb!*+\xskakset+>refpast (key)}% |
| 2174 |
\index{refpast (\texttt{\textbackslash xskakset} key)}% |
| 2175 |
\index{resumechessgame=\verb!*+\resumechessgame+>refnext (key)}% |
| 2176 |
\index{refnext (\texttt{\textbackslash resumechessgame} key)}% |
| 2177 |
\index{newchessgame=\verb!*+\newchessgame+>refnext (key)}% |
| 2178 |
\index{refnext (\texttt{\textbackslash newchessgame} key)}% |
| 2179 |
\index{xskakset=\verb!*+\xskakset+>refnext (key)}% |
| 2180 |
\index{refnext (\texttt{\textbackslash xskakset} key)}% |
| 2181 |
\index{chessboard=\verb!*+\chessboard+>refpast (key)}% |
| 2182 |
\index{refpast (\texttt{\textbackslash chessboard} key)}% |
| 2183 |
\index{chessboard=\verb!*+\chessboard+>refnext (key)}% |
| 2184 |
\index{refnext (\texttt{\textbackslash chessboard} key)}% |
| 2185 |
|
| 2186 |
|
| 2187 |
This keys will set the \meta{GameId} and the \meta{MoveId} in one go. |
| 2188 |
E.g. \key{refpast} is a shortcut for\\ |
| 2189 |
\key{reftag=}\meta{tag},\key{id=}\cs{xskakget}verb+{refid}+,\key{moveid=}\cs{xskakget}verb+{refpastmoveid}+ |
| 2190 |
|
| 2191 |
|
| 2192 |
|
| 2193 |
|
| 2194 |
\item[\key{reffen=}\meta{tag}] |
| 2195 |
\index{chessboard=\verb!*+\chessboard+>reffen (key)}% |
| 2196 |
\index{reffen (\texttt{\textbackslash chessboard} key)}% |
| 2197 |
\index{newchessgame=\verb!*+\newchessgame+>reffen (key)}% |
| 2198 |
\index{reffen (\texttt{\textbackslash newchessgame} key)}% |
| 2199 |
|
| 2200 |
This is a \cs{chessboard} key. It will add the position at the tag on |
| 2201 |
the board, its effect is identical to using the key {\ttfamily |
| 2202 |
addfen =}\meta{Position at tag} described in the documentation of |
| 2203 |
\pchessboard. So be aware that it really only places pieces on the |
| 2204 |
board. It will not change the \meta{GameId} nor the \meta{MoveId} or |
| 2205 |
the move counter of \packagename{skak}. So it is quite possible to |
| 2206 |
use a position where black should move next to start a game with |
| 2207 |
white to move. |
| 2208 |
|
| 2209 |
|
| 2210 |
\begin{LTXexample} |
| 2211 |
\newchessgame[id=new]% to set a new id |
| 2212 |
\chessboard[reffen=B] |
| 2213 |
\end{LTXexample} |
| 2214 |
|
| 2215 |
|
| 2216 |
|
| 2217 |
|
| 2218 |
\begin{LTXexample} |
| 2219 |
\newchessgame[id=A]% |
| 2220 |
\mainline{1.e4 e5 2. Nf3\xskakset{tag=C} Nc6 |
| 2221 |
3. Bb5 Nf6 4. O-O Nxe4 5.Bxc6 bxc6} |
| 2222 |
|
| 2223 |
|
| 2224 |
\newchessgame[id=B,reffen=C] |
| 2225 |
\mainline{1. Nc3} |
| 2226 |
|
| 2227 |
\chessboard |
| 2228 |
|
| 2229 |
\chessboard[reffen=C, |
| 2230 |
markstyle=circle, |
| 2231 |
color=red, |
| 2232 |
%from game B: |
| 2233 |
markfield=\xskakget{movefrom}, |
| 2234 |
refpast=C, |
| 2235 |
color=green, |
| 2236 |
%from game A: |
| 2237 |
markfield=\xskakget{movefrom}] |
| 2238 |
\end{LTXexample} |
| 2239 |
\end{description} |
| 2240 |
|
| 2241 |
\section{Looping} |
| 2242 |
|
| 2243 |
Looping with the \cs{whiledo} command of the package |
| 2244 |
\packagename{ifthen} is not very difficult. But to adjust to the |
| 2245 |
special numbering of chessmoves (1w, 1b, 2w, 2b, 3w \ldots) one needs |
| 2246 |
some special commands to step through the moves and test for the end |
| 2247 |
of the loop. |
| 2248 |
|
| 2249 |
\DescribeMacro{\xskaktestmoveid}% |
| 2250 |
Stepping can be done with the key \key{stepmoveid} described |
| 2251 |
earlier.\\ \cs{xskaktestmoveid}\marg{movenr}\marg{player} is a test |
| 2252 |
(defined with the help of package \packagename{xifthen}) which you |
| 2253 |
can use in the first argument of \cs{whiledo}. It will give true if |
| 2254 |
the move is in the current game. |
| 2255 |
|
| 2256 |
\begin{LTXexample} |
| 2257 |
\newchessgame[id=A] |
| 2258 |
\mainline{1. e4 e5 2. Nf3 Nf6} |
| 2259 |
|
| 2260 |
\newchessgame[id=B] |
| 2261 |
(a second game) |
| 2262 |
|
| 2263 |
Reprinting the first game: |
| 2264 |
\xskakset{id=A, |
| 2265 |
moveid=\xskakgetgame{initmoveid}} |
| 2266 |
\whiledo{\xskaktestmoveid |
| 2267 |
{\xskakget{movenr}}{\xskakget{player}}} |
| 2268 |
{\ifthenelse% |
| 2269 |
{\equal{\xskakget{player}}{w}} |
| 2270 |
{ \xskakget{movenr}.\,} |
| 2271 |
{ }% |
| 2272 |
\xskakget{lan}% |
| 2273 |
\xskakset{stepmoveid}} |
| 2274 |
|
| 2275 |
Reprinting only the black moves: |
| 2276 |
\xskakset{% |
| 2277 |
id=A, |
| 2278 |
moveid=\xskakgetgame{initmoveid},stepmoveid} |
| 2279 |
\whiledo{\xskaktestmoveid |
| 2280 |
{\xskakget{movenr}}{\xskakget{player}}} |
| 2281 |
{ \xskakget{lan}% |
| 2282 |
\xskakset{stepmoveid=2}} |
| 2283 |
\end{LTXexample} |
| 2284 |
|
| 2285 |
|
| 2286 |
\DescribeMacro{\xskakloop}% |
| 2287 |
\cs{xskakloop}\keyoarg\marg{code} is a wrapper command for such a |
| 2288 |
\cs{whiledo} loop. |
| 2289 |
|
| 2290 |
The possible keys are: |
| 2291 |
|
| 2292 |
\begin{description} |
| 2293 |
\item[\key{id=}\meta{string}] |
| 2294 |
\index{xskakloop=\verb!*+\xskakloop+>id (key)}% |
| 2295 |
\index{id (\texttt{\textbackslash xskakloop} key)}% |
| 2296 |
Which sets the game identification. The setting is global. |
| 2297 |
|
| 2298 |
\item[\key{initmovenr=}\meta{number}, \key{initplayer=}\meta{«w» or «b»}, |
| 2299 |
\key{initmoveid=}\meta{number + «w» or «b»}] |
| 2300 |
\index{xskakloop=\verb!*+\xskakloop+>initmovenr (key)}% |
| 2301 |
\index{initmovenr (\texttt{\textbackslash xskakloop} key)}% |
| 2302 |
\index{xskakloop=\verb!*+\xskakloop+>initplayer (key)}% |
| 2303 |
\index{initplayer (\texttt{\textbackslash xskakloop} key)}% |
| 2304 |
\index{xskakloop=\verb!*+\xskakloop+>initmoveid (key)}% |
| 2305 |
\index{initmoveid (\texttt{\textbackslash xskakloop} key)}% |
| 2306 |
This sets the move the loop should start with. Default is the |
| 2307 |
first move of the game. |
| 2308 |
|
| 2309 |
\item[\key{stopmovenr =}\meta{number}, \key{stopplayer =}\meta{«w» or «b»}, |
| 2310 |
\key{stopmoveid=}\meta{number + «w» or «b»}] |
| 2311 |
\index{xskakloop=\verb!*+\xskakloop+>stopmovenr (key)}% |
| 2312 |
\index{stopmovenr (\texttt{\textbackslash xskakloop} key)}% |
| 2313 |
\index{xskakloop=\verb!*+\xskakloop+>stopplayer (key)}% |
| 2314 |
\index{stopplayer (\texttt{\textbackslash xskakloop} key)}% |
| 2315 |
\index{xskakloop=\verb!*+\xskakloop+>stopmoveid (key)}% |
| 2316 |
\index{stopmoveid (\texttt{\textbackslash xskakloop} key)}% |
| 2317 |
This sets the move where the loop should stop. Default is the |
| 2318 |
last move of the game. |
| 2319 |
|
| 2320 |
\item[\key{step=}\meta{number}] |
| 2321 |
\index{xskakloop=\verb!*+\xskakloop+>step (key)}% |
| 2322 |
\index{step (\texttt{\textbackslash xskakloop} key)}% |
| 2323 |
This sets the length of the steps of the loop. The number gives the number of |
| 2324 |
halfmoves. Default is one. |
| 2325 |
|
| 2326 |
|
| 2327 |
\item[\key{showlast=}\meta{true|false}] |
| 2328 |
\index{xskakloop=\verb!*+\xskakloop+>showlast (key)}% |
| 2329 |
\index{showlast (\texttt{\textbackslash xskakloop} key)}% |
| 2330 |
When you are using the key \key{step} with a number unequal to |
| 2331 |
one, it is possible that the last move (possibly set by |
| 2332 |
\key{stopmoveid}) is left out. With the key \key{showlast} you can force \cs{xskakloop} to process |
| 2333 |
the code for the last move. |
| 2334 |
\end{description} |
| 2335 |
|
| 2336 |
|
| 2337 |
\begin{LTXexample}[pos=t,width=\textwidth] |
| 2338 |
\newchessgame |
| 2339 |
\mainline{% |
| 2340 |
1.d4 Nf6 2.c4 g6 3.Nc3 Bg7 4.e4 d6 5.Nge2 O-O 6.Ng3 c6 7.Be2 a6 8.a4 |
| 2341 |
a5 9.h4 h5 10.Be3 Na6 11.f3 e5 12.d5 Nd7 13.Nf1 Ndc5 14.Nd2 Qb6 |
| 2342 |
15.Qb1 Nb4 16.Nb3 Ncd3+ 17.Kd2 Qxe3+} |
| 2343 |
|
| 2344 |
\xskakloop[step=6,showlast]{% |
| 2345 |
\begin{tabular}{c} |
| 2346 |
\chessboard[tinyboard, |
| 2347 |
setfen=\xskakget{nextfen}] |
| 2348 |
\\ |
| 2349 |
\xskakget{opennr}\xskakget{lan}% |
| 2350 |
\end{tabular}\quad}% |
| 2351 |
\end{LTXexample} |
| 2352 |
|
| 2353 |
With the help of the package \packagename{animate} and \cs{xskakloop} |
| 2354 |
you can make animated boards:\mynobreakpar |
| 2355 |
\begingroup |
| 2356 |
\setchessboard{boardfontsize=0.8cm,shortenend=5pt, margin=false}% |
| 2357 |
\setboardfontencoding{LSBC4}% |
| 2358 |
\newskaklanguage{german}{KDTLSB}\skaklanguage[german]% |
| 2359 |
% |
| 2360 |
\newcommand\getmovestyle[1]{% |
| 2361 |
\ifthenelse |
| 2362 |
{\equal{#1}{N}}%knight move |
| 2363 |
{\def\mymovestyle{[clockwise=false,style=knight]curvemove}} |
| 2364 |
{\ifthenelse |
| 2365 |
{\equal{#1}{}}% castling |
| 2366 |
{\def\mymovestyle{curvemove}} |
| 2367 |
{\def\mymovestyle{straightmove}}}}% |
| 2368 |
% |
| 2369 |
\newchessgame[white=Paethz,black=Dirr,result=0-1,id=anim]% |
| 2370 |
\hidemoves{% |
| 2371 |
1.d4 Sf6 2.c4 g6 3.Sc3 Lg7 4.e4 d6 5.Sge2 O-O |
| 2372 |
6.Sg3 c6 7.Le2 a6 8.a4 a5 9.h4 h5 10.Le3 Sa6 |
| 2373 |
11.f3 e5 12.d5 Sd7 13.Sf1 Sdc5 14.Sd2 Db6 |
| 2374 |
15.Db1 Sb4 16.Sb3 Scd3+ 17.Kd2 Dxe3+}% |
| 2375 |
% |
| 2376 |
\unitlength0.8cm\relax |
| 2377 |
\begin{animateinline}[autoplay,loop,controls]{0.5}% |
| 2378 |
\begin{picture}(11,11) |
| 2379 |
\put(1.5,1.5){\chessboard[setfen=\xskakgetgame{initfen}]}% |
| 2380 |
\end{picture} |
| 2381 |
\newframe |
| 2382 |
\xskakloop{% |
| 2383 |
\getmovestyle{\xskakget{piecechar}}% |
| 2384 |
\begin{picture}(11,11) |
| 2385 |
\put(1.5,1.5){% |
| 2386 |
\chessboard[pgfstyle=\mymovestyle, color=blue, |
| 2387 |
pgfshortenend=0.3em,arrow=to, |
| 2388 |
markmoves=\xskakget{move}, |
| 2389 |
coloremph,piececolor=blue, |
| 2390 |
emphfields={\xskakget{moveto}}, |
| 2391 |
setfen=\xskakget{nextfen}]}% |
| 2392 |
\end{picture}% |
| 2393 |
\newframe}% |
| 2394 |
\begin{picture}(11,11) |
| 2395 |
\put(1.5,1.5){\chessboard[setfen=\xskakgetgame{lastfen}]}% |
| 2396 |
\end{picture} |
| 2397 |
\end{animateinline} |
| 2398 |
\endgroup |
| 2399 |
|
| 2400 |
\bigskip |
| 2401 |
The board was made with the following code: |
| 2402 |
|
| 2403 |
\begin{lstlisting} |
| 2404 |
\setchessboard{boardfontsize=0.8cm,shortenend=5pt, margin=false}% |
| 2405 |
\setboardfontencoding{LSBC4}% |
| 2406 |
\newskaklanguage{german}{KDTLSB}\skaklanguage[german]% |
| 2407 |
% |
| 2408 |
\newcommand\getmovestyle[1]{% |
| 2409 |
\ifthenelse |
| 2410 |
{\equal{#1}{N}}%knight move |
| 2411 |
{\def\mymovestyle{[clockwise=false,style=knight]curvemove}} |
| 2412 |
{\ifthenelse |
| 2413 |
{\equal{#1}{}}% castling |
| 2414 |
{\def\mymovestyle{curvemove}} |
| 2415 |
{\def\mymovestyle{straightmove}}}}% |
| 2416 |
% |
| 2417 |
\newchessgame[white=Paethz,black=Dirr,result=0-1,id=anim]% |
| 2418 |
\hidemoves{% |
| 2419 |
1.d4 Sf6 2.c4 g6 3.Sc3 Lg7 4.e4 d6 5.Sge2 O-O |
| 2420 |
6.Sg3 c6 7.Le2 a6 8.a4 a5 9.h4 h5 10.Le3 Sa6 |
| 2421 |
11.f3 e5 12.d5 Sd7 13.Sf1 Sdc5 14.Sd2 Db6 |
| 2422 |
15.Db1 Sb4 16.Sb3 Scd3+ 17.Kd2 Dxe3+}% |
| 2423 |
% |
| 2424 |
\unitlength0.8cm\relax |
| 2425 |
\begin{animateinline}[autoplay,loop,controls]{0.5}% |
| 2426 |
\begin{picture}(11,11) |
| 2427 |
\put(1.5,1.5){\chessboard[setfen=\xskakgetgame{initfen}]}% |
| 2428 |
\end{picture} |
| 2429 |
\newframe |
| 2430 |
\xskakloop{% |
| 2431 |
\getmovestyle{\xskakget{piecechar}}% |
| 2432 |
\begin{picture}(11,11) |
| 2433 |
\put(1.5,1.5){% |
| 2434 |
\chessboard[pgfstyle=\mymovestyle, color=blue, |
| 2435 |
pgfshortenend=0.3em,arrow=to, |
| 2436 |
markmoves=\xskakget{move}, |
| 2437 |
coloremph,piececolor=blue, |
| 2438 |
emphfields={\xskakget{moveto}}, |
| 2439 |
setfen=\xskakget{nextfen}]}% |
| 2440 |
\end{picture}% |
| 2441 |
\newframe}% |
| 2442 |
\begin{picture}(11,11) |
| 2443 |
\put(1.5,1.5){\chessboard[setfen=\xskakgetgame{lastfen}]}% |
| 2444 |
\end{picture} |
| 2445 |
\end{animateinline} |
| 2446 |
\end{lstlisting} |
| 2447 |
|
| 2448 |
\section{Printing} |
| 2449 |
\subsection{\texttt{\textbackslash longmoves} revisitated}\index{longmoves=\verb!*+\longmoves+>}% |
| 2450 |
|
| 2451 |
|
| 2452 |
|
| 2453 |
In the example on page \ref{ex:longmoves} I showed that the |
| 2454 |
\cs{longmoves} of \skaksty doesn't work correctly. This is due to the |
| 2455 |
asynchronous parsing and printing of the \packagename{skak}-engine |
| 2456 |
(\packagename{skak} -- like \TeX~-- has sometimes to look a bit |
| 2457 |
ahead). With \xskak the problem can be easily solved as it is now |
| 2458 |
possible to retrieve information about previous moves. So \xskak |
| 2459 |
redefines the internal commands to get \cs{longmoves} working. |
| 2460 |
|
| 2461 |
\textbf{Attention!} The new \cs{longmoves} command works only |
| 2462 |
correctly if the internal engine parses the moves -- so {\em it |
| 2463 |
doesn't work with \cs{variation}}. So starting with version 1.2 |
| 2464 |
\xskak forces \cs{variation} to use \cs{shortmoves}. |
| 2465 |
|
| 2466 |
|
| 2467 |
The redefinition of \cs{longmoves} is done by first defining a |
| 2468 |
printing command and then (re-)defining \cs{longmoves} such that the |
| 2469 |
internal \cs{printmove} now use the new command. The listing below |
| 2470 |
shows the code\footnote{The code doesn't show the complete truth. In |
| 2471 |
the real code \cs{longmoves} also has to change the printing mode for |
| 2472 |
\cs{printchessgame}. See \ref{sec:print}}. You can take it as a |
| 2473 |
template for your own special printing commands. |
| 2474 |
\cs{WhiteToMove}\marg{code for white}\marg{code for black} is a |
| 2475 |
command of \skaksty that executes the first argument if white is to |
| 2476 |
move and the second if its black turn. The main trick in the new |
| 2477 |
printing command is to go back one halfmove. The new printing command |
| 2478 |
defines only the printing format for the move itself as the number is |
| 2479 |
printed by \skaksty at another place. |
| 2480 |
|
| 2481 |
\begin{lstlisting} |
| 2482 |
\def\xskak@do@printmove@algebraic{% |
| 2483 |
\csname Xskak.\xskak@val@gameid.% |
| 2484 |
\WhiteToMove{\the\numexpr\the\c@move-1\relax}{\the\c@move}.% |
| 2485 |
\WhiteToMove{b}{w}.lan\endcsname |
| 2486 |
\csname Xskak.\xskak@val@gameid.% |
| 2487 |
\WhiteToMove{\the\numexpr\the\c@move-1\relax}{\the\c@move}.% |
| 2488 |
\WhiteToMove{b}{w}.comments\endcsname{}} |
| 2489 |
|
| 2490 |
\def\longmoves{% |
| 2491 |
\let\printmove=\xskak@do@printmove@algebraic} |
| 2492 |
\end{lstlisting} |
| 2493 |
|
| 2494 |
\DescribeMacro{\xskakenpassanttext}% |
| 2495 |
The new printing command inserts a test for enpassant moves. You can |
| 2496 |
suppress it by redefining \cs{xskakenpassantext}. |
| 2497 |
|
| 2498 |
|
| 2499 |
|
| 2500 |
\begin{LTXexample} |
| 2501 |
\longmoves |
| 2502 |
\newchessgame |
| 2503 |
\mainline{1.e4 e5 2.Nf3 Nf6} |
| 2504 |
|
| 2505 |
\newchessgame[restorefen=example] |
| 2506 |
\mainline{1. a4 bxa3!} |
| 2507 |
|
| 2508 |
\renewcommand\xskakenpassanttext{} |
| 2509 |
\newchessgame[restorefen=example] |
| 2510 |
\mainline{1. a4 bxa3!} |
| 2511 |
\end{LTXexample} |
| 2512 |
|
| 2513 |
|
| 2514 |
|
| 2515 |
\subsection{An user interface for styles}\label{sec:interface} |
| 2516 |
|
| 2517 |
To format a game \skaksty puts during parsing commands before and |
| 2518 |
between the moves and the counter. You can see the names of this |
| 2519 |
commands in the following example (the style \key{test} is a simple |
| 2520 |
local style predefined by \packagename{xskak} which contains |
| 2521 |
different tests. In level 1 and 2 it contains style items to show |
| 2522 |
commands. The optional argument \texttt{[invar]} force \cs{variation} |
| 2523 |
to use level 2). |
| 2524 |
|
| 2525 |
\begin{LTXexample}[pos=t,width=\textwidth,caption={The internal commands to format the output}] |
| 2526 |
\newchessgame |
| 2527 |
\xskakset{% |
| 2528 |
style=test, |
| 2529 |
level=1} |
| 2530 |
\color{blue} |
| 2531 |
|
| 2532 |
\mainline{1.d4 Nf6 2.c4} |
| 2533 |
|
| 2534 |
\mainline{2... g6 3.Nc3 Bg7 4.e4} |
| 2535 |
|
| 2536 |
\mainline{4... O-O 5. Nf3 Re8} |
| 2537 |
|
| 2538 |
\mainline{6. Be3 e6} |
| 2539 |
|
| 2540 |
\variation[invar]{6... d6} |
| 2541 |
\end{LTXexample} |
| 2542 |
|
| 2543 |
By judiciously (re-)definining the commands \packagename{skak} |
| 2544 |
inserts one can get almost every chess style one want. |
| 2545 |
\packagename{skak} itself defines three examples that demonstrates |
| 2546 |
the possibilities. These styles can be chosen by the commands |
| 2547 |
\cs{styleA}, \cs{styleB} and \cs{styleC}. The first two are inline |
| 2548 |
styles, the third uses for \cs{mainline} a tabbing environment and |
| 2549 |
switches to an inline style for \cs{variation}. But this styles are |
| 2550 |
really no more than examples. There is no user interface to change |
| 2551 |
and define styles. And due to some dependencies between the |
| 2552 |
predefined styles (\cs{styleB} is not only a stand-alone style but it |
| 2553 |
is also used in the definition of \cs{styleC} for the variation |
| 2554 |
level) adapting the styles is not easy. |
| 2555 |
|
| 2556 |
|
| 2557 |
So I decided to define a real user interface to define styles and |
| 2558 |
switch from one to another. The user interface supports an unlimited |
| 2559 |
number of levels: Each style is a bundle of \emph{levels} where the |
| 2560 |
look on each level is describe by a \emph{style item}\index{style |
| 2561 |
item} and some optional commands. Defining a style is therefore done |
| 2562 |
in two steps: |
| 2563 |
|
| 2564 |
\begin{lstlisting} |
| 2565 |
% Define items: |
| 2566 |
\xskaknewstyleitem{A}{% |
| 2567 |
beforenumber={}, |
| 2568 |
whiteopen={.\,}, |
| 2569 |
...} |
| 2570 |
\xskaknewstyleitem{B}{...} |
| 2571 |
|
| 2572 |
%Define style |
| 2573 |
\xskaknewstyle[% |
| 2574 |
level=1,styleitem=A, |
| 2575 |
font=\bfseries, %add special command to level 1. |
| 2576 |
level=2,styleitem=A, |
| 2577 |
level=3,styleitem=B, |
| 2578 |
...]{mystyle} |
| 2579 |
\end{lstlisting} |
| 2580 |
|
| 2581 |
|
| 2582 |
\textbf{Attention!} The (almost) indefinite number of levels comes at |
| 2583 |
a price: \cs{mainline} and \cs{variation} no longer use |
| 2584 |
automatically different styles. If a \cs{variation} should switch to |
| 2585 |
a «variation style» you will have to use e.g. the option |
| 2586 |
\texttt{[invar]} mentioned above (but you can define your own |
| 2587 |
«variation» commands that do this switch). Please read section |
| 2588 |
\ref{sec:usestyles} for more information. |
| 2589 |
|
| 2590 |
|
| 2591 |
|
| 2592 |
\subsubsection{Defining style items} |
| 2593 |
|
| 2594 |
\DescribeMacro{\xskaknewstyleitem}% |
| 2595 |
With \cs{xskaknewstyleitem}\keyoarg\marg{item} you define the style |
| 2596 |
item \meta{item}. You can use the following keys: |
| 2597 |
|
| 2598 |
|
| 2599 |
\begin{description} |
| 2600 |
\item[\meta{command name}=\meta{commands}] |
| 2601 |
\index{xskaknewstyleitem=\verb!*+\xskaknewstyleitem+>opencommands (key)}% |
| 2602 |
\index{opencommands (\texttt{\textbackslash xskaknewstyleitem} key)}% |
| 2603 |
\index{xskaknewstyleitem=\verb!*+\xskaknewstyleitem+>closecommands (key)}% |
| 2604 |
\index{closecommands (\texttt{\textbackslash xskaknewstyleitem} key)}% |
| 2605 |
\index{xskaknewstyleitem=\verb!*+\xskaknewstyleitem+>beforenumber (key)}% |
| 2606 |
\index{beforenumber (\texttt{\textbackslash xskaknewstyleitem} key)}% |
| 2607 |
\index{xskaknewstyleitem=\verb!*+\xskaknewstyleitem+>whiteopen (key)}% |
| 2608 |
\index{whiteopen (\texttt{\textbackslash xskaknewstyleitem} key)}% |
| 2609 |
\index{xskaknewstyleitem=\verb!*+\xskaknewstyleitem+>beforewhite (key)}% |
| 2610 |
\index{beforewhite (\texttt{\textbackslash xskaknewstyleitem} key)}% |
| 2611 |
\index{xskaknewstyleitem=\verb!*+\xskaknewstyleitem+>afterwhite (key)}% |
| 2612 |
\index{afterwhite (\texttt{\textbackslash xskaknewstyleitem} key)}% |
| 2613 |
\index{xskaknewstyleitem=\verb!*+\xskaknewstyleitem+>blackopen (key)}% |
| 2614 |
\index{blackopen (\texttt{\textbackslash xskaknewstyleitem} key)}% |
| 2615 |
\index{xskaknewstyleitem=\verb!*+\xskaknewstyleitem+>beforeblack (key)}% |
| 2616 |
\index{beforeblack (\texttt{\textbackslash xskaknewstyleitem} key)}% |
| 2617 |
\index{xskaknewstyleitem=\verb!*+\xskaknewstyleitem+>afterblack (key)}% |
| 2618 |
\index{afterblack (\texttt{\textbackslash xskaknewstyleitem} key)}% |
| 2619 |
|
| 2620 |
{\raggedright where \meta{command name} is one of |
| 2621 |
\\\texttt{opencommands}, \texttt{closecommands}, |
| 2622 |
\texttt{beforenumber}, \texttt{whiteopen}, \texttt{blackopen}, |
| 2623 |
\texttt{beforewhite}, \texttt{beforeblack}, \texttt{afterwhite}, |
| 2624 |
\texttt{afterblack}.\par} |
| 2625 |
|
| 2626 |
|
| 2627 |
There are endless possibilities for the value \meta{commands} -- as |
| 2628 |
there are endless possibilities to get more or less horrible errors. |
| 2629 |
So I will give only some general advices for the definitions of style |
| 2630 |
items: |
| 2631 |
|
| 2632 |
\begin{itemize} |
| 2633 |
\item While processing \keylists\/ \packagename{xkeyval} strips spaces. |
| 2634 |
So if you want to set one of the commands to a space use |
| 2635 |
either commands like \verb+\ +, \verb+\space+ and \verb+~+, or |
| 2636 |
protect the space by enough layers of braces. |
| 2637 |
|
| 2638 |
\item While processing \keylists\/ \packagename{xkeyval} strips also braces. |
| 2639 |
If you need some grouping use \cs{begingroup} and \cs{endgroup} or |
| 2640 |
protect the «real» braces by enough other braces. |
| 2641 |
|
| 2642 |
\item Use if possible switches (like \cs{bfseries}) instead of commands with arguments. |
| 2643 |
|
| 2644 |
\item Think about how you want to handle spaces at the start and the end of (bits of) a game |
| 2645 |
or a variation. An input like |
| 2646 |
\verb+\mainline{1. e4}+\verb*+ \variation{1.e5}+ will already insert a |
| 2647 |
space so avoid to insert another one through e.g. \key{opencommands}. |
| 2648 |
|
| 2649 |
|
| 2650 |
\item It is possible to open a group (with |
| 2651 |
\cs{begingroup}) or a environment in one command and close it in |
| 2652 |
another command. If you do this check carefully that you have |
| 2653 |
balanced groups in all four combinations of white/black opening and |
| 2654 |
ending the game! Check also if everything works if you have only one |
| 2655 |
move. |
| 2656 |
|
| 2657 |
\item You don't have to give a definition for all keys/commands. |
| 2658 |
Unused keys are set to empty. |
| 2659 |
|
| 2660 |
\item If you want to force a style (or a style item) to use the long |
| 2661 |
or the short algebraic notation you can add |
| 2662 |
\cs{longmoves}/\hspace{0pt}\cs{shortmoves} to \key{opencommands}. |
| 2663 |
\index{longmoves=\verb!*+\longmoves+>}% |
| 2664 |
\index{shortmoves=\verb!*+\shortmoves+>}% |
| 2665 |
\end{itemize} |
| 2666 |
|
| 2667 |
|
| 2668 |
\item[\meta{beforeNAG}=\meta{commands}, \meta{beforecomment}=\meta{commands}] |
| 2669 |
|
| 2670 |
\packagename{xskak} puts around each NAG and comment given by |
| 2671 |
\cs{xskakcomment} a group and before each NAG's and comment a |
| 2672 |
formatting command. This commands are named \cs{xskak@beforeNAG} and |
| 2673 |
\cs{xskak@beforecomment}. With the keys \key{beforeNAG} and |
| 2674 |
\key{beforecomment} you can change this commands and so to some |
| 2675 |
extend change the formatting of NAG and long comments (the styles of |
| 2676 |
short comments like + or ! are not affected!). The last command in |
| 2677 |
\meta{commands} can be a command that has one argument. NAG and the |
| 2678 |
content of the comment will then be used as this argument. This makes |
| 2679 |
is e.g. possible to gobble commands: |
| 2680 |
|
| 2681 |
\begin{LTXexample}[varwidth=false,width=0.3\textwidth] |
| 2682 |
\providecommand\gobble[1]{} |
| 2683 |
\xskaknewstyleitem[% |
| 2684 |
template=UF,%a predefined style item |
| 2685 |
beforeNAG=\gobble, |
| 2686 |
beforecomment=\gobble]{gobblecomments} |
| 2687 |
|
| 2688 |
\xskakaddtostyle[% |
| 2689 |
level=gobble, |
| 2690 |
styleitem=gobblecomments]{test} |
| 2691 |
|
| 2692 |
\variation[style=test,level=gobble]{1. e4! $1 \xskakcomment{expected} e5 $2} |
| 2693 |
\end{LTXexample} |
| 2694 |
|
| 2695 |
|
| 2696 |
|
| 2697 |
|
| 2698 |
|
| 2699 |
|
| 2700 |
\item[\key{template}=\meta{item}] |
| 2701 |
\index{xskaknewstyleitem=\verb!*+\xskaknewstyleitem+>template (key)}% |
| 2702 |
\index{template (\texttt{\textbackslash xskaknewstyleitem} key)}% |
| 2703 |
|
| 2704 |
With this key you can reuse the definitions from another style item. |
| 2705 |
\end{description} |
| 2706 |
|
| 2707 |
|
| 2708 |
\subsubsection{Defining style} |
| 2709 |
|
| 2710 |
|
| 2711 |
\DescribeMacro{\xskaknewstyle}% |
| 2712 |
\DescribeMacro{\xskakaddtostyle}% |
| 2713 |
With \cs{xskaknewstyle}\keyoarg\marg{style} you define the style |
| 2714 |
\meta{style}. \\With \cs{xskakaddtostyle}\keyoarg\marg{style} you can |
| 2715 |
add more levels (or overwrite existing ones) to a style. Both |
| 2716 |
commands can handle four keys: \key{level}, \key{styleitem}, |
| 2717 |
\key{font} and \key{xfont}. |
| 2718 |
|
| 2719 |
|
| 2720 |
\begin{description} |
| 2721 |
\item[\key{level}=\meta{number}] |
| 2722 |
\index{xskaknewstyle=\verb!*+\xskaknewstyle+>level (key)}% |
| 2723 |
\index{level (\texttt{\textbackslash xskaknewstyle} key)}% |
| 2724 |
|
| 2725 |
With this key you set the number of the level for which you want to |
| 2726 |
declared a «look» with the following keys. The «highest» level number |
| 2727 |
is 1. Normally it should contain the description of the style for the |
| 2728 |
main game. Variation styles should have larger numbers. But the |
| 2729 |
\meta{number} don't need to be a number, strings are also possible. |
| 2730 |
|
| 2731 |
|
| 2732 |
If you want to keep everything simple: Use only (positive) numbers |
| 2733 |
with levels. Then the levels have a well-defined order which is easy |
| 2734 |
to handle. Key \key{invar} will add 1 to a level number, key |
| 2735 |
\key{outvar} will substract 1 and if you set the level to a number |
| 2736 |
for which no style item as been declared \packagename{xskak} will |
| 2737 |
simply substract 1 from this number until it finds a level with a |
| 2738 |
style item it can use. |
| 2739 |
|
| 2740 |
But you can also use level names with chars e.g. to define variants |
| 2741 |
for a specific variation level. So you could e.g. define levels |
| 2742 |
\texttt{1open}, \texttt{1close}, \texttt{1middle}, |
| 2743 |
\texttt{1betteris}. |
| 2744 |
|
| 2745 |
In this case it depends on your compiler how the keys \key{invar} |
| 2746 |
and \key{outvar} and levels without declared style items are handled: |
| 2747 |
|
| 2748 |
\begin{description} |
| 2749 |
\item[Case 1:] You have an old pdf\TeX\ where the (experimental) primitive |
| 2750 |
\cs{pdfmatch} is not defined (or you did use the package option |
| 2751 |
\texttt{nopdfmatch}).\mynobreakpar |
| 2752 |
|
| 2753 |
Then the keys \key{invar} and \key{outvar} will not work when the |
| 2754 |
current level contains chars or other non-numerical tokens. They will |
| 2755 |
issue more or less bewildering errors. |
| 2756 |
|
| 2757 |
Levels without a declared style item will issue errors too. |
| 2758 |
|
| 2759 |
\item[Case 2:] You have a recent pdf\TeX\ where the (experimental) primitive |
| 2760 |
\cs{pdfmatch} is defined (and you didn't use the package option |
| 2761 |
\texttt{nopdfmatch}).\mynobreakpar |
| 2762 |
|
| 2763 |
\begin{description} |
| 2764 |
\item[Case a)] The level name doesn't contain any number, e.g. \texttt{level=gobble}:\mynobreakpar |
| 2765 |
|
| 2766 |
Then you will get an error if you try to set the level and you haven't declared a style item for this level. |
| 2767 |
|
| 2768 |
If the current level is \texttt{gobble} then the keys \key{invar} and \key{outvar} will issue a warning |
| 2769 |
and let the level unchanged. |
| 2770 |
|
| 2771 |
\item[Case b)] The level name do contain numbers, e.g. \texttt{level=a12b567}:\mynobreakpar |
| 2772 |
|
| 2773 |
Then \packagename{xskak} will use the following substituation if you try to set the level and there is no style |
| 2774 |
item declared: |
| 2775 |
\packagename{xskak} will extract the |
| 2776 |
first number from the name (in this case «12»), substract one |
| 2777 |
from this number and try the name with the new number in it. If |
| 2778 |
the first number is 1, level 1 is used (it is always defined). If |
| 2779 |
the first number is 0 you will get an error. |
| 2780 |
|
| 2781 |
In the example \packagename{xskak} will try the levels in the following order until it finds one that it can use: |
| 2782 |
{\ttfamily a12b567 $\rightarrow$ a11b567 $\rightarrow$ a10b567 $\rightarrow$ \ldots a2b567 $\rightarrow$ a1b567 $\rightarrow$ 1} |
| 2783 |
\end{description} |
| 2784 |
|
| 2785 |
\end{description} |
| 2786 |
|
| 2787 |
|
| 2788 |
\item[\key{styleitem}=\meta{item}] |
| 2789 |
\index{xskaknewstyle=\verb!*+\xskaknewstyle+>styleitem (key)}% |
| 2790 |
\index{styleitem (\texttt{\textbackslash xskaknewstyle} key)}% |
| 2791 |
|
| 2792 |
With this key you set the style item used by the current level |
| 2793 |
\emph{and all following levels} until another \key{styleitem} is set. |
| 2794 |
|
| 2795 |
|
| 2796 |
\item[\key{font}=\meta{commands}] |
| 2797 |
\index{xskaknewstyle=\verb!*+\xskaknewstyle+>font (key)}% |
| 2798 |
\index{font (\texttt{\textbackslash xskaknewstyle} key)}% |
| 2799 |
|
| 2800 |
With this key you can add some specific commands to the current |
| 2801 |
level (\emph{and only to the current level}). While the key is meant |
| 2802 |
to add font switches to a level it can also be used to overwrite some |
| 2803 |
commands of a style item. |
| 2804 |
|
| 2805 |
|
| 2806 |
|
| 2807 |
\begin{LTXexample}[varwidth=false,width=0.3\textwidth] |
| 2808 |
\xskaknewstyleitem[% |
| 2809 |
template=UF,%a predefined style item |
| 2810 |
beforenumber=\color{red},% |
| 2811 |
whiteopen=.\,\color{black}, |
| 2812 |
blackopen=\ldots\,\color{black}]{rednumbers} |
| 2813 |
|
| 2814 |
%% add to existing style test |
| 2815 |
\xskakaddtostyle[% |
| 2816 |
level=10,styleitem=rednumbers, |
| 2817 |
level=12, |
| 2818 |
font=\def\beforenumber{\color{green}}\bfseries] |
| 2819 |
{test} |
| 2820 |
|
| 2821 |
|
| 2822 |
\newchessgame |
| 2823 |
\mainline[style=test,level=12]{1. Nf3 Nf6 2. d4} |
| 2824 |
|
| 2825 |
\variation[level=10]{2. Nc3} |
| 2826 |
|
| 2827 |
|
| 2828 |
\mainline[level=11]{2... d5} |
| 2829 |
\end{LTXexample} |
| 2830 |
|
| 2831 |
\begin{LTXexample}[varwidth=false,width=0.3\textwidth] |
| 2832 |
\xskakset{style=test}% |
| 2833 |
\xskaknewstyleitem[% |
| 2834 |
template=UF,%a predefined style item |
| 2835 |
beforeNAG=\color{blue}, |
| 2836 |
beforecomment=\mdseries]{mycomments} |
| 2837 |
|
| 2838 |
\xskakaddtostyle[level=13,styleitem=mycomments, |
| 2839 |
font=\bfseries]{test} |
| 2840 |
|
| 2841 |
\variation[level=13]{1. e4 $1 \xskakcomment{ as expected} e5} |
| 2842 |
|
| 2843 |
\makeatletter |
| 2844 |
\xskakaddtostyle[% |
| 2845 |
level=gobbleB,styleitem=gobblecomments, |
| 2846 |
font=\renewcommand\xskak@beforeNAG{\color{red}}]% |
| 2847 |
{test} |
| 2848 |
\makeatother |
| 2849 |
|
| 2850 |
\variation[level=gobbleB]{1. e4! $1 \xskakcomment{ I expected it} e5 $2} |
| 2851 |
\end{LTXexample} |
| 2852 |
|
| 2853 |
\item[\key{xfont}=\meta{commands}] |
| 2854 |
\index{xskaknewstyle=\verb!*+\xskaknewstyle+>xfont (key)}% |
| 2855 |
\index{xfont (\texttt{\textbackslash xskaknewstyle} key)}% |
| 2856 |
|
| 2857 |
With this key you can add some specific commands to all levels with |
| 2858 |
the same first number in their name. It needs a recent pdf\TeX\ with |
| 2859 |
the command \cs{pdfmatch}. |
| 2860 |
|
| 2861 |
As an example lets add three levels to the test style used above: the |
| 2862 |
first (main) level should use a bold font, the second \cs{mdseries} |
| 2863 |
and the third an italic font. For each level we will define a variant |
| 2864 |
which puts a \cs{betteris} (\betteris) before the first move. |
| 2865 |
|
| 2866 |
The example also demonstrates how to retrieve the current level. |
| 2867 |
Please note the braces around some of the \cs{variations} which keep |
| 2868 |
the level change local. |
| 2869 |
|
| 2870 |
\begin{LTXexample}[width=0.3\textwidth,varwidth=false,caption=«betteris» style,label=sty:betteris] |
| 2871 |
\xskaknewstyleitem[% |
| 2872 |
template=UF, |
| 2873 |
opencommands=(\betteris, |
| 2874 |
closecommands=)]{betteris} |
| 2875 |
|
| 2876 |
|
| 2877 |
\xskakaddtostyle |
| 2878 |
[level=20 ,styleitem=UF,xfont=\bfseries, |
| 2879 |
level=20bis,styleitem=betteris, |
| 2880 |
level=21 ,xfont=\mdseries, |
| 2881 |
level=22 ,xfont=\itshape]{test} |
| 2882 |
|
| 2883 |
\xskakset{style=test} |
| 2884 |
|
| 2885 |
\variation[level=20]{1. e4 e5} (level \xskakget{level}) |
| 2886 |
\variation[level=20bis]{1... e6} (level \xskakget{level}) |
| 2887 |
|
| 2888 |
\variation[level=21]{1. e4 e5} (level \xskakget{level}) |
| 2889 |
\variation[level=21bis]{1... e6} (level \xskakget{level}) |
| 2890 |
|
| 2891 |
\variation[level=22]{1. e4 e5} (level \xskakget{level}) |
| 2892 |
\variation[level=22bis]{1... e6} (level \xskakget{level}) |
| 2893 |
|
| 2894 |
|
| 2895 |
\variation[level=20]{1. e4 e5} |
| 2896 |
{\variation[level=\xskakget{level}bis]{1... e6} |
| 2897 |
\variation[invar]{1... e6} \variation[invar]{1... e6}} |
| 2898 |
|
| 2899 |
\variation[invar]{1. e4 e5} %to level 21 |
| 2900 |
{\variation[level=\xskakget{level}bis]{1... e6}} |
| 2901 |
|
| 2902 |
\variation[invar]{1. e4 e5} %to level 22 |
| 2903 |
{\variation[level=\xskakget{level}bis]{1... e6}} |
| 2904 |
|
| 2905 |
\end{LTXexample} |
| 2906 |
|
| 2907 |
|
| 2908 |
\end{description} |
| 2909 |
|
| 2910 |
|
| 2911 |
The previous examples demonstrate some important points to consider |
| 2912 |
when defining styles: |
| 2913 |
|
| 2914 |
\begin{itemize} |
| 2915 |
\item You can define as much levels as you want. |
| 2916 |
|
| 2917 |
\item The number of the levels don't have to be consecutive (they even need to be numbers). If there |
| 2918 |
is no definition for a level (in the first example level 11), the |
| 2919 |
style item of a previous level (in this case level 10) is used if |
| 2920 |
\packagename{xskak} is able to figure out what the previous level |
| 2921 |
could be. |
| 2922 |
|
| 2923 |
\item While it is often sensible to store the settings for the main level |
| 2924 |
in level 1, and for the first variation level in level 2 and so on, |
| 2925 |
you can also chose other orders or use more than one level for each |
| 2926 |
logical variation level. If you e.g. want sometimes to add braces |
| 2927 |
through \key{opencommands} you could define variants $n$a, $n$b etc |
| 2928 |
of the involved variation level. |
| 2929 |
|
| 2930 |
|
| 2931 |
|
| 2932 |
\item While it is easy to define style items and styles it is not |
| 2933 |
easy sort and bundle them in a sensible way. |
| 2934 |
|
| 2935 |
\end{itemize} |
| 2936 |
|
| 2937 |
|
| 2938 |
\subsection{Using the styles}\label{sec:usestyles} |
| 2939 |
|
| 2940 |
The names of the commands \cs{mainline} and \cs{variation} give the |
| 2941 |
impression that you should use the first for the main game and the |
| 2942 |
second for the variations. But at my opinion this impression is |
| 2943 |
wrong: You should use |
| 2944 |
\begin{itemize} |
| 2945 |
\item \cs{mainline} if you want to parse \emph{and} print chess moves, |
| 2946 |
\item \cs{variation} if you want only to print chess moves, |
| 2947 |
\item \cs{hidemoves} if you want only to parse moves and |
| 2948 |
\item \cs{printchessgame} (described later) if you want to |
| 2949 |
(re)print a previously parsed game. |
| 2950 |
\end{itemize} |
| 2951 |
|
| 2952 |
This means that each of the printing commands can be used for the |
| 2953 |
main game and for variations. And so it should be possible for each |
| 2954 |
of the printing commands to set and use every style level. |
| 2955 |
|
| 2956 |
In consequence this means that if you use the new interface -- you |
| 2957 |
don't have to -- \cs{variation} will no longer switch to another |
| 2958 |
style. |
| 2959 |
|
| 2960 |
You can set the style and the level either with \cs{xskakset} or in |
| 2961 |
the optional argument of the three printing commands. The keys you |
| 2962 |
can use in both cases are: |
| 2963 |
|
| 2964 |
|
| 2965 |
|
| 2966 |
\begin{description} |
| 2967 |
\item[\key{style}=\meta{style name}] |
| 2968 |
\index{xskakset=\verb!*+\xskakset+>style (key)}% |
| 2969 |
\index{style (\texttt{\textbackslash xskakset} key)}% |
| 2970 |
\index{mainline=\verb!*+\mainline+>style (key)}% |
| 2971 |
\index{style (\texttt{\textbackslash mainline} key)}% |
| 2972 |
\index{variation=\verb!*+\variation+>style (key)}% |
| 2973 |
\index{style (\texttt{\textbackslash variation} key)}% |
| 2974 |
\index{printchessgame=\verb!*+\printchessgame+>style (key)}% |
| 2975 |
\index{style (\texttt{\textbackslash printchessgame} key)}% |
| 2976 |
|
| 2977 |
This key sets the name of the style the following printing commands |
| 2978 |
should use. The setting is always local to the current group (even |
| 2979 |
with \cs{xskakset}\footnote{At first \cs{xskakset} did the settings |
| 2980 |
globally. I changed it after the third time I had to correct the |
| 2981 |
documentation because I forgot to reset a style after an example.}. |
| 2982 |
|
| 2983 |
|
| 2984 |
\item[\key{gstyle}=\meta{style name}] |
| 2985 |
\index{xskakset=\verb!*+\xskakset+>gstyle (key)}% |
| 2986 |
\index{gstyle (\texttt{\textbackslash xskakset} key)}% |
| 2987 |
\index{mainline=\verb!*+\mainline+>gstyle (key)}% |
| 2988 |
\index{gstyle (\texttt{\textbackslash mainline} key)}% |
| 2989 |
\index{variation=\verb!*+\variation+>gstyle (key)}% |
| 2990 |
\index{gstyle (\texttt{\textbackslash variation} key)}% |
| 2991 |
\index{printchessgame=\verb!*+\printchessgame+>gstyle (key)}% |
| 2992 |
\index{gstyle (\texttt{\textbackslash printchessgame} key)}% |
| 2993 |
|
| 2994 |
This key sets the name of the style globally. |
| 2995 |
|
| 2996 |
|
| 2997 |
\item[\key{level}=\meta{number}] |
| 2998 |
\index{xskakset=\verb!*+\xskakset+>level (key)}% |
| 2999 |
\index{level (\texttt{\textbackslash xskakset} key)}% |
| 3000 |
\index{mainline=\verb!*+\mainline+>level (key)}% |
| 3001 |
\index{level (\texttt{\textbackslash mainline} key)}% |
| 3002 |
\index{variation=\verb!*+\variation+>level (key)}% |
| 3003 |
\index{level (\texttt{\textbackslash variation} key)}% |
| 3004 |
\index{printchessgame=\verb!*+\printchessgame+>level (key)}% |
| 3005 |
\index{level (\texttt{\textbackslash printchessgame} key)}% |
| 3006 |
|
| 3007 |
This key sets the level the following printing commands should use. |
| 3008 |
The setting is always local to the current group. |
| 3009 |
|
| 3010 |
\item[\key{glevel}=\meta{number}] |
| 3011 |
\index{xskakset=\verb!*+\xskakset+>glevel (key)}% |
| 3012 |
\index{glevel (\texttt{\textbackslash xskakset} key)}% |
| 3013 |
\index{mainline=\verb!*+\mainline+>glevel (key)}% |
| 3014 |
\index{glevel (\texttt{\textbackslash mainline} key)}% |
| 3015 |
\index{variation=\verb!*+\variation+>glevel (key)}% |
| 3016 |
\index{glevel (\texttt{\textbackslash variation} key)}% |
| 3017 |
\index{printchessgame=\verb!*+\printchessgame+>glevel (key)}% |
| 3018 |
\index{glevel (\texttt{\textbackslash printchessgame} key)}% |
| 3019 |
|
| 3020 |
This key sets the level globally. |
| 3021 |
|
| 3022 |
\item[\key{invar}] |
| 3023 |
\index{xskakset=\verb!*+\xskakset+>invar (key)}% |
| 3024 |
\index{invar (\texttt{\textbackslash xskakset} key)}% |
| 3025 |
\index{mainline=\verb!*+\mainline+>invar (key)}% |
| 3026 |
\index{invar (\texttt{\textbackslash mainline} key)}% |
| 3027 |
\index{variation=\verb!*+\variation+>invar (key)}% |
| 3028 |
\index{invar (\texttt{\textbackslash variation} key)}% |
| 3029 |
\index{printchessgame=\verb!*+\printchessgame+>invar (key)}% |
| 3030 |
\index{invar (\texttt{\textbackslash printchessgame} key)}% |
| 3031 |
|
| 3032 |
This will add 1 to the first number in the current level (so it goes |
| 3033 |
towards «higher» (deeper) levels). Again the change is local to the |
| 3034 |
group. This key can break if the current value of the level is not a |
| 3035 |
number. |
| 3036 |
|
| 3037 |
\item[\key{ginvar}] |
| 3038 |
\index{xskakset=\verb!*+\xskakset+>ginvar (key)}% |
| 3039 |
\index{ginvar (\texttt{\textbackslash xskakset} key)}% |
| 3040 |
\index{mainline=\verb!*+\mainline+>ginvar (key)}% |
| 3041 |
\index{ginvar (\texttt{\textbackslash mainline} key)}% |
| 3042 |
\index{variation=\verb!*+\variation+>ginvar (key)}% |
| 3043 |
\index{ginvar (\texttt{\textbackslash variation} key)}% |
| 3044 |
\index{printchessgame=\verb!*+\printchessgame+>ginvar (key)}% |
| 3045 |
\index{ginvar (\texttt{\textbackslash printchessgame} key)}% |
| 3046 |
|
| 3047 |
This is the global variant of \key{invar}. |
| 3048 |
|
| 3049 |
\item[\key{outvar}] |
| 3050 |
\index{xskakset=\verb!*+\xskakset+>outvar (key)}% |
| 3051 |
\index{outvar (\texttt{\textbackslash xskakset} key)}% |
| 3052 |
\index{mainline=\verb!*+\mainline+>outvar (key)}% |
| 3053 |
\index{outvar (\texttt{\textbackslash mainline} key)}% |
| 3054 |
\index{variation=\verb!*+\variation+>outvar (key)}% |
| 3055 |
\index{outvar (\texttt{\textbackslash variation} key)}% |
| 3056 |
\index{printchessgame=\verb!*+\printchessgame+>outvar (key)}% |
| 3057 |
\index{outvar (\texttt{\textbackslash printchessgame} key)}% |
| 3058 |
|
| 3059 |
This will substract 1 to the first number in the current level (so it |
| 3060 |
goes towards level 1 as the main level). This key can break if the |
| 3061 |
current value of the level is not a number. |
| 3062 |
|
| 3063 |
\item[\key{goutvar}] |
| 3064 |
\index{xskakset=\verb!*+\xskakset+>goutvar (key)}% |
| 3065 |
\index{goutvar (\texttt{\textbackslash xskakset} key)}% |
| 3066 |
\index{mainline=\verb!*+\mainline+>goutvar (key)}% |
| 3067 |
\index{goutvar (\texttt{\textbackslash mainline} key)}% |
| 3068 |
\index{variation=\verb!*+\variation+>goutvar (key)}% |
| 3069 |
\index{goutvar (\texttt{\textbackslash variation} key)}% |
| 3070 |
\index{printchessgame=\verb!*+\printchessgame+>goutvar (key)}% |
| 3071 |
\index{goutvar (\texttt{\textbackslash printchessgame} key)}% |
| 3072 |
|
| 3073 |
This is the global variant of \key{outvar}. |
| 3074 |
\end{description} |
| 3075 |
|
| 3076 |
|
| 3077 |
\subsection{The predefined styles} |
| 3078 |
|
| 3079 |
\Xskak predefines five styles: \texttt{styleA}, \texttt{styleB} and |
| 3080 |
\texttt{styleC} imitate the predefined styles of \packagename{skak} |
| 3081 |
with the addition that they change to italic in the third level. |
| 3082 |
Style \texttt{UF} is my style and style \texttt{test} is a large |
| 3083 |
container for all sorts of tests. |
| 3084 |
|
| 3085 |
|
| 3086 |
\begin{LTXexample}[width=0.4\textwidth,varwidth=false] |
| 3087 |
\minisec{style \enquote{styleA}} |
| 3088 |
\newchessgame |
| 3089 |
\xskakset{style=styleA} |
| 3090 |
\mainline[level=1]{% |
| 3091 |
1. e4 e6 2. d4 d5 3. e5 c5 4. c3 Qb6} |
| 3092 |
(\variation[invar]{4... Ne7 5. Nf3 Nec6} |
| 3093 |
(\variation[invar]{5... Nf5 6. h4 Be7 |
| 3094 |
7. Bd3 cxd4 8. cxd4 Nc6 9. Bxf5 exf5 10. Bg5 $14}) |
| 3095 |
\variation[outvar]{6. Bd3} |
| 3096 |
(\variation[invar]{6. h4 Nd7 7. h5 f6 $1 $132})) |
| 3097 |
\mainline[outvar,outvar]{ 5. Nf3 Bd7} |
| 3098 |
|
| 3099 |
\end{LTXexample} |
| 3100 |
|
| 3101 |
|
| 3102 |
\begin{LTXexample}[width=0.4\textwidth,varwidth=false] |
| 3103 |
\minisec{style \enquote{styleB}} |
| 3104 |
\newchessgame |
| 3105 |
\xskakset{style=styleB} |
| 3106 |
\mainline[level=1]{% |
| 3107 |
1. e4 e6 2. d4 d5 3. e5 c5 4. c3 Qb6} |
| 3108 |
(\variation[invar]{4... Ne7 5. Nf3 Nec6} |
| 3109 |
(\variation[invar]{5... Nf5 6. h4 Be7 |
| 3110 |
7. Bd3 cxd4 8. cxd4 Nc6 9. Bxf5 exf5 10. Bg5 $14}) |
| 3111 |
\variation[outvar]{6. Bd3} |
| 3112 |
(\variation[invar]{6. h4 Nd7 7. h5 f6 $1 $132})) |
| 3113 |
\mainline[outvar,outvar]{ 5. Nf3 Bd7} |
| 3114 |
|
| 3115 |
\end{LTXexample} |
| 3116 |
|
| 3117 |
\begin{LTXexample}[width=0.4\textwidth,varwidth=false] |
| 3118 |
\minisec{style \enquote{UF}} |
| 3119 |
\newchessgame |
| 3120 |
\xskakset{style=UF} |
| 3121 |
\mainline[level=1]{% |
| 3122 |
1. e4 e6 2. d4 d5 3. e5 c5 4. c3 Qb6} |
| 3123 |
(\variation[invar]{4... Ne7 5. Nf3 Nec6} |
| 3124 |
(\variation[invar]{5... Nf5 6. h4 Be7 |
| 3125 |
7. Bd3 cxd4 8. cxd4 Nc6 9. Bxf5 exf5 10. Bg5 $14}) |
| 3126 |
\variation[outvar]{6. Bd3} |
| 3127 |
(\variation[invar]{6. h4 Nd7 7. h5 f6 $1 $132})) |
| 3128 |
\mainline[outvar,outvar]{ 5. Nf3 Bd7} |
| 3129 |
|
| 3130 |
\end{LTXexample} |
| 3131 |
|
| 3132 |
\minisec{style \enquote{styleC}} |
| 3133 |
styleC sets the moves in a tabbing and should be used only for the main moves. |
| 3134 |
\begin{LTXexample}[width=0.4\textwidth,varwidth=false] |
| 3135 |
\newchessgame |
| 3136 |
\mainline[style=styleC,level=1]{% |
| 3137 |
1. e4 e6 2. d4 d5 3. e5 c5 4. c3 Qb6} |
| 3138 |
(\variation[invar]{4... Ne7 5. Nf3 Nec6} |
| 3139 |
(\variation[invar]{5... Nf5 6. h4 Be7 |
| 3140 |
7. Bd3 cxd4 8. cxd4 Nc6 9. Bxf5 exf5 10. Bg5 $14}) |
| 3141 |
\variation[outvar]{6. Bd3} |
| 3142 |
(\variation[invar]{6. h4 Nd7 7. h5 f6 $1 $132})) |
| 3143 |
\mainline[outvar,outvar]{ 5. Nf3 Bd7} |
| 3144 |
|
| 3145 |
\end{LTXexample} |
| 3146 |
|
| 3147 |
|
| 3148 |
\subsection{The new \texorpdfstring{\texttt{xskak}}{xskak} printing |
| 3149 |
command}\label{sec:print} |
| 3150 |
|
| 3151 |
\DescribeMacro{\printchessgame}% |
| 3152 |
As one of the aims of \packagename{xskak} is to separate the parsing |
| 3153 |
from the printing of a game there is naturally also a printing |
| 3154 |
command. With \cs{printchessgame}\keyoarg{} you can print a |
| 3155 |
previously parsed and saved game. Without any options |
| 3156 |
\cs{printchessgame} will print the game with the currently active |
| 3157 |
\meta{GameId} from start to end. |
| 3158 |
|
| 3159 |
|
| 3160 |
|
| 3161 |
As keys you can use |
| 3162 |
\begin{description} |
| 3163 |
\item[\key{id}=\meta{GameId}, \key{refid}=\meta{tag}] |
| 3164 |
\index{printchessgame=\verb!*+\printchessgame+>id (key)}% |
| 3165 |
\index{id (\texttt{\textbackslash printchessgame} key)}% |
| 3166 |
\index{printchessgame=\verb!*+\printchessgame+>refid (key)}% |
| 3167 |
\index{refid (\texttt{\textbackslash printchessgame} key)}% |
| 3168 |
|
| 3169 |
This keys change only for the printing the current \meta{GameId}. |
| 3170 |
Afterwards the old \meta{GameId} is restored. |
| 3171 |
|
| 3172 |
\item[\key{initmovenr=}\meta{number}, \key{initplayer=}\meta{«w» or «b»}, \key{initmoveid=}\meta{number + «w» or «b»}]\index{printchessgame=\verb!*+\printchessgame+>initmovenr (key)}% |
| 3173 |
\index{initmovenr (\texttt{\textbackslash printchessgame} key)}% |
| 3174 |
\index{printchessgame=\verb!*+\printchessgame+>initplayer (key)}% |
| 3175 |
\index{initplayer (\texttt{\textbackslash printchessgame} key)}% |
| 3176 |
\index{printchessgame=\verb!*+\printchessgame+>initmoveid (key)}% |
| 3177 |
\index{initmoveid (\texttt{\textbackslash printchessgame} key)}% |
| 3178 |
~\\ This keys sets the move the printing should start with. If the |
| 3179 |
move isn't in the game a warning is issued and the first move of the |
| 3180 |
game is used instead. |
| 3181 |
|
| 3182 |
\item[\key{stopmovenr=}\meta{number}, \key{stopplayer=}\meta{«w» or «b»}, \key{stopmoveid=}\meta{number + «w» or «b»}] |
| 3183 |
\index{printchessgame=\verb!*+\printchessgame+>stopmovenr (key)}% |
| 3184 |
\index{stopmovenr (\texttt{\textbackslash printchessgame} key)}% |
| 3185 |
\index{printchessgame=\verb!*+\printchessgame+>stopplayer (key)}% |
| 3186 |
\index{stopplayer (\texttt{\textbackslash printchessgame} key)}% |
| 3187 |
\index{printchessgame=\verb!*+\printchessgame+>stopmoveid (key)}% |
| 3188 |
\index{stopmoveid (\texttt{\textbackslash printchessgame} key)}% |
| 3189 |
~\\ This keys sets the move the printing should end with. If the move |
| 3190 |
isn't in the game a warning is issued and the last move of the game |
| 3191 |
is used instead. |
| 3192 |
|
| 3193 |
\item[\key{reftag}=\meta{tag}] |
| 3194 |
\index{printchessgame=\verb!*+\printchessgame+>reftag (key)}% |
| 3195 |
\index{reftag (\texttt{\textbackslash printchessgame} key)}% |
| 3196 |
|
| 3197 |
This sets the tag name in case that you want to use tagged moves as |
| 3198 |
start or end of the printing. There are no keys like |
| 3199 |
\key{initrefpastmoveid} (I thought so long names are no longer |
| 3200 |
manageable), so you will have to use e.g. \texttt{reftag=}\meta{tag}, |
| 3201 |
\texttt{initmovenr=}\cs{xskakget}\verb+{refpast}+. |
| 3202 |
|
| 3203 |
|
| 3204 |
\item[\key{style}, \key{level}, key{invar} and \key{outvar}]% |
| 3205 |
\index{printchessgame=\verb!*+\printchessgame+>level (key)}% |
| 3206 |
\index{level (\texttt{\textbackslash printchessgame} key)}% |
| 3207 |
\index{printchessgame=\verb!*+\printchessgame+>invar (key)}% |
| 3208 |
\index{invar (\texttt{\textbackslash printchessgame} key)}% |
| 3209 |
\index{printchessgame=\verb!*+\printchessgame+>outvar (key)}% |
| 3210 |
\index{outvar (\texttt{\textbackslash printchessgame} key)}% |
| 3211 |
\index{printchessgame=\verb!*+\printchessgame+>style (key)}% |
| 3212 |
\index{style (\texttt{\textbackslash printchessgame} key)}% |
| 3213 |
|
| 3214 |
\cs{printchessgame} use the same formatting commands as |
| 3215 |
\packagename{skak}, so the style can be change through the interface |
| 3216 |
defined and described in section \ref{sec:interface}. |
| 3217 |
|
| 3218 |
|
| 3219 |
To set the level and the style you can use the keys described in |
| 3220 |
section \ref{sec:usestyles} in the optional argument of |
| 3221 |
\cs{printchessgame}. Like with \cs{mainline} and \cs{variation} the |
| 3222 |
keys sets the values locally for the current group. |
| 3223 |
|
| 3224 |
To print the actual moves, \cs{printchessgame} doesn't use the |
| 3225 |
command \cs{printmove} from \packagename{skaksty} but an internal |
| 3226 |
command named \cs{xskak@do@printmove}. So commands like |
| 3227 |
\cs{longmoves} must set this command appropriately. |
| 3228 |
|
| 3229 |
|
| 3230 |
\end{description} |
| 3231 |
|
| 3232 |
\begin{LTXexample} |
| 3233 |
\input{xskakgames.xsk} |
| 3234 |
\printchessgame[style=UF,level=1,id=export, |
| 3235 |
initmoveid=7w,stopmoveid=12b] |
| 3236 |
\end{LTXexample} |
| 3237 |
|
| 3238 |
|
| 3239 |
\subsection{Game titles and chessboard captions} |
| 3240 |
|
| 3241 |
There are no pre-made commands. You will have to define them with the |
| 3242 |
help of the stored game data/move data. For titles I advise you to |
| 3243 |
use a sort of sectioning command -- this will prevent page breaks |
| 3244 |
between the title and the game. Look e.g. at the definition of |
| 3245 |
\cs{minisec} in one of the classes from the KOMA-bundle. For |
| 3246 |
captions: look at the package \packagename{caption}. |
| 3247 |
|
| 3248 |
|
| 3249 |
|
| 3250 |
|
| 3251 |
\section{PGN2LTX or How to sort the input} |
| 3252 |
|
| 3253 |
While \packagename{skak}/\packagename{xskak} can handle games in |
| 3254 |
PGN-notation they can't handle PGN-files: neither the PGN-infos |
| 3255 |
(which is a small nuisances) nor the variations and the comments in |
| 3256 |
the game notation (which makes it tedious to print large games with a |
| 3257 |
lot of annotations). |
| 3258 |
|
| 3259 |
There exists a small number of perl scripts and applications to help |
| 3260 |
to convert PGN to \LaTeX\ but none is really satisfactory. One of the |
| 3261 |
problems that prevents better solutions is that there is no clear |
| 3262 |
description what should be the result of a conversion from PGN to |
| 3263 |
\LaTeX. In this section I will make some remarks about what I think |
| 3264 |
would be a good output from such a converter for |
| 3265 |
\packagename{xskak}\footnote{\packagename{texmate} needs another |
| 3266 |
output.} and where I see problems. The description should also help |
| 3267 |
you to enter or convert complicated games manually. |
| 3268 |
|
| 3269 |
|
| 3270 |
\minisec{The PGN-infos} |
| 3271 |
|
| 3272 |
The «tag pair» section of a chess game in PGN shouldn't pose problems |
| 3273 |
to a converter. The tags should be simply converted to the equivalent |
| 3274 |
keys of a \cs{newchessgame}: |
| 3275 |
|
| 3276 |
\begin{lstlisting} |
| 3277 |
[Round "29"] |
| 3278 |
[White "Fischer, Robert J."] |
| 3279 |
[Black "Spassky, Boris V."] |
| 3280 |
[Result "1/2-1/2"] |
| 3281 |
\end{lstlisting} |
| 3282 |
% |
| 3283 |
\begin{lstlisting}[escapechar=/] |
| 3284 |
\newchessgame[id=/\meta{GameId}/, %see below |
| 3285 |
round={29}, |
| 3286 |
white={Fischer, Robert J.}, |
| 3287 |
black={Spassky, Boris V.}, |
| 3288 |
result={1/2-1/2}] |
| 3289 |
\end{lstlisting} |
| 3290 |
|
| 3291 |
\xskakset{style=UF}% |
| 3292 |
If the game use a \texttt{SetUp} and a \texttt{FEN} tag to set an |
| 3293 |
alternative starting position, the converter will have to extract the |
| 3294 |
start move from the FEN and set it with the key \key{moveid}. |
| 3295 |
|
| 3296 |
\minisec{The \meta{GameId}} |
| 3297 |
|
| 3298 |
While it is probably possible to give each game an unique |
| 3299 |
\meta{GameId} I don't think that it is sensible or really necessary. |
| 3300 |
I would suggest, that each game gets uses\\ |
| 3301 |
\verb+\newchessgame[id=main\xskakaddtoid,...]+ where |
| 3302 |
\cs{xskakaddtoid} is empty by default but can be redefined to allow |
| 3303 |
some automatic numbering. |
| 3304 |
|
| 3305 |
\minisec{The parsing command} |
| 3306 |
|
| 3307 |
As you will probably sometimes use \cs{mainline} and sometimes |
| 3308 |
\cs{hidemoves} it is probably best if the converter use an general |
| 3309 |
\cs{parsechessgame} which can be \cs{let} to both commands. |
| 3310 |
|
| 3311 |
\minisec{NAG's} |
| 3312 |
|
| 3313 |
Most NAG's don't need any special handling as \packagename{xskak} can |
| 3314 |
parse them. |
| 3315 |
|
| 3316 |
But some chess applications seems to put NAG's \emph{after} a move to |
| 3317 |
denote a symbol that should go \emph{before} the move. E.g. |
| 3318 |
\verb+1. e5 $142+ |
| 3319 |
% |
| 3320 |
should become \betteris\variation{1. e5}. |
| 3321 |
|
| 3322 |
Putting such symbols before a move number is in most cases only |
| 3323 |
possible at the start of a \cs{mainline} or \cs{variation} so the |
| 3324 |
converter will have probably to split the input and add the symbol |
| 3325 |
either directly or through a style. A converter will need a list of |
| 3326 |
all this special cases and good rules how to handle them. |
| 3327 |
|
| 3328 |
|
| 3329 |
|
| 3330 |
|
| 3331 |
\minisec{Long comments} |
| 3332 |
|
| 3333 |
Longer commands (in the PGN in curly braces) could be handled either |
| 3334 |
by adding a \cs{xskakcomment} at the begin of the comment or by |
| 3335 |
ending the parsing and starting it again after the comment. The first |
| 3336 |
method has the advantage that one can use styles to format to some |
| 3337 |
extend the comments (or gobble them) but can cause problems if the |
| 3338 |
comment contains something that isn't allowed in the argument of a |
| 3339 |
command. |
| 3340 |
|
| 3341 |
I think some real examples are needed to decide what is the best way. |
| 3342 |
|
| 3343 |
|
| 3344 |
\minisec{The content of long comments} |
| 3345 |
|
| 3346 |
I don't think that is possible to handle all possible contents |
| 3347 |
automatically and get a suitable result for \LaTeX. You will either |
| 3348 |
have to follow some rules while inputing the comments or tidy them up |
| 3349 |
later. |
| 3350 |
|
| 3351 |
But a converter will probably be able to identify moves like |
| 3352 |
\texttt{4.\,\,Nf3} and to surround them by suitable |
| 3353 |
\verb+\variation[style=...,level=...]{...}+. |
| 3354 |
|
| 3355 |
\minisec{Diagrams} |
| 3356 |
|
| 3357 |
Some chess applications let you put markers at places where you would |
| 3358 |
like to print a diagram. E.g. chessbase put |
| 3359 |
\texttt{Diagramm~\#}\footnote{I don't know if «Diagramm» is language |
| 3360 |
dependent. Probably yes.} in a comment. |
| 3361 |
|
| 3362 |
A converter should also be able to recognize such markers for |
| 3363 |
diagrams. But it is not easy to decide what should be done with this |
| 3364 |
markers. In some cases you would probably not want to print boards at |
| 3365 |
all. Sometimes the game should be interrupted and the diagram printed |
| 3366 |
directly. Sometimes it should float. And I recall that someone once |
| 3367 |
tried to put all diagrams in the order there were mentioned in the |
| 3368 |
margin. If such markers are used it is probably the best if the |
| 3369 |
converter sets a tag and sets one of the fake NAG's \texttt{\$D} and |
| 3370 |
\texttt{\$d}. Then \cs{printchessgame} and the list of diagrams could |
| 3371 |
be used to print the moves and the diagrams in the intended order |
| 3372 |
(but it will probably need some coding to get the right results). The |
| 3373 |
tag and the NAG should be move outside of the comment as the comment |
| 3374 |
isn't processed in all cases. |
| 3375 |
|
| 3376 |
\begin{lstlisting}[caption={Input and suggested output for diagram |
| 3377 |
markers}] |
| 3378 |
10. c3 e5 $1 {Diagramm # Die energische und konsequente |
| 3379 |
Fortsetzung, Schwarz öffnet das Zentrum, um seine Figuren zu |
| 3380 |
aktivieren.} 11. h3 |
| 3381 |
\end{lstlisting} |
| 3382 |
|
| 3383 |
\begin{lstlisting} |
| 3384 |
\mainline{10. c3 e5\xskakset{tag=dia1} $d $1 |
| 3385 |
\xskakcomment{ Die energische und konsequente Fortsetzung, |
| 3386 |
Schwarz öffnet das Zentrum, um seine Figuren zu aktivieren. } |
| 3387 |
11. h3} |
| 3388 |
\end{lstlisting} |
| 3389 |
|
| 3390 |
|
| 3391 |
|
| 3392 |
|
| 3393 |
\minisec{Variations} |
| 3394 |
|
| 3395 |
Here starts the real problems. Even if we forget for the moment the |
| 3396 |
parsing of moves and diagrams it is not easy to describe a suitable |
| 3397 |
output. The main problems come from the fact that styles and good |
| 3398 |
typesetting are involved: E.g. PGN code two variations in a row as |
| 3399 |
\texttt{(1...~e5) (1...~e6)}. But you would probably print this as |
| 3400 |
(\variation{1... e5}; \variation{1... e6}). |
| 3401 |
|
| 3402 |
So the converter will have to look ahead and use suitable «open», |
| 3403 |
«middle», «close» and «single» styles in the different combinations. |
| 3404 |
|
| 3405 |
If you make long analyzes you will probably want to use numbered list |
| 3406 |
for the variations -- but not every variation is so important that |
| 3407 |
it need its own number. In this case there must be a marker that |
| 3408 |
tells the converter to handle this variation differently. |
| 3409 |
|
| 3410 |
I haven't solved all this problems but I think that the following |
| 3411 |
code could be used as starting point for further discussion about a |
| 3412 |
\LaTeX-chess input\footnote{If one really wants to parse all |
| 3413 |
variations a better naming for the nodes is needed.}: |
| 3414 |
|
| 3415 |
\begin{lstlisting} |
| 3416 |
\newchessgame[id=main, ...] |
| 3417 |
\mainline{...} |
| 3418 |
%new var level |
| 3419 |
\newchessgame[newvar=main,id=var1a]% |
| 3420 |
\mainline[level=1open]{.....} |
| 3421 |
%same var level |
| 3422 |
\newchessgame[newvar=main,id=var1b]% |
| 3423 |
\mainline[level=1close]{....} |
| 3424 |
%new var level |
| 3425 |
\newchessgame[newvar=var1b,id=var2a]% |
| 3426 |
\mainline[level=2single]{....} |
| 3427 |
%% return to var1b: |
| 3428 |
\resumechessgame[id=var1b] |
| 3429 |
\mainline[level=1open]{....} |
| 3430 |
\end{lstlisting} |
| 3431 |
|
| 3432 |
|
| 3433 |
\minisec{Initialization and title} |
| 3434 |
|
| 3435 |
Until now I have only discussed the game itself. But you would |
| 3436 |
probably want to print titles, make table of contents and other |
| 3437 |
lists. So one should also add some generic commands or environments |
| 3438 |
like \verb+\begin{chessgame}+/\hspace{0pt}\verb+\end{chessgame}+ and |
| 3439 |
\verb+{\chessgameheader}+ to each game. |
| 3440 |
|
| 3441 |
|
| 3442 |
|
| 3443 |
|
| 3444 |
|
| 3445 |
|
| 3446 |
\section{Compability issues} |
| 3447 |
\subsection{\texorpdfstring{\packagename{xskak} and |
| 3448 |
\packagename{texmate}}{xskak and texmate}}\index{texmate} |
| 3449 |
|
| 3450 |
It will probably work fine to use both packages in one document. |
| 3451 |
|
| 3452 |
\cs{newchessgame} and \cs{resumechessgame} will both internally issue |
| 3453 |
a \cs{fenposition} command that will setup the games also for |
| 3454 |
\packagename{texmate}. This naturally means in return that both |
| 3455 |
commands interfere with \packagename{texmate}! |
| 3456 |
|
| 3457 |
You can't benefit of the extended input possibilities for NAG's and |
| 3458 |
comments. \packagename{texmate} has its own parsing method. |
| 3459 |
|
| 3460 |
Btw: If you are using \packagename{texmate} you should always indent |
| 3461 |
your input as the package doesn't recognize new lines as spaces. |
| 3462 |
|
| 3463 |
\subsection{\texorpdfstring{\packagename{xskak} and |
| 3464 |
\packagename{beamer}}{xskak and beamer}}\index{beamer} |
| 3465 |
|
| 3466 |
When making presentations with \packagename{beamer} you should |
| 3467 |
remember two things: First you can't use verbatim material or other |
| 3468 |
commands that relies on catcode changes in the |
| 3469 |
\texttt{frame}-environment or -command. That means for \skaksty that |
| 3470 |
you can't use \# in a \cs{mainline} but should replace it by |
| 3471 |
\cs{mate}. |
| 3472 |
|
| 3473 |
Second, if you are using overlays the content of the frame is |
| 3474 |
processed more than once. That means that you should be careful to |
| 3475 |
reset counters if you don't want to run into never ending loops. |
| 3476 |
|
| 3477 |
The following listing shows an example how to print a chessgame with |
| 3478 |
beamer. If your pdf-reader can handle annotations you can see the |
| 3479 |
result in the attached file: \attachfile{xskak_and_beamer.pdf} It |
| 3480 |
uses overlays (which worked fine) and also shows how you can handle |
| 3481 |
games in another language: |
| 3482 |
|
| 3483 |
\lstinputlisting{xskak_and_beamer.tex} |
| 3484 |
|
| 3485 |
\phantomsection |
| 3486 |
\makeatletter\def\index@prologue{\section*{Index}\addcontentsline{toc}{section}{Index}}\makeatother |
| 3487 |
\printindex |
| 3488 |
\end{document} |
| 3489 |
|
| 3490 |
\end{document} |