git.iko.soy/typeable/pandoc
on master help sign in
LaTeX writer: Correctly handle figures in notes.

Notes can't contain figures in LaTeX, so we fake it to avoid an error. Closes #1053.

commitd81b4358ea8d0da615c01a468196fd0592934af6 authorJohn MacFarlane <jgm@berkeley.edu> dateFri 20 Jun 2014, 11:26 (12 years ago) parent56c410e
1 file changed+7−5
src/Text/Pandoc/Writers/LaTeX.hs+7−5
src/Text/Pandoc/Writers/LaTeX.hs+7−5
@@ -311,12 +311,14 @@ blockToLaTeX (Plain lst) =
311311 inlineListToLaTeX $ dropWhile isLineBreakOrSpace lst
312312-- title beginning with fig: indicates that the image is a figure
313313blockToLaTeX (Para [Image txt (src,'f':'i':'g':':':tit)]) = do
314− capt <- if null txt
315− then return empty
316− else (\c -> "\\caption" <> braces c) `fmap` inlineListToLaTeX txt
314+ inNote <- gets stInNote
315+ capt <- inlineListToLaTeX txt
317316 img <- inlineToLaTeX (Image txt (src,tit))
318− return $ "\\begin{figure}[htbp]" $$ "\\centering" $$ img $$
319− capt $$ "\\end{figure}"
317+ return $ if inNote
318+ -- can't have figures in notes
319+ then "\\begin{center}" $$ img $+$ capt $$ "\\end{center}"
320+ else "\\begin{figure}[htbp]" $$ "\\centering" $$ img $$
321+ ("\\caption" <> braces capt) $$ "\\end{figure}"
320322-- . . . indicates pause in beamer slides
321323blockToLaTeX (Para [Str ".",Space,Str ".",Space,Str "."]) = do
322324 beamer <- writerBeamer `fmap` gets stOptions