summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2016-11-20 17:01:51 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2016-11-20 17:01:51 +0100
commitbd1917602658467ca2335244ea97f0b39f4f680a (patch)
tree191a79344547f8a0c7a9d7d10d7df842f46a39b2
parent2761fecd57203c7dcdb30d72e194386942e62251 (diff)
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.
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index 0fd8cdd8c..19f29ceeb 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -635,7 +635,14 @@ tableRowToLaTeX header aligns widths cols = do
-- scale factor compensates for extra space between columns
-- so the whole table isn't larger than columnwidth
let scaleFactor = 0.97 ** fromIntegral (length aligns)
- let widths' = map (scaleFactor *) widths
+ let isSimple [Plain _] = True
+ isSimple [Para _] = True
+ isSimple _ = False
+ -- simple tables have to have simple cells:
+ let widths' = if not (all isSimple cols)
+ then replicate (length aligns)
+ (0.97 / fromIntegral (length aligns))
+ else map (scaleFactor *) widths
cells <- mapM (tableCellToLaTeX header) $ zip3 widths' aligns cols
return $ hsep (intersperse "&" cells) <> "\\tabularnewline"