From c4ea64203aee543682738b54fa761d53be9269aa Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Sun, 1 Nov 2015 13:42:36 -0800 Subject: [PATCH] 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. --- src/Text/Pandoc/Writers/LaTeX.hs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 7cbfce950..c9c6b3f96 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -395,12 +395,17 @@ blockToLaTeX (Plain lst) = blockToLaTeX (Para [Image txt (src,'f':'i':'g':':':tit)]) = do inNote <- gets stInNote capt <- inlineListToLaTeX txt + -- We can't have footnotes in the list of figures, so remove them: + captForLof <- if null (query queryNote txt) + then return empty + else brackets <$> inlineListToLaTeX (walk deNote txt) img <- inlineToLaTeX (Image txt (src,tit)) return $ if inNote -- can't have figures in notes then "\\begin{center}" $$ img $+$ capt $$ "\\end{center}" else "\\begin{figure}[htbp]" $$ "\\centering" $$ img $$ - ("\\caption" <> braces capt) $$ "\\end{figure}" + ("\\caption" <> captForLof <> braces capt) $$ + "\\end{figure}" -- . . . indicates pause in beamer slides blockToLaTeX (Para [Str ".",Space,Str ".",Space,Str "."]) = do beamer <- writerBeamer `fmap` gets stOptions @@ -1202,3 +1207,11 @@ commonFromBcp47 x = fromIso $ head x fromIso "ur" = "urdu" fromIso "vi" = "vietnamese" fromIso _ = "" + +queryNote :: Inline -> [Inline] +queryNote (Note xs) = [Note xs] +queryNote _ = [] + +deNote :: Inline -> Inline +deNote (Note _) = RawInline (Format "latex") "" +deNote x = x