Crosswords in typst

I’ve made a function to create crosswords with typst (thanks a lot to PgBiel for the improved tables). My code is a mess so I won’t share it right now, but I wanted some opinions on the API.

For example:


Can be created with:

#crossword(
  (x:  9, y: 2, d: ttb, w: "text"),
  (x: 11, y: 0, d: ttb, w: "markup"),
  (x: 15, y: 5, d: ttb, w: "typst"),
  (x: 17, y: 0, d: ttb, w: "printing"),
  (x:  9, y: 5, d: ltr, w: "typesetting"),
  (x: 13, y: 9, d: ltr, w: "latex"),
)

x and y are the coordinates in a grid of the first letter of the word, d is the direction of the word. Manually setting the coordinates isn’t convenient at all, but I don’t know what would be a better interface.

5 Likes

Sounds like a cool project, and the results so far are good.

Instead of specifying locations (x, y) for words it would be really cool (and likely really hard) to just give it the words and have the template/package figure out how to lay them out. Or if you specify a shared letter between pairs of words. There could be existing algorithms for the problem of laying out crosswords.

One omission that I see though is the hints. I think each word should also have a hint, then that will be used to create the table.2.

#crossword(
  (x:  9, y: 2, d: ttb, w: "text", h:"what you type"),
  //etc...
)

//Which would result in a list like this
= Down
1. what you type
= Across
//...
1 Like