Typesetting Chess in LATEXwith the skak Package Version 1.5.3

Torben Hoffmann e-mail: [email protected] January 8, 2018

Abstract This user guide shows how to use an enhancement to the existing A package for typesetting chess in LTEX(skak). The primary improvement over the old package is that it has become easier to typeset chess games with this new package.

1 Contents

1 Terms of Usage 3

2 Installing the skak Package 3 2.1 Using the lambda Package...... 3

3 Basic usage of the skak package 3

4 Intermediate Usage of the skak Package 5 4.1 GameManagement...... 5

5 Ornaments 7 5.1 ShowingtheBoard...... 7 5.2 HandyCommands ...... 9

6 Advanced Usage 9 6.1 TailoringoftheBoardAppearance ...... 9 6.2 SettinguptheBoard...... 11 6.3 TypesettingStyle...... 12 6.3.1 \styleA ...... 12 6.3.2 \styleB ...... 12 6.3.3 \styleC ...... 12 6.3.4 \variationstyle and \mainlinestyle ...... 13 6.3.5 \longmoves and \sanmoves ...... 13 6.4 InputLanguage...... 13

2 1 Terms of Usage

This package is distributed under the terms described in the Latex Project Public Licence, i.e.,

This software is copyright but you are granted a license which gives you, the “user” of the software, legal permission to copy, distribute, and/or modify the software. However, if you modify the software and then distribute it (even just locally) you must change the name of the software to avoid confusion.

2 Installing the skak Package

I could not get the makefile to do the job, so if someone could help me out on this I would be very glad indeed. Basically all you have to do is to follow the guidelines in the makefile. First you create all the required directories (stated in the install section of the makefile) and then you run the make install command. Remember to run texhash after you have updated your texmf tree. Sorry that it is not working 100%— I just do not have the time for it right now. If you cannot get the things working just put the files where TEXand the other tools can find them and you will be just fine. For Windows user I can recommend the MikTeX installation since it has skak as a package and all you have to do is to use the MikTeX installation tools and select installation of skak and you’re up and running. A Ultimately the skak package should be documented using the LTEXstandard documentation, but that is a major undertaking that will not happen right now.

2.1 Using the lambda Package The skak package uses the lambda package to do some of the hard processing necessary to allow the PGN notation as input — since it is not standard in A LTEXdistributions it is included in the distribution of the skak package.

3 Basic usage of the skak package

Once the skak package has been installed you only need to know very few things in order to produce nicely typeset chess games:

• write \usepackage{skak} in the preamble.

• the \newgame command.

• the \mainline command.

3 • the \variation command. • the \showboard command.

As an example I will describe some moves from the opening — please note that the comments are just idle talk. In the left column the input is shown and the corresponding output is shown in the right column.

1 e4 e5 2 Nf3 Nc6 3 Bb5 8 rZblkans 7 opopZpop 6 0ZnZ0Z0Z 1 \newgame 5 ZBZ0o0Z0 2 \mainline{1.e4 e5 2. Nf3 Nc6 3.Bb5} 3 4 0Z0ZPZ0Z 4 \showboard 3 Z0Z0ZNZ0 2 POPO0OPO 1 SNAQJ0ZR abcdefgh

The \newgame command sets up the internal board or a new game. The \mainline command does two things: it typesets the moves and updates the board so that \showboard will show the current board position.

3. . . a6 Rarely used these days, 3... Nf6 is more in fashion since blah blah... 4 Ba4 1 \mainline{3...a6} \savegame{pap1} 8 rZblkans 2 Rarely used these days, 7 ZpopZpop 3 \variation {3... Nf6} is more in 4 fashion since blah blah ... 6 pZnZ0Z0Z 5 \mainline{4.Ba4} 5 Z0Z0o0Z0 6 4 BZ0ZPZ0Z 7 \showboard 3 Z0Z0ZNZ0 2 POPO0OPO 1 SNAQJ0ZR abcdefgh

