Is there a way to only #include references?

I am writing a long document with several chapters. Each chapter has its own .typ file and I #include these in a main.typ file. To speed up compilation, I comment out the #include chap.typ lines for chapters I am not currently working on. However, now I cannot reference things in these chapters, which I would like to do. Is there a way to #include only the references from a .typ file? Or is there a better way to go about writing a long document in Typst?

Hello!
An alternative to commenting #include directives is to use a “draft mode” in your document, e.g., implement a show rules for figures/tables/images that add delays to your compilation.
Then,

#if draft-mode {
   ... // your content
}

In order to find out what is slowing down your document, either use --timings and open the resulting profile in https://ui.perfetto.dev/, or simply comment each chapter one-by-one, then every content until you find the “culprit”!

Although, I am surprised that your document compiles long enough for writing to be a problem. What sort of content do you have?

1 Like

To add to the great answer above: We plan to downgrade missing references to warnings so that the document continues to compile in such cases.

5 Likes

I apologise if this is too trivial a suggestion, but do you use typst watch instead of compiling anew each time with typst compile? See this paragraph from the usage section of the Typst compiler README:

You can also watch source files and automatically recompile on changes. This is faster than compiling from scratch each time because Typst has incremental compilation.

# Watches source files and recompiles on changes.
typst watch file.typ

There are also projects like typst-preview.nvim, which allows low-latency (virtually instant) Typst preview in NeoVim, and the official Typst web application.

Was this change implemented in 0.12? I am still getting missing reference errors. I am using the web app.

Unfortunately no, it was decided that, because of the lack of fine grained warning suppression necessary to silence plenty of package errors from deprecation, missing references could easily be glossed over. See the discussion here Downgrade missing references and citations from errors to warning by laurmaedje · Pull Request #4974 · typst/typst · GitHub.

1 Like

I understand. Thank you for your reply.