How to prevent footnotes in headings from expanding to PDF TOC/Contents

I have noticed a peculiar thing about footnotes in headings. They show up nicely in the main document, but add visual clutter to the table of contents, as shown on my example below (click here to open).
#set page(paper: "a7")

== My Heading #footnote[#link("https://typst.app/")[Link to typst];]

#lorem(50)

How can I keep using footnotes in headers, but keep the TOC clean?

Hello @Jarko,

this is a known issue tracked in #2415. There are some solutions in a related thread (1889).

There are different ways to do this, but the simplest one I recommend is to split the bookmark and the actual heading. Then, it’s just a matter of convenience. You can wrap it all in a custom function.

#set page(paper: "a7")
#{
  show heading: none
  heading("Heading")
}
#heading(bookmarked: false)[Heading#footnote[Footnote]]
#lorem(50)

For completeness, see:

2 Likes

PDF TOC/Contents

FYI, it is called Document Outline.