@@ -51,7 +51,8 @@ import qualified Data.Text.Normalize as Normalize
5151data WriterState =
5252 WriterState { stInNote :: Bool -- true if we're in a note
5353 , stInQuote :: Bool -- true if in a blockquote
54− , stInMinipage :: Bool -- true if in minipage
54+ , stExternalNotes :: Bool -- true if in context where
55+ -- we need to store footnotes
5556 , stInHeading :: Bool -- true if in a section heading
5657 , stInItem :: Bool -- true if in \item[..]
5758 , stNotes :: [Doc] -- notes in a minipage
@@ -76,7 +77,7 @@ startingState :: WriterOptions -> WriterState
7677startingState options = WriterState {
7778 stInNote = False
7879 , stInQuote = False
79− , stInMinipage = False
80+ , stExternalNotes = False
8081 , stInHeading = False
8182 , stInItem = False
8283 , stNotes = []
@@ -606,7 +607,7 @@ blockToLaTeX (Para [Image attr@(ident, _, _) txt (src,'f':'i':'g':':':tit)]) = d
606607 "\\centering" $$ img $$ caption <> cr
607608 let figure = cr <> "\\begin{figure}" $$ innards $$ "\\end{figure}"
608609 st <- get
609− return $ if stInNote st || stInMinipage st
610+ return $ if stExternalNotes st
610611 -- can't have figures in notes or minipage (here, table cell)
611612 -- http://www.tex.ac.uk/FAQ-ouparmd.html
612613 then "\\begin{center}" $$ img $+$ capt $$ "\\end{center}"
@@ -826,11 +827,11 @@ blockToLaTeX (Table caption aligns widths heads rows) = do
826827
827828getCaption :: PandocMonad m => Bool -> [Inline] -> LW m (Doc, Doc, Doc)
828829getCaption externalNotes txt = do
829− oldIsMinipage <- gets stInMinipage
830− modify $ \st -> st{ stInMinipage = externalNotes, stNotes = [] }
830+ oldExternalNotes <- gets stExternalNotes
831+ modify $ \st -> st{ stExternalNotes = externalNotes, stNotes = [] }
831832 capt <- inlineListToLaTeX txt
832833 notes <- gets stNotes
833− modify $ \st -> st{ stInMinipage = oldIsMinipage, stNotes = [] }
834+ modify $ \st -> st{ stExternalNotes = oldExternalNotes, stNotes = [] }
834835 -- We can't have footnotes in the list of figures/tables, so remove them:
835836 captForLof <- if null notes
836837 then return empty
@@ -904,12 +905,12 @@ tableCellToLaTeX _ (0, _, blocks) =
904905 blockListToLaTeX $ walk fixLineBreaks $ walk displayMathToInline blocks
905906tableCellToLaTeX header (width, align, blocks) = do
906907 beamer <- gets stBeamer
907− oldInMinipage <- gets stInMinipage
908+ externalNotes <- gets stExternalNotes
908909 -- See #5367 -- footnotehyper/footnote don't work in beamer,
909910 -- so we need to produce the notes outside the table...
910− modify $ \st -> st{ stInMinipage = beamer }
911+ modify $ \st -> st{ stExternalNotes = beamer }
911912 cellContents <- blockListToLaTeX blocks
912− modify $ \st -> st{ stInMinipage = oldInMinipage }
913+ modify $ \st -> st{ stExternalNotes = externalNotes }
913914 let valign = text $ if header then "[b]" else "[t]"
914915 let halign = case align of
915916 AlignLeft -> "\\raggedright"
@@ -1286,10 +1287,10 @@ inlineToLaTeX (Image attr _ (source, _)) = do
12861287 dims <> braces (text source'')
12871288inlineToLaTeX (Note contents) = do
12881289 setEmptyLine False
1289− inMinipage <- gets stInMinipage
1290− modify (\s -> s{stInNote = True})
1290+ externalNotes <- gets stExternalNotes
1291+ modify (\s -> s{stInNote = True, stExternalNotes = True})
12911292 contents' <- blockListToLaTeX contents
1292− modify (\s -> s {stInNote = False})
1293+ modify (\s -> s {stInNote = False, stExternalNotes = externalNotes})
12931294 let optnl = case reverse contents of
12941295 (CodeBlock _ _ : _) -> cr
12951296 _ -> empty
@@ -1301,7 +1302,7 @@ inlineToLaTeX (Note contents) = do
13011302 else empty
13021303 modify $ \st -> st{ stNotes = noteContents : stNotes st }
13031304 return $
1304− if inMinipage
1305+ if externalNotes
13051306 then "\\footnotemark{}"
13061307 -- note: a \n before } needed when note ends with a Verbatim environment
13071308 else "\\footnote" <> beamerMark <> braces noteContents