| 1 |
% !Mode:: "TeX:DE:UTF-8:Main" |
| 2 |
% -*- mode: TeX -*- -*- coding: UTF-8 -*- |
| 3 |
\listfiles |
| 4 |
\def\UFcurrentpackage{chessboard} |
| 5 |
\def\UFcurrentversion{2.0} |
| 6 |
%$Date$$Version$ |
| 7 |
%\ExplSyntaxOn |
| 8 |
%\sys_ensure_backend: |
| 9 |
%\pdf_uncompress: |
| 10 |
%%\pdf_version_gset:n{2.0} |
| 11 |
%\ExplSyntaxOff |
| 12 |
|
| 13 |
\RequirePackage{fix-cm} |
| 14 |
|
| 15 |
\documentclass[pagesize,parskip=half-,fontsize=12pt]{scrartcl} |
| 16 |
%% chessboard specific commands |
| 17 |
\usepackage[LSB1,LSB2, LSB3,LSBC2,LSBC3,LSBC4,LSBC5, T1]{fontenc} |
| 18 |
%\usepackage[skak-parse]{xskak} |
| 19 |
\usepackage{xskak} |
| 20 |
\usepackage{pifont} |
| 21 |
\usepackage{eqparbox} |
| 22 |
|
| 23 |
\newcommand\Chess[1][1cm]{\boardfont\fontsize{#1}{#1}\setboardfontsize{#1}\selectfont} |
| 24 |
\newcommand\Plus{\raisebox{0.5ex}{\normalfont\fontsize{1.5ex}{1.5ex}\bfseries\,+\,}} |
| 25 |
\newcommand\Equal{\raisebox{0.5ex}{\normalfont\fontsize{1.5ex}{1.5ex}\bfseries\,=\,}} |
| 26 |
|
| 27 |
\makeatletter |
| 28 |
\newcommand\Describesetkey[4]{\par\index{#1}% |
| 29 |
\colorbox{yellow!50}{\makebox[\dimexpr\textwidth-2\fboxsep\relax]{\ttfamily% |
| 30 |
\eqparbox{setkey}{#1=\meta{#2}}\hfill |
| 31 |
\eqparbox{setexample}{% |
| 32 |
\ifthenelse{\equal{#3}{}}% |
| 33 |
{#1} |
| 34 |
{#1={#3}}}\hfill |
| 35 |
\eqparbox{setdefault}{\hfill #4}}}\par\nobreak\@afterheading} |
| 36 |
|
| 37 |
|
| 38 |
\newcommand\Describefillkey[4][]{\par\index{#2}% |
| 39 |
\makebox[0pt][r]{\scriptsize #1\hspace{1em}}% |
| 40 |
\colorbox{green!25}{\makebox[\dimexpr\textwidth-2\fboxsep\relax]{\ttfamily% |
| 41 |
\eqparbox{fillkey}{#2=\meta{#3}}\hfill |
| 42 |
\eqparbox{fillexample}{% |
| 43 |
\ifthenelse{\equal{#4}{}}% |
| 44 |
{#2} |
| 45 |
{#2={#4}}}}}% |
| 46 |
\par\nobreak\@afterheading} |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
\makeatother |
| 51 |
|
| 52 |
%\usepackage{filecontents} only needed after change of docu.sty |
| 53 |
\usepackage{UF-chessboard-documentation} |
| 54 |
|
| 55 |
%initialisation |
| 56 |
\setchessboard{smallboard, showmover=false} |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
\begin{document} |
| 61 |
\newchessgame |
| 62 |
\title{\packagename{chessboard}: A package to print chessboards} |
| 63 |
\author{Ulrike Fischer} |
| 64 |
\maketitle |
| 65 |
|
| 66 |
\begin{center} |
| 67 |
\newchessgame |
| 68 |
\setchessboard{shortenend=5pt,color=red,margin=false}% |
| 69 |
\unitlength1pt |
| 70 |
\newcommand\currentboard[1][]{% |
| 71 |
\begin{picture}(150,150) |
| 72 |
\put(10,10){\chessboard[#1]} |
| 73 |
\end{picture}}% |
| 74 |
\begin{animateinline}[autoplay,loop]{1}% |
| 75 |
\currentboard |
| 76 |
\newframe |
| 77 |
\hidemoves{1.e4}% |
| 78 |
\currentboard[pgfstyle=straightmove,markmove=e2-e4, |
| 79 |
pgfstyle=border,markfields={e2,e4}] |
| 80 |
\newframe |
| 81 |
\hidemoves{1... e5}% |
| 82 |
\currentboard[pgfstyle=straightmove,markmove=e7-e5, |
| 83 |
pgfstyle=border,markfields={e7,e5}] |
| 84 |
\newframe |
| 85 |
\hidemoves{2. Nf3}% |
| 86 |
\currentboard[pgfstyle=knightmove,markmove=g1-f3, |
| 87 |
pgfstyle=border,markfields={g1,f3}] |
| 88 |
\newframe |
| 89 |
\hidemoves{2... Nc6}% |
| 90 |
\currentboard[pgfstyle=knightmove,markmove=b8-c6, |
| 91 |
pgfstyle=border,markfields={b8,c6}] |
| 92 |
\newframe |
| 93 |
\hidemoves{3.Bb5}% |
| 94 |
\currentboard[pgfstyle=straightmove,markmove=f1-b5, |
| 95 |
pgfstyle=border,markfields={f1,b5}] |
| 96 |
\newframe |
| 97 |
\hidemoves{3... a6}% |
| 98 |
\currentboard[pgfstyle=straightmove,markmove=a7-a6, |
| 99 |
pgfstyle=border,markfields={a7,a6}] |
| 100 |
\end{animateinline} |
| 101 |
\end{center} |
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
\tableofcontents |
| 106 |
\section{Changes} |
| 107 |
\minisec{Attention!} From version 1.5 on the documentation uses the |
| 108 |
(new) package \packagename{xskak} instead of \packagename{skak}. The |
| 109 |
most notable difference is that in some examples \cs{newchessgame} |
| 110 |
instead of \cs{newgame} is used. But in most cases all examples |
| 111 |
should work with \packagename{skak} alone too. The package |
| 112 |
\packagename{xskak} adds quite a lot new keys to \cs{chessboard} to |
| 113 |
show arbitrary positions from previously parsed games. Read its |
| 114 |
documentation if you want to use them. |
| 115 |
|
| 116 |
|
| 117 |
In version 1.3 I made a lot of changes. I tried to preserve the |
| 118 |
behaviour of existing keys and commands. But is possible that older |
| 119 |
documents will look different when processed with this version. |
| 120 |
|
| 121 |
Notably two things can give problems: The value of the |
| 122 |
\key{padding} key now affects much more objects (marks) in the pgf |
| 123 |
pictures. So it could be necessary to reset the padding. And the |
| 124 |
\key{applycolor} has changed its behaviour. It will now also affect |
| 125 |
the foreground picture. |
| 126 |
|
| 127 |
\begin{description} |
| 128 |
\item[2024-11-07 (Version 2.0)] The background and foreground pictures are now |
| 129 |
ti\textit{k}z-pictures and no longer basic pgf-pictures. This allows to use all ti\textit{k}z-commands and so makes drawing and style definitions easier. |
| 130 |
|
| 131 |
\item[2020-11-01 (Version 1.9)] Corrected a bug reported by |
| 132 |
Phelype Oleinik. \texttt{colorbackareas} (and other area keys) didn't process lists of areas correctly. |
| 133 |
|
| 134 |
\item[2019-06-23 (Version 1.8)] Uploaded the source of the documentation to ctan. |
| 135 |
No longer use \cs{arabic} internally, to avoid problems with packages redefining the command. (Issue \#1). |
| 136 |
|
| 137 |
\item[2011-03-17 (Version 1.7)] Changed definition of the triangle mover |
| 138 |
style. It now uses \packagename{tikz} and no longer |
| 139 |
\packagename{amssymb}. \packagename{chessboard} no longer loads |
| 140 |
\packagename{amssymb} (it clashes with \packagename{xunicode}). |
| 141 |
|
| 142 |
\item[2011-03-13 (Version 1.7)] Corrected a bug with spacing when the |
| 143 |
\packagename{amsart} is used. |
| 144 |
|
| 145 |
|
| 146 |
\item[2008-11-27 (Version 1.6)] Corrected a bug in \key{getpiecelists} |
| 147 |
(empty lists were undefined). |
| 148 |
|
| 149 |
|
| 150 |
\item[2007-12-11 (Version 1.5)] Added the key \key{getpiecelists} to |
| 151 |
retrieve the positions of pieces. Quite a lot new keys to show |
| 152 |
arbitrary positions from previously parsed games are added by the |
| 153 |
package \packagename{xskak}. Read its documentation if you want to |
| 154 |
use them. |
| 155 |
|
| 156 |
\item[2007-08-20 (Version 1.5)] Added curvemove-style to draw moves. |
| 157 |
Corrected some bugs. Changed a lot internally to adapt the package to |
| 158 |
\packagename{xskak.sty}. |
| 159 |
|
| 160 |
\item[2007-07-03 (Version 1.4)] Rewrote the code that process the |
| 161 |
keys saved globally (with \cs{chessboard}) and in styles (with |
| 162 |
\cs{storechessboardstyle}) to go around a problem due to a change in |
| 163 |
\packagename{xkeyval 2.5}. Corrected some errors in the |
| 164 |
documentation. |
| 165 |
\item[2006-07-20 (Version 1.3)] Rearranged and rewrote the keys and commands for |
| 166 |
the pgf-pictures. Now all styles and marks can be used in both |
| 167 |
pictures. Added definitions for partial borders. Extended trim and |
| 168 |
clip commands. \packagename{xifthen} is now required. |
| 169 |
\item[2006-06-22] Added keys for fancy borders, added local commands for |
| 170 |
the boardarea and the printarea. Disabled the option skaknew as it |
| 171 |
not longer works in \chessfss. |
| 172 |
\end{description} |
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
\section{Introduction} |
| 178 |
\minisec{What it does} \DescribeMacro{\chessboard} This package |
| 179 |
offers a command \cs{chessboard}\keyoarg{} to print boards of chess |
| 180 |
positions and similar games. It is intended to replace the |
| 181 |
\cs{showboard} command of \skaksty which has some deficiencies: |
| 182 |
\begin{itemize} |
| 183 |
\item To print a special position one always has to type the |
| 184 |
complete FEN. |
| 185 |
\item It frames all boards with a rule of 1pt -- which is okay |
| 186 |
for a large board but doesn't look good on small boards. |
| 187 |
\item It's difficult (up to impossible) to color some squares. |
| 188 |
\item Even for simple markings like crosses or the mover \skaksty use |
| 189 |
postscript. That makes it difficult to use pdf\LaTeX. |
| 190 |
\item It's difficult to print partial boards. |
| 191 |
\item It's difficult (up to impossible) to print boards with exotic |
| 192 |
pieces e.g.\ fairy chess. |
| 193 |
\item It's impossible to print boards with unusual dimension or unusual labels used by other games e.g.\ |
| 194 |
10\texttimes10 boards with numbers instead of characters. |
| 195 |
\item The labels at the bottom changes the baseline which makes it |
| 196 |
difficult to align boards. |
| 197 |
\item Some commands e.g., \cs{notationoff} of \skaksty redefines \cs{skakboard}, so it |
| 198 |
is difficult to patch the command e.g.\ to get larger margins. |
| 199 |
\end{itemize} |
| 200 |
|
| 201 |
|
| 202 |
With \pchessboard you have now full control about size, content and |
| 203 |
look of the board. I have tried to make \cs{chessboard} as flexible |
| 204 |
as possible. So I added a lot of options to change values that |
| 205 |
control the size, layout and filling of the board. In most cases you |
| 206 |
can ignore them but being able to change them can come handy if you |
| 207 |
need something unusual. |
| 208 |
|
| 209 |
But I didn't tried to stretch flexibility too much. The main aim of |
| 210 |
the package is to print chessboards easily, so e.g.\ the inputs use |
| 211 |
the naming conventions of chess. That means that -- as the files are |
| 212 |
numbered alphabetically -- the width of the board is restricted to 26 |
| 213 |
fields (27 with option \key{zero}). The board is build with |
| 214 |
alternating black and white fields, changing to e.g.\ three colors |
| 215 |
could be difficult. The pieces are named with simple ASCII-chars, so |
| 216 |
the number of different pieces is restricted. (It is perhaps possible |
| 217 |
to define piecenames consisting of two or more chars, and to use such |
| 218 |
names by putting braces around the chars e.g., |
| 219 |
\verb+{KK}a3+. A small test worked fine for me, but I wouldn't bet |
| 220 |
that it really works everywhere.) |
| 221 |
|
| 222 |
\minisec{What it doesn't} \Pchessboard doesn't offer commands to type |
| 223 |
captions or titles or a list of the chessboards. There are no options |
| 224 |
that control the placement of the board in the text flow, e.g. to |
| 225 |
center it or to let it float. This is a design decision. |
| 226 |
\cs{chessboard} prints only chessboards like \cs{includegraphics} |
| 227 |
inserts only graphics. |
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
\subsection{Bugs and errors} |
| 232 |
|
| 233 |
I'm quite sure that they are bugs and errors in the package. I did |
| 234 |
find some quite horrible while making the documentation and I'm sure |
| 235 |
I overlooked some. E.g.\ I have a lot of doubts if spaces and braces |
| 236 |
in keys saved in a style or with \cs{setchessboard} are handled |
| 237 |
correctly in every case. |
| 238 |
|
| 239 |
If you have questions ask them in the newsgroups |
| 240 |
\nolinkurl{comp.text.tex} or |
| 241 |
\nolinkurl{de.comp.text.tex}. I'm reading these groups regularly and |
| 242 |
I'm much better in answering there than in answering e-mails. |
| 243 |
|
| 244 |
|
| 245 |
If you find errors in this text (this includes wrong english) or in |
| 246 |
the package, you can write me a bugreport at |
| 247 |
\nolinkurl{[email protected]}. A bugreport should contain a complete \emph{minimal} |
| 248 |
example and the log-file of the pdf\LaTeX\ run (this is the engine |
| 249 |
that makes a pdf!). |
| 250 |
|
| 251 |
Before sending a bug record check the following things: |
| 252 |
|
| 253 |
|
| 254 |
\minisec{If you get mysterious error messages} |
| 255 |
\begin{itemize} |
| 256 |
\item Check the commas in the \keylists. |
| 257 |
\end{itemize} |
| 258 |
|
| 259 |
\minisec{Missing or faulty pgf-decorations} |
| 260 |
\begin{itemize} |
| 261 |
\item Check if the borders or marks are hidden under other decorations or under board chars with solid fieldmasks. |
| 262 |
\item Check if trimming is responsible: try the key \verb+trim=false+. |
| 263 |
\item Check the state of the key \key{pgf}. |
| 264 |
\item Try another previewer, zoom in and out, print the document. |
| 265 |
\item Go through your log-file and search for chessboard warnings. |
| 266 |
\end{itemize} |
| 267 |
|
| 268 |
|
| 269 |
\subsection{Requirements} |
| 270 |
|
| 271 |
\Pchessboard uses some primitives of e\TeX. It needs a recent version |
| 272 |
of \chessfss (chess font selection), \packagename{xkeyval} |
| 273 |
(\textit{key=value}-syntax) and \packagename{xifthen}. It also needs |
| 274 |
the packages \packagename{pgfcore}, \packagename{pgfbaseshapes} (from |
| 275 |
pgf for the highlighting commands), \packagename{pst-node} (from |
| 276 |
pstricks). |
| 277 |
|
| 278 |
|
| 279 |
\subsection{Installation} |
| 280 |
Run \filetype{chessboard.ins} through \LaTeX\ and then put the four |
| 281 |
\filetype{.sty}-files somewhere where \LaTeX\ finds them. |
| 282 |
\path{<texmf>/tex/latex/chessboard/} is a good place. Update the |
| 283 |
filename database. |
| 284 |
|
| 285 |
\subsection{Robustness: using \texorpdfstring{\cs{chessboard}}{\textbackslash chessboard} in moving arguments} |
| 286 |
I have used \cs{chessboard} in tabulars and in moving arguments. It |
| 287 |
seems to work fine, so I would say the command is quite robust. |
| 288 |
|
| 289 |
Putting chessboards in the table of contents or the header will in |
| 290 |
most case not look very good, so it is sensible to avoid it with |
| 291 |
\lstinline+\section[short text]{\chessboard Title}+. |
| 292 |
But if you want to do some advices: |
| 293 |
\begin{itemize} |
| 294 |
\item |
| 295 |
Boards in the title and in the table of contents are built at different times during the run, when perhaps |
| 296 |
different options and different games are active, so they can look |
| 297 |
different if you are not careful. |
| 298 |
\item You can't put boards in the bookmarks of a pdf, use |
| 299 |
\verb+\texorpdfstring+ from \packagename{hyperref} to provide a |
| 300 |
replacement. |
| 301 |
\item Some pagestyles puts a command to uppercase around the header. |
| 302 |
This affects keys in the optional argument of \cs{chessboard} and |
| 303 |
will give error messages about undefined keys. Try to surround the |
| 304 |
\cs{chessboard} command with \cs{lowercase}\verb+{...}+. |
| 305 |
\end{itemize} |
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
\subsection{Setting the options} |
| 310 |
|
| 311 |
\Pchessboard use the keyval syntax \meta{key}\texttt{=}\meta{value}. |
| 312 |
|
| 313 |
It differs in some respects to other packages with keyval syntax: |
| 314 |
\mynobreakpar |
| 315 |
\begin{itemize} |
| 316 |
\item |
| 317 |
There are really \emph{very} much keys. |
| 318 |
\item |
| 319 |
Some keys don't set properties of a board (like a width) but |
| 320 |
\emph{do} things like drawing. |
| 321 |
\item |
| 322 |
The order of the keys can matter. |
| 323 |
\item |
| 324 |
Some effects are achieved by using two or more keys after one other. |
| 325 |
\end{itemize} |
| 326 |
|
| 327 |
There are keys that need a certain type of argument, e.g.\ a length |
| 328 |
or a list of fields. There are boolean keys that accept only the |
| 329 |
values \texttt{=true} and \texttt{=false} where the value |
| 330 |
\texttt{=true} can always be omitted. And at last there are keys |
| 331 |
that works as \emph{commands}, you can use whatever argument you want |
| 332 |
or leave it blank. Don't confound this commands with boolean keys. |
| 333 |
E.g.\ |
| 334 |
\texttt{clearboard}, \texttt{clearboard=hallo} and even |
| 335 |
\texttt{clearboard=false} will always clear the board. |
| 336 |
|
| 337 |
|
| 338 |
I'm struggling permanently with the naming of the keys. Giving them |
| 339 |
names that are not to long, but descriptive and a bit systematic |
| 340 |
isn't easy. Also it isn't easy to decide if a special effect should |
| 341 |
be achieve with one key (which gives a short input) or with a |
| 342 |
combination of keys (with is more flexible as it can be used to |
| 343 |
implement similar effects but gives longer input). While the package |
| 344 |
evolved I sometimes tumbled in problems and inconsistencies of the |
| 345 |
current naming scheme and had to reconsider my decisions and |
| 346 |
implemented better names or new key combinations. I didn't delete or |
| 347 |
disable older, now perhaps obsolate keys in any case, as I wanted to |
| 348 |
avoid that older documents breaks. I also sometimes add a key that |
| 349 |
is simply a copy of an existing key only to get a more consistent |
| 350 |
naming. So ist quite possible that you can get the same result with |
| 351 |
different key combination. For a lot of things there isn't one |
| 352 |
correct way -- you can choose the one which suits you more. |
| 353 |
|
| 354 |
|
| 355 |
It's easy to make mistakes when using a lot of keys. So if you get |
| 356 |
mysterious errors check that you don't have forgot a comma between |
| 357 |
the keys, that you put braces around lists used as value, that you |
| 358 |
didn't use a backslash before a key, that you didn't used a list of |
| 359 |
fields when a list of pieces is requested. |
| 360 |
|
| 361 |
|
| 362 |
\DescribeMacro{\setchessboard} You can set an option either for one |
| 363 |
board by using the optional argument of \cs{chessboard} or by using |
| 364 |
\cs{setchessboard}\keymarg{} which sets the keys for all following |
| 365 |
boards in the same environment/group. |
| 366 |
|
| 367 |
\begin{LTXexample} |
| 368 |
Default setting in this Dokumentation: |
| 369 |
\setchessboard{ |
| 370 |
smallboard, |
| 371 |
showmover=false} |
| 372 |
\newchessgame |
| 373 |
\chessboard |
| 374 |
\end{LTXexample} |
| 375 |
|
| 376 |
Even if they share the same name, keys used in the argument of |
| 377 |
\cs{chessboard} are implementated differently than the keys used in |
| 378 |
\cs{setchessboard}. They do different things: In the first case the |
| 379 |
key gets «executed» while in the second case the \keyvalue pair is |
| 380 |
only stored for later use. So it is quite possible that a key works |
| 381 |
with \cs{chessboard} but fails because of a bug when used in |
| 382 |
\cs{setchessboard} or vice-versa. |
| 383 |
|
| 384 |
|
| 385 |
Values set by keys in the argument of \cs{chessboard} will if |
| 386 |
appropriate overwrite the ones set by \cs{setchessboard}. |
| 387 |
|
| 388 |
The keys belong roughly to two classes: There are the keys that set |
| 389 |
one property of the board, e.g.\ the width of a rule or the size. |
| 390 |
Such keys always have a default and only the last value set is used, |
| 391 |
it overwrites all previous values. Internally I call such keys |
| 392 |
«set-keys». In the second class there are keys that can be used more |
| 393 |
than once, e.g.\ keys that add a piece or a mark or a color to the |
| 394 |
board. I call such keys «fill-keys».\footnote{I did realize only |
| 395 |
quite late that using keys not only to set some parameters but also |
| 396 |
for the real content is a bit unusual. It is a bit as if one would |
| 397 |
use keys for the items of a list or the lines of tabular or the code |
| 398 |
in a listing -- in most cases quite a bad idea. But at my opinion it |
| 399 |
works fine in this special case because a chessboard is a quite |
| 400 |
restricted room with only 64 fields.} |
| 401 |
|
| 402 |
|
| 403 |
The «set-keys» are always processed first. Inside the classes the |
| 404 |
keys are processed in general from «left to right», so later keys can |
| 405 |
overwrite values set by earlier keys. This is also true for values |
| 406 |
hidden in a \key{style}. |
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
|
| 412 |
|
| 413 |
For each «set-key» you will find in this documentation a box like |
| 414 |
this: |
| 415 |
|
| 416 |
\Describesetkey{zero}{true|false}{false, zero}{false} |
| 417 |
|
| 418 |
|
| 419 |
It shows on the left the general description of the possible values, |
| 420 |
in the middle one or more examples of correct input, and on the |
| 421 |
right the default value. |
| 422 |
|
| 423 |
For each «fill-key» you will find in this documentation a box like |
| 424 |
this: |
| 425 |
|
| 426 |
\Describefillkey{clearranks}{list of ranks}{8} |
| 427 |
|
| 428 |
It shows on the left the general description of the possible values |
| 429 |
and on the right one or more examples of correct input. |
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
\subsection{Saving optionlists} |
| 434 |
|
| 435 |
\Describefillkey{style}{name}{mystyle} |
| 436 |
|
| 437 |
\DescribeMacro{\storechessboardstyle} With the |
| 438 |
\cs{storechessboardstyle}\marg{name}\keymarg{} it is possible to |
| 439 |
store a list of \keyvalue-pairs in a «style» and to use this style |
| 440 |
instead of the keys themselves. |
| 441 |
|
| 442 |
\begin{LTXexample} |
| 443 |
\storechessboardstyle{10x10}{% |
| 444 |
maxfield=j10, |
| 445 |
clearboard, |
| 446 |
startfen=b9, |
| 447 |
restorefen=current, |
| 448 |
labelleftwidth=1.5ex} |
| 449 |
|
| 450 |
\storechessboardstyle{red-yellow}{% |
| 451 |
boardfontencoding=LSBC3, |
| 452 |
whitepiececolor=red, |
| 453 |
blackpiececolor=yellow, |
| 454 |
setfontcolors} |
| 455 |
|
| 456 |
\setchessboard{style=red-yellow} |
| 457 |
\newchessgame |
| 458 |
\chessboard |
| 459 |
|
| 460 |
\chessboard[style=10x10] |
| 461 |
\end{LTXexample} |
| 462 |
|
| 463 |
\minisec{Attention} \cs{storechessboardstyle} and \cs{setchessboard} |
| 464 |
only store the \keyvalue pair, they don't expand anything and they |
| 465 |
don't do anything with them. So be careful when using commands that |
| 466 |
could be redefined later: |
| 467 |
|
| 468 |
\begin{LTXexample} |
| 469 |
\def\mylist{Ke1, qe2, kf3} |
| 470 |
\setchessboard{setpieces=\mylist} |
| 471 |
\def\mylist{Ke1, ra1, ke3} |
| 472 |
\chessboard |
| 473 |
\end{LTXexample} |
| 474 |
|
| 475 |
|
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
\subsection{Naming the board} |
| 480 |
|
| 481 |
In chess the rows of the board are called \emph{ranks} and are |
| 482 |
numbered from 1 to 8. The columns are called \emph{files} and are |
| 483 |
«numbered» from a to h.\footnote{% |
| 484 |
I have some difficulties to remember the english names, so I use the |
| 485 |
following mnemonics: |
| 486 |
\textbf{F}i\textbf{L}e = co\textbf{L}umn = \textbf{L}inie = |
| 487 |
al\textbf{F}abet, |
| 488 |
\textbf{R}ank = \textbf{R}ow = \textbf{R}eihe = numbe\textbf{R}ed} |
| 489 |
|
| 490 |
\Pchessboard use this naming conventions for all inputs: |
| 491 |
Every time \meta{field} is used in this documentation, you should |
| 492 |
give a char from a--z followed by a number. |
| 493 |
|
| 494 |
|
| 495 |
\subsection{Naming areas of the board} |
| 496 |
|
| 497 |
Rectangular areas are normally described by giving the coordinates |
| 498 |
of the left bottom corner and the right upper corner. But when using |
| 499 |
the Forsyth Edwards Notation (FEN) chessboards are filled starting |
| 500 |
from the left upper corner a8 and then going on to the right and |
| 501 |
down to the right bottom corner -- like the normal typesetting |
| 502 |
direction. So it is quite natural to use for FEN related areas this |
| 503 |
corners. As it would be awkward to have two different ways to |
| 504 |
describe areas, I decided to use the fen convention everywhere: Each |
| 505 |
area has a |
| 506 |
\emph{startfield}, the left upper corner, and a \emph{stopfield}, |
| 507 |
the right bottom corner. If some area related keys don't seem to |
| 508 |
work, check that you have used the correct corners! |
| 509 |
|
| 510 |
|
| 511 |
An area can also be given as two fields separated by an hyphen. When |
| 512 |
using this input you don't have to worry about the corners, the |
| 513 |
package will sort them:\\ |
| 514 |
\meta{area}=\meta{a corner}-\meta{the opposite corner}. |
| 515 |
|
| 516 |
|
| 517 |
\DescribeMacro{\printarea} \DescribeMacro{\board} \cs{chessboard} |
| 518 |
sets at the start this two command to the current values of the |
| 519 |
printarea and the total board as given by the keys \key{zero}, |
| 520 |
\key{maxfield} and \key{printarea}. You can use this commands in |
| 521 |
later keys. |
| 522 |
|
| 523 |
|
| 524 |
\subsection{FEN: Forsyth-Edwards Notation}\label{sec:FEN} |
| 525 |
|
| 526 |
FEN describes a chess position. It consist of 6 fields, separated by |
| 527 |
spaces. The first field represents the placement of the pieces on |
| 528 |
the board. The second field represents the active color. A lower |
| 529 |
case «w» is used if White is to move; a lower case «b» is used if |
| 530 |
Black is the active player. The third field represents castling |
| 531 |
availability. The fourth field is the en passant target square. The |
| 532 |
fifth field is a nonnegative integer representing the halfmove |
| 533 |
clock. The sixth and last field is a positive integer that gives the |
| 534 |
fullmove number. |
| 535 |
|
| 536 |
In the first field the board contents are specified starting with |
| 537 |
the eighth rank and ending with the first rank («in typesetting |
| 538 |
direction» when the board has the standard orientation). For each |
| 539 |
rank, the squares are specified from file a to file h. White pieces |
| 540 |
are identified by uppercase piece letters («\texttt{PNBRQK}») and |
| 541 |
black pieces are identified by lowercase piece letters |
| 542 |
(«\texttt{pnbrqk}»). Empty squares are represented by the digits one |
| 543 |
through eight; the digit used represents the count of contiguous |
| 544 |
empty squares along a rank. A solidus character «\texttt{/}» is used |
| 545 |
to separate data of adjacent ranks. |
| 546 |
|
| 547 |
\cs{chessboard} handles FEN-input but also only «FEN-like»-input. If |
| 548 |
given a complete FEN \cs{chessboard} will store all fields in |
| 549 |
commands and evaluate the first field to fill the board. But if they |
| 550 |
are less than six fields, \cs{chessboard} will not complain but |
| 551 |
simply fill up the missing fields with some default values. |
| 552 |
|
| 553 |
In the first field there don't need to be exact 8 pieces in each rank |
| 554 |
and exactly 8 rank descriptions. When there are more pieces than |
| 555 |
needed, \cs{chessboard} will ignore them. When there are less pieces |
| 556 |
than needed then \cs{chessboard} will leave the remaining fields in |
| 557 |
this rank untouched. |
| 558 |
|
| 559 |
|
| 560 |
The FEN can also be stored in a command. So all \cs{chessboard} will |
| 561 |
accept all the following inputs as \meta{FEN}: |
| 562 |
|
| 563 |
{\ttfamily |
| 564 |
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1\\ |
| 565 |
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR \\ |
| 566 |
8qK\\ |
| 567 |
10 w - - 0 10}\\ |
| 568 |
\verb+\myfen+ |
| 569 |
|
| 570 |
\subsection{The main parts of the board} |
| 571 |
Each chessboard is build by printing three «layers» on top of each |
| 572 |
other: |
| 573 |
|
| 574 |
\minisec{1. The background layer} |
| 575 |
|
| 576 |
This is a ti\textit{k}z-picture that lies under the board. It can be used for |
| 577 |
background colors or fancy borders or other background decoration. |
| 578 |
%Coloring or drawing something in this layers means adding a color |
| 579 |
%command or pgf commands to the code of the picture. How to do this |
| 580 |
%will be described in the section about decorating the background. |
| 581 |
|
| 582 |
%\minisec{2. The (four) font layers} |
| 583 |
\minisec{2. The main board layer} |
| 584 |
This is the main part of the board. It lies above the background |
| 585 |
picture. It uses only «normal» \LaTeX\ objects like rules and chars. |
| 586 |
Labels, movers and figures are all build together in this layer. |
| 587 |
|
| 588 |
\minisec{3. The mark layer} |
| 589 |
|
| 590 |
This layer is again a ti\textit{k}z-picture now over the board. It can be used |
| 591 |
to draw crosses, arrows etc on the board. |
| 592 |
|
| 593 |
The sections \ref{startmain} to \ref{stopmain} describe how to |
| 594 |
manipulate the main layer. The section \ref{startpgf} describes |
| 595 |
how to handle the ti\textit{k}z-picture. |
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
\section{Setting the contents of the board}\label{startmain} |
| 603 |
|
| 604 |
\subsection{The maximum number of fields} |
| 605 |
\Describesetkey{maxfield}{field}{j10}{h8}% |
| 606 |
Chessboards have 8\texttimes8 fields. So this is the default. If you |
| 607 |
want another size you should declare a new right upper corner with |
| 608 |
\key{maxfield=}\meta{Field} e.g., \key{maxfield=j10} for a 10\texttimes10 board. |
| 609 |
Don't use this key if you want only to print a partial board, there |
| 610 |
is another key to achieve this. Use it to change the maximum size |
| 611 |
of a board. All fields and areas you use in other arguments should lie inside this maximum size. |
| 612 |
|
| 613 |
\begin{LTXexample} |
| 614 |
\newchessgame |
| 615 |
\chessboard[tinyboard, |
| 616 |
maxfield=f6] |
| 617 |
\end{LTXexample} |
| 618 |
|
| 619 |
|
| 620 |
\begin{LTXexample} |
| 621 |
\newchessgame |
| 622 |
\chessboard[tinyboard, |
| 623 |
maxfield=j10, |
| 624 |
labelleftwidth=2ex] |
| 625 |
\end{LTXexample} |
| 626 |
|
| 627 |
\Describesetkey{zero}{true|false}{false}{false}% |
| 628 |
I was told that some games numbers the fields starting with 0. So I |
| 629 |
added this option. When set to true the rank numbers start with 0 and |
| 630 |
a file named Z is added left to the file a. |
| 631 |
|
| 632 |
\begin{LTXexample} |
| 633 |
\newchessgame |
| 634 |
\chessboard[zero, |
| 635 |
labelbottomformat=\arabic{filelabel}, |
| 636 |
addpieces={KZ0, QZ8}] |
| 637 |
\end{LTXexample} |
| 638 |
|
| 639 |
|
| 640 |
\subsection{Filling with \skaksty} |
| 641 |
When \skaksty is loaded and there is a running game, \cs{chessboard} |
| 642 |
will fill the board with the current position. |
| 643 |
|
| 644 |
\begin{LTXexample} |
| 645 |
\newchessgame |
| 646 |
\mainline{1. e4 e5 2. Nf3 Nc6 3. Bb5 a6} |
| 647 |
\chessboard |
| 648 |
\end{LTXexample} |
| 649 |
|
| 650 |
\subsection{Clearing} |
| 651 |
\Describefillkey{clearboard}{arbitrary}{} |
| 652 |
\Describefillkey{cleararea}{area}{a1-c3} |
| 653 |
\Describefillkey{clearareas}{list of areas}{\{a1-c3,g7-h8\}} |
| 654 |
\Describefillkey{clearfile}{file}{g} |
| 655 |
\Describefillkey{clearfiles}{list of files}{\{g,h\}} |
| 656 |
\Describefillkey{clearrank}{rank}{5} |
| 657 |
\Describefillkey{clearranks}{list of ranks}{\{8,7\}} |
| 658 |
\Describefillkey{clearfield}{field}{c6} |
| 659 |
\Describefillkey{clearfields}{list of fields}{\{b5,c6\}} |
| 660 |
|
| 661 |
You can't prevent that \cs{chessboard} fills up the board with the |
| 662 |
running game, so if you need an empty board, you should clear it -- |
| 663 |
either with the keys mentioned here, or by using one of the keys |
| 664 |
described later that clears the board before adding new pieces. |
| 665 |
|
| 666 |
\begin{LTXexample} |
| 667 |
\newchessgame |
| 668 |
\mainline{1. e4 e5 2. Nf3 Nc6 3. Bb5 a6} |
| 669 |
\def\ranklist{7 ,6 } |
| 670 |
\def\cleararea{a1-b2} |
| 671 |
\chessboard[clearfiles=g, |
| 672 |
clearranks=\ranklist, |
| 673 |
cleararea=\cleararea, |
| 674 |
clearfields={b5,c6}] |
| 675 |
\end{LTXexample} |
| 676 |
|
| 677 |
|
| 678 |
\subsection{Adding single pieces} |
| 679 |
|
| 680 |
\Describefillkey{setpieces}{List of piece positions}{\{Ke4, Qe1, kd6\}}% |
| 681 |
\Describefillkey{addpieces}{List of piece positions}{\{Ke4, Qe1, kd6\}}% |
| 682 |
|
| 683 |
The \key{setpieces} first clears the board and then set the pieces, |
| 684 |
the \key{addpieces} only set the new pieces but lets the existing |
| 685 |
pieces undisturbed. |
| 686 |
|
| 687 |
\begin{LTXexample} |
| 688 |
\newchessgame |
| 689 |
\mainline{1. e4 e5 2. Nf3 Nc6 3. Bb5 a6} |
| 690 |
\def\piecelist{Ke1,Qd1 , Rg1} |
| 691 |
\chessboard[setpieces={ra1, rh8, ke8}, |
| 692 |
addpieces=\piecelist] |
| 693 |
\end{LTXexample} |
| 694 |
|
| 695 |
\Describefillkey{setwhite}{List of piece positions}{\{Ke4, Qe1, kd6\}} |
| 696 |
\Describefillkey{addwhite}{List of piece positions}{\{Ke4, Qe1, kd6\}} |
| 697 |
\Describefillkey{setblack}{List of piece positions}{\{Ke4, Qe1, kd6\}} |
| 698 |
\Describefillkey{addblack}{List of piece positions}{\{Ke4, Qe1, kd6\}} |
| 699 |
|
| 700 |
It is a bit cumbersome to have to be careful to use uppercase chars |
| 701 |
for the white and lowercase chars for the black piece. With the keys |
| 702 |
\key{setwhite}, \key{addwhite}, \key{setblack} and \key{addblack} |
| 703 |
you can add white and black pieces |
| 704 |
without caring about the cases. Like the keys for adding pieces, the |
| 705 |
keys starting with \key{set} first clears the board, so if you don't |
| 706 |
want to loose all the set pieces, you should use such a key only |
| 707 |
once. |
| 708 |
|
| 709 |
\begin{LTXexample} |
| 710 |
\def\whitepieces{kc3, nc2, pa2, Pd4} |
| 711 |
\chessboard[setwhite=\whitepieces, |
| 712 |
addblack={Kc8,bh7, pa7}] |
| 713 |
\end{LTXexample} |
| 714 |
|
| 715 |
|
| 716 |
\subsection{Adding FEN-positions} |
| 717 |
|
| 718 |
|
| 719 |
\Describefillkey{setfen}{FEN}{\string\myfen, rnbqk/8/RNBQK} |
| 720 |
\Describefillkey{addfen}{FEN}{\string\myfen, rnbqk/8/RNBQK} |
| 721 |
|
| 722 |
With this keys you can add pieces to the board by given a FEN. The |
| 723 |
\key{setfen} will clear the board, \key{addfen} will left pieces |
| 724 |
outside the fields described by the FEN undisturbed. |
| 725 |
|
| 726 |
\begin{LTXexample} |
| 727 |
\newchessgame |
| 728 |
\def\myfen{KK//KK} |
| 729 |
\chessboard[addfen=\myfen] |
| 730 |
\end{LTXexample} |
| 731 |
|
| 732 |
\Describefillkey{startfen}{field}{b7}% |
| 733 |
|
| 734 |
As a default \cs{chessboard} fills the board with a FEN-position |
| 735 |
starting at the left upper corner. You can shift this start field |
| 736 |
with the key \key{startfen}. |
| 737 |
|
| 738 |
\begin{LTXexample} |
| 739 |
\newchessgame |
| 740 |
\def\myfen{KK//KK} |
| 741 |
\chessboard[startfen=c7, addfen=KK//KK, |
| 742 |
startfen=f3, addfen=\myfen] |
| 743 |
\end{LTXexample} |
| 744 |
|
| 745 |
|
| 746 |
\Describefillkey{startfill}{field}{b7} |
| 747 |
\Describefillkey{stopfill}{field}{f2} |
| 748 |
\Describefillkey{fillarea}{area}{c2-d4} |
| 749 |
|
| 750 |
With this keys you can restrict the part of the board that is filled |
| 751 |
by a FEN. Only the pieces inside the fillarea are set. |
| 752 |
|
| 753 |
\begin{LTXexample} |
| 754 |
\newchessgame |
| 755 |
\def\myfen{kqrb///KQRB} |
| 756 |
\chessboard[setfen=\myfen, startfen=e4, fillarea=f2-g4, addfen=\myfen] |
| 757 |
\end{LTXexample} |
| 758 |
|
| 759 |
\subsection{Saving positions} |
| 760 |
\Skaksty has the command \cs{storegame}\marg{name} that stores the |
| 761 |
FEN of the current game in an internal command, and the command |
| 762 |
\cs{savegame}\marg{name} that stores the FEN in a file |
| 763 |
\marg{name}\filetype{.fen} |
| 764 |
|
| 765 |
\Pchessboard defines similar keys. The key \key{storefen}=\meta{name} |
| 766 |
stores the FEN in an internal command \emph{with the same name} as |
| 767 |
used by \cs{storegame}\marg{name}. That means that you can exchange |
| 768 |
the games stored by \skaksty and \pchessboard, but it also means that |
| 769 |
\pchessboard can \emph{overwrite} games stored with \skaksty. So be |
| 770 |
careful! |
| 771 |
|
| 772 |
\medskip |
| 773 |
\Describefillkey{storefen}{name}{game1} |
| 774 |
\Describefillkey{savefen}{name of file}{game} |
| 775 |
|
| 776 |
\key{storefen} saves the current position as FEN to a internal command. |
| 777 |
\key{savefen} saves the current position as FEN to a file. |
| 778 |
|
| 779 |
\medskip |
| 780 |
\Describefillkey{startstore}{field}{b7} |
| 781 |
\Describefillkey{stopstore}{field}{f2} |
| 782 |
\Describefillkey{storearea}{area}{c2-d4} |
| 783 |
|
| 784 |
With this keys you can restrict the area that is stored or saved. But |
| 785 |
attention: \skaksty absolutly doesn't like «illegal» FENs that |
| 786 |
doesn't describe a full 8\texttimes8 board. |
| 787 |
|
| 788 |
\medskip |
| 789 |
\Describefillkey{mover}{w|b}{w} |
| 790 |
\Describefillkey{castling}{castling possibilies}{Kq} |
| 791 |
\Describefillkey{enpassant}{field|-}{c4} |
| 792 |
\Describefillkey{halfmove}{number}{14} |
| 793 |
\Describefillkey{fullmove}{number}{20} |
| 794 |
|
| 795 |
With this keys you can set the rest of the FEN-fields. Apart from |
| 796 |
\key{mover} the values are only used if you save FENs. The values |
| 797 |
are also set, if you use in the argument of a |
| 798 |
\key{setfen} or \key{addfen} key complete FENs instead of only the position part. |
| 799 |
|
| 800 |
\subsection{Getting the positions of pieces} |
| 801 |
|
| 802 |
\Describefillkey{getpiecelists}{}{} |
| 803 |
|
| 804 |
New in version 1.5 there is a key, that retrieves the position of the |
| 805 |
pieces on the board. For each piece type there is a list called |
| 806 |
\cs{cblist}\meta{piece}.\index{cblists=\verb!*+\cblist+\meta{piece}}. |
| 807 |
The lists can be used everywhere where a list of fields is expected. |
| 808 |
E.g. it is possible to use the lists to highlight all pawns (see |
| 809 |
section \ref{sec:drawfields}). |
| 810 |
|
| 811 |
Unlike almost all other commands of \packagename{chessboard} this |
| 812 |
commands are saved globally. This makes it possible to use the lists |
| 813 |
after the board: |
| 814 |
|
| 815 |
\begin{LTXexample} |
| 816 |
\newchessgame |
| 817 |
\chessboard[getpiecelists] |
| 818 |
|
| 819 |
White pieces: \king\cblistK, \queen\cblistQ, |
| 820 |
\rook\cblistR, \bishop\cblistB, |
| 821 |
\knight\cblistN, \pawn\cblistP. |
| 822 |
|
| 823 |
Black pieces: \king\cblistk, \queen\cblistq, |
| 824 |
\rook\cblistr, \bishop\cblistb, |
| 825 |
\knight\cblistn, \pawn\cblistp. |
| 826 |
\end{LTXexample} |
| 827 |
|
| 828 |
|
| 829 |
\subsection{Using saved and stored games} |
| 830 |
|
| 831 |
When you are using \skaksty, you can use the saved games to set the |
| 832 |
start position of a game with the \skaksty-commands |
| 833 |
\cs{restoregame}\marg{name} (restores the game stored with |
| 834 |
\cs{storegame}) and \cs{loadgame}\marg{name} (loads the game saved |
| 835 |
with \cs{savegame}). This only works if you have saved the position |
| 836 |
of a normal 8\texttimes8-board! |
| 837 |
|
| 838 |
|
| 839 |
|
| 840 |
\medskip |
| 841 |
\Describefillkey{restorefen}{name}{game1} |
| 842 |
\Describefillkey{loadfen}{name}{game} |
| 843 |
|
| 844 |
You can also use the saved games to set positions on \cs{chessboard}. |
| 845 |
\key{restorefen} will use games saved with \cs{storegame} and |
| 846 |
\key{storefen}, \key{loadfen} will load games saved with |
| 847 |
\cs{savegame} and \key{savefen}. |
| 848 |
|
| 849 |
|
| 850 |
|
| 851 |
|
| 852 |
\begin{LTXexample} |
| 853 |
\newchessgame |
| 854 |
\def\gamename{rank7} |
| 855 |
\chessboard[storearea=a7-h7, storefen=\gamename, |
| 856 |
startfen=a5, restorefen=rank7] |
| 857 |
\end{LTXexample} |
| 858 |
\begin{LTXexample} |
| 859 |
\mainline{1. e4 e5} |
| 860 |
\savegame{file} % to file.fen |
| 861 |
\mainline{2. Nf3 Nf6} |
| 862 |
\def\filename{file} |
| 863 |
\chessboard[loadfen=\filename] |
| 864 |
\end{LTXexample} |
| 865 |
|
| 866 |
\subsection{Restoring the running game} |
| 867 |
|
| 868 |
\cs{chessboard} saves the running game at the start under the name |
| 869 |
«current». |
| 870 |
|
| 871 |
\begin{LTXexample} |
| 872 |
\newchessgame |
| 873 |
\mainline{1. e4 e5 2. Nf3 Nc6 3. Bb5 a6} |
| 874 |
|
| 875 |
\chessboard[maxfield=j10, |
| 876 |
clearboard, |
| 877 |
startfen=b9, |
| 878 |
restorefen=current] |
| 879 |
\end{LTXexample} |
| 880 |
|
| 881 |
|
| 882 |
\subsection{Changing the input language} |
| 883 |
|
| 884 |
\Describefillkey{language}{name}{german} |
| 885 |
\DescribeMacro{\cbDefineLanguage} |
| 886 |
\DescribeMacro{\cbDefineTranslation} With this key you can change the |
| 887 |
language used for input of pieces. The key doesn't affect the input |
| 888 |
language of \skaksty. It also doesn't affect the language of saved |
| 889 |
and restored games. \cs{chessboard} will always switch to english in |
| 890 |
this cases! Up to now only german translations are built in (I don't |
| 891 |
know how chess pieces are called in other languages), but it isn't |
| 892 |
difficult to add other languages. The code for german should be quite |
| 893 |
selfexplanatory: |
| 894 |
|
| 895 |
\begin{lstlisting} |
| 896 |
\cbDefineLanguage{german}% |
| 897 |
\cbDefineTranslation{german}{K}{K}% |
| 898 |
\cbDefineTranslation{german}{Q}{D}% |
| 899 |
\cbDefineTranslation{german}{R}{T}% |
| 900 |
\cbDefineTranslation{german}{B}{L}% |
| 901 |
\cbDefineTranslation{german}{N}{S}% |
| 902 |
\cbDefineTranslation{german}{P}{B}% |
| 903 |
\cbDefineTranslation{german}{k}{k}% |
| 904 |
\cbDefineTranslation{german}{q}{d}% |
| 905 |
\cbDefineTranslation{german}{r}{t}% |
| 906 |
\cbDefineTranslation{german}{b}{l}% |
| 907 |
\cbDefineTranslation{german}{n}{s}% |
| 908 |
\cbDefineTranslation{german}{p}{b}% |
| 909 |
\end{lstlisting} |
| 910 |
|
| 911 |
You can mix the languages in the input (but I don't think you should |
| 912 |
do it, it can get quite confusing, it's better to stick to one |
| 913 |
language). |
| 914 |
|
| 915 |
\begin{LTXexample} |
| 916 |
\def\whitepieces{lc4, sg1} |
| 917 |
\chessboard[setpieces={qd8, ra8, bh8}, |
| 918 |
language=german, |
| 919 |
addpieces={Da1, Th4}, |
| 920 |
addwhite=\whitepieces, |
| 921 |
addblack={Bb7}] |
| 922 |
\end{LTXexample} |
| 923 |
|
| 924 |
\section{The look of the board} |
| 925 |
|
| 926 |
\subsection{Units for lengths} |
| 927 |
|
| 928 |
For many of the following commands you will have to enter a length. |
| 929 |
This can be an absolute length like 1in, 2cm, 4pt. But often you will |
| 930 |
prefer a relative length. In most cases the font related length 1ex, |
| 931 |
1em and \cs{baselineskip} will be the same as a half of the square |
| 932 |
width, the width of the square and the total height of a |
| 933 |
square.\footnote{I learned on the hard way that you shouldn't rely |
| 934 |
that fonts sets em and ex correctly, e.g.\ the font |
| 935 |
\chessfontname{skak} doesn't do it and so the units default to zero |
| 936 |
which can be quite confusing. So I decided to set the fontdimen |
| 937 |
values explicitly.} The package uses internally the three lengths |
| 938 |
offered by \chessfss\ -- \cs{len@cfss@squarewidth}, |
| 939 |
\cs{len@cfss@squaretotalheight} and \cs{len@cfss@squaredepth} --. In |
| 940 |
most cases they will only give inside \cs{chessboard} (locally) the |
| 941 |
correct sizes, but if you use the key \key{psset} they are set |
| 942 |
globally. |
| 943 |
|
| 944 |
|
| 945 |
\subsection{Some words about box sizes} |
| 946 |
|
| 947 |
In \TeX\ almost everything is either a box (a character box, a line |
| 948 |
box, a page box, a box with a tabular in it~\ldots) or a space. And |
| 949 |
larger objects are build by putting boxes and spaces in a surrounding |
| 950 |
box. In the real world a box has always to be larger as its content. |
| 951 |
In the virtual |
| 952 |
\TeX-world a lot of magic is possible: The content can be much larger |
| 953 |
than the surrounding box or even be partly or completely outside the |
| 954 |
surrounding box. |
| 955 |
|
| 956 |
|
| 957 |
\begin{LTXexample} |
| 958 |
x% shows the current line |
| 959 |
\fbox{% a box |
| 960 |
\raisebox{3ex}[0pt][0pt]{% |
| 961 |
\makebox[0pt]{% |
| 962 |
large content outside the box}}}% |
| 963 |
x% and here something after the fbox |
| 964 |
\end{LTXexample} |
| 965 |
|
| 966 |
So the outside size of a box can be quite different from the inside |
| 967 |
size. And the outside baseline of a box can be at quite different |
| 968 |
place as the inside baseline. |
| 969 |
|
| 970 |
In the concrete case of \cs{chessboard} the outside size of the board |
| 971 |
is determined through the size of the font, the fields shown and the |
| 972 |
margin. All other things like border, label, highlighting, mover will |
| 973 |
not affect this size. The baseline of a chess board is always at the |
| 974 |
bottom of the bottom rank. Margins, labels or borders or anything |
| 975 |
else will not change this. If you want to move the baseline you will |
| 976 |
have to use a \cs{raisebox}. |
| 977 |
|
| 978 |
|
| 979 |
\subsection{Margins} |
| 980 |
|
| 981 |
The «outside size» («the bounding box») of a chess board is the size |
| 982 |
of the printed fields plus a margin. |
| 983 |
|
| 984 |
\medskip |
| 985 |
\Describesetkey{marginleftwidth}{length}{1em}{1em} |
| 986 |
\Describesetkey{marginrightwidth}{length}{1em}{1em}\goodbreak |
| 987 |
\Describesetkey{margintopwidth}{length}{1em}{1em}\goodbreak |
| 988 |
\Describesetkey{marginbottomwidth}{length}{1em}{1em}\goodbreak |
| 989 |
\Describesetkey{hmarginwidth}{length}{1em}{1em}\goodbreak |
| 990 |
\Describesetkey{vmarginwidth}{length}{1em}{1em}\goodbreak |
| 991 |
\Describesetkey{marginwidth}{length}{1em}{1em} |
| 992 |
|
| 993 |
|
| 994 |
With this keys you can set and change the thickness of the margin. As |
| 995 |
you can see you can set each margin differently, but there are also |
| 996 |
keys to set more than one margin at one time. |
| 997 |
|
| 998 |
|
| 999 |
|
| 1000 |
|
| 1001 |
\medskip |
| 1002 |
\Describesetkey{marginleft}{true|false}{}{true} |
| 1003 |
\Describesetkey{marginright}{true|false}{false}{true}\goodbreak |
| 1004 |
\Describesetkey{margintop}{true|false}{}{true}\goodbreak |
| 1005 |
\Describesetkey{marginbottom}{true|false}{}{true}\goodbreak |
| 1006 |
\Describesetkey{hmargin}{true|false}{}{true}\goodbreak |
| 1007 |
\Describesetkey{vmargin}{true|false}{}{true}\goodbreak |
| 1008 |
\Describesetkey{margin}{true|false}{}{true} |
| 1009 |
|
| 1010 |
You can disable the margin either by setting its width to 0pt or with |
| 1011 |
this boolean keys. |
| 1012 |
|
| 1013 |
\goodbreak |
| 1014 |
\begin{LTXexample} |
| 1015 |
x\fbox{\chessboard[printarea=a1-a1, |
| 1016 |
marginwidth=0pt]} |
| 1017 |
|
| 1018 |
x\fbox{\chessboard[printarea=a1-a1, |
| 1019 |
marginwidth=0.5cm]} |
| 1020 |
|
| 1021 |
x\fbox{\chessboard[printarea=a1-a1, |
| 1022 |
marginwidth=0.5cm, |
| 1023 |
margin=false]} |
| 1024 |
\end{LTXexample} |
| 1025 |
|
| 1026 |
\goodbreak |
| 1027 |
\subsection{Borders} |
| 1028 |
|
| 1029 |
The borders are made with rules. You will perhaps notice that on |
| 1030 |
screen the edges looks like as if they don't contact properly. This |
| 1031 |
is a problem of the rather bad resolution of a screen. When you zoom |
| 1032 |
in you can see that the edges are fine. If this bothers you, you can |
| 1033 |
try the fancy borders made with the pgf-commands decribed later. As |
| 1034 |
they are made with one line, they seem to have better edges -- but |
| 1035 |
you can't color them individually and it isn't yet possible to |
| 1036 |
disable the borders of single sides. |
| 1037 |
|
| 1038 |
\Describesetkey{borderleftwidth}{length}{1em}{0.04em} |
| 1039 |
\Describesetkey{borderrightwidth}{length}{1em}{0.04em} |
| 1040 |
\Describesetkey{bordertopwidth}{length}{1em}{0.04em} |
| 1041 |
\Describesetkey{borderbottomwidth}{length}{1em}{0.04em} |
| 1042 |
\Describesetkey{hborderwidth}{length}{1em}{0.04em} |
| 1043 |
\Describesetkey{vborderwidth}{length}{1em}{0.04em} |
| 1044 |
\Describesetkey{borderwidth}{length}{1em}{0.04em} |
| 1045 |
|
| 1046 |
|
| 1047 |
With this keys you can set and change the thickness of the border. |
| 1048 |
The border doesn't change the bounding box of the board. If there |
| 1049 |
isn't an adequate margin it will stick outside! |
| 1050 |
|
| 1051 |
\medskip |
| 1052 |
\Describesetkey{borderleft}{true|false}{}{true} |
| 1053 |
\Describesetkey{borderright}{true|false}{false}{true} |
| 1054 |
\Describesetkey{bordertop}{true|false}{}{true} |
| 1055 |
\Describesetkey{borderbottom}{true|false}{}{true} |
| 1056 |
\Describesetkey{hborder}{true|false}{}{true} |
| 1057 |
\Describesetkey{vborder}{true|false}{}{true} |
| 1058 |
\Describesetkey{border}{true|false}{}{true} |
| 1059 |
|
| 1060 |
You can disable the border either by setting its width to 0pt or with |
| 1061 |
this boolean keys. |
| 1062 |
|
| 1063 |
|
| 1064 |
\medskip |
| 1065 |
\Describesetkey{borderleftcolor}{color}{red}{black} |
| 1066 |
\Describesetkey{borderrightcolor}{color}{red}{black} |
| 1067 |
\Describesetkey{bordertopcolor}{color}{red}{black} |
| 1068 |
\Describesetkey{borderbottomcolor}{color}{red}{black} |
| 1069 |
\Describesetkey{hbordercolor}{color}{red}{black} |
| 1070 |
\Describesetkey{vbordercolor}{color}{red}{black} |
| 1071 |
\Describesetkey{bordercolor}{color}{red}{black} |
| 1072 |
|
| 1073 |
With this keys you can set and change the color of the border. |
| 1074 |
|
| 1075 |
{\bfseries You must load a color package like \packagename{xcolor} or |
| 1076 |
\packagename{color} to be able to use colors!}\footnote{I must |
| 1077 |
correct myself: the pgf-package will load \packagename{xcolor}, so |
| 1078 |
you should load a color package only if you want to use it with other |
| 1079 |
options} |
| 1080 |
|
| 1081 |
\begin{LTXexample} |
| 1082 |
\raggedright |
| 1083 |
some text above the board\\ |
| 1084 |
the board will overwrite this!\\ |
| 1085 |
left% |
| 1086 |
\def\borderwidth{12pt} |
| 1087 |
\def\mycolor{red!50} |
| 1088 |
\chessboard[tinyboard, |
| 1089 |
marginleftwidth=1em, |
| 1090 |
margintopwidth=0pt, |
| 1091 |
bordertopwidth=\borderwidth, |
| 1092 |
borderleftcolor=\mycolor, |
| 1093 |
bordertopcolor=yellow!25, |
| 1094 |
marginright=false]% |
| 1095 |
right\\ |
| 1096 |
text below the board |
| 1097 |
\end{LTXexample} |
| 1098 |
|
| 1099 |
|
| 1100 |
\subsection{The size of the boardfont} |
| 1101 |
|
| 1102 |
\Describesetkey{boardfontsize}{length}{10pt}{20pt} |
| 1103 |
\Describesetkey{fontsize}{length}{10pt}{20pt} |
| 1104 |
\Describesetkey{tinyboard}{arbitrary}{}{} |
| 1105 |
\Describesetkey{smallboard}{arbitrary}{}{} |
| 1106 |
\Describesetkey{normalboard}{arbitrary}{}{default} |
| 1107 |
\Describesetkey{largeboard}{arbitrary}{}{} |
| 1108 |
|
| 1109 |
With this keys you can change the size of the board font. The keys |
| 1110 |
\key{tinyboard} etc.\ gives the same sizes as the similar commands |
| 1111 |
\cs{tinyboard} of \skaksty, they also change the size of the font of |
| 1112 |
the labels. |
| 1113 |
|
| 1114 |
You can also change the size of the board font with the commands |
| 1115 |
described in the documentation of \chessfss. But you should be aware |
| 1116 |
that the keys used in \cs{setchessboard} or \cs{chessboard} will |
| 1117 |
always win over the commands from \chessfss. |
| 1118 |
|
| 1119 |
|
| 1120 |
\subsection{Changing the boardfont} |
| 1121 |
|
| 1122 |
Instead of using the keys described below you can also change the |
| 1123 |
board font with the commands described in the documentation of |
| 1124 |
\chessfss. But you should be aware that the keys used in |
| 1125 |
\cs{setchessboard} or \cs{chessboard} will always win over the |
| 1126 |
commands from \chessfss. |
| 1127 |
|
| 1128 |
|
| 1129 |
\Describesetkey{boardfontfamily}{family name}{maya}{skak/skaknew} |
| 1130 |
|
| 1131 |
With the above key you can change the board font by setting the |
| 1132 |
family. This works quite similar as for text font where you can |
| 1133 |
switch e.g. from times to helvetica by changing the font family. The |
| 1134 |
font families |
| 1135 |
\chessfontname{skak} and \chessfontname{skaknew} will work from the |
| 1136 |
start. You must install other families before being able to use them! |
| 1137 |
|
| 1138 |
\begin{LTXexample} |
| 1139 |
\chessboard[boardfontfamily=maya] |
| 1140 |
\end{LTXexample} |
| 1141 |
|
| 1142 |
\goodbreak |
| 1143 |
\Describesetkey{boardfontseries}{series name}{b}{} |
| 1144 |
|
| 1145 |
Setting the series to bold (b) only works for a quite small set of |
| 1146 |
fonts which have the chars in two weights. But to tell the truth: I |
| 1147 |
don't find the result very satisfying. |
| 1148 |
|
| 1149 |
|
| 1150 |
There are no keys to change the shape of the font as I really don't |
| 1151 |
know what an italic (\cs{itshape}) or slanted board font should be. |
| 1152 |
(And I never saw such a font). |
| 1153 |
|
| 1154 |
|
| 1155 |
\begin{LTXexample} |
| 1156 |
\newchessgame |
| 1157 |
\chessboard[boardfontfamily=millennia, |
| 1158 |
tinyboard] |
| 1159 |
\chessboard[boardfontfamily=millennia, |
| 1160 |
boardfontseries=b, |
| 1161 |
tinyboard] |
| 1162 |
|
| 1163 |
\end{LTXexample} |
| 1164 |
|
| 1165 |
|
| 1166 |
|
| 1167 |
\Describesetkey{boardfontencoding}{encoding}{LSB1}{LSB} |
| 1168 |
|
| 1169 |
|
| 1170 |
With this key you can change the encoding of the board font. While in |
| 1171 |
a normal document you probably seldom or never need to bother with |
| 1172 |
encodings they are highly useful in connection chess board if you |
| 1173 |
want to add colors to the chars on the board. When using other |
| 1174 |
encodings that the standard LSB the chars on the board are composed |
| 1175 |
with special chars that allows to color e.g. the lines of the black |
| 1176 |
field differently to the figure on the field. I will come back to |
| 1177 |
this when I describe how to color the chars. |
| 1178 |
|
| 1179 |
There are simple encodings called LSB, LSB1, LSB2 \ldots, which works |
| 1180 |
with almost every font family. And there are special encodings LSBC1, |
| 1181 |
LSBC2 \ldots, which works only with professional chess fonts with |
| 1182 |
special chars. Happily the default board font, the free font |
| 1183 |
\chessfontname{skaknew}, is such a professional chess font. |
| 1184 |
|
| 1185 |
|
| 1186 |
|
| 1187 |
If you want to use one of the extended encodings LSB1, LSB2, etc and |
| 1188 |
LSBC1, LSBC2 etc you must load the definition files e.g.\ with |
| 1189 |
\lstinline+\usepackage[LSB1,T1]{fontenc}+. You find more |
| 1190 |
informations in the documentation of \chessfss. |
| 1191 |
|
| 1192 |
|
| 1193 |
|
| 1194 |
|
| 1195 |
\subsection{Coloring and emphasizing the board chars} |
| 1196 |
\subsubsection{In short} |
| 1197 |
|
| 1198 |
\begin{itemize} |
| 1199 |
|
| 1200 |
\item Coloring the board or parts of the chars is a two step process: |
| 1201 |
|
| 1202 |
First you set the colors you want, then you apply them. |
| 1203 |
|
| 1204 |
\item |
| 1205 |
Colors can be applied to the whole board (to set the default colors |
| 1206 |
of the white and black pieces and fields). This done with the keys |
| 1207 |
\key{setfontcolors} and \key{addfontcolors}. |
| 1208 |
|
| 1209 |
\item Colors can be applied to part of the board together with other commands like \cs{bfseries} |
| 1210 |
(e.g. to emphasize special fields or ranks) |
| 1211 |
by first enabling color emphasing with the key \key{coloremph} and |
| 1212 |
then by setting the area or field that should get the colors with |
| 1213 |
e.g. the key \key{empharea}. |
| 1214 |
|
| 1215 |
|
| 1216 |
\end{itemize} |
| 1217 |
|
| 1218 |
|
| 1219 |
|
| 1220 |
\subsubsection{Introduction: About composed chars and encodings} |
| 1221 |
In simple chess fonts each field with and without a figure on it is |
| 1222 |
\emph{one} char. You can color such a char but -- as in the case of normal chars -- only |
| 1223 |
in one color: |
| 1224 |
|
| 1225 |
\textcolor{red}{\Large A \BlackKingOnBlack} |
| 1226 |
|
| 1227 |
This is certainly not very satisfying. You probably would like to be |
| 1228 |
able to color the white figures diffently from the black ones, and |
| 1229 |
the black fields in a third color. |
| 1230 |
|
| 1231 |
To be able to do this, one has to use more than one char to build a |
| 1232 |
field and to print them on top of each other. Look e.g. at this |
| 1233 |
example: |
| 1234 |
|
| 1235 |
\colorbox{yellow}{\Chess |
| 1236 |
\makebox[0pt][l]{\color{blue}\BlackEmptySquare}% |
| 1237 |
\color{green}T% |
| 1238 |
\color{red}K} |
| 1239 |
|
| 1240 |
It is build by putting four different objects on top of each other: |
| 1241 |
|
| 1242 |
At start there is a standard yellow colorbox |
| 1243 |
|
| 1244 |
\colorbox{yellow}{\Chess\phantom{\BlackEmptySquare}} |
| 1245 |
|
| 1246 |
Above there is a black empty square colored in blue: |
| 1247 |
|
| 1248 |
{\Chess\color{blue}\BlackEmptySquare} |
| 1249 |
|
| 1250 |
Then comes a solid, filled and colored char with the same shape as |
| 1251 |
the king: |
| 1252 |
|
| 1253 |
{\Chess\color{green}T} |
| 1254 |
|
| 1255 |
At last there is the char for the king: |
| 1256 |
|
| 1257 |
{\Chess\color{red}K} |
| 1258 |
|
| 1259 |
So |
| 1260 |
|
| 1261 |
{\Chess\colorbox{yellow}{\phantom{\BlackEmptySquare}}\Plus |
| 1262 |
{\color{blue}\BlackEmptySquare}\Plus |
| 1263 |
{\color{green}T\phantom{\BlackEmptySquare}}\Plus |
| 1264 |
{\color{red}K}\Equal |
| 1265 |
\colorbox{yellow}{% |
| 1266 |
\makebox[0pt][l]{\color{blue}\BlackEmptySquare}% |
| 1267 |
\color{green}T% |
| 1268 |
\color{red}K}} |
| 1269 |
|
| 1270 |
|
| 1271 |
There are a lot of other possibilities to compose the board fields. |
| 1272 |
Some more «poor man's» compositions that use only chars present in |
| 1273 |
every chess font, other that need special masking chars which only |
| 1274 |
special chess fonts provide. |
| 1275 |
|
| 1276 |
{\bfseries Each such construction is connected to a font encoding: By |
| 1277 |
changing the encoding of the board font you change the rules that |
| 1278 |
compose the board chars and so you change also the options to color |
| 1279 |
the chars.} |
| 1280 |
|
| 1281 |
|
| 1282 |
In \chessfss I have defined a bundle of such «construction rules» |
| 1283 |
(=encodings) to use and color composed board chars. As it would be a |
| 1284 |
strain if each of this construction rules would let to a different |
| 1285 |
set of commands to color the chars I had to systemize the |
| 1286 |
construction rules. For this I have divided the possible individual |
| 1287 |
components of a composed chars in four logical layers and assign to |
| 1288 |
each layer generic color commands that are used in the definition of |
| 1289 |
the composed chars and can be used to color the components. The four |
| 1290 |
layers are named fieldmask, field, piecemask and piece. |
| 1291 |
|
| 1292 |
As an example table~\ref{tab:encLSBC3} shows a tabular that |
| 1293 |
demonstrates how the encoding LSBC3 is built. As you can see the |
| 1294 |
chars are built by putting up three or four chars on top of each |
| 1295 |
other. (The green and yellow colors are not the default settings!). |
| 1296 |
The documentation of |
| 1297 |
\chessfss shows the other encodings. |
| 1298 |
%The colors have been set with the |
| 1299 |
%\chessfss-command |
| 1300 |
%\begin{lstlisting} |
| 1301 |
%\setboardfontcolors{ |
| 1302 |
% whitepiece=red!70, |
| 1303 |
% blackfield=green, |
| 1304 |
% whiteonwhitepiecemask=yellow} |
| 1305 |
%\end{lstlisting} |
| 1306 |
|
| 1307 |
|
| 1308 |
|
| 1309 |
\begin{table} |
| 1310 |
\setboardfontcolors{whitepiece=red!70, |
| 1311 |
blackfield=green,whiteonwhitepiecemask=yellow}% |
| 1312 |
|
| 1313 |
\caption{The contruction rules of encoding LSBC3}\label{tab:encLSBC3} |
| 1314 |
|
| 1315 |
%\medskip |
| 1316 |
\showchessboardencoding{LSBC3} |
| 1317 |
|
| 1318 |
|
| 1319 |
\end{table} |
| 1320 |
|
| 1321 |
Table~\ref{tab:intcom} shows the internal commands used to color the |
| 1322 |
different part of a composed char. You will probably never need them |
| 1323 |
but they will give you an idea what can be colored (I hope that is |
| 1324 |
clear that it makes only sense to change the colors of layers that |
| 1325 |
are used in the actual encoding -- you can't color an solid fieldmask |
| 1326 |
that isn't there). |
| 1327 |
|
| 1328 |
%\begin{minipage}[t]{\textwidth} |
| 1329 |
\begin{table} |
| 1330 |
\caption{The internal color commands}\label{tab:intcom} |
| 1331 |
|
| 1332 |
\begin{tabular}[t]{@{}lll} |
| 1333 |
\itshape layer & \itshape internal color commands & \itshape default definition\\\hline\\ |
| 1334 |
|
| 1335 |
fieldmask & \cs{cfss@whitefieldmaskcolor} &\cs{color}\ttfamily\{white\}\\ |
| 1336 |
& \cs{cfss@blackfieldmaskcolor} &\cs{color}\ttfamily\{gray\}\\ |
| 1337 |
field & \cs{cfss@whitefieldcolor} &\ttfamily\{\}\\ |
| 1338 |
& \cs{cfss@blackfieldcolor} &\ttfamily\{\}\\ |
| 1339 |
piecemask & \cs{cfss@whiteonwhitepiecemaskcolor}&\cs{color}\ttfamily\{white\}\\ |
| 1340 |
& \cs{cfss@whiteonblackpiecemaskcolor}&\cs{color}\ttfamily\{white\}\\ |
| 1341 |
& \cs{cfss@blackonwhitepiecemaskcolor}&\cs{color}\ttfamily\{white\}\\ |
| 1342 |
& \cs{cfss@blackonblackpiecemaskcolor}&\cs{color}\ttfamily\{white\}\\ |
| 1343 |
piece & \cs{cfss@whitepiececolor} &\ttfamily\{\}\\ |
| 1344 |
& \cs{cfss@blackpiececolor} &\ttfamily\{\} \\ |
| 1345 |
\end{tabular} |
| 1346 |
|
| 1347 |
|
| 1348 |
\end{table} |
| 1349 |
%\end{minipage} |
| 1350 |
|
| 1351 |
|
| 1352 |
I would like to draw your attention to two things: |
| 1353 |
|
| 1354 |
\begin{enumerate} |
| 1355 |
\item The field-layers distinguish between black and white field |
| 1356 |
while the piece layer distinguish between black and white pieces and |
| 1357 |
the piecemask offers all possible combinations. |
| 1358 |
|
| 1359 |
\item |
| 1360 |
The fieldmask and the piecemask are colored by default and so they |
| 1361 |
will overwrite or block out external colors from \cs{colorbox} or |
| 1362 |
\cs{textcolor} commands: |
| 1363 |
|
| 1364 |
\begin{LTXexample} |
| 1365 |
%Uses commands from chessfss.sty |
| 1366 |
\setboardfontencoding{LSBC3}% |
| 1367 |
\setboardfontsize{2cm} |
| 1368 |
|
| 1369 |
\colorbox{yellow}{% |
| 1370 |
\textcolor{red}{\WhiteKingOnWhite}} |
| 1371 |
% |
| 1372 |
\setboardfontcolors{ |
| 1373 |
whitefieldmask=yellow, |
| 1374 |
whiteonwhitepiecemask=red} |
| 1375 |
\colorbox{yellow}{% |
| 1376 |
\textcolor{red}{\WhiteKingOnWhite}} |
| 1377 |
\end{LTXexample} |
| 1378 |
|
| 1379 |
\end{enumerate} |
| 1380 |
|
| 1381 |
|
| 1382 |
|
| 1383 |
|
| 1384 |
|
| 1385 |
So coloring the board is not really difficult: one must only redefine |
| 1386 |
the internal commands mentioned above to the wanted color. That's |
| 1387 |
what the \cs{setboardfontcolors} command of \chessfss does and it |
| 1388 |
will work fine with chessboard. |
| 1389 |
|
| 1390 |
Naturally I also wanted to add keys for \cs{chessboard} and |
| 1391 |
\cs{setchessboard} to change the colors. This is a bit more |
| 1392 |
complicated because I wanted not only to be able to change the colors |
| 1393 |
of the whole board but also of single fields or areas. And I had also |
| 1394 |
to add keys to change the color in the two pgf pictures. Finding |
| 1395 |
names for all this keys and effects wasn't easy. And I hope that it |
| 1396 |
isn't to confusing. |
| 1397 |
|
| 1398 |
\subsubsection{Setting the default colors of the board} |
| 1399 |
|
| 1400 |
\Describefillkey{clearfontcolors}{arbitrary}{} |
| 1401 |
|
| 1402 |
When you set with the following keys a color for one of the font |
| 1403 |
layers, \cs{chessboard} adds simply the color definition to an |
| 1404 |
internal command (the «font color stack»). When you use later a key |
| 1405 |
to apply the colors to the board or an area this internal command is |
| 1406 |
inserted at the start of the board or the fields of the area. The |
| 1407 |
internal command can get quite long if you set a lot of colors. With |
| 1408 |
the key \key{clearfontcolors} you can empty the internal command |
| 1409 |
(this will not destroy the colors that you have already applied). |
| 1410 |
|
| 1411 |
|
| 1412 |
|
| 1413 |
|
| 1414 |
\Describefillkey{whitefieldmaskcolor}{color}{red!50} |
| 1415 |
\Describefillkey{blackfieldmaskcolor}{color}{red!50} |
| 1416 |
\Describefillkey{fieldmaskcolor}{color}{red!50}\goodbreak |
| 1417 |
|
| 1418 |
\Describefillkey{whitefieldcolor}{color}{red!50} |
| 1419 |
\Describefillkey{blackfieldcolor}{color}{red!50} |
| 1420 |
\Describefillkey{fieldcolor}{color}{red!50}\goodbreak |
| 1421 |
|
| 1422 |
\Describefillkey{whiteonwhitepiecemaskcolor}{color}{red!50}\goodbreak |
| 1423 |
\Describefillkey{whiteonblackpiecemaskcolor}{color}{red!50} |
| 1424 |
\Describefillkey{blackonwhitepiecemaskcolor}{color}{red!50} |
| 1425 |
\Describefillkey{blackonblackpiecemaskcolor}{color}{red!50}\goodbreak |
| 1426 |
\Describefillkey{whitepiecemaskcolor}{color}{red!50} |
| 1427 |
\Describefillkey{blackpiecemaskcolor}{color}{red!50}\goodbreak |
| 1428 |
\Describefillkey{onwhitepiecemaskcolor}{color}{red!50} |
| 1429 |
\Describefillkey{onblackpiecemaskcolor}{color}{red!50} |
| 1430 |
\Describefillkey{piecemaskcolor}{color}{red!50}\goodbreak |
| 1431 |
|
| 1432 |
\Describefillkey{whitepiececolor}{color}{red!50} |
| 1433 |
\Describefillkey{blackpiececolor}{color}{red!50} |
| 1434 |
\Describefillkey{piececolor}{color}{red!50} |
| 1435 |
|
| 1436 |
|
| 1437 |
With this keys you set the colors of the different parts of a |
| 1438 |
composed char. The colors are saved to an internal stack. A key like |
| 1439 |
\key{whitepiececolor} saves the color for one of the layer color |
| 1440 |
commands. \key{piecemaskcolor} will set the color for all four |
| 1441 |
piecemasks in one go. |
| 1442 |
|
| 1443 |
|
| 1444 |
|
| 1445 |
|
| 1446 |
The keys \obsoletekey{colorwhite} and \obsoletekey{colorblack} of the |
| 1447 |
previous version of this package are copies of the keys |
| 1448 |
\key{whitepiececolor} and \key{blackpiececolor}. |
| 1449 |
|
| 1450 |
|
| 1451 |
|
| 1452 |
\subsubsection{Applying the colors to the whole board} |
| 1453 |
|
| 1454 |
\Describefillkey{setfontcolors}{arbitrary}{} |
| 1455 |
\Describefillkey{addfontcolors}{arbitrary}{} |
| 1456 |
|
| 1457 |
This keys will put the «font color stack» in a command that is |
| 1458 |
executed at the start of the board. So the colors will affect any |
| 1459 |
fields that don't get individual colors with the command described in |
| 1460 |
the next subsection. |
| 1461 |
\key{setfontcolors} will replace any font colors that have been set |
| 1462 |
before, \key{addfontcolors} will add the new colors to perhaps |
| 1463 |
already existing ones. |
| 1464 |
|
| 1465 |
\begin{LTXexample} |
| 1466 |
\def\mycolor{yellow!50} |
| 1467 |
\setchessboard{ |
| 1468 |
boardfontencoding=LSBC3, |
| 1469 |
piecemaskcolor=\mycolor, |
| 1470 |
setfontcolors} |
| 1471 |
|
| 1472 |
\chessboard[tinyboard] |
| 1473 |
|
| 1474 |
\def\mycolor{green}% will set the |
| 1475 |
% piecemask to green: |
| 1476 |
\chessboard[tinyboard, |
| 1477 |
whitepiececolor=red, |
| 1478 |
blackpiececolor=blue, |
| 1479 |
fieldcolor=white, |
| 1480 |
addfontcolors] |
| 1481 |
\end{LTXexample} |
| 1482 |
|
| 1483 |
\subsubsection{Emphasising and coloring individual areas} |
| 1484 |
|
| 1485 |
|
| 1486 |
\Describefillkey{emphstyle}{commands}{\cs{bfseries}} |
| 1487 |
|
| 1488 |
With this key you can set a command that should be applied to an |
| 1489 |
area. The commands can be whatever you want, (it is a good idea not |
| 1490 |
use something that takes up some space). In my opinion the only |
| 1491 |
senseful commands are \cs{color} and -- for the few fonts that have a |
| 1492 |
bold boardfont -- \cs{bfseries}. You can use the key e.g. for simple |
| 1493 |
coloring. |
| 1494 |
|
| 1495 |
\begin{LTXexample} |
| 1496 |
\newchessgame |
| 1497 |
\def\empharea{ h8-f4 } |
| 1498 |
\chessboard[emphstyle=\color{red}, |
| 1499 |
empharea=\empharea] |
| 1500 |
\end{LTXexample} |
| 1501 |
|
| 1502 |
You can't color with \key{emphstyle} the fieldmask and the piecemask |
| 1503 |
of chars as they have a default color that takes precedence. |
| 1504 |
|
| 1505 |
\Describefillkey{coloremph}{true|false}{} |
| 1506 |
With this key you enable or disable color emphasising. When set to |
| 1507 |
true, font colors set earlier will be added to emphstyle and so used |
| 1508 |
to color the area. The colors are added after the commands of the key |
| 1509 |
\key{emphstyle} and so will eventually overwrite them. |
| 1510 |
This allows more complicated coloring: |
| 1511 |
|
| 1512 |
\begin{LTXexample} |
| 1513 |
\newchessgame |
| 1514 |
\def\empharea{ h8-f1 } |
| 1515 |
\chessboard[boardfontencoding=LSBC3, |
| 1516 |
whiteonwhitepiecemaskcolor=green, |
| 1517 |
whitepiececolor=red, |
| 1518 |
blackpiececolor=blue, |
| 1519 |
emphstyle=\color{yellow}, |
| 1520 |
%doesn't affect the default white color |
| 1521 |
%of the piecemask |
| 1522 |
empharea=a1-c8, |
| 1523 |
coloremph, |
| 1524 |
empharea=\empharea] |
| 1525 |
\end{LTXexample} |
| 1526 |
|
| 1527 |
|
| 1528 |
|
| 1529 |
|
| 1530 |
|
| 1531 |
\goodbreak |
| 1532 |
|
| 1533 |
\Describefillkey{coloremphstyle}{commands}{\cs{bfseries}} |
| 1534 |
|
| 1535 |
This key combines the keys \key{coloremph} and \key{emphstyle}. |
| 1536 |
|
| 1537 |
|
| 1538 |
|
| 1539 |
\goodbreak |
| 1540 |
\Describefillkey{emphboard}{arbitrary}{} |
| 1541 |
\Describefillkey{empharea}{area}{a1-c3} |
| 1542 |
\Describefillkey{emphareas}{list of areas}{\{f6-h7,a1-c3\}} |
| 1543 |
\Describefillkey{emphfile}{file}{a} |
| 1544 |
\Describefillkey{emphfiles}{list of files}{\{g,h\}} |
| 1545 |
\Describefillkey{emphrank}{rank}{5} |
| 1546 |
\Describefillkey{emphranks}{list of ranks}{\{8,7\}} |
| 1547 |
\Describefillkey{emphfield}{field}{a3} |
| 1548 |
\Describefillkey{emphfields}{list of fields}{\{b5,c6\}} |
| 1549 |
|
| 1550 |
This keys apply the emphasize commands and eventually the colors to |
| 1551 |
the area they define. |
| 1552 |
|
| 1553 |
\begin{LTXexample} |
| 1554 |
\def\empharea{ h8-f4 } |
| 1555 |
\chessboard[boardfontfamily=millennia, |
| 1556 |
coloremphstyle=\bfseries, |
| 1557 |
empharea=\empharea, |
| 1558 |
whitepiececolor=red, |
| 1559 |
emphrank=1, |
| 1560 |
whitepiececolor=blue, |
| 1561 |
emphareas={a2-a2, c1-e2}, |
| 1562 |
coloremph=false, |
| 1563 |
emphfield=f2] |
| 1564 |
\end{LTXexample} |
| 1565 |
|
| 1566 |
|
| 1567 |
\begin{LTXexample} |
| 1568 |
\chessboard[boardfontencoding=LSBC3, |
| 1569 |
coloremph, |
| 1570 |
emphfield={f1}, |
| 1571 |
whitepiececolor=red, |
| 1572 |
emphranks={1}, |
| 1573 |
whitepiececolor=blue, |
| 1574 |
emphfields=a2, |
| 1575 |
blackpiececolor=green, |
| 1576 |
empharea=a8-c7] |
| 1577 |
\end{LTXexample} |
| 1578 |
|
| 1579 |
|
| 1580 |
The key \obsoletekey{colorpieces} doesn't work anymore, it will issue |
| 1581 |
only a warning. Use |
| 1582 |
\key{emphfields} instead. |
| 1583 |
|
| 1584 |
|
| 1585 |
\subsubsection{Transparency/opacity} |
| 1586 |
|
| 1587 |
Pgf has commands to set the opacity of a color. This works only for |
| 1588 |
some drivers and output formats (e.g.\ with pdf\LaTeX), but it also |
| 1589 |
works outside pgf pictures in running text. The main drawbacks are |
| 1590 |
that the opacity settings gets lost at a pagebreak and that |
| 1591 |
\TeX-groups and boxes are not respected, that means that you must |
| 1592 |
reset the opacity explicitly. It is possible to add to boxes that use |
| 1593 |
internally |
| 1594 |
\cs{color@begingroup}/""\cs{color@endgroup}\footnote{Almost all |
| 1595 |
\LaTeX-boxes but not e.g.\ \cs{mbox} and \cs{makebox} when used |
| 1596 |
without optional argument.} some code that resets the opacity outside |
| 1597 |
the box to 1. As \cs{chessboard} uses only such safe boxes it is |
| 1598 |
possible to smuggle transparency in parts of the composed chars. But |
| 1599 |
the whole is not very safe so use it at your own risk. |
| 1600 |
|
| 1601 |
\begin{LTXexample} |
| 1602 |
\makebox[0pt][l]{\rule{12em}{10pt}}% |
| 1603 |
\color{red}% |
| 1604 |
\rule{1em}{14pt} ABC |
| 1605 |
\pgfsetfillopacity{0.5}% |
| 1606 |
\rule{1em}{14pt} ABC |
| 1607 |
\pgfsetfillopacity{1}% |
| 1608 |
\rule{1em}{14pt} ABC |
| 1609 |
|
| 1610 |
\makeatletter |
| 1611 |
\let\color@endgroupORI\color@endgroup |
| 1612 |
\def\color@endgroup |
| 1613 |
{\color@endgroupORI\pgfsetfillopacity{1}} |
| 1614 |
|
| 1615 |
\chessboard[boardfontencoding=LSBC4, |
| 1616 |
whitepiececolor=red, |
| 1617 |
blackpiececolor=blue, |
| 1618 |
setfontcolors] |
| 1619 |
|
| 1620 |
\def\cfss@whitepiececolor |
| 1621 |
{\pgfsetfillopacity{0.5}\color{red}} |
| 1622 |
\def\cfss@blackpiececolor |
| 1623 |
{\pgfsetfillopacity{0.5}\color{blue}} |
| 1624 |
|
| 1625 |
\chessboard[boardfontencoding=LSBC4] |
| 1626 |
|
| 1627 |
\end{LTXexample} |
| 1628 |
|
| 1629 |
|
| 1630 |
\subsection{Labels} |
| 1631 |
|
| 1632 |
In \chessfss I used the name sidefont for the label. I did it mostly |
| 1633 |
because I didn't dare to use the command \cs{labelfont}, I was quite |
| 1634 |
sure that somewhere in the packages for \LaTeX\ someone else had |
| 1635 |
already used this name. When using keys name clash are not a problem |
| 1636 |
as internally a unique prefix is used, so I decided to use names |
| 1637 |
starting with «label» in this package. |
| 1638 |
|
| 1639 |
\medskip |
| 1640 |
\Describesetkey{labelleft}{true|false}{}{true} |
| 1641 |
\Describesetkey{labelright}{true|false}{false}{false}\goodbreak |
| 1642 |
\Describesetkey{labeltop}{true|false}{}{false}\goodbreak |
| 1643 |
\Describesetkey{labelbottom}{true|false}{}{true}\goodbreak |
| 1644 |
\Describesetkey{hlabel}{true|false}{}{false}\goodbreak |
| 1645 |
\Describesetkey{vlabel}{true|false}{}{false}\goodbreak |
| 1646 |
\Describesetkey{label}{true|false}{}{false} |
| 1647 |
|
| 1648 |
You can disable the labels with this boolean keys. |
| 1649 |
|
| 1650 |
\Describesetkey{labelleftwidth}{length}{1em}{1ex} |
| 1651 |
\Describesetkey{labelrightwidth}{length}{1em}{1ex} |
| 1652 |
\Describesetkey{hlabelwidth}{length}{1em}{1ex} |
| 1653 |
|
| 1654 |
The labels on the left side are set raggedleft, the ones on the right |
| 1655 |
side raggedright at the distance given by the keys. This width don't |
| 1656 |
change the size of the board! The top and bottom labels are centered. |
| 1657 |
|
| 1658 |
\begin{LTXexample} |
| 1659 |
\def\mywidth{1em} |
| 1660 |
left% |
| 1661 |
\chessboard[maxfield=j10, |
| 1662 |
tinyboard, |
| 1663 |
printarea=d5-j10, |
| 1664 |
hmarginwidth=1em, |
| 1665 |
hlabelwidth=\mywidth, |
| 1666 |
hlabel, |
| 1667 |
vlabel=false]% |
| 1668 |
right |
| 1669 |
\end{LTXexample} |
| 1670 |
|
| 1671 |
\Describesetkey{labelleftlift}{length}{1em}{0.35em} |
| 1672 |
\Describesetkey{labelrightlift}{length}{1em}{0.35em} |
| 1673 |
\Describesetkey{hlabellift}{length}{1em}{0.35em} |
| 1674 |
|
| 1675 |
With this keys you can move up and down the left and right labels. |
| 1676 |
|
| 1677 |
|
| 1678 |
|
| 1679 |
|
| 1680 |
\medskip |
| 1681 |
\Describesetkey{labeltoplift}{length}{1em}{1.1\cs{baselineskip}} |
| 1682 |
\Describesetkey{labelbottomlift}{length}{1em}{0.2\cs{baselineskip}} |
| 1683 |
\Describesetkey{vlabellift}{length}{1em}{--} |
| 1684 |
|
| 1685 |
With this keys you can set the distance of the baselines of the top |
| 1686 |
and bottom labels from the board sides. \cs{baselineskip}, ex and em |
| 1687 |
refer in this keys \emph{not} to the size of the board, but to the |
| 1688 |
size of the label font -- I thought this would be easier to handle. |
| 1689 |
|
| 1690 |
\medskip |
| 1691 |
\Describesetkey{labelleftfont}{fontcommand}{\cs{itshape}}{\cs{sfdefault}} |
| 1692 |
\Describesetkey{labelrightfont}{fontcommand}{\cs{itshape}}{\cs{sfdefault}}\goodbreak |
| 1693 |
\Describesetkey{labeltopfont}{fontcommand}{\cs{itshape}}{\cs{sfdefault}}\goodbreak |
| 1694 |
\Describesetkey{labelbottomfont}{fontcommand}{\cs{itshape}}{\cs{sfdefault}}\goodbreak |
| 1695 |
\Describesetkey{hlabelfont}{fontcommand}{\cs{itshape}}{\cs{sfdefault}}\goodbreak |
| 1696 |
\Describesetkey{vlabelfont}{fontcommand}{\cs{itshape}}{\cs{sfdefault}}\goodbreak |
| 1697 |
\Describesetkey{labelfont}{fontcommand}{\cs{itshape}}{\cs{sfdefault}} |
| 1698 |
|
| 1699 |
With this keys you can set the font used by the labels. As a default |
| 1700 |
(this is set in \chessfss) the sans serif font of the document is |
| 1701 |
used. You can also use the \chessfss commands to change the font. |
| 1702 |
|
| 1703 |
|
| 1704 |
\Describesetkey{labelfontsize}{length}{0.5em}{10pt} |
| 1705 |
|
| 1706 |
This key sets the font size of the label. The default value is set by |
| 1707 |
the key \key{normalboard}. There aren't keys to set the size of each |
| 1708 |
label separatly. If you really need different sizes, use the key |
| 1709 |
\key{hlabelfont} etc (and be careful when using font relative sizes). |
| 1710 |
|
| 1711 |
\begin{LTXexample} |
| 1712 |
\setchessboard{labelfont=\bfseries} |
| 1713 |
\setsidefontfamily{ptm} % from chessfss.sty |
| 1714 |
\chessboard[labelfontsize=6pt] |
| 1715 |
\end{LTXexample} |
| 1716 |
|
| 1717 |
|
| 1718 |
\Describesetkey{labelleftformat}{commands}{}{\arabic{ranklabel}} |
| 1719 |
\Describesetkey{labelrightformat}{commands}{}{\arabic{ranklabel}}\goodbreak |
| 1720 |
\Describesetkey{labeltopformat}{commands}{}{\alph{filelabel}}\goodbreak |
| 1721 |
\Describesetkey{labelbottomformat}{commands}{}{\alph{filelabel}}\goodbreak |
| 1722 |
\Describesetkey{hlabelformat}{commands}{}{\arabic{ranklabel}}\goodbreak |
| 1723 |
\Describesetkey{vlabelformat}{commands}{}{\alph{filelabel}}\goodbreak |
| 1724 |
\Describesetkey{labelformat}{commands}{}{} |
| 1725 |
|
| 1726 |
With this keys you can control how the number of the files and ranks |
| 1727 |
are printed. \texttt{ranklabel} and \texttt{filelabel} are counters |
| 1728 |
that contain the current rank and file. You can use them freely (even |
| 1729 |
change if you want). |
| 1730 |
|
| 1731 |
The commands can be a lot of things. You can e.g.\ use them to color |
| 1732 |
the labels or to move the labels around. When you use commands with |
| 1733 |
optional arguments you must put braces around the value of the key! |
| 1734 |
|
| 1735 |
\begin{LTXexample} |
| 1736 |
\def\mylabelformat{% |
| 1737 |
{\makebox[0pt][r]{% |
| 1738 |
\ifthenelse{\isodd{\value{ranklabel}}} |
| 1739 |
{\color{red}\roman{ranklabel}} |
| 1740 |
{\color{green}\roman{ranklabel}}}}} |
| 1741 |
|
| 1742 |
\chessboard[hlabelformat=\mylabelformat, |
| 1743 |
vlabelformat=\arabic{filelabel}\hfill] |
| 1744 |
\end{LTXexample} |
| 1745 |
|
| 1746 |
|
| 1747 |
\subsection{The mover} |
| 1748 |
The «mover» is a sign at the side of the board that indicates which |
| 1749 |
player is to move. \cs{chessboard} gets this information either from |
| 1750 |
the FEN (if it contains the information as is the case when the FEN |
| 1751 |
comes from \skaksty), or through the following key: |
| 1752 |
|
| 1753 |
\Describefillkey{mover}{w|b}{b} |
| 1754 |
|
| 1755 |
You can use this key more than once, e.g.\ to control the mover |
| 1756 |
field in the FEN that you save, the last value is used for the |
| 1757 |
print. |
| 1758 |
|
| 1759 |
\medskip |
| 1760 |
\Describesetkey{showmover}{true|false}{false}{true} |
| 1761 |
|
| 1762 |
This key switch the print of the mover sign on and off. |
| 1763 |
|
| 1764 |
\begin{LTXexample} |
| 1765 |
\chessboard[smallboard,showmover=true] |
| 1766 |
\end{LTXexample} |
| 1767 |
|
| 1768 |
|
| 1769 |
\Describesetkey{moversize}{length}{1ex}{1em} |
| 1770 |
|
| 1771 |
This key sets the fontsize of the mover. It only has an effect if |
| 1772 |
the mover sign comes from a font -- and if the definition doesn't |
| 1773 |
change the fontsize. |
| 1774 |
|
| 1775 |
The value is saved in an inner command with the name |
| 1776 |
\cs{board@val@moversize}, you can use this command in your own mover |
| 1777 |
definitions. |
| 1778 |
|
| 1779 |
\medskip |
| 1780 |
\Describesetkey{moverlift}{length}{1ex}{0pt} |
| 1781 |
\Describesetkey{movertoplift}{length}{1ex}{0pt} |
| 1782 |
\Describesetkey{moverbottomlift}{length}{1ex}{0pt} |
| 1783 |
|
| 1784 |
With this keys you can move the mover vertically. Positive values |
| 1785 |
will move the bottom mover up and the top mover down\footnote{This |
| 1786 |
isn't perhaps the correct meaning of the word «lift» but I guessed |
| 1787 |
that user expect the mover to move either both towards or apart.}. |
| 1788 |
0pt will align the bottom mover along the baseline, and the top of |
| 1789 |
the upper mover along the upper side of the board. |
| 1790 |
|
| 1791 |
|
| 1792 |
\begin{LTXexample}[width=0.55\textwidth] |
| 1793 |
\setchessboard{showmover}% |
| 1794 |
\chessboard[tinyboard, setfen=k1K b]% |
| 1795 |
\chessboard[tinyboard, setfen=k1K w] |
| 1796 |
|
| 1797 |
|
| 1798 |
\chessboard[tinyboard, setfen=k1K b, |
| 1799 |
moverlift=-1ex]% |
| 1800 |
\chessboard[tinyboard, setfen=k1K w, |
| 1801 |
moverlift=-1ex] |
| 1802 |
\end{LTXexample} |
| 1803 |
|
| 1804 |
|
| 1805 |
\Describesetkey{movershift}{length}{1ex}{1ex} |
| 1806 |
\Describesetkey{movertopshift}{length}{1ex}{1ex} |
| 1807 |
\Describesetkey{moverbottomshift}{length}{1ex}{1ex} |
| 1808 |
|
| 1809 |
With this keys you can shift the mover horizontaly. If you want to |
| 1810 |
put it on the left side of the board, use a large negative value. |
| 1811 |
|
| 1812 |
\begin{LTXexample}[width=0.55\textwidth] |
| 1813 |
\setchessboard{showmover}% |
| 1814 |
\chessboard[setfen=k1K b, |
| 1815 |
movershift=-9em, |
| 1816 |
labelleft=false, |
| 1817 |
labelright]% |
| 1818 |
\end{LTXexample} |
| 1819 |
|
| 1820 |
\Describesetkey{moverstyle}{typename}{squarearrow}{square} |
| 1821 |
|
| 1822 |
With this key you can change the mover type. Up to now four types |
| 1823 |
are defined, but you can define your own one if you want. |
| 1824 |
|
| 1825 |
|
| 1826 |
|
| 1827 |
\begin{LTXexample}[width=0.55\textwidth] |
| 1828 |
\setchessboard{showmover}% |
| 1829 |
\chessboard[tinyboard, setfen=k1K b, |
| 1830 |
moverstyle=circle]% |
| 1831 |
\chessboard[tinyboard, setfen=k1K w, |
| 1832 |
moverstyle=triangle] |
| 1833 |
|
| 1834 |
%This moverstyle needs pifont and graphics! |
| 1835 |
\chessboard[tinyboard, setfen=k1K b, |
| 1836 |
moverstyle=squarearrow]% |
| 1837 |
%This will give a warning and square is used: |
| 1838 |
\chessboard[tinyboard, setfen=k1K w, |
| 1839 |
moverstyle=unknown] |
| 1840 |
\end{LTXexample} |
| 1841 |
|
| 1842 |
|
| 1843 |
\DescribeMacro{\cbDefineMoverStyle} With this command you can define |
| 1844 |
your own moverstyle. \cs{cbDefineMoverStyle} takes six arguments (the |
| 1845 |
first is optional). The first mandatory argument is the name of the |
| 1846 |
style, the following arguments get the definitions for the mover for |
| 1847 |
black and white for normal and inverse board. |
| 1848 |
|
| 1849 |
\cs{cbDefineMoverStyle}\oarg{commands}\marg{name of style}\marg{white |
| 1850 |
top}\newline% |
| 1851 |
\hspace*{4em}\marg{white bottom}\marg{black top}\marg{black bottom}. |
| 1852 |
|
| 1853 |
The listing shows the definition of the mover «squarearrow»: |
| 1854 |
|
| 1855 |
|
| 1856 |
|
| 1857 |
\begin{lstlisting} |
| 1858 |
\cbDefineMoverStyle% |
| 1859 |
%#1: optional, can be used e.g. for checks |
| 1860 |
%#2=style name, #3=white top, #4=white bottom, |
| 1861 |
%#5=black top, #6=black bottom |
| 1862 |
[\@ifundefined{rotatebox}% |
| 1863 |
{\PackageError{chessboard}% |
| 1864 |
{You must load the package graphics or graphicx |
| 1865 |
if you want to use the mover style squarearrow}{}}% |
| 1866 |
{}% |
| 1867 |
\@ifundefined{ding}% |
| 1868 |
{\PackageError{chessboard}% |
| 1869 |
{You must load the package pifont |
| 1870 |
if you want to use the mover style squarearrow}{}}% |
| 1871 |
{}] |
| 1872 |
{squarearrow}% #2 |
| 1873 |
{\rotatebox{-90}{$\square$\,\ding{222}}}% |
| 1874 |
{\rotatebox{90}{$\square$\,\ding{222}}}% |
| 1875 |
{\rotatebox{-90}{$\blacksquare$\,\ding{222}}}% |
| 1876 |
{\rotatebox{90}{$\blacksquare$\,\ding{222}}}% |
| 1877 |
\end{lstlisting} |
| 1878 |
|
| 1879 |
|
| 1880 |
|
| 1881 |
|
| 1882 |
\section{Controlling the printing}\label{stopmain} |
| 1883 |
\subsection{Printing partial boards} |
| 1884 |
\Describesetkey{print}{true|false}{false}{true} |
| 1885 |
|
| 1886 |
With this key you can disable the printing of the board. This is |
| 1887 |
useful if you want to use \cs{chessboard} to save FEN. |
| 1888 |
|
| 1889 |
|
| 1890 |
|
| 1891 |
\begin{LTXexample} |
| 1892 |
left\chessboard[print=false]right |
| 1893 |
\end{LTXexample} |
| 1894 |
|
| 1895 |
|
| 1896 |
\Describefillkey{startprint}{field}{b7} |
| 1897 |
\Describefillkey{stopprint}{field}{f2} |
| 1898 |
\Describefillkey{printarea}{area}{c2-d4} |
| 1899 |
|
| 1900 |
|
| 1901 |
With this keys you can define the area that gets printed. |
| 1902 |
|
| 1903 |
\begin{LTXexample} |
| 1904 |
\newchessgame |
| 1905 |
left\chessboard[printarea=a4-d8]right |
| 1906 |
\end{LTXexample} |
| 1907 |
|
| 1908 |
|
| 1909 |
\subsection{Rotating the board} |
| 1910 |
\Describesetkey{inverse}{true|false}{false}{false} |
| 1911 |
|
| 1912 |
With this key you can print the black side at the bottom. It won't |
| 1913 |
switch labels or margins etc. |
| 1914 |
|
| 1915 |
\begin{LTXexample} |
| 1916 |
\newchessgame |
| 1917 |
left\chessboard[inverse]right |
| 1918 |
\end{LTXexample} |
| 1919 |
|
| 1920 |
|
| 1921 |
\subsection{Hiding the content of the board} |
| 1922 |
|
| 1923 |
\subsubsection{Hiding the content of fields} |
| 1924 |
|
| 1925 |
\Describefillkey{hideboard}{arbitrary}{} |
| 1926 |
\Describefillkey{hidearea}{area}{a1-c3} |
| 1927 |
\Describefillkey{hideareas}{list of areas}{\{a1-c3,g7-h8\}} |
| 1928 |
\Describefillkey{hidefile}{file}{g} |
| 1929 |
\Describefillkey{hidefiles}{list of files}{\{g,h\}}\goodbreak |
| 1930 |
\Describefillkey{hiderank}{rank}{5} |
| 1931 |
\Describefillkey{hideranks}{list of ranks}{\{8,7\}} |
| 1932 |
\Describefillkey{hidefield}{field}{c6} |
| 1933 |
\Describefillkey{hidefields}{list of fields}{\{b5,c6\}} |
| 1934 |
|
| 1935 |
|
| 1936 |
With this keys you can hide pieces on certain fields. The pieces are |
| 1937 |
not deleted, e.g.\ when you save the position to FEN they will be |
| 1938 |
there. But the content of hidden fields don't appear if you add |
| 1939 |
pieces to this fields! |
| 1940 |
|
| 1941 |
\begin{LTXexample}[width=0.55\textwidth] |
| 1942 |
\newchessgame |
| 1943 |
\def\myfiles{a,b} |
| 1944 |
\setchessboard{tinyboard} |
| 1945 |
\chessboard[hidefiles=\myfiles, |
| 1946 |
addpieces=Ra2, |
| 1947 |
hidearea=d7-e8, |
| 1948 |
storefen=myfen] |
| 1949 |
\chessboard[restorefen=myfen] |
| 1950 |
\end{LTXexample} |
| 1951 |
|
| 1952 |
\subsubsection{Hiding piecetypes} |
| 1953 |
|
| 1954 |
\Describefillkey{hidepiece}{piece char}{q} |
| 1955 |
\Describefillkey{hidepieces}{list of piece chars}{\{K, b\}} |
| 1956 |
\Describefillkey{hidewhite}{arbitrary}{} |
| 1957 |
\Describefillkey{hideblack}{arbitrary}{} |
| 1958 |
\Describefillkey{hideall}{arbitrary}{} |
| 1959 |
|
| 1960 |
|
| 1961 |
This keys doesn't hide the content of fields but piecestypes like |
| 1962 |
the kings or the pawns. Here too: you can't add pieces if their type |
| 1963 |
is hidden. |
| 1964 |
|
| 1965 |
|
| 1966 |
\begin{LTXexample}[width=0.55\textwidth] |
| 1967 |
\newchessgame |
| 1968 |
\def\mypieces{R,Q} |
| 1969 |
\setchessboard{tinyboard} |
| 1970 |
\chessboard[hidepieces=\mypieces, |
| 1971 |
addpieces={Ra2, ra7}, |
| 1972 |
hideblack, |
| 1973 |
storefen=myfen]% |
| 1974 |
\chessboard[restorefen=myfen] |
| 1975 |
\end{LTXexample} |
| 1976 |
|
| 1977 |
\subsubsection{Showing the content of fields} |
| 1978 |
|
| 1979 |
\Describefillkey{showboard}{arbitrary}{} |
| 1980 |
\Describefillkey{showarea}{area}{a1-c3}\goodbreak |
| 1981 |
\Describefillkey{showareas}{list of areas}{\{a1-c3,g7-h8\}} |
| 1982 |
\Describefillkey{showfile}{file}{g} |
| 1983 |
\Describefillkey{showfiles}{list of files}{\{g,h\}}\goodbreak |
| 1984 |
\Describefillkey{showrank}{rank}{5} |
| 1985 |
\Describefillkey{showranks}{list of ranks}{\{8,7\}} |
| 1986 |
\Describefillkey{showfield}{field}{c6} |
| 1987 |
\Describefillkey{showfields}{list of fields}{\{b5,c6\}} |
| 1988 |
|
| 1989 |
With this keys you can let reappear the content of hidden fields. |
| 1990 |
|
| 1991 |
\begin{LTXexample} |
| 1992 |
\newchessgame |
| 1993 |
\def\myfiles{a,b} |
| 1994 |
\chessboard[hidefiles=\myfiles, |
| 1995 |
addpieces=Ra2, |
| 1996 |
showfiles=a, |
| 1997 |
showranks=2] |
| 1998 |
\end{LTXexample} |
| 1999 |
|
| 2000 |
\subsubsection{Showing piecetypes} |
| 2001 |
|
| 2002 |
\Describefillkey{showpiece}{piece char}{q} |
| 2003 |
\Describefillkey{showpieces}{list of piece chars}{\{K, b\}} |
| 2004 |
\Describefillkey{showwhite}{arbitrary}{} |
| 2005 |
\Describefillkey{showblack}{arbitrary}{} |
| 2006 |
\Describefillkey{showall}{arbitrary}{} |
| 2007 |
And this keys lets reappear hidden piecestypes. Attention: hidden |
| 2008 |
pieces on hidden fields reappear only if you use the key to show the |
| 2009 |
field |
| 2010 |
\emph{and} the key to show the piece! |
| 2011 |
|
| 2012 |
\begin{LTXexample} |
| 2013 |
\newchessgame |
| 2014 |
\def\myfiles{a,e} |
| 2015 |
\chessboard[hidefiles=\myfiles, |
| 2016 |
hidepieces={K,R}, |
| 2017 |
showfiles=a, |
| 2018 |
showranks=1, |
| 2019 |
showpieces=K] |
| 2020 |
\end{LTXexample} |
| 2021 |
|
| 2022 |
|
| 2023 |
Keys like \key{showonlypawns} or \key{showonlybut} could be easily |
| 2024 |
added as they are simple combinations of the existing keys: |
| 2025 |
|
| 2026 |
\begin{LTXexample} |
| 2027 |
\newchessgame |
| 2028 |
\chessboard[hideall, |
| 2029 |
showpieces={P,p}, |
| 2030 |
addpieces=pe5] |
| 2031 |
\end{LTXexample} |
| 2032 |
|
| 2033 |
|
| 2034 |
|
| 2035 |
|
| 2036 |
\section{«Decoration»: Colors, background, fancy borders, highlighting}\label{startpgf} |
| 2037 |
|
| 2038 |
|
| 2039 |
%\section{Coloring and emphasizing the board chars} |
| 2040 |
|
| 2041 |
Coloring and decorating the board is a bit complicated as there is |
| 2042 |
so much that can get different colors and so much different |
| 2043 |
possibilities for marks, arrows, fancy borders and so on. So it can |
| 2044 |
take some time to find out how to achieve a certain effect. |
| 2045 |
|
| 2046 |
Don't forget that not every effect is sensible or even works |
| 2047 |
everywhere. Transparency/opacity e.g.\ don't work for every driver or |
| 2048 |
output format or printer or previewer (the documentation of pgf says |
| 2049 |
that it works for dvips only with new ghostscript versions). Some |
| 2050 |
colors looks good on screen but bad if printed with a greyscale |
| 2051 |
printer. Colors can change if you use another monitor. Some color |
| 2052 |
combinations are a problem for color blinds. |
| 2053 |
|
| 2054 |
\Skaksty has some own highlighting commands. They use |
| 2055 |
postscript/pstricks commands and they only work if you load |
| 2056 |
\skaksty with the option \textsf{ps}. That means that you have to use the |
| 2057 |
\filetype{.tex}$\rightarrow$\filetype{.dvi}$\rightarrow$\filetype{.ps}$\rightarrow$\filetype{.pdf}-way |
| 2058 |
to process the document. If you want to use pdf\LaTeX\ directly you |
| 2059 |
have to use a package like \packagename{pst-pdf} to first make pdf |
| 2060 |
graphics from all boards and then include this graphics during the |
| 2061 |
pdf\LaTeX-run. I find this quite cumbersome and sometimes it is even |
| 2062 |
difficult to get it to work. |
| 2063 |
|
| 2064 |
So I decided to use \packagename{pgf} to implement my own |
| 2065 |
highlighting commands. But I also tried to offer a possibility to use |
| 2066 |
the commands of \skaksty. |
| 2067 |
|
| 2068 |
The package only loads the package \packagename{tikz}. If you want to use |
| 2069 |
additional libraries you have to load them yourself. |
| 2070 |
|
| 2071 |
\Describesetkey{pgf}{true|false}{}{true} |
| 2072 |
|
| 2073 |
ti\textit{k}z-commands works fine with \LaTeX\ and pdf\LaTeX\ but in some case |
| 2074 |
(e.g.\ if you use \cs{chessboard} in an environment that calls the |
| 2075 |
environment \texttt{preview}) they can induce errors. So I added a |
| 2076 |
key to disable all the ti\textit{k}z-commands. It is also useful to disable |
| 2077 |
most of the highlighting. |
| 2078 |
|
| 2079 |
|
| 2080 |
|
| 2081 |
|
| 2082 |
|
| 2083 |
\subsection{The ti\textit{k}z-pictures} |
| 2084 |
The decorations in the two other layers (background layer and mark |
| 2085 |
layer) use pgf/ti\textit{k}z-commands -- or to be more precise: the two other |
| 2086 |
layers are ti\textit{k}z-pictures. |
| 2087 |
|
| 2088 |
In the first version of \pchessboard the pictures where pgf-pictures and not |
| 2089 |
ti\textit{k}z-pictures. Also the background picture wasn't |
| 2090 |
used much: I had only implemented some code to color the fields. But |
| 2091 |
then I got the request to add some more commands for fancy borders |
| 2092 |
which did mean that I had to transfer the code which draws borders in |
| 2093 |
the foreground picture to the background picture. And I got a request |
| 2094 |
for coloring fields in the foreground picture which did mean that I |
| 2095 |
had to transfer the code from the background to the foreground. |
| 2096 |
|
| 2097 |
So I decided to rewrite and extend the codes so that each |
| 2098 |
highlighting/drawing in the pgf-pictures can be done in either the |
| 2099 |
background or the foreground or in both. I don't know if someone will |
| 2100 |
ever have a need for a cross under the figures, but why shouldn't I |
| 2101 |
offer some code to do it? |
| 2102 |
|
| 2103 |
I also tried to unify the keys that affect the pgf-pictures, to |
| 2104 |
improve the possibilities for the user to control which pgf-picture |
| 2105 |
is affected and put a bit more order in the keys. At the end quite a |
| 2106 |
lot of the code has been rearranged and changed. |
| 2107 |
|
| 2108 |
Finally a number of questions came up how to adapt the styles and I realized that restricting the picture to the basic layer pgf-commands makes it harder than necessary and that today the additional compilation time and memory use for full ti\textit{k}z support no long matters. So this was changed too. |
| 2109 |
|
| 2110 |
|
| 2111 |
\subsubsection{Naming of the pgf related keys} |
| 2112 |
|
| 2113 |
There are more or less three set of keys |
| 2114 |
|
| 2115 |
\begin{itemize} |
| 2116 |
\item Keys which affect only the foreground picture. The keys starts with or contains the |
| 2117 |
string «\bfseries\ttfamily mark». |
| 2118 |
\item Keys which affect only the background picture. The keys starts with or contains the |
| 2119 |
string «\bfseries\ttfamily back». |
| 2120 |
|
| 2121 |
\item |
| 2122 |
Keys that saves or set properties that are used in both picture, |
| 2123 |
e.g.\ to change the color or the linewidth. Such keys start or |
| 2124 |
contain in most cases the string «\bfseries\ttfamily pgf» (with some |
| 2125 |
exceptions like the key for clipping and trimming). For a lot of such |
| 2126 |
keys there exist a shorter (but less descriptive) name without the |
| 2127 |
«\ttfamily pgf». In most cases there isn't a difference between the |
| 2128 |
two. |
| 2129 |
|
| 2130 |
\end{itemize} |
| 2131 |
%Using two pictures raises the question how properties that make sense |
| 2132 |
%for both pictures should be implemented and how commands that should |
| 2133 |
%affect only one picture should be distinguish from a similar command |
| 2134 |
%that affect the other picture. E.g.\ there are a lot of keys that |
| 2135 |
%sets properties that are or can be of interest in both pictures like |
| 2136 |
%setting the color or some variables like linewidth or some padding. |
| 2137 |
%I stood for the choice if I should define two keys e.g. |
| 2138 |
%\key{colorback} and \key{colormark} or one key \key{color} that puts |
| 2139 |
%the color in both pictures. The first alternative is longer and more |
| 2140 |
%tiresome, the second can give confusing results if the user don't |
| 2141 |
%realize that a key can also affect the other picture. |
| 2142 |
% |
| 2143 |
%I used both alternatives depending on which I thought more natural in |
| 2144 |
%the special cases. |
| 2145 |
|
| 2146 |
|
| 2147 |
|
| 2148 |
|
| 2149 |
\subsubsection{Executing the drawing commands} |
| 2150 |
|
| 2151 |
A chessboard consists of fields on which figures make moves and so |
| 2152 |
the decoration of the board is field and move orientated. |
| 2153 |
|
| 2154 |
There are three different types of graphical object: |
| 2155 |
\begin{itemize} |
| 2156 |
\item You can draw something on a set of |
| 2157 |
single \emph{fields} e.g., put a cross on each of the fields or put a |
| 2158 |
border around each field. To get these pictures on or under the field |
| 2159 |
the inner commands first shift the origin to the middle of field and |
| 2160 |
then inserts the code stored in the style definition in the |
| 2161 |
foreground or background image. |
| 2162 |
|
| 2163 |
|
| 2164 |
\item |
| 2165 |
You can draw something on or around a \emph{region} -- a rectangle |
| 2166 |
made of fields --, e.g.\ by putting a border around the center or a |
| 2167 |
rank or the whole board. Here the inner commands shift the origin to |
| 2168 |
the left upper corner of the region. The name of the other corner is |
| 2169 |
available in the style definition through |
| 2170 |
\lstinline+#1+. |
| 2171 |
|
| 2172 |
|
| 2173 |
\item And you can mark a \emph{move}. |
| 2174 |
The main difference between a move and a region is that the order of the «corners» given in the argument matters. |
| 2175 |
For moves the origin is in the first corner (the from field). |
| 2176 |
\end{itemize} |
| 2177 |
|
| 2178 |
The drawing is done by first setting with various key the style and |
| 2179 |
the properties of the pgf object and then executed by telling |
| 2180 |
\cs{chessboard} which fields, moves or regions should get the |
| 2181 |
drawings. |
| 2182 |
|
| 2183 |
\subsubsection{Drawing on and under fields}\label{sec:drawfields} |
| 2184 |
|
| 2185 |
\Describefillkey{markboard}{arbitrary}{} |
| 2186 |
\Describefillkey{markarea}{area}{a1-c3} |
| 2187 |
\Describefillkey{markareas}{list of areas}{\{a1-c3,d5-e5\}} |
| 2188 |
\Describefillkey{markfiles}{file}{g} |
| 2189 |
\Describefillkey{markfiles}{list of files}{\{g,h\}} |
| 2190 |
\Describefillkey{markrank}{rank}{7} |
| 2191 |
\Describefillkey{markranks}{list of ranks}{\{8,7\}} |
| 2192 |
\Describefillkey{markfield}{field}{c6} |
| 2193 |
\Describefillkey{markfields}{list of fields}{\{b5,c6\}} |
| 2194 |
\Describefillkey{backboard}{arbitrary}{} |
| 2195 |
\Describefillkey{backarea}{area}{a1-c3} |
| 2196 |
\Describefillkey{backareas}{list of areas}{\{a1-c3,d5-e5\}} |
| 2197 |
\Describefillkey{backfiles}{file}{g} |
| 2198 |
\Describefillkey{backfiles}{list of files}{\{g,h\}} |
| 2199 |
\Describefillkey{backrank}{rank}{7} |
| 2200 |
\Describefillkey{backranks}{list of ranks}{\{8,7\}} |
| 2201 |
\Describefillkey{backfield}{field}{c6} |
| 2202 |
\Describefillkey{backfields}{list of fields}{\{b5,c6\}} |
| 2203 |
|
| 2204 |
|
| 2205 |
This keys executes the pgf-commands stored in the style command for |
| 2206 |
each single field. |
| 2207 |
|
| 2208 |
In the following example you should look at the difference it makes |
| 2209 |
if you put a cross or a border in the background or the foreground. |
| 2210 |
|
| 2211 |
\begin{LTXexample} |
| 2212 |
\newchessgame |
| 2213 |
\def\myarea{a1-b8} |
| 2214 |
\chessboard[pgfstyle=cross, |
| 2215 |
color=blue, |
| 2216 |
markfile=h, |
| 2217 |
backarea=\myarea, |
| 2218 |
color=red, |
| 2219 |
padding=-0.2em, |
| 2220 |
pgfstyle=circle, |
| 2221 |
markfields=g1,backfields=g8, |
| 2222 |
linewidth=0.1em, |
| 2223 |
pgfstyle=border, |
| 2224 |
markranks=6, backrank=4] |
| 2225 |
\end{LTXexample} |
| 2226 |
|
| 2227 |
The new key \key{getpiecelists} can be used to mark e.g. all pawns on |
| 2228 |
a board: |
| 2229 |
|
| 2230 |
\begin{LTXexample} |
| 2231 |
\newchessgame |
| 2232 |
\mainline{1. e4 e6 2.d4 d5} |
| 2233 |
|
| 2234 |
\chessboard[pgfstyle=cross, |
| 2235 |
color=blue, |
| 2236 |
getpiecelists, |
| 2237 |
markfields={\cblistP,\cblistp}] |
| 2238 |
\end{LTXexample} |
| 2239 |
|
| 2240 |
|
| 2241 |
|
| 2242 |
\subsubsection{Drawing on regions} |
| 2243 |
|
| 2244 |
\Describefillkey{markregions}{list of regions}{\{a1-c3, b7-c6\}} |
| 2245 |
\Describefillkey{markregion}{list of regions}{\{a1-c3, b7-c6\}} |
| 2246 |
\Describefillkey{backregions}{list of regions}{\{a1-c3, b7-c6\}} |
| 2247 |
\Describefillkey{backregion}{list of regions}{\{a1-c3, b7-c6\}} |
| 2248 |
|
| 2249 |
|
| 2250 |
\begin{LTXexample} |
| 2251 |
\newchessgame |
| 2252 |
\def\pawnranks{a2-h2, h7-a7} |
| 2253 |
\chessboard[inverse, |
| 2254 |
pgfstyle=border, |
| 2255 |
markregions=\pawnranks, |
| 2256 |
color=red, padding=0.3ex, |
| 2257 |
linewidth=0.1ex, |
| 2258 |
backregions={\board,d4-e5}, |
| 2259 |
pgfstyle=text, |
| 2260 |
text=$\leftarrow$% |
| 2261 |
\currentbk-\currentwq |
| 2262 |
$\rightarrow$, |
| 2263 |
markregion=a3-h3, |
| 2264 |
pgfstyle={[rotate=45]text}, |
| 2265 |
backregion=h8-a1] |
| 2266 |
\end{LTXexample} |
| 2267 |
|
| 2268 |
|
| 2269 |
\subsubsection{Drawing move related} |
| 2270 |
|
| 2271 |
\Describefillkey{markmoves}{list of moves}{\{a1-c3, b7-c6\}} |
| 2272 |
\Describefillkey{markmove}{list of moves}{\{a1-c3, b7-c6\}} |
| 2273 |
\Describefillkey{backmoves}{list of moves}{\{a1-c3, b7-c6\}} |
| 2274 |
\Describefillkey{backmove}{list of moves}{\{a1-c3, b7-c6\}} |
| 2275 |
|
| 2276 |
|
| 2277 |
\begin{LTXexample} |
| 2278 |
\def\mymove{d1-d5}% |
| 2279 |
\chessboard[pgfstyle=straightmove, |
| 2280 |
markmoves={a1-a3, c3-e5, g1-f3}, |
| 2281 |
pgfstyle=knightmove, |
| 2282 |
backmoves={g8-f6, h1-f4}, |
| 2283 |
arrow=to, linewidth=0.2em, |
| 2284 |
markmove= \mymove] |
| 2285 |
\end{LTXexample} |
| 2286 |
|
| 2287 |
I'm not very good in designing beautiful curves and moves arrows. If |
| 2288 |
someone could offer me better code I will be happy to implement it. |
| 2289 |
|
| 2290 |
|
| 2291 |
|
| 2292 |
|
| 2293 |
|
| 2294 |
|
| 2295 |
|
| 2296 |
\subsubsection{Choosing what is drawn: pgf styles} |
| 2297 |
|
| 2298 |
|
| 2299 |
|
| 2300 |
%\subsubsection{Mark styles} |
| 2301 |
\Describefillkey{markstyle}{[options]style name}{cross} |
| 2302 |
\Describefillkey{backstyle}{[options]style name}{cross} |
| 2303 |
\Describefillkey{pgfstyle}{[options]style name}{[left]text} |
| 2304 |
|
| 2305 |
|
| 2306 |
With this keys you set the style the drawing commands will use. |
| 2307 |
\key{markstyle} sets only the style for the foreground (the «mark» |
| 2308 |
picture). \key{backstyle} sets only the style for the background |
| 2309 |
picture. \key{pgfstyle} sets the style for both pictures (\key{style} |
| 2310 |
is not a shorter version of \key{pgfstyle}!). |
| 2311 |
|
| 2312 |
If the value starts with \verb+[+ the text until \verb+]+ is |
| 2313 |
interpreted as an option of the style. It depends on the definition |
| 2314 |
of the style if and how this option is used (until now the text |
| 2315 |
style, the circle style and (since version 1.5) the curvemove style |
| 2316 |
use such options). \textbf{Attention}: to prevent \cs{chessboard} to |
| 2317 |
interpret the \verb+]+ as the end of its optional argument you must |
| 2318 |
put braces around the whole value if you want to use options. |
| 2319 |
|
| 2320 |
Not every style is useful for everything, e.g.\ it doesn't make sense |
| 2321 |
to put a border around a move. The following tabular shows the |
| 2322 |
predefined styles and the types for which they work. |
| 2323 |
|
| 2324 |
\begin{tabular}{lccc} |
| 2325 |
& fields & regions & moves \\ |
| 2326 |
cross & \ding{52} & & \\ |
| 2327 |
circle& \ding{52} \\ |
| 2328 |
text & \ding{52} & \ding{52} \\ |
| 2329 |
border(s)& \ding{52} & \ding{52} \\ |
| 2330 |
color &\ding{52} &\ding{52}\\ |
| 2331 |
straightmove & & & \ding{52}\\ |
| 2332 |
knightmove & & & \ding{52}\\ |
| 2333 |
curvemove & & & \ding{52}\\ |
| 2334 |
\end{tabular} |
| 2335 |
|
| 2336 |
|
| 2337 |
|
| 2338 |
\DescribeMacro{\cbDefinePgfFieldStyle} |
| 2339 |
\DescribeMacro{\cbDefinePgfRegionStyle} |
| 2340 |
\DescribeMacro{\cbDefinePgfMoveStyle} |
| 2341 |
With these commands you can define your own styles. The commands take |
| 2342 |
two argument: the first is the name of the style, the second should |
| 2343 |
be the pgf-commands or ti\textit{k}z-commands needed to draw. |
| 2344 |
|
| 2345 |
|
| 2346 |
The next listing shows two style definition using basic pgf-commands. |
| 2347 |
At first an example for a field mark, then an example |
| 2348 |
for a region where the second corner is accessed through the |
| 2349 |
\lstinline+#1+, |
| 2350 |
and at last the definition for the text mark -- here it is necessary |
| 2351 |
to rotate the text if the key \key{inverse} is true and the |
| 2352 |
definition shows how the optional argument of the \key{pgfstyle} key |
| 2353 |
can be use with \verb+#2+: |
| 2354 |
|
| 2355 |
\begin{lstlisting} |
| 2356 |
\cbDefinePgfFieldStyle{circle}{% |
| 2357 |
\pgfsetlinewidth{\board@pgf@linewidth}% |
| 2358 |
\setlength\len@board@tempx{% |
| 2359 |
\dimexpr 0.55em + \board@pgf@padding \relax}% |
| 2360 |
\pgfpathcircle{\pgfpointxy{0}{0}}{\len@board@tempx}% |
| 2361 |
\pgfusepath{stroke,#2}}%% |
| 2362 |
|
| 2363 |
\cbDefinePgfRegionStyle{border}{% |
| 2364 |
\pgfsetlinewidth{\board@pgf@linewidth}% |
| 2365 |
\pgfsetcornersarced{\pgfpoint{\board@pgf@corner}{\board@pgf@corner}} |
| 2366 |
\pgfpathrectanglecorners% |
| 2367 |
{\pgfpointadd% |
| 2368 |
{\pgfpoint{-\board@pgf@padding}{\board@pgf@padding}} |
| 2369 |
{\pgfpointxy{-0.5}{0.5}}}% |
| 2370 |
{\pgfpointadd% |
| 2371 |
{\pgfpointanchor{#1}{center}} |
| 2372 |
{\pgfpointadd% |
| 2373 |
{\pgfpoint{\board@pgf@padding}{-\board@pgf@padding}} |
| 2374 |
{\pgfpointxy{0.5}{-0.5}}}}% |
| 2375 |
\pgfusepath{stroke}}% |
| 2376 |
|
| 2377 |
\cbDefinePgfFieldStyle{text}{% |
| 2378 |
\ifthenelse% |
| 2379 |
{\boolean{\XKV@UFCB@locset@inverse@value}}% |
| 2380 |
{\pgftext[rotate=180,#2]{\normalfont\board@pgf@curtext}}% |
| 2381 |
{\pgftext[#2]{\normalfont\board@pgf@curtext}}}% |
| 2382 |
\end{lstlisting} |
| 2383 |
|
| 2384 |
A definition could also use ti\textit{k}z-commands |
| 2385 |
\begin{lstlisting} |
| 2386 |
\cbDefinePgfMoveStyle{moveto}{\draw[->,#2](0,0)--(#1);} |
| 2387 |
\end{lstlisting} |
| 2388 |
and then be used like this |
| 2389 |
|
| 2390 |
\cbDefinePgfMoveStyle{moveto}{\draw[->,#2](0,0)--(#1);} |
| 2391 |
\begin{LTXexample} |
| 2392 |
\newchessgame |
| 2393 |
\chessboard[ |
| 2394 |
pgfstyle={[red, very thick,dashed]moveto}, |
| 2395 |
markmove=e2-e4, |
| 2396 |
] |
| 2397 |
\end{LTXexample} |
| 2398 |
|
| 2399 |
\subsubsection{Introduction to the predefined pgf styles} |
| 2400 |
|
| 2401 |
%\subsubsection{Graphic properties} |
| 2402 |
% |
| 2403 |
%Some of the graphic properties can be changed with predefined keys: |
| 2404 |
%You already know about the keys \key{color} and \key{opacity}. |
| 2405 |
|
| 2406 |
%\medskip |
| 2407 |
%\Describefillkey{linewidth}{length}{1ex} |
| 2408 |
%\Describefillkey{marklinewidth}{length}{1ex} |
| 2409 |
%With this keys you can change an internal command that is used to set |
| 2410 |
%the linewidth. The first will affect also the linewidth in the |
| 2411 |
%background layer, will the second affect only the mark layer. |
| 2412 |
|
| 2413 |
\minisec{Borders} |
| 2414 |
|
| 2415 |
\index{border (style)}% |
| 2416 |
\index{border (style)>leftborder}% |
| 2417 |
\index{border (style)>rightborder}% |
| 2418 |
\index{border (style)>topborder}% |
| 2419 |
\index{border (style)>bottomborder}% |
| 2420 |
\index{border (style)>lefttopborder}% |
| 2421 |
\index{border (style)>lefttoprightborder}% |
| 2422 |
\index{border (style)>toprightborder}% |
| 2423 |
\index{border (style)>toprightbottomborder}% |
| 2424 |
\index{border (style)>rightbottomborder}% |
| 2425 |
\index{border (style)>rightbottomleftborder}% |
| 2426 |
\index{border (style)>bottomleftborder}% |
| 2427 |
\index{border (style)>bottomlefttopborder}% |
| 2428 |
Borders can be put around fields and regions. There exist also |
| 2429 |
partial borders for one, two or three margins of an area, this |
| 2430 |
borders are drawn and named «clockwise». «left», «right», «top», and |
| 2431 |
«bottom» refer to the position of the border if the white player is |
| 2432 |
at the bottom. If you use the key |
| 2433 |
\key{inverse} the positions of the lines don't change in relation to |
| 2434 |
the players colors. |
| 2435 |
|
| 2436 |
\begin{LTXexample} |
| 2437 |
\newchessgame |
| 2438 |
\setchessboard{smallboard, |
| 2439 |
pgfstyle=rightbottomborder, |
| 2440 |
color=orange, |
| 2441 |
markrank=7, |
| 2442 |
pgfstyle=lefttoprightborder, |
| 2443 |
markregion=a1-b3, |
| 2444 |
shortenstart=-1ex, |
| 2445 |
padding=1ex, |
| 2446 |
linewidth=0.3em, |
| 2447 |
pgfstyle=leftborder,color=red, |
| 2448 |
markregion=\mycenter, |
| 2449 |
pgfstyle=topborder,color=blue, |
| 2450 |
markregion=\mycenter, |
| 2451 |
pgfstyle=rightborder,color=green, |
| 2452 |
markregion=\mycenter, |
| 2453 |
pgfstyle=bottomborder,color=yellow, |
| 2454 |
markregion=\mycenter} |
| 2455 |
\def\mycenter{d4-e5} |
| 2456 |
\chessboard\ |
| 2457 |
\chessboard[inverse] |
| 2458 |
\end{LTXexample} |
| 2459 |
|
| 2460 |
\minisec{Circle} |
| 2461 |
|
| 2462 |
\index{circle (style)}% |
| 2463 |
\index{circle (style)>fill (option)}% |
| 2464 |
This style can only be used in connection with fields. The optional |
| 2465 |
argument can be used to fill the circle (default is stroke). |
| 2466 |
|
| 2467 |
\begin{LTXexample} |
| 2468 |
\newchessgame |
| 2469 |
\def\mycenter{d4-e5} |
| 2470 |
\chessboard[pgfstyle=circle, |
| 2471 |
color=red, |
| 2472 |
markrank=7, |
| 2473 |
linewidth=0.2em, |
| 2474 |
markrank=6, |
| 2475 |
pgfstyle={[fill]circle}, |
| 2476 |
markarea=\mycenter, |
| 2477 |
padding=-0.8ex,color=blue, |
| 2478 |
backfile=b] |
| 2479 |
\end{LTXexample} |
| 2480 |
|
| 2481 |
|
| 2482 |
\minisec{Cross} |
| 2483 |
|
| 2484 |
\index{cross (style)}% |
| 2485 |
This style can only be used in connection with fields. |
| 2486 |
|
| 2487 |
\begin{LTXexample} |
| 2488 |
\newchessgame |
| 2489 |
\def\mycenter{d4-e5} |
| 2490 |
\chessboard[pgfstyle=cross, |
| 2491 |
color=red, |
| 2492 |
markrank=7, |
| 2493 |
linewidth=0.2em, |
| 2494 |
markrank=6, |
| 2495 |
shortenstart=0.5ex, |
| 2496 |
markarea=\mycenter, |
| 2497 |
shortenend=0.5ex,color=blue, |
| 2498 |
backfile=b] |
| 2499 |
\end{LTXexample} |
| 2500 |
|
| 2501 |
\minisec{Text} |
| 2502 |
|
| 2503 |
\index{text (style)}% |
| 2504 |
\index{text (style)>options}% |
| 2505 |
Text can be used for fields and regions. It is the only style where |
| 2506 |
it isn't enough to simply chose the style, you must also give a value |
| 2507 |
to the text content with the key \key{text} (don't confuse the key |
| 2508 |
«text» with the style «text»!). |
| 2509 |
|
| 2510 |
The option of the style is passed to the optional argument of the |
| 2511 |
\cs{pgftext} command, so everything that is allowed there can be put |
| 2512 |
in the option. In the definition of the text content you can use |
| 2513 |
informations about the current field or the current region. |
| 2514 |
\cs{currentbk}\index{currentbk=\textbackslash currentbk} e.g. gives |
| 2515 |
the \textit{b}lack \textit{k}ing corner of the region (when you draw |
| 2516 |
in a region) or the field name (when you draw in a field). The |
| 2517 |
opposite corner ist |
| 2518 |
\cs{currentwq}\index{currentwq=\textbackslash currentwq},% |
| 2519 |
\index{currentbq=\textbackslash currentbq} |
| 2520 |
\index{currentwk =\textbackslash currentwk} |
| 2521 |
the |
| 2522 |
\textit{w}hite \textit{q}ueen corner. |
| 2523 |
|
| 2524 |
As a default the text is centered on the middle of the field or the |
| 2525 |
region. You can use the options to move it around, please look in the |
| 2526 |
documentation of pgf to find out what is possible. |
| 2527 |
|
| 2528 |
\begin{LTXexample} |
| 2529 |
\newchessgame |
| 2530 |
\setchessboard{tinyboard,color=magenta,clearboard} |
| 2531 |
\chessboard[ |
| 2532 |
pgfstyle= |
| 2533 |
{[base,at={\pgfpoint{0pt}{-0.4ex}}]text}, |
| 2534 |
text= \fontsize{1.2ex}{1.2ex}\bfseries |
| 2535 |
\sffamily\currentwq, |
| 2536 |
markboard] |
| 2537 |
|
| 2538 |
\chessboard[ |
| 2539 |
inverse, |
| 2540 |
pgfstyle= |
| 2541 |
{[base,at={\pgfpoint{0pt}{-0.4ex}}]text}, |
| 2542 |
text=\fontsize{1.2ex}{1.2ex}\bfseries |
| 2543 |
\sffamily\currentwq, |
| 2544 |
trimtocolor=black, markboard, |
| 2545 |
trimtocolor=white,color=green, |
| 2546 |
markboard]% |
| 2547 |
|
| 2548 |
\chessboard[pgfstyle={[rotate=90]text}, |
| 2549 |
text= |
| 2550 |
\fontsize{1.2ex}{1.2ex} |
| 2551 |
\bfseries file from \currentwq\ to \currentbk, |
| 2552 |
markregions={a1-a8,b1-b8,c1-c8}]%% |
| 2553 |
\end{LTXexample} |
| 2554 |
|
| 2555 |
\begin{LTXexample} |
| 2556 |
\newchessgame |
| 2557 |
\setchessboard{tinyboard,color=red} |
| 2558 |
|
| 2559 |
\chessboard[pgfstyle={[rotate=45]text}, |
| 2560 |
text= |
| 2561 |
\fontsize{1.2ex}{1.2ex} |
| 2562 |
\bfseries this is the diagonal |
| 2563 |
\currentwq\ to \currentbk, |
| 2564 |
markregions=\board] |
| 2565 |
|
| 2566 |
\chessboard[inverse, pgfstyle={[rotate=45]text}, |
| 2567 |
text= |
| 2568 |
\fontsize{1.2ex}{1.2ex} |
| 2569 |
\bfseries this is the diagonal |
| 2570 |
\currentwq\ to \currentbk, |
| 2571 |
markregions=\board] |
| 2572 |
|
| 2573 |
\end{LTXexample} |
| 2574 |
|
| 2575 |
|
| 2576 |
\minisec{Color} |
| 2577 |
|
| 2578 |
\index{color (style)}% |
| 2579 |
This style puts a colored square on or under the field or region. At |
| 2580 |
the start it was meant to color the background of the fields (and so |
| 2581 |
it was only defined for the background). If used for the foreground |
| 2582 |
on should set an adequate opacity. |
| 2583 |
|
| 2584 |
\begin{LTXexample}[width=0.55\textwidth] |
| 2585 |
\newchessgame |
| 2586 |
\setchessboard{tinyboard, |
| 2587 |
color=orange!80} |
| 2588 |
\chessboard[boardfontencoding=LSBC5, |
| 2589 |
pgfstyle=color, |
| 2590 |
trimtocolor=black, |
| 2591 |
backboard, |
| 2592 |
trimtocolor=white, |
| 2593 |
color=gray!50, |
| 2594 |
backboard]% |
| 2595 |
\chessboard[pgfstyle=color, |
| 2596 |
padding=-0.2em, |
| 2597 |
opacity=0.5, |
| 2598 |
markfiles={a,b}, |
| 2599 |
markregion={e1-h8}]% |
| 2600 |
\end{LTXexample} |
| 2601 |
|
| 2602 |
|
| 2603 |
\minisec{Moves} |
| 2604 |
|
| 2605 |
\index{straightmove (style)}% |
| 2606 |
\index{curvemove (style)}% |
| 2607 |
\index{knightmove (style)}% |
| 2608 |
Three styles draw arrows for moves. Two are quite simple: |
| 2609 |
\key{straightmove} which draws straight arrows, |
| 2610 |
\key{knightmove} which make a curve suited for knight moves. |
| 2611 |
|
| 2612 |
|
| 2613 |
|
| 2614 |
|
| 2615 |
|
| 2616 |
\begin{LTXexample} |
| 2617 |
\newchessgame |
| 2618 |
\chessboard[pgfstyle=straightmove, |
| 2619 |
markmove=a1-a8, |
| 2620 |
arrow=to,linewidth=0.2ex, |
| 2621 |
color=red, |
| 2622 |
pgfstyle=knightmove, |
| 2623 |
markmoves={g1-f3, e1-h4}, |
| 2624 |
shortenstart=-1ex, |
| 2625 |
markmoves=h1-g3]% |
| 2626 |
\end{LTXexample} |
| 2627 |
|
| 2628 |
|
| 2629 |
\paragraph*{curvemove} New in version 1.5 there is the more sophisticated |
| 2630 |
\key{curvemove} which draws an arbitrary bezier curve between start |
| 2631 |
and end field. |
| 2632 |
|
| 2633 |
\key{curvemove} accept an optional argument in key val syntax. (If you use it, |
| 2634 |
don't forget to put braces arround the value!). |
| 2635 |
|
| 2636 |
\index{curvemove (style)>x1 (key)}% |
| 2637 |
\index{curvemove (style)>x2 (key)}% |
| 2638 |
\index{curvemove (style)>y1 (key)}% |
| 2639 |
\index{curvemove (style)>y2 (key)}% |
| 2640 |
\index{curvemove (style)>clockwise (key)}% |
| 2641 |
First, there are keys that lets you change the support points of the |
| 2642 |
bezier curve. The curve use a local coordinate system: The x-axis |
| 2643 |
goes along the line from the start point to the end point. The |
| 2644 |
x-values set with the keys listed below are relative to the length of |
| 2645 |
this arrow from start to end, while the y-values are absolute (unit |
| 2646 |
it the width of a square). Positive y values give a curve going |
| 2647 |
clockwise, negative y values give a curve going anticlockwise. With |
| 2648 |
the |
| 2649 |
\texttt{clockwise=false} you can change the sign of the y values. |
| 2650 |
|
| 2651 |
\begin{tabular}{>{\ttfamily}l>{~=~}l} |
| 2652 |
x1 & \meta{number}\\ |
| 2653 |
x2 & \meta{number}\\ |
| 2654 |
y1 & \meta{number}\\ |
| 2655 |
y2 & \meta{number}\\ |
| 2656 |
clockwise & \meta{true|false} |
| 2657 |
\end{tabular} |
| 2658 |
|
| 2659 |
Second, there are keys to change \emph{locally} (only for the curve) |
| 2660 |
the look of the arrow. They work like the keys for \cs{chessboard} |
| 2661 |
with the same name: |
| 2662 |
\index{curvemove (style)>arrow (key)}% |
| 2663 |
\index{curvemove (style)>pgfarrow (key)}% |
| 2664 |
\key{arrow}, \key{pgfarrow}, |
| 2665 |
\index{curvemove (style)>linewidth (key)}% |
| 2666 |
\index{curvemove (style)>pgflinewidth (key)}% |
| 2667 |
\key{linewidth}, \key{pgflinewidth}, |
| 2668 |
\index{curvemove (style)>shortenstart (key)}% |
| 2669 |
\index{curvemove (style)>pgfshortenstart (key)}% |
| 2670 |
\key{shortenstart}, \key{pgfshortenstart}, |
| 2671 |
\index{curvemove (style)>shortenend (key)}% |
| 2672 |
\index{curvemove (style)>pgfshortenend (key)}% |
| 2673 |
\key{shortenend}, \key{pgfshortenend}. |
| 2674 |
|
| 2675 |
\index{curvemove (style)>style (key)}% |
| 2676 |
At last there is a key \key{style} which you can use to reuse saved |
| 2677 |
keyval-lists. Until now only style \texttt{knight} exists and there |
| 2678 |
is no user command to define new ones. You want to use own keys, sent |
| 2679 |
me either a feature request or do it by defining the low level |
| 2680 |
command: |
| 2681 |
|
| 2682 |
\verb+\def\board@pgf@curvemovestyle@+\meta{name}\verb+{\setkeys[UFCB]{bez}{+\meta{keyval-list}\verb+}}+ |
| 2683 |
|
| 2684 |
\begin{LTXexample} |
| 2685 |
\newchessgame |
| 2686 |
\def\mystyle{[clockwise=false,style=knight]curvemove} |
| 2687 |
\chessboard[arrow=latex, |
| 2688 |
pgfstyle=straightmove, |
| 2689 |
shortenstart=0.1em, |
| 2690 |
color=blue, |
| 2691 |
linewidth=3pt, |
| 2692 |
markmoves={e1-e8}, |
| 2693 |
pgfstyle={[linewidth=2pt,arrow=to, |
| 2694 |
style=knight]curvemove}, |
| 2695 |
markmove=b1-c3, |
| 2696 |
color=red, |
| 2697 |
pgfstyle=\mystyle, |
| 2698 |
markmoves={b1-c3,b1-a3}, |
| 2699 |
pgfstyle=curvemove, |
| 2700 |
markmoves={e1-g1,h1-f1}] |
| 2701 |
\end{LTXexample} |
| 2702 |
\subsubsection{Setting graphic properties} |
| 2703 |
|
| 2704 |
As the previous examples showed you can change quite a lot things of |
| 2705 |
the pictures. Now here a complete description of the needed keys. The |
| 2706 |
keys don't draw anything directly. They only put commands or |
| 2707 |
definitions like |
| 2708 |
\verb+\color{red}+, \verb+\pgfsetfillopacity{0.3}+ or |
| 2709 |
\verb+\def\board@pgf@arrow{to}+ in the pgf-picture(s). |
| 2710 |
|
| 2711 |
|
| 2712 |
|
| 2713 |
|
| 2714 |
\bigskip |
| 2715 |
Let us now start with the keys which put a command in the pictures: |
| 2716 |
|
| 2717 |
|
| 2718 |
\Describefillkey{color}{color}{red} |
| 2719 |
\Describefillkey{pgfcolor}{color}{red} |
| 2720 |
|
| 2721 |
This keys stores a color command (\verb+\color{red}+) in the pgf |
| 2722 |
picture(s). |
| 2723 |
|
| 2724 |
|
| 2725 |
\medskip |
| 2726 |
\Describefillkey{opacity}{number}{0.5} |
| 2727 |
\Describefillkey{pgfopacity}{number}{0.5} |
| 2728 |
\Describefillkey{fillopacity}{number}{0.5} |
| 2729 |
\Describefillkey{pgffillopacity}{number}{0.5} |
| 2730 |
\Describefillkey{strokeopacity}{number}{0.5} |
| 2731 |
\Describefillkey{pgfstrokeopacity}{number}{0.5} |
| 2732 |
|
| 2733 |
|
| 2734 |
This keys add \cs{pgfsetfillopacity}\marg{number} and/or |
| 2735 |
\cs{pgfsetstrokeopacity}\marg{number} to the pgf-picture(s). The |
| 2736 |
number should be between zero and one. |
| 2737 |
|
| 2738 |
\begin{LTXexample} |
| 2739 |
\chessboard[padding=-0.5ex, |
| 2740 |
color=red,fillopacity=0.5, |
| 2741 |
markstyle=circle,markfields=a1, |
| 2742 |
markstyle=color,markfields=b1, |
| 2743 |
fillopacity=1, |
| 2744 |
strokeopacity=0.5, |
| 2745 |
pgfstyle=circle, |
| 2746 |
markfields=d1,backfield=d8, |
| 2747 |
pgfstyle=color, |
| 2748 |
markfields=e1,backfield=c8] |
| 2749 |
\end{LTXexample} |
| 2750 |
|
| 2751 |
|
| 2752 |
\bigskip |
| 2753 |
The following keys puts only a definition in the pgf-pictures. The |
| 2754 |
values will only affect the styles that use the internal commands in |
| 2755 |
their definitions. |
| 2756 |
|
| 2757 |
\medskip |
| 2758 |
\Describefillkey{padding}{length}{0.1ex} |
| 2759 |
\Describefillkey{pgfpadding}{length}{0.1ex} |
| 2760 |
|
| 2761 |
This keys save \verb+\def\board@pgf@padding+\marg{length} to the |
| 2762 |
pgf-picture(s). The value can be used in various situations to change |
| 2763 |
the offset of a line or a border of the area that is covered by a |
| 2764 |
color. |
| 2765 |
|
| 2766 |
Used currently by the border styles, the styles that color fields in |
| 2767 |
the background or the foreground to enlarge or reduce the covered |
| 2768 |
area and the circle (the length is added to a start diameter). |
| 2769 |
|
| 2770 |
\begin{LTXexample} |
| 2771 |
\chessboard[color=red, |
| 2772 |
markstyle=circle,markfields=a1, |
| 2773 |
markstyle=border,markfields=a3, |
| 2774 |
markstyle=color,markfields=a5, |
| 2775 |
padding=0.3ex,color=green, |
| 2776 |
markstyle=circle,markfields=c3, |
| 2777 |
markstyle=border,markfields=c5, |
| 2778 |
markstyle=color,markfields=e5, |
| 2779 |
padding=-0.3ex,color=blue, |
| 2780 |
markstyle=circle,markfields=g3, |
| 2781 |
markstyle=border,markfields=g5, |
| 2782 |
backstyle=color,backfields=g1] |
| 2783 |
\end{LTXexample} |
| 2784 |
|
| 2785 |
\medskip |
| 2786 |
\Describefillkey{arrow}{arrow type}{to} |
| 2787 |
\Describefillkey{pgfarrow}{arrow type}{to} |
| 2788 |
|
| 2789 |
This keys save \verb+\def\board@pgf@arrow+\marg{arrow type} to the |
| 2790 |
pgf-picture(s). Styles can use the command to set the arrow |
| 2791 |
tips. Look at the documentation of pgf to learn about the existing |
| 2792 |
arrow types (and how to define new ones). |
| 2793 |
|
| 2794 |
Default is \texttt{latex}. Used currently by the move styles. |
| 2795 |
|
| 2796 |
\begin{LTXexample} |
| 2797 |
\chessboard[markstyle=straightmove, |
| 2798 |
markmove=a1-a3, |
| 2799 |
arrow=to, |
| 2800 |
markmove=b1-b3] |
| 2801 |
\end{LTXexample} |
| 2802 |
|
| 2803 |
\Describefillkey{shortenstart}{length}{to} |
| 2804 |
\Describefillkey{pgfshortenstart}{length}{to} |
| 2805 |
\Describefillkey{shortenend}{length}{to} |
| 2806 |
\Describefillkey{pgfshortenend}{length}{to} |
| 2807 |
\Describefillkey{shorten}{length}{to} |
| 2808 |
\Describefillkey{pgfshorten}{length}{to} |
| 2809 |
|
| 2810 |
This keys save the definitions |
| 2811 |
\verb+\def\board@pgf@shortenstart+\marg{length} or\\ |
| 2812 |
\verb+\def\board@pgf@shortenend+\marg{length} or both to the |
| 2813 |
pgf-picture(s). The commands can be used e.g. in a |
| 2814 |
\cs{pgfsetshortenstart} command to shorten a line a the start or the |
| 2815 |
end. |
| 2816 |
|
| 2817 |
As default the lengths are 0pt. Used e.g.\ by the styles |
| 2818 |
straightmove, knightmove, cross and the partial borders. The lengths |
| 2819 |
are |
| 2820 |
\emph{added} to some start values that I thought reasonable. If you |
| 2821 |
use large length (over 1ex) this can change the meaning of move marks |
| 2822 |
as the mark will start in another field! |
| 2823 |
|
| 2824 |
\begin{LTXexample} |
| 2825 |
\chessboard[markstyle=straightmove, |
| 2826 |
markmove=a1-a3, |
| 2827 |
markstyle=cross,markfield=a5, |
| 2828 |
shortenend=1ex,color=red, |
| 2829 |
markstyle=straightmove, |
| 2830 |
markmove=b1-b3, |
| 2831 |
markstyle=cross,markfield=b5, |
| 2832 |
shorten=-0.5em,color=green, |
| 2833 |
pgfstyle=straightmove, |
| 2834 |
backmove=d1-d3, |
| 2835 |
backstyle=cross,backfield=d5] |
| 2836 |
\end{LTXexample} |
| 2837 |
|
| 2838 |
\Describefillkey{linewidth}{length}{1ex} |
| 2839 |
\Describefillkey{pgflinewidth}{length}{1ex} |
| 2840 |
\Describefillkey[relict]{marklinewidth}{length}{1ex} |
| 2841 |
\Describefillkey[relict]{backlinewidth}{length}{1ex} |
| 2842 |
|
| 2843 |
This keys save \verb+\def\board@pgf@linewidth+\marg{length} to the |
| 2844 |
pgf-picture(s). The command can be used e.g. in \cs{pgfsetlinewidth}. |
| 2845 |
The keys \key{marklinewidth} and \key{backlinewidth} are remains from |
| 2846 |
an older version. There put the commands only in one picture, and |
| 2847 |
they ignore the values of the \key{usepgf} keys. |
| 2848 |
|
| 2849 |
\begin{LTXexample} |
| 2850 |
\chessboard[markstyle=straightmove, |
| 2851 |
markmove=a1-a3, |
| 2852 |
markstyle=cross,markfield=a5, |
| 2853 |
linewidth=1ex,color=red, |
| 2854 |
markstyle=straightmove, |
| 2855 |
markmove=b1-b3, |
| 2856 |
markstyle=cross,markfield=b5, |
| 2857 |
pgfstyle=border,backfield=d5] |
| 2858 |
\end{LTXexample} |
| 2859 |
|
| 2860 |
%?????????????????????????????????? |
| 2861 |
%vachange an internal command that can be use to set the linewidth |
| 2862 |
%e.g. of an arrow or a border. The first key affects both |
| 2863 |
%pgf-pictures, the other only the mark or the background layer |
| 2864 |
|
| 2865 |
\Describefillkey{cornerarc}{length}{2pt} |
| 2866 |
\Describefillkey{pgfcornerarc}{length}{2pt} |
| 2867 |
\Describefillkey[relict]{backcornerarc}{length}{2pt} |
| 2868 |
|
| 2869 |
The first two keys save \verb+\def\board@pgf@corner+\marg{length} to |
| 2870 |
the pgf-picture(s). The last key will save the same definition only |
| 2871 |
to the background picture and it will ignore the value of the |
| 2872 |
\key{usebackpgf} and \key{usepgf} keys. \verb+\board@pgf@corner+ can |
| 2873 |
be used e.g. in \cs{pgfsetcornersarced} to round the corners of a |
| 2874 |
border. To get sharp corners use the value 0pt. |
| 2875 |
|
| 2876 |
The value is used currently only used in the border styles. |
| 2877 |
|
| 2878 |
\begin{LTXexample} |
| 2879 |
\chessboard[linewidth=0.3ex,color=red, |
| 2880 |
padding=1ex, |
| 2881 |
pgfstyle=border, |
| 2882 |
backregion=\board, |
| 2883 |
cornerarc=1ex, |
| 2884 |
padding=1.5ex, |
| 2885 |
backregion=\board, |
| 2886 |
pgfstyle=bottomlefttopborder, |
| 2887 |
backregion=c3-f6] |
| 2888 |
\end{LTXexample} |
| 2889 |
|
| 2890 |
|
| 2891 |
\Describefillkey{addpgf}{(pgf)-commands}{\cs{pgfsetroundcap}} |
| 2892 |
|
| 2893 |
With this key you can add arbitrary (pgf)-commands to the pictures. |
| 2894 |
Use it with care. When you use the key without an argument it will |
| 2895 |
end a pgf scope\index{scope} and so reset colors and |
| 2896 |
linewidth and some of the other values to their defaults. |
| 2897 |
|
| 2898 |
\begin{LTXexample} |
| 2899 |
\chessboard[ |
| 2900 |
showmover=false, |
| 2901 |
inverse,markstyle=leftborder, |
| 2902 |
color=red,linewidth=0.3em, |
| 2903 |
markregion=d3-d5, |
| 2904 |
color=blue, |
| 2905 |
addpgf=\pgfsetroundcap, |
| 2906 |
markregion=e3-e5, |
| 2907 |
addpgf, |
| 2908 |
markstyle=cross, |
| 2909 |
markfield=c4] |
| 2910 |
\end{LTXexample} |
| 2911 |
|
| 2912 |
\Describefillkey{usepgf}{back|mark|all|both|none}{} |
| 2913 |
|
| 2914 |
With this key you can control in which picture the commands or |
| 2915 |
definitions are saved when using the keys described above. |
| 2916 |
|
| 2917 |
The default is to save everything in both pictures. This means that |
| 2918 |
is also adds some superfluous code to the other picture, but I don't |
| 2919 |
think this is a problem. In most cases you won't need the key. |
| 2920 |
|
| 2921 |
|
| 2922 |
|
| 2923 |
\subsubsection{A special shortcut key for background border} |
| 2924 |
|
| 2925 |
|
| 2926 |
\Describefillkey{pgfborder}{area}{c3-e4} |
| 2927 |
|
| 2928 |
With this key you can put a border around the area in the background |
| 2929 |
picture. The key saves the current style, calls the \key{backstyle} |
| 2930 |
and the \key{backregions} keys to draw the border and then restores |
| 2931 |
the old style. If you don't give a value to the key, the border is |
| 2932 |
around the printarea. |
| 2933 |
|
| 2934 |
\begin{LTXexample} |
| 2935 |
\newchessgame |
| 2936 |
\chessboard[% |
| 2937 |
showmover=false, |
| 2938 |
border=false, |
| 2939 |
linewidth=0.4pt, |
| 2940 |
padding=0.4pt, |
| 2941 |
pgfborder, |
| 2942 |
linewidth=1pt, |
| 2943 |
padding=2pt, |
| 2944 |
pgfborder] |
| 2945 |
\end{LTXexample} |
| 2946 |
|
| 2947 |
|
| 2948 |
\begin{LTXexample} |
| 2949 |
\chessboard[ |
| 2950 |
showmover=false, |
| 2951 |
border=false, |
| 2952 |
hlabelwidth=0.6em, |
| 2953 |
vlabellift=1.3em, |
| 2954 |
printarea=c3-f6, |
| 2955 |
pgfstyle=cross, |
| 2956 |
color=red, |
| 2957 |
linewidth=1ex, |
| 2958 |
padding=1ex, |
| 2959 |
pgfborder, |
| 2960 |
markfield=d4, |
| 2961 |
color=blue, |
| 2962 |
linewidth=0.5ex, |
| 2963 |
padding=2.5ex, |
| 2964 |
pgfborder, |
| 2965 |
padding=0ex, |
| 2966 |
color=green, |
| 2967 |
trim=false,%to show the next border |
| 2968 |
pgfborder=\board, |
| 2969 |
markfield=e5] |
| 2970 |
\end{LTXexample} |
| 2971 |
|
| 2972 |
|
| 2973 |
|
| 2974 |
|
| 2975 |
\subsubsection{Special shortcut keys for background color} |
| 2976 |
|
| 2977 |
|
| 2978 |
|
| 2979 |
\medskip |
| 2980 |
\Describefillkey{colorbackboard}{arbitrary}{} |
| 2981 |
\Describefillkey{colorbackarea}{area}{a1-c3} |
| 2982 |
\Describefillkey{colorbackareas}{list of areas}{\{a1-c3, f1-f2\}} |
| 2983 |
\Describefillkey{colorbackfile}{file}{h} |
| 2984 |
\Describefillkey{colorbackfiles}{list of files}{\{g,h\}} |
| 2985 |
\Describefillkey{colorbackrank}{rank}{5} |
| 2986 |
\Describefillkey{colorbackranks}{list of ranks}{\{8,7\}} |
| 2987 |
\Describefillkey{colorbackfield}{field}{g4} |
| 2988 |
\Describefillkey{colorbackfields}{list of fields}{\{b5,c6\}} |
| 2989 |
\Describefillkey{colorwhitebackfields}{list of fields}{\{b5,c6\}} |
| 2990 |
\Describefillkey{colorblackbackfields}{list of fields}{\{b5,c6\}} |
| 2991 |
|
| 2992 |
|
| 2993 |
This keys are shortcuts to color the background of the board. They |
| 2994 |
save the current style, color the fields and then restore the style. |
| 2995 |
|
| 2996 |
|
| 2997 |
\begin{LTXexample} |
| 2998 |
\chessboard[ |
| 2999 |
showmover=false, |
| 3000 |
border=false, |
| 3001 |
pgfstyle=cross, |
| 3002 |
color=red!50, |
| 3003 |
colorwhitebackfields, |
| 3004 |
markfield=d4, |
| 3005 |
color=blue!50, |
| 3006 |
colorblackbackfields, |
| 3007 |
markfield=e5, |
| 3008 |
color=green!50, |
| 3009 |
colorbackarea=d4-e5] |
| 3010 |
\end{LTXexample} |
| 3011 |
|
| 3012 |
|
| 3013 |
%\subsection{Marks and highlighting: Adding decoration to the foreground layer} |
| 3014 |
|
| 3015 |
% |
| 3016 |
% |
| 3017 |
%\subsection{Coloring the pieces} |
| 3018 |
% |
| 3019 |
%Coloring the fields isn't really satisfactory. It would be nicer if |
| 3020 |
%one could color only the pieces. But as the background and the piece |
| 3021 |
%is one char this isn't possible, one needs a font where for each |
| 3022 |
%piece there a background mask. One can fake such a font by either |
| 3023 |
%using two chars for the fields with black background, or by not |
| 3024 |
%using the chars with black background. I added three experimental |
| 3025 |
%encodings to |
| 3026 |
%\chessfss and some keys to use them. This isn't perfect but it's a |
| 3027 |
%start until better fonts are available. |
| 3028 |
% |
| 3029 |
%To use the encodings you must load |
| 3030 |
%\filetype{lsb1enc.def}, \filetype{lsb2enc.def} and |
| 3031 |
%\filetype{lsb3enc.def} e.g.\ with |
| 3032 |
%\lstinline+\usepackage[LSB1, LSB2, LSB3, T1]{fontenc}+. |
| 3033 |
% |
| 3034 |
%\Describesetkey{colorwhite}{color}{red}{--} |
| 3035 |
%\Describesetkey{colorblack}{color}{green}{--} |
| 3036 |
% |
| 3037 |
%This keys colors all black and white pieces. |
| 3038 |
% |
| 3039 |
%\begin{LTXexample} |
| 3040 |
%\chessboard[boardfontencoding=LSB1, |
| 3041 |
% emphstyle=\color{green}, |
| 3042 |
% emphboard, |
| 3043 |
% colorwhite=red, |
| 3044 |
% colorblack=blue] |
| 3045 |
%\end{LTXexample} |
| 3046 |
% |
| 3047 |
|
| 3048 |
|
| 3049 |
%\Describefillkey{piececolor}{color}{red} |
| 3050 |
%\Describefillkey{colorpieces}{list of fields}{\{a1,c3\}} |
| 3051 |
%With this keys you can color the pieces on some fields. |
| 3052 |
% |
| 3053 |
%\begin{LTXexample} |
| 3054 |
%\def\fieldlist{a1,b1 , c1}% |
| 3055 |
%\def\mycolor{blue}% |
| 3056 |
%\chessboard[boardfontencoding=LSB1, |
| 3057 |
% emphstyle=\color{green}, |
| 3058 |
% emphboard, |
| 3059 |
% piececolor=red, |
| 3060 |
% colorpieces={a8,b8}, |
| 3061 |
% piececolor=\mycolor, |
| 3062 |
% colorpieces=\fieldlist] |
| 3063 |
%\end{LTXexample} |
| 3064 |
|
| 3065 |
%\begin{LTXexample} |
| 3066 |
% \chessboard[boardfontencoding=LSB1, |
| 3067 |
% colorwhite=red, |
| 3068 |
% colorblack=blue, |
| 3069 |
% addpieces={qd5,ke5,Qd4,Ke4}] |
| 3070 |
%\end{LTXexample} |
| 3071 |
|
| 3072 |
%\subsection{The foreground picture: Marking} |
| 3073 |
|
| 3074 |
%The following highlighting commands all use one large pgf-picture |
| 3075 |
%that is printed above the board. Putting marks on the boards means |
| 3076 |
%inserting some pgf code in this picture. The units of the picture are |
| 3077 |
%equal to the width and height of a square. For each field there exist |
| 3078 |
%a node with the same name as the field in the middle of field. With |
| 3079 |
%the command |
| 3080 |
%\lstinline+\pgftransformshift{\pgfpointanchor{+\meta{field}\lstinline+}{center}+ |
| 3081 |
%one can shift the origin to this field and start to draw. |
| 3082 |
% |
| 3083 |
|
| 3084 |
|
| 3085 |
|
| 3086 |
%\subsubsection{Adding arbitrary pgf-code} |
| 3087 |
|
| 3088 |
|
| 3089 |
|
| 3090 |
|
| 3091 |
\subsubsection{Clearing the pgf-pictures} |
| 3092 |
|
| 3093 |
|
| 3094 |
|
| 3095 |
|
| 3096 |
Removing pgf decoration from the board is easy if you used the |
| 3097 |
optional argument of \cs{chessboard}. But what should you do if you |
| 3098 |
had added e.g.\ a mark with \cs{setchessboard} for the next four |
| 3099 |
board and now want to get rid of it for the fifth? That isn't so easy |
| 3100 |
as the code is burried quite deep in a large list. |
| 3101 |
|
| 3102 |
On the whole there are three possibilities: |
| 3103 |
|
| 3104 |
|
| 3105 |
\begin{itemize} |
| 3106 |
\item Use grouping to keep the marks local to some boards. |
| 3107 |
|
| 3108 |
|
| 3109 |
\begin{LTXexample}[width=0.55\textwidth] |
| 3110 |
\newchessgame |
| 3111 |
\setchessboard{tinyboard} |
| 3112 |
{\setchessboard{markstyle=cross, |
| 3113 |
markranks=4} |
| 3114 |
\chessboard}% |
| 3115 |
\chessboard |
| 3116 |
\end{LTXexample} |
| 3117 |
|
| 3118 |
\item Store the keys in a style that you can redefine: |
| 3119 |
|
| 3120 |
\begin{LTXexample}[width=0.55\textwidth] |
| 3121 |
\newchessgame |
| 3122 |
\storechessboardstyle{mymarks} |
| 3123 |
{markstyle=cross, |
| 3124 |
markranks=4} |
| 3125 |
|
| 3126 |
\setchessboard{style=mymarks} |
| 3127 |
\chessboard% |
| 3128 |
\storechessboardstyle{mymarks}{} |
| 3129 |
\chessboard |
| 3130 |
\end{LTXexample} |
| 3131 |
|
| 3132 |
|
| 3133 |
|
| 3134 |
\item Use the following keys to clear the pgf pictures. |
| 3135 |
|
| 3136 |
\end{itemize} |
| 3137 |
|
| 3138 |
\Describefillkey{clearpgf}{arbitrary}{} |
| 3139 |
\Describefillkey{clearbackpgf}{arbitrary}{} |
| 3140 |
\Describefillkey{clearmarkpgf}{arbitrary}{} |
| 3141 |
|
| 3142 |
(I renamed the keys \key{clearforegroundpgf}% |
| 3143 |
\index{clearforegroundpgf (obsolete)|see{clearmarkpgf}} and |
| 3144 |
\key{clearbackgroundpgf},% |
| 3145 |
\index{clearbackgroundpgf (obsolete)|see{clearbackpgf}} the older names will work too, but I |
| 3146 |
suggest that you switch to the new ones.) |
| 3147 |
|
| 3148 |
\begin{LTXexample}[width=0.55\textwidth] |
| 3149 |
\newchessgame |
| 3150 |
\setchessboard{tinyboard, |
| 3151 |
color=blue, |
| 3152 |
opacity=0.6, |
| 3153 |
colorblackbackfields, |
| 3154 |
color=red, |
| 3155 |
markstyle=cross, |
| 3156 |
markfiles=h} |
| 3157 |
\chessboard% |
| 3158 |
\chessboard[clearmarkpgf] |
| 3159 |
\chessboard[clearbackpgf]% |
| 3160 |
\chessboard[clearpgf, |
| 3161 |
markstyle=circle, |
| 3162 |
markranks=4] |
| 3163 |
\setchessboard{clearmarkpgf}% |
| 3164 |
\chessboard |
| 3165 |
\end{LTXexample} |
| 3166 |
|
| 3167 |
|
| 3168 |
\subsubsection{Clipping the pgf pictures} |
| 3169 |
|
| 3170 |
|
| 3171 |
\Describesetkey{clip}{\keylist}{}{false} |
| 3172 |
\Describesetkey{markclip}{\keylists}{}{false} |
| 3173 |
\Describesetkey{backclip}{\keylists}{}{false} |
| 3174 |
|
| 3175 |
\index{clip>true (subkey)}% |
| 3176 |
\index{clip>false (subkey)}% |
| 3177 |
\index{clip>left (subkey)}% |
| 3178 |
\index{clip>right (subkey)}% |
| 3179 |
\index{clip>top (subkey)}% |
| 3180 |
\index{clip>bottom (subkey)}% |
| 3181 |
With this keys you can add \emph{one} clipping path to each pgf |
| 3182 |
pictures. The clipping paths are always around the print area. The |
| 3183 |
argument of the keys is key-value-list with the possible keys |
| 3184 |
\key{true}, |
| 3185 |
\key{false} to enable or disable the clipping and the four keys |
| 3186 |
\key{left}, \key{top}, \key{right} and \key{bottom} which take as |
| 3187 |
value a length and are used to set the padding. |
| 3188 |
|
| 3189 |
As in other keys the value \texttt{true} can be omitted, but this |
| 3190 |
also means that you have to use the value \texttt{false} explicitly |
| 3191 |
if you only want to set some of the padding values but not enable |
| 3192 |
clipping. |
| 3193 |
|
| 3194 |
|
| 3195 |
\begin{LTXexample}[width=0.55\textwidth] |
| 3196 |
\newchessgame |
| 3197 |
\setchessboard{ |
| 3198 |
trim=false,printarea=b2-g7, |
| 3199 |
clip={left=0.5ex,top=0.5ex, |
| 3200 |
right=-0.5ex,bottom=-0.5ex, |
| 3201 |
false}, |
| 3202 |
% |
| 3203 |
border=false,linewidth=0.3em, |
| 3204 |
pgfborder, |
| 3205 |
% |
| 3206 |
pgfstyle=color, |
| 3207 |
color=blue!50, |
| 3208 |
backrank=6,backfile=c, |
| 3209 |
color=red!50, |
| 3210 |
markrank=4,markfile=f, |
| 3211 |
% |
| 3212 |
pgfstyle=text,color=black, |
| 3213 |
text=a text in the foreground, |
| 3214 |
markfield=b4, |
| 3215 |
text=a text in the background, |
| 3216 |
backfield=f6}% |
| 3217 |
|
| 3218 |
\chessboard |
| 3219 |
|
| 3220 |
\chessboard[markclip] |
| 3221 |
|
| 3222 |
\chessboard[backclip] |
| 3223 |
|
| 3224 |
\chessboard[clip] |
| 3225 |
\end{LTXexample} |
| 3226 |
|
| 3227 |
|
| 3228 |
\subsubsection{Trimming} |
| 3229 |
Clipping cuts simply through the pgf-pictures and throws everything |
| 3230 |
away that is outside the printarea. This has the drawback that in |
| 3231 |
the picture there could be e.g. remains of a move arrow that started |
| 3232 |
outside the shown board. |
| 3233 |
|
| 3234 |
Trimming is an attempt for a more intelligent approach: Objects like |
| 3235 |
crosses, circles, text, borders and arrows are discarded completely |
| 3236 |
if they lie partly or completely outside the defined scope of fields. |
| 3237 |
|
| 3238 |
\minisec{Trimming to a area} |
| 3239 |
\Describefillkey{trimarea}{area|empty}{} |
| 3240 |
|
| 3241 |
This sets and activates an trimarea. If you omit a value printarea is |
| 3242 |
used. If you don't give an area but use the keyword \verb+empty+ |
| 3243 |
everything following the key will be trimmed. If you want to disable |
| 3244 |
trimming use \verb+trimarea=\board+ (or \verb+trim=false+). As a |
| 3245 |
default the trimarea is set to the print area (and so activated). |
| 3246 |
|
| 3247 |
The value of \key{trimarea} will affect all \emph{following} objects |
| 3248 |
drawn with the |
| 3249 |
\key{pgfstyle} and the related \key{mark\ldots} and |
| 3250 |
\key{back\ldots} keys. |
| 3251 |
|
| 3252 |
Field related objects will be drawn if the field lies in the area. |
| 3253 |
Region related objects will be drawn if the complete region lies in |
| 3254 |
the area. Move related objects will be drawn if the complete move |
| 3255 |
lies in the area. |
| 3256 |
|
| 3257 |
|
| 3258 |
\begin{LTXexample} |
| 3259 |
\newchessgame |
| 3260 |
\setchessboard{pgfstyle=color, |
| 3261 |
color=blue!50, |
| 3262 |
backrank=6, |
| 3263 |
trimarea=\myarea, |
| 3264 |
backrank=5, |
| 3265 |
pgfstyle=border, |
| 3266 |
color=red, |
| 3267 |
markregion=d4-d5, |
| 3268 |
markregion=c3-d5,%will disappear |
| 3269 |
pgfstyle=knightmove, |
| 3270 |
color=yellow, |
| 3271 |
markmove=f6-e4, |
| 3272 |
markmove=f7-d5%will disappear |
| 3273 |
} |
| 3274 |
\def\myarea{a1-h8}% nothing trimmed |
| 3275 |
\chessboard |
| 3276 |
|
| 3277 |
\def\myarea{d4-f6}% some deco will disappear |
| 3278 |
\chessboard |
| 3279 |
\end{LTXexample} |
| 3280 |
|
| 3281 |
\begin{LTXexample} |
| 3282 |
\newchessgame |
| 3283 |
\setchessboard{pgfstyle=color, |
| 3284 |
color=blue!50, |
| 3285 |
backrank=6, |
| 3286 |
trimarea=\myarea, |
| 3287 |
backrank=5, |
| 3288 |
pgfstyle=border, |
| 3289 |
color=red, |
| 3290 |
markregion=d4-d5, |
| 3291 |
markregion=c3-d5,%will disappear |
| 3292 |
pgfstyle=knightmove, |
| 3293 |
color=yellow, |
| 3294 |
markmove=f6-e4, |
| 3295 |
markmove=f7-d5%will disappear |
| 3296 |
} |
| 3297 |
\def\myarea{empty} |
| 3298 |
\chessboard |
| 3299 |
\end{LTXexample} |
| 3300 |
As shown in the previous examples you can set a manual trimarea. But |
| 3301 |
you should be aware that you can get unexpected results if this |
| 3302 |
area is larger than the printarea: |
| 3303 |
|
| 3304 |
|
| 3305 |
\begin{LTXexample} |
| 3306 |
\chessboard[printarea=d4-e5, |
| 3307 |
trimarea=c4-g4, |
| 3308 |
pgfstyle=color, |
| 3309 |
trimtocolor=white, |
| 3310 |
color=red, |
| 3311 |
backboard] |
| 3312 |
\end{LTXexample} |
| 3313 |
|
| 3314 |
\Describefillkey{captrimtoprint}{true|false}{true} |
| 3315 |
|
| 3316 |
With this key you can force the \emph{following} trimarea commands to |
| 3317 |
respect the printarea. |
| 3318 |
|
| 3319 |
\begin{LTXexample} |
| 3320 |
\chessboard[printarea=d4-e5, |
| 3321 |
trimarea=c3-f6, |
| 3322 |
captrimtoprint, |
| 3323 |
pgfstyle=cross, |
| 3324 |
color=red, |
| 3325 |
backboard, |
| 3326 |
trimarea=c3-f6,%now captrimtoprint |
| 3327 |
%has an effect |
| 3328 |
pgfstyle=circle, |
| 3329 |
color=green, |
| 3330 |
backboard] |
| 3331 |
\end{LTXexample} |
| 3332 |
|
| 3333 |
|
| 3334 |
\Describefillkey{trim}{true|false}{true} |
| 3335 |
|
| 3336 |
This is a shorter version of \key{trimarea}. It can only be used to |
| 3337 |
set the trimarea to printarea (true) or the complete board (false). |
| 3338 |
|
| 3339 |
%Until now I have only implement some code to draw colored squares in |
| 3340 |
%the background. I don't know really what else could be useful. The |
| 3341 |
%only idea that comes to my mind is some code to insert a real |
| 3342 |
%background image, but it is difficult to decide how size and position |
| 3343 |
%of such an image should be controlled. |
| 3344 |
|
| 3345 |
|
| 3346 |
\begin{LTXexample} |
| 3347 |
\newchessgame |
| 3348 |
\mainline{1. e4 e5 2. Nf3 Nc6 3. Bb5 a6} |
| 3349 |
\setchessboard{linewidth=0.1em,border=false, |
| 3350 |
label=false,showmover=false} |
| 3351 |
\chessboard[printarea=a5-d8, |
| 3352 |
padding=0.25em, |
| 3353 |
trim=false, |
| 3354 |
shortenend=-1ex, |
| 3355 |
pgfstyle=rightborder, |
| 3356 |
markregion=d1-d8, |
| 3357 |
padding=-0.25em, |
| 3358 |
pgfstyle=topborder, |
| 3359 |
markrank=4, |
| 3360 |
marginrightwidth=0.5em, |
| 3361 |
marginbottomwidth=0.5em]% |
| 3362 |
\chessboard[printarea=e5-h8, |
| 3363 |
marginleftwidth=0em, |
| 3364 |
marginbottomwidth=0.5em]\\% |
| 3365 |
\chessboard[printarea=a1-d4, |
| 3366 |
margintopwidth=0em, |
| 3367 |
marginrightwidth=0.5em]% |
| 3368 |
\chessboard[printarea=e1-h4, |
| 3369 |
margintopwidth=0em, |
| 3370 |
marginleftwidth=0em]% |
| 3371 |
\end{LTXexample} |
| 3372 |
|
| 3373 |
|
| 3374 |
\minisec{Trimming to the white or black fields} |
| 3375 |
|
| 3376 |
\Describefillkey{trimtocolor}{white|black|false}{} |
| 3377 |
|
| 3378 |
The key affects only the field related pgf-objects. Regions and moves |
| 3379 |
will ignore it. The key \obsoletekey{applycolor} from previous |
| 3380 |
versions has now a similar effect\footnote{I couldn't retain the older behaviour due to the changes |
| 3381 |
made in the code.}. This means that the key has changed |
| 3382 |
its behaviour: it will now affect also the foreground picture! |
| 3383 |
|
| 3384 |
\begin{LTXexample} |
| 3385 |
\chessboard[printarea=c3-f6, |
| 3386 |
trim, %not really needed, default |
| 3387 |
pgfstyle=color, |
| 3388 |
trimtocolor=white, |
| 3389 |
color=red, |
| 3390 |
backboard, |
| 3391 |
trimarea=b2-g7, |
| 3392 |
trimtocolor=black, |
| 3393 |
color=gray!50, |
| 3394 |
backboard] |
| 3395 |
\end{LTXexample} |
| 3396 |
|
| 3397 |
|
| 3398 |
%\medskip |
| 3399 |
%\Describefillkey{applycolor}{white|black|all|none}{white} |
| 3400 |
% \Describefillkey{colorwhitefields}{arbitrary}{} |
| 3401 |
%\Describefillkey{colorblackfields}{arbitrary}{} |
| 3402 |
|
| 3403 |
%With this key you can chose to color only the black or the white |
| 3404 |
%fields. |
| 3405 |
%\begin{LTXexample} |
| 3406 |
%\def\myareas{f6-f7, h7-h8} |
| 3407 |
%\chessboard[inverse, |
| 3408 |
% printarea=b2-g7, |
| 3409 |
% opacity=0.5, |
| 3410 |
% color=green, padding=-0.2ex, |
| 3411 |
% colorbackareas=\myareas, %trimmed |
| 3412 |
% color=red, |
| 3413 |
% trim=false, %next fields not trimmed |
| 3414 |
% colorbackfields={a1,c3,d4,g8}] |
| 3415 |
%\end{LTXexample} |
| 3416 |
|
| 3417 |
|
| 3418 |
\begin{LTXexample} |
| 3419 |
\chessboard[printarea=f3-c6, |
| 3420 |
padding=.3ex, |
| 3421 |
trimtocolor=white, |
| 3422 |
color=blue, |
| 3423 |
pgfstyle=cross, |
| 3424 |
backranks=5, |
| 3425 |
color=yellow, |
| 3426 |
trimtocolor=black, |
| 3427 |
trim=false, |
| 3428 |
backfiles={d,e}] |
| 3429 |
\end{LTXexample} |
| 3430 |
|
| 3431 |
|
| 3432 |
\begin{LTXexample} |
| 3433 |
\chessboard[padding=.3ex, |
| 3434 |
printarea=f3-c6, |
| 3435 |
trimtocolor=white, |
| 3436 |
color=blue, |
| 3437 |
pgfstyle=text, |
| 3438 |
text=\tiny\bfseries white, |
| 3439 |
markboard, |
| 3440 |
color=yellow, |
| 3441 |
trimtocolor=black, |
| 3442 |
text=\tiny\bfseries black, |
| 3443 |
markboard] |
| 3444 |
\end{LTXexample} |
| 3445 |
|
| 3446 |
|
| 3447 |
\begin{LTXexample} |
| 3448 |
\chessboard[inverse, printarea=a2-g7, |
| 3449 |
boardfontencoding=LSB2, |
| 3450 |
color=lightgray!50, |
| 3451 |
trimtocolor=white, |
| 3452 |
colorbackboard, |
| 3453 |
color=gray!60, |
| 3454 |
trimtocolor=black, |
| 3455 |
colorbackboard] |
| 3456 |
\end{LTXexample}\label{stoppgf} |
| 3457 |
|
| 3458 |
|
| 3459 |
|
| 3460 |
\subsection{Using a graphic as background} |
| 3461 |
|
| 3462 |
It isn't really difficult to use a graphic as background of the |
| 3463 |
board. You must use a boardfont encoding that hasn't fields and |
| 3464 |
fieldmasks. And then you must use trial and error to find out which |
| 3465 |
scalefactor and which viewport is fine. There is absolutly no way to |
| 3466 |
do this automatically as the border of the board in the graphic is |
| 3467 |
unknown. If you change the board size or the size of the left margin, |
| 3468 |
you will have to adjust the values. |
| 3469 |
|
| 3470 |
|
| 3471 |
\begin{LTXexample}[width=0.55\textwidth] |
| 3472 |
\newchessgame |
| 3473 |
\includegraphics |
| 3474 |
[scale=0.477,viewport=-20 17 -20 17] |
| 3475 |
{brett}% |
| 3476 |
\chessboard[showmover=false, |
| 3477 |
border=false, |
| 3478 |
label=false, |
| 3479 |
boardfontencoding=LSBC5, |
| 3480 |
boardfontsize=20pt, |
| 3481 |
whitepiececolor=brown!70, |
| 3482 |
blackpiececolor=black, |
| 3483 |
setfontcolors] |
| 3484 |
\end{LTXexample} |
| 3485 |
|
| 3486 |
\subsection{Using the commands of \skaksty} |
| 3487 |
|
| 3488 |
When used with the option \textsf{ps} \skaksty puts in the middle of |
| 3489 |
the right bottom field (that is either h1 or a8) a postscript node |
| 3490 |
with the name BM. The highlighting commands of \skaksty use this |
| 3491 |
node. |
| 3492 |
|
| 3493 |
To be able to use the commands also with \cs{chessboard} you must |
| 3494 |
load \skaksty with the option \textsf{ps}. |
| 3495 |
|
| 3496 |
As arguments in the commands of \skaksty you can only use the fields |
| 3497 |
of a 8\texttimes8-board. |
| 3498 |
|
| 3499 |
\medskip |
| 3500 |
\Describesetkey{psset}{true|false}{}{false} |
| 3501 |
|
| 3502 |
This key sets the node BM at the place where \skaksty expect it, |
| 3503 |
\emph{and it sets the psunits to the size of the board}. This can |
| 3504 |
affect other pspictures as the changes are made after the board and |
| 3505 |
so aren't local to the board (the commands of \skaksty must have a |
| 3506 |
fighting chance to get the correct values). |
| 3507 |
|
| 3508 |
\medskip |
| 3509 |
\Describesetkey{psskak}{true|false}{}{false} |
| 3510 |
|
| 3511 |
This key redefines some internal commands of \skaksty. I had to do it |
| 3512 |
in order to get the highlighting commands to work. I don't think that |
| 3513 |
it will destroy anything but didn't want to activate the changes |
| 3514 |
unasked. The changes are also \emph{not} local to the board (but |
| 3515 |
local to the group). |
| 3516 |
|
| 3517 |
\begin{LTXexample}[graphic={chessboard-skakps}] |
| 3518 |
\documentclass[parskip]{scrartcl} |
| 3519 |
\usepackage[T1]{fontenc} |
| 3520 |
\usepackage[ps]{skak} |
| 3521 |
\usepackage{chessboard} |
| 3522 |
|
| 3523 |
\pagestyle{empty} |
| 3524 |
\begin{document} |
| 3525 |
\newchessgame |
| 3526 |
\chessboard[psskak,psset,pgf=false, |
| 3527 |
inverse] |
| 3528 |
\ifpdf\else |
| 3529 |
\highlight[X]{c4} |
| 3530 |
\highlight[o]{a8} |
| 3531 |
\highlight[O]{g1} |
| 3532 |
\printknightmove{g8}{f6} |
| 3533 |
BM\pnode{A}\ncline{->}{A}{BM} |
| 3534 |
\fi |
| 3535 |
\end{document} |
| 3536 |
\end{LTXexample} |
| 3537 |
|
| 3538 |
|
| 3539 |
|
| 3540 |
|
| 3541 |
|
| 3542 |
\subsection{Intelligent highlighting} |
| 3543 |
|
| 3544 |
\cs{chessboard} doesn't know anything about chess rules. It can't do |
| 3545 |
things like «show me the possible moves of the rock», «show me the |
| 3546 |
allowed moves» or «highlight the last move». But as the examples show |
| 3547 |
it accepts commands as arguments in the highlighting keys, so it can |
| 3548 |
use the intelligence of external commands or applications. E.g.\ |
| 3549 |
highlighting of the last move would be easy if \skaksty would somehow |
| 3550 |
save the last from-field and the last to-field -- something it |
| 3551 |
doesn't do now. |
| 3552 |
|
| 3553 |
\section{Extending the game} |
| 3554 |
\subsection{Adding new pieces} |
| 3555 |
\DescribeMacro{\cbDefineNewPiece} |
| 3556 |
With this command you can add new pieces that can be used on the |
| 3557 |
board. |
| 3558 |
|
| 3559 |
\cs{cbDefineNewPiece}\oarg{game}\marg{color}\marg{char}\marg{on |
| 3560 |
white}\marg{on black} |
| 3561 |
|
| 3562 |
The optional argument \meta{game} has not much use yet as there is |
| 3563 |
only one sensible value \texttt{skak} which is the default anyway. |
| 3564 |
So leave it out. |
| 3565 |
|
| 3566 |
\meta{color} should by either \texttt{white} or \texttt{black}, it |
| 3567 |
will put the character in the list used by e.g.\ the key |
| 3568 |
\key{hidewhite}. |
| 3569 |
|
| 3570 |
\meta{char} is the character used in FEN and the other input |
| 3571 |
arguments. Use a uppercase char for white pieces and a lowercase |
| 3572 |
char for the black pieces or the keys like \key{addwhite} won't work |
| 3573 |
correctly. |
| 3574 |
|
| 3575 |
\meta{on white} and \meta{on black} should contain the commands |
| 3576 |
needed to print the piece on white and black fields. The symbols |
| 3577 |
should be scalable. So you should either use symbols from a font or |
| 3578 |
use some resizing command from the graphicx package. |
| 3579 |
|
| 3580 |
\begingroup |
| 3581 |
\begin{LTXexample}[width=0.25\textwidth] |
| 3582 |
\makeatletter |
| 3583 |
\cbDefineNewPiece{white}{C} |
| 3584 |
{\raisebox{\depth}{\cfss@whitepiececolor |
| 3585 |
$\heartsuit$}} |
| 3586 |
{\BlackEmptySquare% |
| 3587 |
\makebox[0pt][r]{\cfss@whitepiececolor |
| 3588 |
\raisebox{\depth}{% |
| 3589 |
\makebox[1em]{$\heartsuit$}}}} |
| 3590 |
\cbDefineNewPiece{black}{c} |
| 3591 |
{\raisebox{\depth}{\cfss@blackpiececolor |
| 3592 |
$\clubsuit$}} |
| 3593 |
{\BlackEmptySquare% |
| 3594 |
\makebox[0pt][r]{\cfss@blackpiececolor |
| 3595 |
\raisebox{\depth}{% |
| 3596 |
\makebox[1em]{$\clubsuit$}}}} |
| 3597 |
\makeatother |
| 3598 |
\setchessboard{tinyboard, |
| 3599 |
addpieces={cd4,Ce5},addwhite={ca1,Cb1}, |
| 3600 |
addblack={ca8,Cb8}} |
| 3601 |
\chessboard[addpieces={cd4,Ce5, Ke4}] |
| 3602 |
\chessboard[hidewhite] |
| 3603 |
\chessboard[boardfontencoding=LSB3, |
| 3604 |
whitepiececolor=red,blackpiececolor=blue, |
| 3605 |
setfontcolors,color=lightgray, |
| 3606 |
trimtocolor=black, colorbackboard] |
| 3607 |
\end{LTXexample} |
| 3608 |
\endgroup |
| 3609 |
|
| 3610 |
%\subsection{Clipping and trimming the picture} |
| 3611 |
|
| 3612 |
|
| 3613 |
|
| 3614 |
\subsection{Using \texorpdfstring{\cs{chessboard}}{\textbackslash chessboard} for other games} |
| 3615 |
|
| 3616 |
I have tried to prepare \cs{chessboard} for other games. A lot of |
| 3617 |
internal commands can be changed simply by changing the «name of the |
| 3618 |
game». Up to now there isn't another game, so I don't know if this |
| 3619 |
will really work. |
| 3620 |
|
| 3621 |
|
| 3622 |
It should be easy to make boards for checkers if I find a font |
| 3623 |
somewhere. Chinese chess is a bit more complicated as one would have |
| 3624 |
to decide how to make the background lines. Go is more complicated |
| 3625 |
as the pieces are sometimes numbered, I don't know yet if I could |
| 3626 |
implement a good input handling -- but as there is a quite good |
| 3627 |
package named igo I don't think I will really look into it. |
| 3628 |
|
| 3629 |
|
| 3630 |
The main problem in any cases is the missing partner: \Pchessboard |
| 3631 |
isn't «intelligent». As already mentioned above it doesn't know |
| 3632 |
anything about the rules of chess. To be able to show «the running |
| 3633 |
game» it needs a partner that does the calculation. |
| 3634 |
|
| 3635 |
|
| 3636 |
|
| 3637 |
\section{Compability with other packages} |
| 3638 |
|
| 3639 |
\subsection{\packagename{skak}} |
| 3640 |
\Pchessboard works fine with \skaksty. You can use \cs{chessboard} |
| 3641 |
everywhere instead of \cs{showboard} etc. |
| 3642 |
|
| 3643 |
\subsection{\packagename{texmate}} |
| 3644 |
|
| 3645 |
The new \packagename{texmate} version use \skaksty to follow the |
| 3646 |
game. There is no problem to use \cs{chessboard} where the manual |
| 3647 |
suggest \cs{showboard}. \packagename{texmate} also defines its own |
| 3648 |
diagram commands. They use internaly \cs{showboard}. I haven't made |
| 3649 |
much tests until now, but it looks like after a simple |
| 3650 |
\lstinline+\let\showboard\chessboard+ you can use \cs{chessboard} |
| 3651 |
instead. The main problem is that you can't use the argument of |
| 3652 |
\cs{chessboard}. You will have to set the board properties with |
| 3653 |
\cs{setchessboard}. |
| 3654 |
|
| 3655 |
|
| 3656 |
\subsection{\packagename{beamer}} |
| 3657 |
|
| 3658 |
I wouldn't have thought it, but I had no problem to use |
| 3659 |
\cs{chessboard} with \packagename{beamer}. |
| 3660 |
|
| 3661 |
The following listing shows an example. If your pdf-reader can handle |
| 3662 |
annotations you can see the result in the attached file: |
| 3663 |
\attachfile{chessboard_and_beamer.pdf} |
| 3664 |
|
| 3665 |
\begin{lstlisting} |
| 3666 |
\documentclass{beamer} |
| 3667 |
\usepackage[T1]{fontenc} |
| 3668 |
\usepackage{chessboard, skak} |
| 3669 |
\begin{document} |
| 3670 |
|
| 3671 |
\begin{frame} |
| 3672 |
\newchessgame |
| 3673 |
\only<1->{\setchessboard{hideall,showmover=false}} |
| 3674 |
\only<2->{\setchessboard{showpieces={p,P}}} |
| 3675 |
\only<3->{\setchessboard{showpieces={K,k}}} |
| 3676 |
\only<4->{\setchessboard{showpieces={Q,q}}} |
| 3677 |
\only<5->{\setchessboard{showpieces={R,r}}} |
| 3678 |
\only<6->{\setchessboard{showpieces={B,b}}} |
| 3679 |
\only<7->{\setchessboard{showpieces={N,n}}} |
| 3680 |
\chessboard |
| 3681 |
\end{frame} |
| 3682 |
|
| 3683 |
\begin{frame} |
| 3684 |
\newchessgame\setchessboard{markstyle=border,color=blue} |
| 3685 |
\only<1>{\mainline{1.e4}} |
| 3686 |
\only<1>{\setchessboard{markfields=e4}} |
| 3687 |
\only<2>{\hidemoves{1.e4}\mainline{1... e5}} |
| 3688 |
\only<2>{\setchessboard{markfields=e5}} |
| 3689 |
\only<3>{\hidemoves{1.e4 e5}\mainline{2. Nf3}} |
| 3690 |
\only<3>{\setchessboard{markfields=f3}} |
| 3691 |
\only<4>{\hidemoves{1.e4 e5 2.Nf3}\mainline{2... Nc6}} |
| 3692 |
\only<4>{\setchessboard{markfields=c6}} |
| 3693 |
|
| 3694 |
\chessboard |
| 3695 |
\end{frame} |
| 3696 |
\end{document} |
| 3697 |
\end{lstlisting} |
| 3698 |
|
| 3699 |
\subsection{animate} |
| 3700 |
|
| 3701 |
It also possible to use animate to get «moving» boards (you need a |
| 3702 |
recent pdf-viewer to see the effect). But it is quite tiresome to |
| 3703 |
input all the moves. That's why I wrote the package |
| 3704 |
\packagename{xskak}. It offers a possibility to store all positions |
| 3705 |
of a game with \skaksty and then to loop through them. For an |
| 3706 |
example please read the documentation of \packagename{xskak}. Here an |
| 3707 |
example of the more tiresome input: |
| 3708 |
|
| 3709 |
\begin{lstlisting} |
| 3710 |
\newchessgame |
| 3711 |
\unitlength1pt |
| 3712 |
\newcommand\currentboard{% |
| 3713 |
\begin{picture}(150,150) |
| 3714 |
\put(10,10){\chessboard} |
| 3715 |
\end{picture}} |
| 3716 |
\begin{animateinline}[autoplay,loop]{1}% |
| 3717 |
\currentboard |
| 3718 |
\newframe\hidemoves{1.e4}% |
| 3719 |
\currentboard |
| 3720 |
\newframe\hidemoves{1... e5}% |
| 3721 |
\currentboard |
| 3722 |
\newframe\hidemoves{2. Nf3}% |
| 3723 |
\currentboard |
| 3724 |
\newframe\hidemoves{2... Nc6}% |
| 3725 |
\currentboard |
| 3726 |
\newframe\hidemoves{3.Bb5}% |
| 3727 |
\currentboard |
| 3728 |
\newframe\hidemoves{3... a6}% |
| 3729 |
\currentboard |
| 3730 |
\end{animateinline} |
| 3731 |
\end{lstlisting} |
| 3732 |
|
| 3733 |
|
| 3734 |
\phantomsection |
| 3735 |
\makeatletter\def\index@prologue{\section*{Index}\addcontentsline{toc}{section}{Index}}\makeatother |
| 3736 |
\printindex |
| 3737 |
\end{document} |
| 3738 |
|
| 3739 |
\end{document} |