diff options
author | Jose Luis Duran <jlduran@users.noreply.github.com> | 2014-08-28 02:02:20 +0000 |
---|---|---|
committer | Jose Luis Duran <jlduran@users.noreply.github.com> | 2014-08-28 02:02:20 +0000 |
commit | f1d330b7b5eba55562fdfc6059619cee695bd1e8 (patch) | |
tree | 1eb546ab17d24b26ef7ce2c1d32039b468874dcc /src | |
parent | 8f2aa45d69be2f625a8c558744e980bde30c1457 (diff) | |
download | pandoc-f1d330b7b5eba55562fdfc6059619cee695bd1e8.tar.gz |
LaTeX writer: Fix tables
- [x] Fix a bug introduced in 66378062b622b0815a1a2ddce5d557e3ad13330c, which
causes the table caption to repeat across all pages
- [x] Address the issues discussed
[here](https://groups.google.com/forum/#!msg/pandoc-discuss/qMu6_5lYy0o/ZAU7lzAIKw0J)
regarding the extra vertical space.
- [ ] NOTE: This will cause multiline table cells to appear unpadded. See
http://tex.stackexchange.com/questions/34971
- [x] Use [`\tabularnewline`](http://tex.stackexchange.com/questions/78796)
instead of `\\`.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Writers/LaTeX.hs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index d200ecee1..6c17401d0 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -471,12 +471,18 @@ blockToLaTeX (Header level (id',classes,_) lst) = blockToLaTeX (Table caption aligns widths heads rows) = do headers <- if all null heads then return empty - else ($$ "\\midrule\\endhead") `fmap` + else ($$ "\\midrule\n") `fmap` (tableRowToLaTeX True aligns widths) heads + let endhead = if all null heads + then empty + else text "\\endhead" captionText <- inlineListToLaTeX caption let capt = if isEmpty captionText then empty - else text "\\caption" <> braces captionText <> "\\\\" + else text "\\caption" <> braces captionText + <> "\\tabularnewline\n\\toprule\n" + <> headers + <> "\\endfirsthead" rows' <- mapM (tableRowToLaTeX False aligns widths) rows let colDescriptors = text $ concat $ map toColDescriptor aligns modify $ \s -> s{ stTable = True } @@ -484,8 +490,9 @@ blockToLaTeX (Table caption aligns widths heads rows) = do braces ("@{}" <> colDescriptors <> "@{}") -- the @{} removes extra space at beginning and end $$ capt - $$ "\\toprule\\addlinespace" + $$ "\\toprule" $$ headers + $$ endhead $$ vcat rows' $$ "\\bottomrule" $$ "\\end{longtable}" @@ -512,7 +519,7 @@ tableRowToLaTeX header aligns widths cols = do let scaleFactor = 0.97 ** fromIntegral (length aligns) let widths' = map (scaleFactor *) widths cells <- mapM (tableCellToLaTeX header) $ zip3 widths' aligns cols - return $ hsep (intersperse "&" cells) $$ "\\\\\\addlinespace" + return $ hsep (intersperse "&" cells) <> "\\tabularnewline" -- For simple latex tables (without minipages or parboxes), -- we need to go to some lengths to get line breaks working: |