Some (not all) pages in my document should have a margin for notes. The notes should be at the same height as the relevant parts of the text. I can specify the width of the note margin and I can determine whether the note margin is on the left or right. Is this possible with Typst?
The left and right page margins can be specified in terms of inside
and outside
in case you want a book layout where the notes are always outside.
However, if you only want a big margin on some pages, this is currently not possible. Typst’s layout (currently) assumes that text only flows between containers that all have the same width. For example, when Typst computes where to put the line breaks within a paragraph, it looks at all lines and how they will look. At that time, Typst does not consider on what page (or in what column) the individual lines will line up, which it would have to do if a page break could change the width of a line.
As long as you’re ok with a wide margin that is there even if a page has no notes, that should work fine. The drafting package for example puts content in the margin, at the height where it was inserted.
Maybe it helps to take a look at the code of the tufte-memo template, which contains marginnotes.