I’m using typst to reference manuscripts that are added at the end of the document. I’ve got pages with a heading and a label, and also the page number is set manually to match.
I would like a way to reference the label of that Manuscript heading, in which typst prints out “Manuscript IV (p. 56)” or something like that.
The heading would look like
#show ref: it => if it.element.func() != heading { it } else {
let l = it.target // label
let h = it.element // heading
link(l, [#h.body (p. #h.location().page())])
}
A reference to @paper4
#lorem(100)
// #pagebreak() // This will change "(p. 1)" to "(p. 2)".
= Manuscript IV
<paper4>
#lorem(20)
Yeah, I don’t think so. I did want to use .where() clause but ref() has only target and supplement fields: Reference Function – Typst Documentation, although it didn’t give an error when .where(element) is used. Unfortunately, element is of type content (or sometimes none, I think), so using it inside of .where() is basically useless. And there is no feature that adds lambda function inside .where() clause. Perhaps you can open an issue in the repository explaining the desired feature. It would be cool if you can filter ref occurrences (via .where()) by element type of ref.element field.