Collect footnotes inside figure and table captions

This commit is contained in:
gloamxun committed 2026-10-19 18:39:16 +08:00
1 parent 6414770de7
commit 0c615c8e82
5 files changed
+68 -9

No files matched your search

+26
View File
@@ -1431,3 +1431,29 @@ See \href{https://example.com}{the example site} for details.
assert!(svg.contains("fill=\"#008000\""), "{svg}");
assert!(svg.contains(">example</text>"), "{svg}");
}
#[test]
fn caption_footnotes_follow_the_figure_page() {
let source = r"\documentclass{article}
\usepackage{graphicx}
\begin{document}
Before.\newpage
\begin{figure}[h]
\includegraphics[width=0.5\textwidth]{examples/plot.png}
\caption{A caption with a footnote\footnote{Caption footnote text.}}
\end{figure}
After text.
\end{document}";
let value = fresh_preview(source, "caption-footnote.tex");
assert_eq!(value["status"], "ok", "{value}");
let pages = pages(&value);
assert!(pages.len() >= 2, "expected a new page before the figure");
assert!(
!page_svg(&value, 0).contains(">Caption</text>"),
"caption footnote leaked onto the first page"
);
assert!(
page_svg(&value, 1).contains(">Caption</text>"),
"caption footnote should be painted on the figure page"
);
}