git.iko.soy/typeable/pandoc
on master help sign in
LaTeX writer: ensure that simple tables have simple cells.

If cells contain more than a single Plain or Para, then we need to set nonzero widths and put contents into minipages. Closes #2666.

commitbd1917602658467ca2335244ea97f0b39f4f680a authorJohn MacFarlane <jgm@berkeley.edu> dateSun 20 Nov 2016, 17:01 (10 years ago) parent2761fec
1 file changed+8−1
src/Text/Pandoc/Writers/LaTeX.hs+8−1
src/Text/Pandoc/Writers/LaTeX.hs+8−1
@@ -635,7 +635,14 @@ tableRowToLaTeX header aligns widths cols = do
635635 -- scale factor compensates for extra space between columns
636636 -- so the whole table isn't larger than columnwidth
637637 let scaleFactor = 0.97 ** fromIntegral (length aligns)
638− let widths' = map (scaleFactor *) widths
638+ let isSimple [Plain _] = True
639+ isSimple [Para _] = True
640+ isSimple _ = False
641+ -- simple tables have to have simple cells:
642+ let widths' = if not (all isSimple cols)
643+ then replicate (length aligns)
644+ (0.97 / fromIntegral (length aligns))
645+ else map (scaleFactor *) widths
639646 cells <- mapM (tableCellToLaTeX header) $ zip3 widths' aligns cols
640647 return $ hsep (intersperse "&" cells) <> "\\tabularnewline"
641648