Chess notation
LaTeX supports chess notation by means of the package skak. This package also shows a chessboard where the entered moves are displayed.
Introduction
To start writing chess notation, the board mus be set up to the initial position.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{skak}
\begin{document}
Chess notation in \LaTeX{}
\medskip
\newgame
\showboard
\end{document}
In the example, the package skak is imported by
\usepackage{skak}
After importing the package you can use all the chess-related commands. Two of them are described below:
\newgame
- Starts a new game, sets all the pieces in the starting positions.
\showboard
- Prints the chessboard on the document.
Open an example of the skak package in ShareLaTeX
Writing a move
If you are used to algebraic chess notation, typesetting chess moves is easy. To print the moves as the game progress you must use the command \mainline
.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{skak}
\begin{document}
\mainline{1.e4}
\showboard
\lastmove{} Is the most common opening move
\mainline{1...e5 2.Nf3 Nc6 3.d4}
\showboard
\mainline{3...e5xd4 4.Bb5 a6 5.O-O}
\showboard
\end{document}
The command \mainline{}
takes as parameter a set of moves,
after several moves you can print the current state of the chessboard with the command \showboard
.
The notation for the moves is standard algebraic notation in English. See the further reading section for links about this.
The command \lastmove{}
is used to print the last move.
Open an example of the skak package in ShareLaTeX
Variations and notes
There's an additional command to print chess notation inline in normal font
\mainline{1...e5 2.Nf3 Nc6 3.d4}
\showboard
From this point, \variation{3.d3 d5} is a good but far less
aggressive alternative.
\mainline{3...e5xd4 4.Bb5 a6 5.O-O}
The command \variation{}
helps to analyse variations of a move. The number of the first move passed to this command must be the last move in the immediately previous \mainline
command. For instance, in the example 3.d4
is the last move before analysing a variation, hence 3.d3
is the first move in \variation{}
Open an example of the skak package in ShareLaTeX
Showing only some pieces
If you need to focus on only one side of the board, hiding the opposite colour will greatly help.
\mainline{1...e5 2.Nf3 Nc6 3.d4}
\showonlywhite
\showboard
From this point, \variation{3.d3 d5} is a good but far less
aggressive alternative.
\mainline{3...e5xd4 4.Bb5 a6 5.O-O}
\showonlyblack
\showboard
The commands \showonlywhite
and \showonlyblack
will show on the board only the white or black pieces, respectively.
Another feature that is helpful to analyse some moves is to show only the relevant pieces in said moves. This can be accomplished with \showonly
To the command \showonly{}
a list of comma-separated pieces must be passed as parameter inside the braces. See the reference guide for a description of the letters and the pieces they represent.
Open an example of the skak package in ShareLaTeX
Setting up the chessboard
You can set up the board in any position.
The command \fenboard{ }
uses FEN notation to set up the board (see further reading). For instance, the example above shows in the row 8 a rook, 5 empty squares, the king and 1 empty square; hence the "r5k1".
Open an example of the skak package in ShareLaTeX
Reference guide
The skak package uses the next list of letters for the piece. In the commands \showonly
and \fenboard
Upper-case letters are used for the white side and lower-case for the black side
Letter | Pieces |
---|---|
K | King |
Q | Queen |
R | Rook |
B | Bishop |
N | Knight |
P | Pawn |
Open an example of the skak package in ShareLaTeX
Further reading
For more information see:
- Creating a document in LaTeX
- Inserting Images
- Positioning images and tables
- International language support
- Font sizes, families, and styles
- Font typefaces
- Management in a large project
- The skak pckage documentation
- xskak, an extension package for skak
- Algebraic notation in chess (on Wikipedia)
- Forsyth-Edwards Notation (FEN) (on Wikipedia)
Overleaf guides
- Creating a document in Overleaf
- Uploading a project
- Copying a project
- Creating a project from a template
- Including images in Overleaf
- Exporting your work from Overleaf
- Working offline in Overleaf
- Using Track Changes in Overleaf
- Using bibliographies in Overleaf
- Sharing your work with others
- Debugging Compilation timeout errors
- How-to guides
LaTeX Basics
- Creating your first LaTeX document
- Choosing a LaTeX Compiler
- Paragraphs and new lines
- Bold, italics and underlining
- Lists
- Errors
Mathematics
- Mathematical expressions
- Subscripts and superscripts
- Brackets and Parentheses
- Fractions and Binomials
- Aligning Equations
- Operators
- Spacing in math mode
- Integrals, sums and limits
- Display style in math mode
- List of Greek letters and math symbols
- Mathematical fonts
Figures and tables
- Inserting Images
- Tables
- Positioning Images and Tables
- Lists of Tables and Figures
- Drawing Diagrams Directly in LaTeX
- TikZ package
References and Citations
- Bibliography management in LaTeX
- Bibliography management with biblatex
- Biblatex bibliography styles
- Biblatex citation styles
- Bibliography management with natbib
- Natbib bibliography styles
- Natbib citation styles
- Bibliography management with bibtex
- Bibtex bibliography styles
Languages
- Multilingual typesetting on Overleaf using polyglossia and fontspec
- International language support
- Quotations and quotation marks
- Arabic
- Chinese
- French
- German
- Greek
- Italian
- Japanese
- Korean
- Portuguese
- Russian
- Spanish
Document structure
- Sections and chapters
- Table of contents
- Cross referencing sections and equations
- Indices
- Glossaries
- Nomenclatures
- Management in a large project
- Multi-file LaTeX projects
- Hyperlinks
Formatting
- Lengths in LaTeX
- Headers and footers
- Page numbering
- Paragraph formatting
- Line breaks and blank spaces
- Text alignment
- Page size and margins
- Single sided and double sided documents
- Multiple columns
- Counters
- Code listing
- Code Highlighting with minted
- Using colours in LaTeX
- Footnotes
- Margin notes
Fonts
Presentations
Commands
Field specific
- Theorems and proofs
- Chemistry formulae
- Feynman diagrams
- Molecular orbital diagrams
- Chess notation
- Knitting patterns
- CircuiTikz package
- Pgfplots package
- Typing exams in LaTeX
- Knitr
- Attribute Value Matrices
Class files
- Understanding packages and class files
- List of packages and class files
- Writing your own package
- Writing your own class
- Tips