From 57272eab327caca3eff5ea0cbce0a2174ecd8dd0 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 20 Sep 2026 11:17:47 -0700 Subject: [PATCH] LaTeX writer: don't use footnotehyper for notes in longtable. Instead, generate them manually as we do for floating tables. This removes our dependency on footnotehyper, and solves a compatibility problem with `endfloat`. Closes #11857. --- data/templates/common.latex | 3 --- src/Text/Pandoc/Writers/LaTeX/Table.hs | 7 +------ test/command/2378.md | 3 ++- test/command/5367.md | 12 +++++++++--- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/data/templates/common.latex b/data/templates/common.latex index f7dee4217..0519741cd 100644 --- a/data/templates/common.latex +++ b/data/templates/common.latex @@ -88,9 +88,6 @@ $else$ \makeatletter \patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{} \makeatother -% Allow footnotes in longtable head/foot -\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}} -\makesavenoteenv{longtable} $endif$ $endif$ $-- diff --git a/src/Text/Pandoc/Writers/LaTeX/Table.hs b/src/Text/Pandoc/Writers/LaTeX/Table.hs index 3e1decc78..9e2fbe660 100644 --- a/src/Text/Pandoc/Writers/LaTeX/Table.hs +++ b/src/Text/Pandoc/Writers/LaTeX/Table.hs @@ -53,7 +53,6 @@ tableToLaTeX inlnsToLaTeX blksToLaTeX tbl = do $ lookup "latex-placement" kvs -- if the float class is included in table attributes, we generate a floating -- table environment; otherwise we use longtable - beamer <- gets stBeamer let float = "float" `elem` classes let renderTable = do let unnumbered = "unnumbered" `elem` classes @@ -83,11 +82,7 @@ tableToLaTeX inlnsToLaTeX blksToLaTeX tbl = do then makeUnnumbered else id) <$> makeTable colDesc mkHead mkRow capt thead tbodies tfoot - -- See #5367 -- footnotehyper/footnote don't work in beamer, - -- so we need to produce the notes outside the table... - if float || beamer - then ($$) <$> withExternalNotes renderTable <*> getAccumulatedNotes - else renderTable + ($$) <$> withExternalNotes renderTable <*> getAccumulatedNotes tableToLaTeXTable :: PandocMonad m => Doc Text diff --git a/test/command/2378.md b/test/command/2378.md index 2944df09d..c7baf2aac 100644 --- a/test/command/2378.md +++ b/test/command/2378.md @@ -14,7 +14,7 @@ is used. \begin{longtable}[]{@{}ll@{}} \caption{a table}\tabularnewline \toprule\noalign{} -x & y\footnote{a footnote} \\ +x & y\footnotemark{} \\ \midrule\noalign{} \endfirsthead \toprule\noalign{} @@ -25,4 +25,5 @@ x & y{} \\ \endlastfoot 1 & 2 \\ \end{longtable} +\footnotetext{a footnote} ``` diff --git a/test/command/5367.md b/test/command/5367.md index 55c849a44..f98e6caac 100644 --- a/test/command/5367.md +++ b/test/command/5367.md @@ -22,10 +22,10 @@ hello\footnote{doc footnote} \begin{longtable}[]{@{} >{\centering\arraybackslash}p{(\linewidth - 0\tabcolsep) * \real{0.1667}}@{}} -\caption[Sample table.]{Sample table.\footnote{caption footnote}}\tabularnewline +\caption[Sample table.]{Sample table.\footnotemark{}}\tabularnewline \toprule\noalign{} \begin{minipage}[b]{\linewidth}\centering -Fruit\footnote{header footnote} +Fruit\footnotemark{} \end{minipage} \\ \midrule\noalign{} \endfirsthead @@ -37,8 +37,14 @@ Fruit{} \endhead \bottomrule\noalign{} \endlastfoot -Bans\footnote{table cell footnote} \\ +Bans\footnotemark{} \\ \end{longtable} +\addtocounter{footnote}{-2} +\footnotetext{caption footnote} +\addtocounter{footnote}{1} +\footnotetext{header footnote} +\addtocounter{footnote}{1} +\footnotetext{table cell footnote} dolly\footnote{doc footnote} ```