git.iko.soy/typeable/pandoc
on master help sign in
LaTeX writer: avoid footnotes in list of figures.

Footnotes aren't allowed in the list of figures. This patch causes footnotes to be stripped from captions when entered into the list of figures. Footnotes still don't actually WORK in captions in latex/pdf, but at least an error is no longer raised. See #1506.

commitc4ea64203aee543682738b54fa761d53be9269aa authorJohn MacFarlane <jgm@berkeley.edu> dateSun 1 Nov 2015, 13:42 (11 years ago) parenteb8aee4
1 file changed+14−1
src/Text/Pandoc/Writers/LaTeX.hs+14−1
src/Text/Pandoc/Writers/LaTeX.hs+14−1
@@ -395,12 +395,17 @@ blockToLaTeX (Plain lst) =
395395blockToLaTeX (Para [Image txt (src,'f':'i':'g':':':tit)]) = do
396396 inNote <- gets stInNote
397397 capt <- inlineListToLaTeX txt
398+ -- We can't have footnotes in the list of figures, so remove them:
399+ captForLof <- if null (query queryNote txt)
400+ then return empty
401+ else brackets <$> inlineListToLaTeX (walk deNote txt)
398402 img <- inlineToLaTeX (Image txt (src,tit))
399403 return $ if inNote
400404 -- can't have figures in notes
401405 then "\\begin{center}" $$ img $+$ capt $$ "\\end{center}"
402406 else "\\begin{figure}[htbp]" $$ "\\centering" $$ img $$
403− ("\\caption" <> braces capt) $$ "\\end{figure}"
407+ ("\\caption" <> captForLof <> braces capt) $$
408+ "\\end{figure}"
404409-- . . . indicates pause in beamer slides
405410blockToLaTeX (Para [Str ".",Space,Str ".",Space,Str "."]) = do
406411 beamer <- writerBeamer `fmap` gets stOptions
@@ -1202,3 +1207,11 @@ commonFromBcp47 x = fromIso $ head x
12021207 fromIso "ur" = "urdu"
12031208 fromIso "vi" = "vietnamese"
12041209 fromIso _ = ""
1210+
1211+queryNote :: Inline -> [Inline]
1212+queryNote (Note xs) = [Note xs]
1213+queryNote _ = []
1214+
1215+deNote :: Inline -> Inline
1216+deNote (Note _) = RawInline (Format "latex") ""
1217+deNote x = x