This example shows that if it is black to move the move number shoud be followed by three periods. Furthermore, it also shows that the \variation command merely typesets the moves — it does not update the board, but apart from that it expects the same input as \mainline.

4 The four commands introduced in this section will enable you to comment your games with minimal effort and still get great results — in fact most chess books can be writen using only these commands! But the skak package offers a lot more that can make chess typesetting easier for your — these features are the topics of the next two sections.

4 Intermediate Usage of the skak Package

This section describes how to

• do game management,

• add ornaments to the board and

• controlling some aspects of showing the board.

4.1 Game Management Returning to the Ruy Lopez example suppose you want to go into details about a number of variations after white’s third move, preferably showing the board in all the lines you describe. One way to do this is to use the \hidemoves command like this:

1 e4 e5 2 Nf3 Nc6 3 Bb5 8 rZblkans 7 opopZpop 6 0ZnZ0Z0Z 1 \newgame 5 ZBZ0o0Z0 2 \mainline{1.e4 e5 2. Nf3 Nc6 3.Bb5} 3 4 0Z0ZPZ0Z 4 \showboard 3 Z0Z0ZNZ0 2 POPO0OPO 1 SNAQJ0ZR abcdefgh

5 3. . . a6 blah blah 8 rZblkans 7 ZpopZpop 6 pZnZ0Z0Z 1 \mainline{3...a6} blah blah 5 ZBZ0o0Z0 2 4 0Z0ZPZ0Z 3 \showboard 3 Z0Z0ZNZ0 2 POPO0OPO 1 SNAQJ0ZR abcdefgh

3... Nge7 blah blah

8 rZblka0s 7 opopmpop 1 \newgame 6 0ZnZ0Z0Z 2 \hidemoves{1.e4 e5 2. Nf3 Nc6 3.Bb5} 5 ZBZ0o0Z0 3 \mainline{3...Nge7} blah blah 4 0Z0ZPZ0Z 4 3 Z0Z0ZNZ0 5 \showboard 2 POPO0OPO 1 SNAQJ0ZR abcdefgh

This is, admittedly, a labourious way of doing it, but the example shows how \hidemoves can fast-forward you to any point in a game. skak offers you ways of storing game positions

• in memory or

• in a file.

The former is done using the \storegame and \restoregame commands like this:

6 1 e4 e5 2 Nf3 Nc6 3 Bb5 3...a6 4 Ba4 b5 8 rZblkans 7 Z0opZpop 6 pZnZ0Z0Z 5 ZpZ0o0Z0 4 BZ0ZPZ0Z 1 \newgame 3 Z0Z0ZNZ0 2 \mainline{1.e4 e5 2. Nf3 Nc6 3.Bb5} 2 POPO0OPO 3 \storegame{game1} 4 \mainline{3...a6 4.Ba4 b5} 1 SNAQJ0ZR 5 abcdefgh 6 \showboard 3... Bd7 7 \restoregame{game1} 8 rZ0lkans 8 9 \mainline{3...Bd7} 7 opobZpop 10 \showboard 6 0ZnZ0Z0Z 5 ZBZ0o0Z0 4 0Z0ZPZ0Z 3 Z0Z0ZNZ0 2 POPO0OPO 1 SNAQJ0ZR abcdefgh

Saving and loading to/from a file is the same just with the commands \savegame and \loadgame.

5 Ornaments 5.1 Showing the Board We have already seen \showboard in action, but is is possible to alter the way the board looks like. With the \mover1 command one can request that a little marker is shown next to the board indicating who is to move next.

1\mover only works if the skak is loaded with the ps option.

7 8 rmblkans 7 opopopop 6 0Z0Z0Z0Z 5 Z0Z0Z0Z0 1 \newgame 2 4 0Z0Z0Z0Z 3 \showboard 3 Z0Z0Z0Z0 2 POPOPOPO 1 SNAQJBMR abcdefgh

1 d4 8 rmblkans 7 opopopop 6 0Z0Z0Z0Z 1 \mainline{1.d4} 5 Z0Z0Z0Z0 2 4 0Z0O0Z0Z 3 \showboard 3 Z0Z0Z0Z0 2 POPZPOPO 1 SNAQJBMR abcdefgh

