diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2013-08-19 16:03:22 -0700 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2013-08-19 16:03:22 -0700 |
commit | e8ddcfd997bd1733b715a4321f0e57c7860071d2 (patch) | |
tree | 87dd53d6d9453a5def3ffb2545a20bee9ea540b4 /src/Text | |
parent | 0e2605ffdf69b7a6a7c942a986dec4283a886e82 (diff) | |
download | pandoc-e8ddcfd997bd1733b715a4321f0e57c7860071d2.tar.gz |
Scale LaTeX tables so they don't exceed columnwidth.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Writers/LaTeX.hs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 98553c421..ab579a326 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -470,9 +470,13 @@ tableRowToLaTeX header aligns widths cols = do AlignRight -> "\\raggedleft" AlignCenter -> "\\centering" AlignDefault -> "\\raggedright" + -- 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 toCell 0 _ c = c toCell w a c = "\\begin{minipage}" <> valign <> - braces (text (printf "%.2f\\columnwidth" w)) <> + braces (text (printf "%.2f\\columnwidth" + (w * scaleFactor))) <> (halign a <> cr <> c <> cr) <> "\\end{minipage}" let cells = zipWith3 toCell widths aligns renderedCells return $ hsep (intersperse "&" cells) $$ "\\\\\\noalign{\\medskip}" |