How can I separate a preamble (with functions and formatting rules) from my main typ file?

Hi @tom1, welcome and thank you for your question! I have changed your post’s title to bring it in line with the question guidelines and thus make it easier to understand from the title:

Good titles are questions you would ask your friend about Typst.

I also added the templates tag, as it makes your question easier to find.