How can I change the default form for references?

This may generalise to other defaults.

My document needs cross-references by page only. Having to specify the form every time is inelegant and clunky, harder to quickly skim text, etc. I thought a show rule might enable this.

I’ve found out how to change the prefix from “page” to “p.”, and how to do quite complicated-looking things with equations, but I couldn’t see a way to tell typst that all refs within the doc should be treated as page.

Is this possible? In general, is there a way to change defaults of this kind?

Use a set rule.

#set page(numbering: "1", supplement: "p.")
#set ref(form: "page")

#figure[] <this>
@this

image

1 Like

Thank you. I think it would be useful for this example to be added to the documentation.

Here? The show rule? https://github.com/typst/typst/issues/new?template=3-docs.yml

You can make a shorter (I guess also) English-specific version:

#show ref.where(form: "page"): it => {
  show "page": "p."
  it
}

I was thinking under the ref documentation. I think it’ll be useful to other people and it wasn’t obvious to me.

I would personally suggest putting it under Customization, before the quite complex example that’s currently there.

Add page reference customization example by Andrew15-5 · Pull Request #6480 · typst/typst · GitHub.