-
a script
run_pgn2tex.py
that generates one TeX file from one chess PGN1 match, with a chessboard for each half move, and a 'main.tex' that collects all the sections TeX file, with this you can generate one PDF out of that bunch of TeX files.- the script processes all
*.pgn
files that it find atPGN/
directory. - be aware, a PGN file can have thousends of games inside, and with this script each of its games will get a TeX file in
TEX/
directory - each game's TeX generation take about 1/2 seconds (on my old machine.)
- a TeX to PDF generation of a single game in 'hatless' mode take about 60 sec for 4-5 PDF pages Din A4; e.g. the complete generation of the PDF 'Tata Steel Masters 2022' (1.300 pages) take about 4 hours.
- my works here was not possible without
python chess
and for TeX / PDF generation:TeX Live
- the script processes all
... was to support myself learning chess by studying chess games offline, from selected PGN printouts / PDF files reading at any tablet, incl. making notes at the PDF's.
For online studies a good starting point learning chess is lichess.org or others.
I am not quite sure even the bigger PDFs are usefull, as we have free online and offline chess tools that let us interactively play the PGN files, incl. analysis; see SCID etc.
That project allows me to play with all that free tools, we have today: Linux OS (Debian, Ubuntu), Github, VScode, Python3 / Jupyter, LaTeX, LibreOffice etc.
-
Initially please have a look at
- the PGN1 examples; see
PGN/
- the TeX examples; see
TEX/
- the PDF examples; see
PDF/
- requirements.txt for the venv or pipenv (which I prefer)
- the PGN1 examples; see
-
install a python3 (e.g. 3.9.5 or better)
-
clone / download that code from the repo
-
run the Python script
run_pgn2tex.py
; its will generate TeX files only at subdirTEX/<pgn_filename>/
-
at Ubuntu: install a TeX Live with its editor's TeX Maker or TeX Works,
- same with a Mac,
- on Windows MiKTeX
-
use your prefered TeX editor (TeX Maker, TeX Works, Kile others) and generate the PDF file from a TeX file
-
or use batch mode aka 'hatless' command
latexmk --g -pdf
within yourTEX/<pgn_filename>/sections/
folder at the console prompt -
e.g.:
- 1st start at
TEX/<pgn_filename>/sections/
generating all PDF subfiles and check them - you may like to make some changes at some.tex
files. - 2nd go to
TEX/<pgn_filename>/
and generate the main.pdf that collects all the subfiles, TOC, Players and Openings Index.
- 1st start at
- add ECO Opening diagram to each game's TeX
- collect all games' TeX files to multiple TeX file(s) using TeX
\subfile{}
machanism, so that we got one (main.tex) and in subfoldersections/
one.tex
for each game. - add a TOC
- add index about Players and Openings
- add PDF outline headline at
\section
level [ Site, Event, Round, (Date) ], and\subsection
level [ Players, Result, ECO ] - allow some options; see
config.py
- move_arrows = False (default); see
PDF/examples
True: 'Tarrasch7games.pdf', False: 'Carlsen8games.pdf' - print_detailed_moves = True (default); change to False for games' one-pagers only; see
PDF/examples
True: 'WorldChamps1886.pdf', False: 'Capablanca.pdf'
- move_arrows = False (default); see
- complete testing
- documentation, e.g. wiki
- add different Openings
csv
to chose by renaming; onlyeco.scv
will be used - layout enhancements, in most cases the game's 1st page shows the opening and the game moves after the opening in tabular figurine long notation and the Opening, 2nd page give all game halfmoves' diagrams
Footnotes
-
PGN - see Wikipedia Portable Game Notation ↩ ↩2