Files
pandoc/test/command/8240.md
T
John MacFarlaneandClaude Opus 5.5 5bca190d12 LaTeX writer: fix hyperlinks for deferred footnotes.
Notes in tables, captions, and definition list terms are rendered
as a mark followed later by the note text. Previously we used
`\footnotemark{}` and `\footnotetext` with manual adjustments to
the footnote counter. But hyperref anchors each `\footnotetext` at
the destination of the most recent `\footnotemark`, so when there
were several such notes, all of the texts got the last mark's
anchor and the links for the other marks were broken (visibly so
with xelatex; pdflatex and lualatex silently substituted
page-level destinations).

We now emit `\pandocfootnotemark{n}` and `\pandocfootnotetext{n}{..}`,
where `n` is a unique id. These macros, defined in the default
template when the `deferred-notes` variable is set, save the
footnote mark and hyperref anchor at the mark and restore them
at the text. This removes the need for counter arithmetic, works
when the footnote counter is reset by chapter, and handles notes
nested inside deferred notes (whose texts are now emitted after
the text containing their marks). Since `\@footnotetext` is used
directly, verbatim content in such notes (`\VerbatimFootnotes`)
still works.

Users of custom LaTeX templates, or of LaTeX fragments produced
without `--standalone`, will need to include the definitions of
`\pandocfootnotemark` and `\pandocfootnotetext` from the default
template.

Closes #11936.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 20:13:38 -08:00

223 B

% pandoc -t latex
Header[^fn]:
:    Some other text.

[^fn]: A footnote.
^D
\begin{description}
\tightlist
\item[Header\pandocfootnotemark{1}:]
Some other text.
\end{description}
\pandocfootnotetext{1}{A footnote.}