How to check for boolean state?

so the including (main) file sets b, and the included (part) file should set its page size according to it? You could probably do that like this:

#show: it => context {
  set page ("a5") if b()
  it
}

Strangely, it seems that the set page only takes effect if there is some content on the page before. This is probably related to the workaround I had to use here: Why is the page counter in the background of my page wrong after using counter.update()? - #11 by SillyFreak – if I have the time, I’ll see if the situation has changed since the 0.11.1 release. (EDIT: I just tested this using a nightly Tinymist based on Typst 8c813cb (2024-09-22) and it seems to work as intended)

That said, context that goes over large ranges, e.g. entire sections, is indeed not ideal (as far as I know). If the boolean is set once and then just exists (i.e. you don’t update it, it’s just configuration), I would actually use import: Why can't I use a function in a chapter even though I imported it at the start of my main file? - #2 by SillyFreak

It should be possible to import "main.typ": b if you don’t want to put the variables in a separate preamble.typ (or similar) file.