You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add an optional argument to query e.g. of the form external_file: none. If the argument is set to a valid typst file, e.g. file.typ, query returns elements found in that file.
Use Case
Currently a single typst compile call can only generate a single PDF document (?), e.g. A.typ produces A.pdf. If we are dealing with several documents, e.g we have B.typ -> B.pdf, we would like to create correct references in B.pdf which refer to A.pdf and vice versa.
A possible workaround is performing a pre-compile step using an external script e.g. python which calls typst query and dumps info into a file structure which is later read by the typst compile step. This however is cumbersome and does not make use of the already strong feature set available for intra-document introspection.
A possible difficulty arises from convergence issues of inter-dependent documents, this however is also the case for intra-document query.
An alternative could be a feature to reset the current state, so that multiple documents are exported into a single PDF file which is then split up by an external tool.
Reacted by Jeremie Knuesel, Degrange Mathieu, Quint Guvernator, benrob0329, Andonome, Leo Gaskin and João Vítor Carli Pereira
Another use case is querying to include content (rather than make references). For example, I have a document where exercises are interspersed with theory. I want to produce another document with just the exercises. It would be nice if I could write
In simple cases something similar can be achieved with #include and show rules for hiding other content, but it's hacky and quickly runs into additional complexity for example to deal with interference between headings in both documents.
I guess a proper way to hide "everything but" together with a solution for #1841 would go a long way in addressing this use case.
A special case of this use case is wanting to include the content of the whole frozen document as in #3723.
Reacted by aaeberharter, bluss, Ludwig Austermann, cAttte, jacobramirez-pt and benrob0329
Types of more technical writing (like TTRPGs or other games) would greatly benefit from this, as it's very common to reference or include sections from multiple reference/source documents.
This can even go as far as to include a subsection in one place, and the surrounding section in another (e.g. one relevant rule vs the whole group of rules with context), which is made trivial via section tagging but quite difficult otherwise.
There's also the (currently quite difficult) use for generated glossary documents, which can prove most useful if you have a breadth of options or mechanics.
Not having this has resulted in needing to either make writing exceptionally more difficult by converting an ordinary document into a hierarchal data structure (not fun to make or work with for writers), or by using hacky functions to include but not display another document so that pieces of it can be included (will break and doesn't solve page references).
I make heavy use of cross referencing for an RPG book.
As an extreme example, the footnotes here in italics reference another book and pull the sentence from it, so that rule-adjustments update across all other books.
Activity
sijow commentedon Mar 17, 2025
Another use case is querying to include content (rather than make references). For example, I have a document where exercises are interspersed with theory. I want to produce another document with just the exercises. It would be nice if I could write
In simple cases something similar can be achieved with
#includeand show rules for hiding other content, but it's hacky and quickly runs into additional complexity for example to deal with interference between headings in both documents.I guess a proper way to hide "everything but" together with a solution for #1841 would go a long way in addressing this use case.
A special case of this use case is wanting to include the content of the whole frozen document as in #3723.
benrob0329 commentedon Apr 17, 2026
Types of more technical writing (like TTRPGs or other games) would greatly benefit from this, as it's very common to reference or include sections from multiple reference/source documents.
This can even go as far as to include a subsection in one place, and the surrounding section in another (e.g. one relevant rule vs the whole group of rules with context), which is made trivial via section tagging but quite difficult otherwise.
There's also the (currently quite difficult) use for generated glossary documents, which can prove most useful if you have a breadth of options or mechanics.
Not having this has resulted in needing to either make writing exceptionally more difficult by converting an ordinary document into a hierarchal data structure (not fun to make or work with for writers), or by using hacky functions to include but not display another document so that pieces of it can be included (will break and doesn't solve page references).
Andonome commentedon Apr 19, 2026
I make heavy use of cross referencing for an RPG book.
As an extreme example, the footnotes here in italics reference another book and pull the sentence from it, so that rule-adjustments update across all other books.