> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/latex/field-specific/05-chess-notation.md).

# Chess notation

## Introduction

This article explores the basics of chess typesetting, including [brief reviews/summaries of some chess conventions](#chess-conventions-a-brief-review) that you might encounter in LaTeX chess package documentation. Readers who don't need that introductory material can jump straight to the [LaTeX package examples](#a-first-example-with-the-xskak-package).

## One package to rule them all

The CTAN repository lists a number of [chess-related packages](https://ctan.org/search?phrase=chess\&ext=false&_PKG=\&PKG=on&_AUTHORS=\&AUTHORS=on&_TOPICS=\&TOPICS=on&_FILES=&_PORTAL=\&PORTAL=on\&wildcard=on\&max=32), so you may be wondering which one to choose? This article uses the [`xskak` package](https://ctan.org/pkg/xskak?lang=en), which is highly recommended for typesetting chess due to its wide range of features, extensive configuration options and excellent documentation. `xskak` loads and extends the original [`skak` package](https://ctan.org/pkg/skak?lang=en) and also loads the [`chessboard` package](https://ctan.org/pkg/chessboard?lang=en) which provides a huge range of options to configure and create chess boards.

The examples provided by this article cannot substitute for the *excellent* documentation accompanying the [`xskak`](https://texdoc.org/serve/xskak/0) and [`chessboard`](https://texdoc.org/serve/chessboard/0) packages, which we strongly encourage you to browse, review and explore because both sets of documentation contain numerous, and very helpful, examples.

**Note**: Both `skak` and `xskak` can parse and typeset chess games in (a subset of) the [Portable Game Notation (PGN)](#portable-game-notation). `xskak` extends the subset of PGN supported by `skak`.

**Trivia**: skak is the Danish word for chess.

### Some notes

Here are some important points noted in the `xskak` documentation:

> `xskak` will load the package `skak` without option (and won’t pass options to it). So, if you want to load `skak` with options, you must do it before loading the package `xskak`.

> `xskak` is an extension (and not a replacement) the **main work is still done by the package `skak`**... please read first the documentation of the package `skak`...

* **Note**: Among the chess-related packages [listed on CTAN](https://ctan.org/search?phrase=chess\&ext=false&_PKG=\&PKG=on&_AUTHORS=\&AUTHORS=on&_TOPICS=\&TOPICS=on&_FILES=&_PORTAL=\&PORTAL=on\&wildcard=on\&max=32) is one called [`skaknew`](https://ctan.org/pkg/skaknew). Despite its name, the `skaknew` package is *not* a new or enhanced version of the original `skak` package: it is set of Type 1 chess fonts. The `xskak` package utilizes the `skaknew` fonts so there's no need for you to manually load them into your project.

### Minimal xskak example

To "set the scene", and without further explanation, here is a minimal `xskak` package example that typesets two chess boards: one is empty, the other has all the chess pieces in their initial positions:

```latex
\documentclass{article}
% Note: you only need to load xskak,
% not the skak or chessboard packages.
\usepackage{xskak}
\begin{document}
% This \chessboard command draws
% an empty chess board: the option
% showmover=false will be discussed
% later in the article
\chessboard[showmover=false]
% The \newchessgame command
% initializes a new game:
\newchessgame
% Because a new game was initialized,
% \chessboard now draws a
% board with chess pieces:
\chessboard
The small white square to the right of the second board is called the \textit{mover}.
\end{document}
```

[Open this example in Overleaf](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=A+basic+xskak+package+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%25+Note%3A+you+only+need+to+load+xskak%2C%0A%25+not+the+skak+or+chessboard+packages.%0A%5Cusepackage%7Bxskak%7D%0A%5Cbegin%7Bdocument%7D%0A%25+This+%5Cchessboard+command+draws+%0A%25+an+empty+chess+board%3A+the+option%0A%25+showmover%3Dfalse+will+be+discussed%0A%25+later+in+the+article%0A%5Cchessboard%5Bshowmover%3Dfalse%5D%0A%25+The+%5Cnewchessgame+command+%0A%25+initializes+a+new+game%3A%0A%5Cnewchessgame%0A%25+Because+a+new+game+was+initialized%2C+%0A%25+%5Cchessboard+now+draws+a+%0A%25+board+with+chess+pieces%3A%0A%5Cchessboard%0AThe+small+white+square+to+the+right+of+the+second+board+is+called+the+%5Ctextit%7Bmover%7D.%0A%5Cend%7Bdocument%7D)

This `xskak` example produces the following output:

![](/files/3lCdrREX7LlcT3zM8TGO)

## Chess conventions: a brief review

For the benefit of readers new to chess, especially typesetting it, the following sections provide *brief* introductions to topics and conventions you will encounter within LaTeX chess packages and their accompanying documentation. Readers familiar with chess conventions can skip these sections and jump to the LaTeX examples.

### Portable Game Notation

The skak and xskak packages support a subset of the [Portable Game Notation](https://en.wikipedia.org/wiki/Portable_Game_Notation) (PGN), a standard which was invented circa 1994 by [Steven Edwards](https://www.chessprogramming.org/Steven_Edwards). The original PGN specification, dated 1994, is [available on archive.org](https://archive.org/details/pgn-standard-1994-03-12). A direct link to the standard is <https://tim-mann.org/Standard>.

According to [the text of the PGN standard](https://tim-mann.org/Standard):

> PGN is "Portable Game Notation", a standard designed for the representation of chess game data using ASCII text files. PGN is structured for easy reading and writing by human users and for easy parsing and generation by computer programs... PGN is proposed as a universal portable representation for data interchange.

Note that PGN files are designed for the *interchange of **game** data*; i.e., PGN files are designed to contain *complete game* information—such as the name of the players, details of the event/date etc., together with a record, in algebraic notation, of *all moves* in the game.

**Note**: For another short introduction to PGN visit <http://www.enpassant.dk/chess/palview/p3manual/p3pgn.htm>

### Chess board ranks and files

A chess board is an 8×8 grid of squares which could, normally, be described as 8 horizontal rows and 8 vertical columns; however, a different terminology is used to describe a chess board:

* there are 8 horizontal ***ranks*** (instead of rows)
* there are 8 vertical ***files*** (instead of columns)

Each square on the chess board can be identified (named) using [several conventions](https://en.wikipedia.org/wiki/Chessboard#Board_notation) but the [algebraic notation](https://en.wikipedia.org/wiki/Algebraic_notation_\(chess\)) (coordinate system) is the accepted international standard.

### Algebraic notation

Within the algebraic notation system the ranks and files are labelled as follows:

* the 8 horizontal ***ranks*** are labelled using the numbers `1` to `8`
* the 8 vertical ***files*** are labelled using the letters `a` to `h`.

The next diagram shows a chess board with the algebraic notation labels used for the files and ranks:

![](/files/lAC4EiPsSFQ8MHhHwVzE)

Each square on the chess board is at the intersection of a particular file (column) and rank (row): the corresponding file and rank value can be used as coordinates to uniquely identify each square for use in describing the location and movement of chess pieces.

By way of example, the following diagram shows the square located at **e7** followed by a second chess board which enumerates the location of all 64 squares:

![](/files/zBwGLnI9EWfU2VjnrvAk)

If you are new to chess, the Wikipedia page [Algebraic notation](https://en.wikipedia.org/wiki/Algebraic_notation_\(chess\)) contains some useful background information, some of which we summarize below.

### Notation for chess pieces

Each chess piece type, usually excepting pawns, is identified by an uppercase letter which can vary according the language being used. English-speaking players use the following letters:

| Letter | Pieces |
| ------ | ------ |
| K      | King   |
| Q      | Queen  |
| R      | Rook   |
| B      | Bishop |
| N      | Knight |

In standard algebraic notation pawns are not *usually* identified by an uppercase letter; instead, they are recognizable by the *absence* of an uppercase letter. However, that convention is not always adopted; the uppercase letter P may be used to identify pawns. In [Forsyth-Edwards Notation (FEN)](#forsyth-edwards-notation-fen) uppercase and lowercase letters are used to represent chess pieces.

### Notation for an individual move

To record the movement of a chess-piece you need to identify the piece and its destination square. That can be achieved by using the piece's uppercase letter plus the coordinates of the destination square.

**Note**: when describing a pawn move, a letter indicating the piece is a pawn is not *usually* used; only the destination square is *usually* given, as shown in the following examples:

* *non-pawn* moves:
  * **Be5**: **B**ishop moves to square **e5**
  * **Nf3**: k**N**night moves to square **f3**
* *pawn* moves:
  * **c5**: a pawn moves to square **c5**
  * **Note**: in certain circumstances (e.g., some LaTeX commands) pawns *are identified* by uppercase letter **P**; so **c5** might be written **Pc5**.

#### Three dots (...) black piece move indication

Section 8.2.2.2 of the [Portable Game Notation standard](https://tim-mann.org/Standard) explains the use of three dots (...) after a move number indicator (e.g., **3...e6**):

> A white move number indication is formed from the integer giving the fullmove number with a single period character appended. A black move number indication is formed from the integer giving the fullmove number with ***three period characters appended***.

### Convention for a series of moves

As explained in the Wikipedia article on [Algebraic notation](https://en.wikipedia.org/wiki/Algebraic_notation_\(chess\)#Formatting), to describe a series of moves:

* each individual move *usually* uses uppercase letters for non-pawn pieces, although, as noted above, in some circumstances (conventions) a capital P might be used to indicate a pawn move.
* a series of chess moves is a sequence of `<white piece move> <black piece move>` pairs—note that each move pair is numbered (see example below)

### Other chess notations: FAN and FEN

#### Figurine Algebraic Notation (or FAN)

Language-specific letters used to represent chess pieces are often replaced by universally recognized symbols representing chess pieces. This symbolic representation is known as Figurine Algebraic Notation, or FAN. For example, the symbol ♞ (or ♘) can be used in place of N (for kNight).

The Unicode specification encodes chess characters within the [Miscellaneous Symbols set](https://www.unicode.org/charts/PDF/U2600.pdf). The following table lists the Unicode value, name, and representative symbol for each chess character—the actual glyphs (character designs) used to display the chess symbols will depend on your device/browser fonts settings.

| <p>Representative symbol<br>(glyph)</p> | <p>Unicode value<br>(in HEX)</p> | <p>Unicode character name<br>(formal)</p> |
| --------------------------------------- | -------------------------------- | ----------------------------------------- |
| ♔                                       | 2654                             | WHITE CHESS KING                          |
| ♕                                       | 2655                             | WHITE CHESS QUEEN                         |
| ♖                                       | 2656                             | WHITE CHESS ROOK                          |
| ♗                                       | 2657                             | WHITE CHESS BISHOP                        |
| ♘                                       | 2658                             | WHITE CHESS KNIGHT                        |
| ♙                                       | 2659                             | WHITE CHESS PAWN                          |
| ♚                                       | 265A                             | BLACK CHESS KING                          |
| ♛                                       | 265B                             | BLACK CHESS QUEEN                         |
| ♜                                       | 265C                             | BLACK CHESS ROOK                          |
| ♝                                       | 265D                             | BLACK CHESS BISHOP                        |
| ♞                                       | 265E                             | BLACK CHESS KNIGHT                        |
| ♟                                       | 265F                             | BLACK CHESS PAWN                          |

#### Forsyth-Edwards Notation (FEN)

As noted, PGN is used for the storage and interchange of *entire games*, including all moves played in that game. By contrast, the [Forsyth-Edwards Notation (FEN)](https://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notation) provides a snapshot of a game at some point in time. FEN notation makes use of uppercase and lowercase letters to represent chess pieces:

* white pieces are identified by uppercase letters (PNBRQK)
* black pieces are identified by lowercase letters (pnbrqk)

where P is for a white pawn and p is for a black pawn.

A detailed discussion of FEN, and comparing it to PGN, is outside the scope of this article. Readers wanting to better understand the differences between PGN and FEN may wish to explore the following video:

{% embed url="<https://www.youtube.com/embed/3PvmsmqKF_I>" %}

## A first example with the xskak package

### Making your moves

To typeset chess moves as the game progresses you use the command `\mainline{*list of moves*}` where `*list of moves*` is expressed in [algebraic chess notation](#algebraic-notation). We'll demonstrate typesetting the following sequence of moves:

1. **e4 e5**: white pawn moves to **e4**, black pawn moves to **e5**
2. **Nf3 Nc6**: white k**N**ight moves to **f3**, black k**N**ight moves to **c6**
3. **Bb5 a6**: white **B**ishop moves to **b5**, black pawn moves to **a6**

This sequence of moves can be written using the [`xskak` package](https://ctan.org/pkg/xskak?lang=en) command `\mainline{1.e4 e5 2.Nf3 Nc6 3.Bb5 a6}`—note that each move–pair is numbered (e.g., `**1.**e4 e5`):

```latex
\documentclass{article}
\usepackage{xskak}
\begin{document}
\newchessgame
\mainline{1.e4 e5 2.Nf3 Nc6 3.Bb5 a6}
\showboard % A skak package command. Future examples will use \chessboard[...]
\end{document}
```

[Open this example in Overleaf](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=First+xskak+package+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bxskak%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cnewchessgame%0A%5Cmainline%7B1.e4+e5+2.Nf3+Nc6+3.Bb5+a6%7D%0A%5Cshowboard+%25+A+skak+package+command.+Future+examples+will+use+%5Cchessboard%5B...%5D%0A%5Cend%7Bdocument%7D)

This `xskak` example produces the following output:

![](/files/U1YIHVdT11rLBKPI1dih)

The following commands are used:

* **`\newchessgame[〈key=value list〉]`**: starts a new game and initializes the chess board. The `[〈key=value list〉]` is optional so you can also write `\newchessgame` and rely on the default board setup. The set of optional keys is listed is the [`xskak` documentation](https://texdoc.org/serve/xskak/0).
* **`\mainline{〈list of chess moves〉}`**: processes the `〈list of chess moves〉` and updates the board so that `\showboard` (or `\chessboard`) typesets the board's current status.
* **`\showboard`**: typesets the chess board. The `\showboard` command originates from the underlying `skak` package, which `xskak` extends. The [`chessboard` package](https://ctan.org/pkg/chessboard?lang=en), which is loaded by `xskak`, provides the very versatile **`\chessboard[〈key=value list〉]`** command to which the `xskak` package adds additional keys. Because `\chessboard[...]` is intended to replace `\showboard`, future examples in this article will only use the `\chessboard[...]` command.

### Introducing the \chessboard command

The command **`\chessboard[〈key=value list〉]`**: typesets chess boards using an optional `〈key=value list〉`. The list of `keys` available to use is *extensive*, providing a great deal of control over the size, content, layout, design, annotation etc of chess boards. Readers are encouraged to read the excellent package documentation for [`chessboard` (PDF)](https://texdoc.org/serve/chessboard/0) and [`xskak` (PDF)](https://texdoc.org/serve/xskak/0), both of which contain numerous helpful examples—*many* more than we can demonstrate in this article.

Because the keys are optional you can write `\chessboard` which uses package default values to typeset a chess board; for example, the following code typesets two boards using `\chessboard` without any options. Further annotations, added manually in Inkscape, show the *movers* (here as squares) that are typeset by default:

```latex
\documentclass{article}
\usepackage{xskak}
\begin{document}
\newchessgame
\mainline{1.e4 e5 2.Nf3 Nc6 3.Bb5}
\chessboard % instead of \showboard

\newchessgame
\mainline{1.e4 e5 2.Nf3 Nc6 3.Bb5 a6}
\chessboard % instead of \showboard
\end{document}
```

[Open this example in Overleaf.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=chessboard+command+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bxskak%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cnewchessgame%0A%5Cmainline%7B1.e4+e5+2.Nf3+Nc6+3.Bb5%7D%0A%5Cchessboard+%25+instead+of+%5Cshowboard%0A%0A%5Cnewchessgame%0A%5Cmainline%7B1.e4+e5+2.Nf3+Nc6+3.Bb5+a6%7D%0A%5Cchessboard+%25+instead+of+%5Cshowboard%0A%5Cend%7Bdocument%7D)

The following graphic shows the two chess boards produced by the code above, both were typeset using `\chessboard`:

![](/files/JG7tZVNAnF9cF5CVo4bZ)

Unsurprisingly, various keys are provided to control the mover, including showing or hiding it; for example, to hide the mover you can use the `showmover` key with a value of `false`:

```latex
\documentclass{article}
\usepackage{xskak}
\begin{document}
\newchessgame
\mainline{1.e4 e5 2.Nf3 Nc6 3.Bb5 a6}\par
\chessboard[showmover=false] % Hide the mover
\end{document}
```

[Open this example in Overleaf.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Hiding+the+chessboard+mover\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bxskak%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cnewchessgame%0A%5Cmainline%7B1.e4+e5+2.Nf3+Nc6+3.Bb5+a6%7D%5Cpar%0A%5Cchessboard%5Bshowmover%3Dfalse%5D+%25+Hide+the+mover%0A%5Cend%7Bdocument%7D)

This example produces the following output—a chess board without the mover:

![](/files/V2760JGEJozbAtrNtrKw)

The [`chessboard` package documentation (PDF)](https://texdoc.org/serve/chessboard/0) provides a list of keys for customizing the mover, together with a note on how to design your own mover!

## Additional xskak examples

### Text comments

The PGN specification supports making comments using braces around the text of the comment: `{〈Text〉}`; however, the `xskak` package prefers text comments to be written as `\xskakcomment{〈Text〉}`, as demonstrated in the following example:

```latex
\documentclass{article}
\usepackage{xskak}
\begin{document}
\newchessgame %Start a new chess game
\mainline{1.e4 e5 2.Nf3 Nc6 3.Bb5 a6 \xskakcomment{ This is a comment. }}\vspace{3mm}

\chessboard
\end{document}
```

[Open this example in Overleaf.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=xskak+chess+comment+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bxskak%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cnewchessgame+%25Start+a+new+chess+game%0A%5Cmainline%7B1.e4+e5+2.Nf3+Nc6+3.Bb5+a6+%5Cxskakcomment%7B+This+is+a+comment.+%7D%7D%5Cvspace%7B3mm%7D%0A%0A%5Cchessboard%0A%5Cend%7Bdocument%7D)

This example produces the following output:

![](/files/h36QluECcK4vYfWy3WfG)

### Initializing a board using FEN notation

You can use FEN to start the board in any position. The following example uses the `setfen` key in a `\chessboard` command to demonstrate a FEN example taken from the `skak` package documentation:

```latex
\documentclass{article}
\usepackage{xskak}
\begin{document}
\newchessgame
\chessboard[setfen=r5k1/1b1p1ppp/p7/1p1Q4/2p1r3/PP4Pq/BBP2b1P/R4R1K w - - 0 20]
\end{document}
```

[Open this example in Overleaf.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=FEN+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bxskak%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cnewchessgame%0A%5Cchessboard%5Bsetfen%3Dr5k1%2F1b1p1ppp%2Fp7%2F1p1Q4%2F2p1r3%2FPP4Pq%2FBBP2b1P%2FR4R1K+w+-+-+0+20%5D%0A%5Cend%7Bdocument%7D)

This example produces the following output:

![](/files/lJ2aBf5VsydLCarTXGjC)

The FEN notation populates the board starting with the uppermost rank (number 8) and works downwards to populate subsequent ranks. For example, to initialize the board above rank 8 is described using **r5k1**:

* **r**ook
* **5** empty squares
* the **k**ing
* **1** empty square

hence using the notation **r5k1**. Note the use of lowercase letters to describe black chess pieces together with the use of uppercase **P** for white pawns and lowercase **p** for black pawns.

### Using \lastmove

The `\lastmove` command can be used for commenting on the last move made:

```latex
\documentclass{article}
\usepackage{xskak}
\begin{document}
\newchessgame
\mainline{1.e4}

\chessboard

\lastmove{} is the most common opening move.
\end{document}
```

[Open this example in Overleaf.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=xskak+lastmove+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bxskak%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cnewchessgame%0A%5Cmainline%7B1.e4%7D%0A%0A%5Cchessboard%0A%0A%5Clastmove%7B%7D+is+the+most+common+opening+move.%0A%5Cend%7Bdocument%7D)

This example produces the following output:

![](/files/969wlpTZLhf6gbNjg6E5)

### Variations and an example of the ... notation

The following reproduces an example contained in the `skak` package documentation, updated to use `xskak` commands. Here, we see an example of the `\variation` command and the three-dot (...) syntax [used to indicate a black move](#three-dots-black-piece-move-indication):

```latex
\documentclass{article}
\usepackage{xskak}
\begin{document}
\newchessgame
\mainline{1.e4 e5 2.Nf3 Nc6 3.Bb5}

\chessboard

\mainline{3...a6}

A variant \variation{3...Nf6} is used here to show a \texttt{\string\variation} command.

\mainline{4.Ba4}

\chessboard
\end{document}
```

[Open this example in Overleaf.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=xskak+variations+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bxskak%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cnewchessgame%0A%5Cmainline%7B1.e4+e5+2.Nf3+Nc6+3.Bb5%7D%0A%0A%5Cchessboard%0A%0A%5Cmainline%7B3...a6%7D%0A%0AA+variant+%5Cvariation%7B3...Nf6%7D+is+used+here+to+show+a+%5Ctexttt%7B%5Cstring%5Cvariation%7D+command.%0A%0A%5Cmainline%7B4.Ba4%7D%0A%0A%5Cchessboard%0A%5Cend%7Bdocument%7D)

This example produces the following output:

![](/files/A0TruSKfYlwigZdaVmFX)

### Showing only certain chess pieces

Because `xskak` loads the `chessboard` package you can use the extremely powerful **`\chessboard[〈key=value list〉]`** command to show or hide areas of the board, or collections of chess pieces, that are of interest. The [chessboard documentation](https://texdoc.org/serve/chessboard/0) contains numerous examples, such as those reproduced below.

#### Using keys to hide certain fields

This example uses the keys `hideall`, `showpieces` and `addpieces`:

```latex
\documentclass{article}
\usepackage{xskak}
\begin{document}
\newchessgame
\chessboard[hideall,
showpieces={P,p},
addpieces=pe5]
\end{document}
```

[Open this example in Overleaf](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Showing+selected+pieces+in+xskak+example+1\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bxskak%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cnewchessgame%0A%5Cchessboard%5Bhideall%2C%0Ashowpieces%3D%7BP%2Cp%7D%2C%0Aaddpieces%3Dpe5%5D%0A%5Cend%7Bdocument%7D)

This `xskak` example produces the following output:

![](/files/3zEgXHf62xaaciOs0zW3)

This example uses the keys `hidefiles`, `showfiles` and `showranks`:

```latex
\documentclass{article}
\usepackage{xskak}
\begin{document}
\newchessgame
\def\myfiles{a,b}
\chessboard[hidefiles=\myfiles,
addpieces=Ra2,
showfiles=a,
showranks=2]
\end{document}
```

[Open this example in Overleaf](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Showing+selected+pieces+in+xskak+example+2\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bxskak%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cnewchessgame%0A%5Cdef%5Cmyfiles%7Ba%2Cb%7D%0A%5Cchessboard%5Bhidefiles%3D%5Cmyfiles%2C%0Aaddpieces%3DRa2%2C%0Ashowfiles%3Da%2C%0Ashowranks%3D2%5D%0A%5Cend%7Bdocument%7D)

This `xskak` example produces the following output:

![](/files/WEPYlTCJtGz6evNKONid)

#### Using keys to hide all white or all black pieces

The following example demonstrates the keys `hidewhite` and `hideblack`:

```latex
\documentclass{article}
\usepackage{xskak}
\begin{document}
\newchessgame
\mainline{1.e4 e5 2.Nf3 Nc6}\chessboard[hidewhite]

\newchessgame
\mainline{1.e4 e5 2.Nf3 Nc6}\chessboard[hideblack]
\end{document}
```

[Open this example in Overleaf](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Showing+selected+pieces+in+xskak+example+3\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bxskak%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cnewchessgame%0A%5Cmainline%7B1.e4+e5+2.Nf3+Nc6%7D%5Cchessboard%5Bhidewhite%5D%0A%0A%5Cnewchessgame%0A%5Cmainline%7B1.e4+e5+2.Nf3+Nc6%7D%5Cchessboard%5Bhideblack%5D%0A%5Cend%7Bdocument%7D)

This `xskak` example produces the following output:

![](/files/FrkT2fM27LwmPgWo4wzv)

## Further examples from tex.stackexchange

The following examples use solutions found on [tex.stackexchange.com](https://tex.stackexchange.com).

### How to highlight squares?

Source: based on <https://tex.stackexchange.com/a/215334>

```latex
\documentclass{article}
\usepackage{xskak}
\begin{document}
\newgame
\chessboard[setfen=8/8/8/3Q4/8/8/8/8 w - - 0 0,
            pgfstyle=border,markfields={d4,d6},
            color=blue!50,
            colorbackfield=c5,
            pgfstyle=color,
            opacity=0.5,
            color=red,
            markfield={d5}]
\end{document}
```

[Open this example in Overleaf.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Highlighting+chess+board+squares\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bxskak%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cnewgame%0A%5Cchessboard%5Bsetfen%3D8%2F8%2F8%2F3Q4%2F8%2F8%2F8%2F8+w+-+-+0+0%2C%0A++++++++++++pgfstyle%3Dborder%2Cmarkfields%3D%7Bd4%2Cd6%7D%2C%0A++++++++++++color%3Dblue%2150%2C%0A++++++++++++colorbackfield%3Dc5%2C%0A++++++++++++pgfstyle%3Dcolor%2C%0A++++++++++++opacity%3D0.5%2C%0A++++++++++++color%3Dred%2C%0A++++++++++++markfield%3D%7Bd5%7D%5D%0A%5Cend%7Bdocument%7D)

![](/files/ecsrzSQTwyemOj8ZSyE3)

### Creating different board styles

Source: based on <https://tex.stackexchange.com/a/358041>

```latex
\documentclass{article}
\usepackage{xskak}
\begin{document}
\storechessboardstyle{4x16}{%
  maxfield=d16,
  borderwidth=1mm,
  color=white,
  colorwhitebackfields,
  color=black,
  colorblackbackfields,
  blackfieldmaskcolor=black,
  whitepiececolor=yellow,
  whitepiecemaskcolor=red,
  blackpiececolor=cyan,
  blackpiecemaskcolor=blue,
  addfontcolors,
  pgfstyle=border,
  color=white,
  markregion=a1-d16,
  showmover=false,
  hlabelwidth=18pt,
  vlabellift=16pt}
  \chessboard[
    style=4x16,
    setpieces={Qa8,Qb4,Qc1,Qd3,Qb16,Qc12,Qa7,Qc15,qa1,qb14,qc11,qd13,qb6,qc2,qa4,qc5},
    padding=1ex,
  ]
\end{document}
```

[Open this example in Overleaf.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Creating+a+custom+chess+board\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bxskak%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cstorechessboardstyle%7B4x16%7D%7B%25%0A++maxfield%3Dd16%2C%0A++borderwidth%3D1mm%2C%0A++color%3Dwhite%2C%0A++colorwhitebackfields%2C%0A++color%3Dblack%2C%0A++colorblackbackfields%2C%0A++blackfieldmaskcolor%3Dblack%2C%0A++whitepiececolor%3Dyellow%2C%0A++whitepiecemaskcolor%3Dred%2C%0A++blackpiececolor%3Dcyan%2C%0A++blackpiecemaskcolor%3Dblue%2C%0A++addfontcolors%2C%0A++pgfstyle%3Dborder%2C%0A++color%3Dwhite%2C%0A++markregion%3Da1-d16%2C%0A++showmover%3Dfalse%2C%0A++hlabelwidth%3D18pt%2C%0A++vlabellift%3D16pt%7D%0A++%5Cchessboard%5B%0A++++style%3D4x16%2C%0A++++setpieces%3D%7BQa8%2CQb4%2CQc1%2CQd3%2CQb16%2CQc12%2CQa7%2CQc15%2Cqa1%2Cqb14%2Cqc11%2Cqd13%2Cqb6%2Cqc2%2Cqa4%2Cqc5%7D%2C%0A++++padding%3D1ex%2C%0A++%5D%0A%5Cend%7Bdocument%7D)

This `xskak` example produces the following output:

![](/files/7TIf0E8rCcRbiGsI4jy3)

## Further reading

For more information see:

* [Creating a document in LaTeX](/latex/latex-basics/01-learn-latex-in-30-minutes.md)
* [Inserting Images](/latex/more-topics/27-inserting-images.md)
* [Positioning images and tables](/latex/figures-and-tables/02-positioning-images-and-tables.md)
* [International language support](/latex/languages/03-international-language-support.md)
* [Font sizes, families, and styles](/latex/fonts/01-font-sizes-families-and-styles.md)
* [Font typefaces](/latex/fonts/02-font-typefaces.md)
* [Management in a large project](/latex/document-structure/07-management-in-a-large-project.md)
* [The `skak` package](https://ctan.org/pkg/skak?lang=en)
* [The `xskak` package](https://ctan.org/pkg/xskak?lang=en)
* [Algebraic notation in chess (on Wikipedia)](http://en.wikipedia.org/wiki/Algebraic_notation_\(chess\))
* [Forsyth-Edwards Notation (FEN) (on Wikipedia)](http://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notation)
* [The `chessboard` package](https://ctan.org/pkg/chessboard?lang=en)
* [Text of the PGN standard](https://tim-mann.org/Standard)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/latex/field-specific/05-chess-notation.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
