Multi-file projects with individually-compilable parts, akin to LaTeX' subfiles package.
Description
This feature request originated from a question I asked on the Discord server.
I would like to implement the use case described below, but have not yet found a good way to do so.
A first idea was to create a common file style.typ containing the relevant set rules and show rules and include it in all files.
But this has a few problems, for example that all show-rules need to be idempotent.
Another problem is that there can often be links or labels that refer to targets outside the subdocument, for example to a definition in another chapter.
tinger suggested the following show rule on Discord:
#show ref: it => if query(it.target, it.location()).len() == 0 [ NOT FOUND ] else { it }
Use Case
I am considering writing my PhD thesis and a series of lecture notes using typst. These will be fairly long documents, as it is often their nature.
With LaTeX, I usually do the following, using the subfiles package:
- Split the document into multiple, smaller files, which can be built individually. → These can then be distributed to others (for review, to use in preparation for the lectures, …)
- Have a "main file" that, when built, consists of all (included) parts. → That would be the finished thesis or the finished lecture notes at the end of the semester.
Using the subfiles package, all subfiles (chapters, lectures, …) use the preamble of the main file, thus providing consistent styling, etc. of both the smaller, individual documents, and the main document.
Also, I set it up such that a corresponding cover page would automatically be generated for them.
Source: typst/typst