-
-
Notifications
You must be signed in to change notification settings - Fork 798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
references to labels in #include documents bomb on standalone #1276
Comments
This should be achievable right now by creating a custom ref function that uses https://typst.app/docs/reference/meta/query/ to check for the existence of the label. Though I haven't actually tried. It wouldn't be a bad idea to have an optional fallback value for #ref so it fails more gracefully. |
Great, could you perhaps do that? It’s way beyond my capabilities. |
Proof of concept: main.typ
child.typ
|
Could probably also use a ref show rule instead of a custom ref function. |
I considered the possibility, but I didn't know exactly how to make it work. |
@Enivex posted the solution to the Discord (which I have slightly adapted: main.typ
child.typ #set heading(numbering: "1.")
#show ref: it =>{
if it.element == none{
text(fill: red)[(?)]
} else {
it
}
}
= Second <test2>
@test which does the trick very nicely indeed. Thank you very much. |
Description
I am re-doing a largeish handbook from LaTeX/LyX in typst.
In LyX the concept of “child document” allows referencing labels in other (child) documents even when compiling a (child) document standalone (for speed).
When I try to do this in typst it generates errors when the labels are missing (standalone). It works very well when doing the master document (with the required) #includes.
I would not mind a warning on compilation and perhaps an obvious text being inserted, ie bold and uppercase MISSINGLABEL in the PDF, perhaps even in red or something.
Use Case
This would allow to generate #include’d files to be compiled standalone.
The text was updated successfully, but these errors were encountered: