Typst Support - Cross Reference
cross-link(path, reference: none, content)cross-link(path, reference: none, content) creates a link that works in native HTML, dynamic paged output, and a combined ebook.
pathpath(strstr): Absolute book path beginning with//. A.typ.typsuffix is converted to.html.html.referencereference(labellabelornonenone): Optional heading or element label.contentcontent(content): Visible link content.
#import "@preview/shiroa:0.4.0": cross-link#cross-link("/guide/get-started.typ")[Getting Started]#cross-link( "/guide/get-started.typ", reference: <configuration>,)[Configuration]
#import "@preview/shiroa:0.4.0": cross-link#cross-link("/guide/get-started.typ")[Getting Started]#cross-link( "/guide/get-started.typ", reference: <configuration>,)[Configuration]
Use heading-referenceheading-reference when a heading label must be calculated from heading content. The same function is used by Shiroa’s generated heading anchors.
- cross reference to the sample page
- cross reference to
== Subsection== Subsectionin the sample page - cross reference to
= Math equation $f = lambda x . x$ in heading= Math equation $f = lambda x . x$ in headingin the sample page
#import "@preview/shiroa:0.4.0": cross-link, templates#import templates: heading-reference#let p = "/supports/cross-ref-sample.typ"- #cross-link(p)[cross reference to the sample page]#let sub = heading-reference[= Subsection]- #cross-link(p, reference: sub)[cross reference to ```typ == Subsection``` in the sample page]#let ref-head = "= Math equation $f = lambda x . x$ in heading"#let sub = heading-reference(eval(ref-head, mode: "markup"))- #cross-link(p, reference: sub)[cross reference to #raw(lang: "typ", ref-head) in the sample page]
#import "@preview/shiroa:0.4.0": cross-link, templates#import templates: heading-reference#let p = "/supports/cross-ref-sample.typ"- #cross-link(p)[cross reference to the sample page]#let sub = heading-reference[= Subsection]- #cross-link(p, reference: sub)[cross reference to ```typ == Subsection``` in the sample page]#let ref-head = "= Math equation $f = lambda x . x$ in heading"#let sub = heading-reference(eval(ref-head, mode: "markup"))- #cross-link(p, reference: sub)[cross reference to #raw(lang: "typ", ref-head) in the sample page]
#import "@preview/shiroa:0.4.0": cross-link-path-label, link2page#assert(cross-link-path-label("/guide/get-started.typ") == "/guide/get-started.html")
#import "@preview/shiroa:0.4.0": cross-link-path-label, link2page#assert(cross-link-path-label("/guide/get-started.typ") == "/guide/get-started.html")
cross-link-path-labelcross-link-path-label requires an absolute book path and changes a trailing .typ.typ to .html.html. Official sidebars use it before applying x-url-basex-url-base. link2pagelink2page records the page number of each included chapter while producing a combined paged book. Normal page and theme code should call cross-linkcross-link instead of reading this state.