How can I customize footnote entry without losing link functionality?

If I try to customize the footnote entry, even following an example from the docs, the link from the text to the footnote entry stops working: it’s still a link, but it seems to point to nowhere (my PDF reader jumps to the beginning of document).

Below is a minimal working example. Commenting the entire #show block makes the footnote link work again.

#set page(paper: "a6")

#show footnote.entry: it => {
  let loc = it.note.location()
  numbering(
    "1: ",
    ..counter(footnote).at(loc),
  )
  it.note.body
}

#lorem(200)

A text
#footnote[And a footnote]  // this link stops working
#lorem(5)

In an HTML way, I would try to add an anchor with correct id (or label in Typst) wrapping the numbering of the footnote entry. But I don’t know how to do that (or if it’s even possible) in Typst…

1 Like

Hello!
Unfortunately, this an ongoing issue with styling footnote.entry, see Footnote styling breaks links · Issue #2430 · typst/typst · GitHub.

1 Like

I think the exact same issue is when overriding the outline[.entry] show rule.

1 Like

Yes, but perhaps (I haven’t tested it) in outline.entry it’s simpler because the outline entry is the link itself, and we already have the target element to build that link if needed. But a footnote entry is not the link but the target; it would need to know somehow which label it’s assigned to, so that we can properly build it as a link target.

Maybe the footnote entry could receive another field, as a link type, with the link that targets it. That would allow to even put a “back to the text” link in the note.

You can try pitching the improvement in the Typst repository.

1 Like