diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-11-01 13:42:36 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-11-01 13:42:36 -0800 |
commit | c4ea64203aee543682738b54fa761d53be9269aa (patch) | |
tree | 5e671ac7f405d93aaba286ad6fe857ec34be35ae /src | |
parent | eb8aee477db045a7449bc752975528263964b8ce (diff) | |
download | pandoc-c4ea64203aee543682738b54fa761d53be9269aa.tar.gz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Writers/LaTeX.hs | 15 |
1 files changed, 14 insertions, 1 deletions
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 |