This guide addresses Windows-specific considerations for using ChessPublisher.
Problem: On Windows, usernames with long directory names (e.g., C:\Users\MyName\...) are sometimes converted to short 8.3 format paths (e.g., C:\Users\MYNAME~1\...). The tilde (~) in these paths can cause LaTeX engines like pdflatex to fail with errors like:
! I can't find file `C:/Users/MYNAME'.
Solution: ChessPublisher automatically converts short 8.3 paths to long paths before passing them to the LaTeX engine. This fix is built into the library.
If you still encounter path issues, you can use a custom working directory in a simple path:
from pathlib import Path
from chess_generator import ChessDiagramGenerator
generator = ChessDiagramGenerator(verbose=True)
# Use a simple path without spaces or special characters
working_dir = Path("C:/chess/temp")
working_dir.mkdir(parents=True, exist_ok=True)If you want to inspect, modify, or compile the LaTeX code yourself, you can use the tex_only=True parameter:
from pathlib import Path
from chess_generator import ChessDiagramGenerator
generator = ChessDiagramGenerator(verbose=True)
# Generate only the .tex file, without compiling to PDF
fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
generator.generate_single_diagram(
fen=fen,
output_path=Path("output/starting_position.pdf"), # Will save as .tex
title="Starting Position",
tex_only=True # Saves .tex file instead of compiling to PDF
)This works with all generation methods:
generate_single_diagram(..., tex_only=True)generate_diagram_at_move(..., tex_only=True)generate_annotated_game(..., tex_only=True)
The .tex file will be saved in the same location as the intended PDF output, with the extension changed to .tex.
If you prefer LuaLaTeX over pdfLaTeX (e.g., for better OpenType font support), you can specify it as your preferred engine:
from chess_generator import ChessDiagramGenerator
# Use LuaLaTeX instead of pdfLaTeX
generator = ChessDiagramGenerator(
verbose=True,
preferred_engine='lualatex'
)
# Now all compilations will use LuaLaTeX
generator.generate_single_diagram(...)The following LaTeX engines are supported (in default priority order):
- pdflatex - Most reliable for chess packages
- lualatex - Better OpenType font support, modern features
- xelatex - Good Unicode and font support
- tectonic - Modern, self-contained engine (limited chess package support)
- Direct use of system fonts (OpenType, TrueType)
- No need for MAP files or font encoding issues
- Modern Lua scripting capabilities
- Better handling of Unicode text
When using LuaLaTeX, you generally don't need to configure MAP files for fonts. If you encounter font issues with pdfLaTeX, switching to LuaLaTeX often resolves them:
# If pdflatex has font issues, try lualatex
generator = ChessDiagramGenerator(preferred_engine='lualatex')If you're using TeX Live on Windows, make sure your PATH includes the TeX Live bin directory (e.g., C:\texlive\2024\bin\windows).
Install required chess packages if not already present:
tlmgr install xskak chessboard chessfss skak- Check if the path contains tildes (
~) - the automatic fix should handle this - Try moving your project to a simpler path (e.g.,
C:\chess\project) - Use
tex_only=Trueto generate the.texfile, then compile manually
- Try using LuaLaTeX:
ChessDiagramGenerator(preferred_engine='lualatex') - Update your TeX distribution:
tlmgr update --all - Regenerate font maps:
mktexlsrandupdmap-sys
- Don't run from system-protected directories
- Ensure you have write access to the output directory
- Close any PDF viewers that might have the output file open