This can be turned off with \moveroff. You can also remove the notation around the board using \notationoff which gives this appearance:

rmblkans opopopop

0Z0Z0Z0Z 1 \newgame Z0Z0Z0Z0 2 \notationoff 0Z0Z0Z0Z 3 \showboard Z0Z0Z0Z0 POPOPOPO SNAQJBMR

The notation is added again after one has issued \notationon. A more elaborate explanation of how the appearance of the notation around the board is configured can be found in [?]. Although it is rarely seen is chess books skak offers the possibility of showing the board from black’s perspective using the \showinverseboard command.

8 8 rmblkans 7 opopopop 6 0Z0Z0Z0Z

5 Z0Z0Z0Z0 1 \newgame 4 0Z0Z0Z0Z 2 \showboard 3 Z0Z0Z0Z0 2 POPOPOPO 1 SNAQJBMR abcdefgh

If you are writing about an opening from black’s point of view this com- mand/feature could be a welcome refreshment in presentation style.

5.2 Handy Commands By requst of users and own usage a couple of handy commands have been added to skak that you might find useful too. \wmove{move } typesets a single move, whereas \bmove{move } does the same only with leading ellipses (see 6for in-depth explanation). This is useful for short remarks like:

... Nd4 would have been better. 1 \bmove{Nd4} would have been better.

\lastmove is a shorthand for commenting on the last move made:

1 \newgame 1 a3 2 \mainline{1.a3} 1 a3 is bad. 3 4 \lastmove{} is bad.

6 Advanced Usage

This section will describe some features of the skak package that allows you to control a lot with regards to the typesetting of moves as well as how the board is shown. Furthermore, we will take a look at how the board is set up in arbitrary positions and how the input language can be changed.

6.1 Tailoring of the Board Appearance In additon to the ornaments and showing the board upside down described in 4 one can choose to show only a subset of the pieces actually on the board. The simple commands \showonlywhite and \showonlyblack shows only one colour on the board:

9 1 e4 e5 2 Nf3 Nc6 3 Bb5 8 0Z0Z0Z0Z 7 Z0Z0Z0Z0 1 \newgame 6 0Z0Z0Z0Z 2 \mainline{1.e4 e5 2. Nf3 Nc6 3.Bb5} 5 ZBZ0Z0Z0 3 4 0Z0ZPZ0Z 4 \showonlywhite 3 Z0Z0ZNZ0 5 \showboard 2 POPO0OPO 1 SNAQJ0ZR abcdefgh

8 rZblkans 7 opopZpop 6 0ZnZ0Z0Z

5 Z0Z0o0Z0 1 \showonlyblack 4 0Z0Z0Z0Z 2 \showboard 3 Z0Z0Z0Z0 2 0Z0Z0Z0Z 1 Z0Z0Z0Z0 abcdefgh

This is often used when describing openingswhere one wants to focus on the merrits of the piece set-up on one side without considering how the other side is positioned. In addition to the commands for showing only one colour it is also possible to show any subset of the pieces on the board using the \showonly command that takes a comma sperated list of piece names as argument:

The structure is now like this: 8 0Z0Z0Z0Z 7 opopZpop 1 The pawn structure is 6 0Z0Z0Z0Z 2 now like this: 5 Z0Z0o0Z0 3 4 \showonly{P,p} 4 0Z0ZPZ0Z 5 \showboard 3 Z0Z0Z0Z0 2 POPO0OPO 1 Z0Z0Z0Z0 abcdefgh

10 The piece names are the standard English name with the addition that white pieces are denoted by upper case and black’s by lowercase. Pawns are P and p. It is also possible to do the opposite of \showonly using \showallbut:

8 rZblkans 7 Z0Z0Z0Z0 6 0ZnZ0Z0Z

