How to get elements by tag (or something similar)?

Hello @FrederikRichter,
to complement @jbirnick’s answer using great-theorems:

  • If you theorems and examples are figures, then it’s easier to query and retrieve the content. You might find it easier to write things like outline(target: figure.where(kind: "theorems") ! :smiley:
  • I do not think there is a way to import labels from an external file (see How to cross-reference labels defined in external typst projects?), your best bet is probably to have a specific show rule to filter the content you do not want, e.g., show: only-maths where only-maths reads the whole document body and selects only your theorems/examples.
  • I think you might find it easier to just query all your theorems/examples on a separate page and specifically output that one using typst --pages <PAGES>. (See above answer on how to query).

If you have any code that minimally reproduces your use case, don’t hesitate to share it, or to share more details!