@@ -517,25 +517,15 @@ blockToLaTeX (Plain lst) =
517517 inlineListToLaTeX $ dropWhile isLineBreakOrSpace lst
518518-- title beginning with fig: indicates that the image is a figure
519519blockToLaTeX (Para [Image attr@(ident, _, _) txt (src,'f':'i':'g':':':tit)]) = do
520− inNote <- gets stInNote
521− inMinipage <- gets stInMinipage
522− modify $ \st -> st{ stInMinipage = True, stNotes = [] }
523− capt <- inlineListToLaTeX txt
524− notes <- gets stNotes
525− modify $ \st -> st{ stInMinipage = False, stNotes = [] }
526−
527− -- We can't have footnotes in the list of figures, so remove them:
528− captForLof <- if null notes
529− then return empty
530− else brackets <$> inlineListToLaTeX (walk deNote txt)
531− img <- inlineToLaTeX (Image attr txt (src,tit))
532− let footnotes = notesToLaTeX notes
520+ (capt, captForLof, footnotes) <- getCaption txt
533521 lab <- labelFor ident
534522 let caption = "\\caption" <> captForLof <> braces capt <> lab
523+ img <- inlineToLaTeX (Image attr txt (src,tit))
535524 innards <- hypertarget True ident $
536525 "\\centering" $$ img $$ caption <> cr
537526 let figure = cr <> "\\begin{figure}" $$ innards $$ "\\end{figure}"
538− return $ if inNote || inMinipage
527+ st <- get
528+ return $ if stInNote st || stInMinipage st
539529 -- can't have figures in notes or minipage (here, table cell)
540530 -- http://www.tex.ac.uk/FAQ-ouparmd.html
541531 then "\\begin{center}" $$ img $+$ capt $$ "\\end{center}"
@@ -714,11 +704,11 @@ blockToLaTeX (Header level (id',classes,_) lst) = do
714704 modify $ \s -> s{stInHeading = False}
715705 return hdr
716706blockToLaTeX (Table caption aligns widths heads rows) = do
707+ (captionText, captForLof, footnotes) <- getCaption caption
717708 let toHeaders hs = do contents <- tableRowToLaTeX True aligns widths hs
718709 return ("\\toprule" $$ contents $$ "\\midrule")
719710 let removeNote (Note _) = Span ("", [], []) []
720711 removeNote x = x
721− captionText <- inlineListToLaTeX caption
722712 firsthead <- if isEmpty captionText || all null heads
723713 then return empty
724714 else ($$ text "\\endfirsthead") <$> toHeaders heads
@@ -730,8 +720,8 @@ blockToLaTeX (Table caption aligns widths heads rows) = do
730720 else walk removeNote heads)
731721 let capt = if isEmpty captionText
732722 then empty
733− else text "\\caption" <>
734− braces captionText <> "\\tabularnewline"
723+ else "\\caption" <> captForLof <> braces captionText
724+ <> "\\tabularnewline"
735725 rows' <- mapM (tableRowToLaTeX False aligns widths) rows
736726 let colDescriptors = text $ concatMap toColDescriptor aligns
737727 modify $ \s -> s{ stTable = True }
@@ -745,6 +735,21 @@ blockToLaTeX (Table caption aligns widths heads rows) = do
745735 $$ vcat rows'
746736 $$ "\\bottomrule"
747737 $$ "\\end{longtable}"
738+ $$ footnotes
739+
740+getCaption :: PandocMonad m => [Inline] -> LW m (Doc, Doc, Doc)
741+getCaption txt = do
742+ inMinipage <- gets stInMinipage
743+ modify $ \st -> st{ stInMinipage = True, stNotes = [] }
744+ capt <- inlineListToLaTeX txt
745+ notes <- gets stNotes
746+ modify $ \st -> st{ stInMinipage = inMinipage, stNotes = [] }
747+ -- We can't have footnotes in the list of figures/tables, so remove them:
748+ captForLof <- if null notes
749+ then return empty
750+ else brackets <$> inlineListToLaTeX (walk deNote txt)
751+ let footnotes = notesToLaTeX notes
752+ return (capt, captForLof, footnotes)
748753
749754toColDescriptor :: Alignment -> String
750755toColDescriptor align =