5 ZBZ0Z0Z0 1 \showallbut{P,p} 4 0Z0Z0Z0Z 2 \showboard 3 Z0Z0ZNZ0 2 0Z0Z0Z0Z 1 SNAQJ0ZR abcdefgh

6.2 Setting up the Board So far we have only looked how to start a new game, but you can also set up the board in any position using the command \fenboard: Forsyth-Edwards Notation (FEN) is a standard used to describe chess po- sitions. It starts with a description of the contents of the ranks on the board. The ranks are separted by a slash starting with the eighth row, so if you want to write down the FEN of a position you should be seated as white and work your way dow the board. The pieces are designated using the stardard English piece names. After the position of the pieces the following information is given separated by spaces:

• who it is to move (w or b).

• castling options left for white. - for none, and K and Q for options to castle kingside or queenside for white and k and q for black

• en passant square, if applicable otherwise a -. • number of halfmoves since the last capture.

• the move number.

11 4

1 \fenboard{r5k1/1b1p1ppp/p7/1p1Q4/ 8 rZ0Z0ZkZ 2 2p1r3/PP4Pq/BBP2b1P/R4R1K w − − 0 20} 7 ZbZpZpop 3 4 \mbox{} 6 pZ0Z0Z0Z 5 \bigskip 5 ZpZQZ0Z0 6 4 0Z0ZPZ0Z 7 \showboard 3 OPZ0Z0Oq 8 9 2 BAPZ0a0O 10 \mainline{20.Qxb7 Rae8 21.Qd5} 1 S0Z0ZRZK abcdefgh 20 QXb7 Rae8 21 Qd5

6.3 Typesetting Style There are a couple of ways to configure how the move are typeset as described in the following.

6.3.1 \styleA The \styleA will switch the typesetting to the way it has been the standard in Denmark and — I believe — Germany.

1 \newgame 2 \styleA 1. e4, c5 2. Nf3, Nc6 3 4 \mainline{1.e4 c5 2.Nf3 Nc6}

6.3.2 \styleB The style selected by \styleB is the default one.

1 \newgame 2 \styleB 1 e4 c5 2 Nf3 Nc6 3 4 \mainline{1.e4 c5 2.Nf3 Nc6}

6.3.3 \styleC The style selected by \styleC is an elaboration on \styleB: it typesets the moves line by line for each move for the mainline but on the same line for variations — this style is used in many books these days, but look the best in a two-column setting where the linewidth is small.

12 1 \newgame 1 e4 c5 2 \styleC 2 Nf3 Nc6 3 4 \mainline{1.e4 c5 2.Nf3 Nc6} Interesting how 2...d6 is blah blah. 5 6 Interesting how \variation {2... d6} is blah blah.

6.3.4 \variationstyle and \mainlinestyle Configuration of these commands allows for total control of the typesetting of the mainline and variations, they default to: \def\mainlinestyle{\bfseries}% could also contain % definitions of the % various style options \def\variationstyle{}% as with mainlinestyle They are used by \styleC to control the switching back and forth between a tabbed environment and normal typesetting: \def\mainlinestyle{\styleC\bfseries} \def\variationstyle{\styleB}

6.3.5 \longmoves and \sanmoves The \longmoves command will ensure that the full move, i.e., including the from square is typeset. This is also know as algebraic notation — can be quite handy when writing about chess for children or other newcommers to chess notation.

1 \newgame 2 \longmoves 1 e2-e4 c7-c5 2 Ng1-f3 Nb8-c6 3 4 \mainline{1.e4 c5 2.Nf3 Nc6} The \shortmoves command returns things to normal.

6.4 Input Language The skak package by default uses the English letters for the pieces, i.e., K for King, Q for , R for Rook, B for Bishop, N for Knight and P for Pawn. The \newskaklanguage command makes it possible to define other lan- guages than English, e.g., suppose I want to use the Danish piece letters:

1 \newskaklanguage{danish}{KDTLSB} 2 3 \skaklanguage[danish] 1 e4 c5 2 Nf3 Nc6 4 5 \newgame 6 \mainline{1.e4 c5 2.Sf3 Sc6}

13