-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
feature requestNew feature or requestNew feature or requestmodelRelated to model category, which is all about structure and semantics.Related to model category, which is all about structure and semantics.
Description
Description
A possibility to get the page number when referencing an image or table would be good. Below is my own implementation that I use in Typst right now. It takes the label text and tries to find the label in the document. If the label is found it determines the page number of the label and formats it as a link to the label. In case the label is not defined it throws an error so it is not possible to compile the document with unresolved references when using pageref.
#let pageref(labelText) = {
locate(loc => {
let label = label(labelText)
let elems = query(selector(label), loc)
if elems.len() == 1 {
let pageNumber = elems.at(0).location().page()
link(label, str(pageNumber))
} else {
let errorMessage = "Label '" + labelText + "' is not defined"
panic(errorMessage)
}
})
}Use Case
Sometimes it can be handy to reference the page number in a document for example "As you can see in fig. x on page y".
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
feature requestNew feature or requestNew feature or requestmodelRelated to model category, which is all about structure and semantics.Related to model category, which is all about structure and semantics.