git.iko.soy/typeable/pandoc
on master help sign in
LaTeX writer: better handling of display math in simple tables.

We convert display math to inline math in simple tables, since LaTeX can't deal with display math in simple tables. Closes #1754.

commit61d2c2e8cb3ba5e55ac059324abca0bf235bb36d authorJohn MacFarlane <jgm@berkeley.edu> dateMon 15 Dec 2014, 21:14 (12 years ago) parentcb8bb47
1 file changed+7−1
src/Text/Pandoc/Writers/LaTeX.hs+7−1
src/Text/Pandoc/Writers/LaTeX.hs+7−1
@@ -545,10 +545,16 @@ fixLineBreaks' ils = case splitBy (== LineBreak) ils of
545545 where tohbox ys = RawInline "tex" "\\hbox{\\strut " : ys ++
546546 [RawInline "tex" "}"]
547547
548+-- We also change display math to inline math, since display
549+-- math breaks in simple tables.
550+displayMathToInline :: Inline -> Inline
551+displayMathToInline (Math DisplayMath x) = Math InlineMath x
552+displayMathToInline x = x
553+
548554tableCellToLaTeX :: Bool -> (Double, Alignment, [Block])
549555 -> State WriterState Doc
550556tableCellToLaTeX _ (0, _, blocks) =
551− blockListToLaTeX $ walk fixLineBreaks blocks
557+ blockListToLaTeX $ walk fixLineBreaks $ walk displayMathToInline blocks
552558tableCellToLaTeX header (width, align, blocks) = do
553559 modify $ \st -> st{ stInMinipage = True, stNotes = [] }
554560 cellContents <- blockListToLaTeX blocks