Staunton — chess boards, diagrams and tournament tables

Hi all,

For my chess publishing I wanted more than “just boards”, so I built staunton, and it’s now on Typst Universe. :tada:

The idea: you hand it a position or a whole game, and it hands you a proper,
referenceable #figure. FEN and PGN both work, and there’s a small pure-Typst
legal-move engine underneath, so you can play a game forward and ask for “the board after White’s 7th move” without pre-computing anything. It also does localized move notation (with variations, figurines, NAGs), tournament tables with the usual tie-breaks, and diagram/table outlines — all in seven languages.

Parse a game, then drop in the position after a given move:


#import "@preview/staunton:0.1.0": parse-pgn, diagram-after

#let opera = parse-pgn(```

[White "Morphy"] [Black "Duke & Count"] [Result "1-0"]

1. e4 e5 2. Nf3 d6 3. d4 Bg4 4. dxe5 Bxf3 5. Qxf3 dxe5 6. Bc4 Nf6 7. Qb3 Qe7 *

```).first()

// A captioned figure of the position after Black's 7th move — you can @ref it.

#diagram-after(opera, "7b")

Just say what you mean and get a figure you can cross-reference. Everything else — themes, board flip, highlights and arrows, custom piece sets, “what-if” variation play, FEN export, HTML output — is in the manual rather than this post, so I’ll just point you there.

The package on Typst Universe:

Source + manual are on GitHub, grab the PDF from the latest release):

It’s just a start, so I genuinely would love your feedback — rough edges, missing chess things or notation quirks in your language. I also want to acknowledge boards-n-pieces
(board-n-pieces – Typst Universe) that was an inspiration for
some of the features.

— Frank

16 Likes

staunton 0.2.2 is out :tada:

Three releases since the announcement above — the highlights:

  • Chess960 / Freestyle chess (0.2.0): start positions from X-FEN or a position number 0–959, with generalized castling.
  • Custom pieces (0.2.0): install your own piece sets, or define fairy pieces and whole custom variants with define-variant.
  • New markings (0.2.0–0.2.2): in-check glow, move-quality badges, and reworked arrows/crosses/circles (clearly visible defaults, proportional strokes, settable margins).
  • Localization (0.2.1–0.2.2): diagram captions (“Position after …”, side to move) and tournament-table headers now follow the document language.

Plus smaller polish: spaced move numbers by default (with a spaced switch), cleaner separation of document defaults vs. per-position options, and an outline fix for caption-less figures.

As always: Typst Universe · GitHub (the manual PDF is attached to each release). Feedback and feature wishes welcome!

5 Likes

I’m not in the chess world but I just wanted to tell you how impressive this package is. It seems to have so many features and I could imagine it being very useful for writing strategy guides for instance.

Thanks! I’m eager to hear from users how the API feels for them usability-wise.

A new version - Staunton 0.3.0 - is out

Highlights:

  • Themed boards — reusable color-theme / board-theme values, eleven built-ins each (the nine kokopu-react themes plus two of our own), covering everything from a flat two-color pairing to a full “look.”

  • Square patternscolor-theme(.., pattern: ..) overlays a texture on the squares (diagonal stripes, marble, or wood grain) over your chosen colors

  • Matching border bandsborder-theme gains "marble" and "wood" values, so the label border can carry the same material as the squares.

  • Brightness / contrastcolor-theme(.., brightness: .., contrast: ..) post-adjusts a square-color pair.

  • Tournament-table styling — eight new options for standings tables, cross-tables, and progress charts (grid style, header/body alignment and fill, zebra rows, winner highlighting, and more), settable per call or document-wide via set-table-defaults(..).

  • move-to-san — names an engine-generated move from a bare position, the inverse of the SAN parser. Handy for puzzle solutions or generated lines without a pre-existing PGN.

  • Faster rendering — the checkerboard is memoized across diagrams sharing geometry/colors, and square parsing has a fast path.

  • Wider compiler support — Typst 0.14.2 is supported as long as you can live without HTML export.

As always, the manual has the full reference with live examples.

1 Like

Staunton 1.0.0 is out and can be found on Universe (staunton – Typst Universe).

  • (breaking): scope was narrowed to western chess, that is standard play, Chess960, non-standard
    boards and limited support for fairy pieces. If I ever implement other chess traditions, it would be in their own packages.
  • (breaking): simpler API; the variant-named wrappers are gone - use #board(), #diagram(), #notation() for everything, Chess960 included; #chess-moves() was renamed to #play(); #chess-diagram-outline() / #chess-table-outline() / #chess-outlines() turned into #diagram-outline() / #table-outline() / #outlines().
  • Wood and marble material patterns were redesigned from scratch: real grain/veining instead of
    noise, monochrome so it tints correctly under any color-theme. These material patterns also follow now the chosen color-theme instead of fixed colors. The wood pattern now affects light squares, too. Set pattern-light: false for the old dark-only behavior.

Not sure, whether I used “SemVer” correctly: I chose 1.0.0 due to breaking changes, instead of
the standard 0.4.0.

1 Like

Staunton 2.0.0 is out on Typst Universe.

This is a major breaking redesign of the game/PGN API around two rules - there’s one way to do each thing, and moves must be explicitely passed, not hidden behind some opaque structures.

  • parse-pgn/parse-fengames()/game()/position()
  • diagram-after(g, "17w")diagram(g, at: "17w") (same for board)
  • move-san/move-node → single move-at(game, at: ..)
  • Consistent f(subject, setting: .., ..) argument shape everywhere

New since 1.0.0:

  • Arrow styling — hook-tip arrowheads (new default), optional fade-to-tail
  • last-move — auto-highlight the move that produced a diagrammed position
  • Figurine notation input (♔♕♖…) — no lang: needed
  • Localized movetext input — DE/FR/ES/IT/PT/RU piece letters, independent of print/output language

No aliases were kept for the renames, so stick to your version if you’re not ready to migrate. Full changelog: GitHub - ndg6/staunton: A Typst package for publishing chess games · GitHub

1 Like