git.iko.soy/typeable/pandoc
on master help sign in
LaTeX tables: more space btw lines, top-align cells.
09479baJohn MacFarlane
src/Text/Pandoc/Writers/LaTeX.hs+4−3
@@ -271,7 +271,8 @@ blockToLaTeX (Header level lst) = do
271blockToLaTeX (Table caption aligns widths heads rows) = do
271blockToLaTeX (Table caption aligns widths heads rows) = do
272 headers <- if all null heads
272 headers <- if all null heads
273 then return empty
273 then return empty
274+ else liftM ($$ "\\hline\\noalign{\\smallskip}")
274− else liftM ($$ "\\hline") $ (tableRowToLaTeX widths) heads
275+ $ (tableRowToLaTeX widths) heads
275 captionText <- inlineListToLaTeX $ deVerb caption
276 captionText <- inlineListToLaTeX $ deVerb caption
276 rows' <- mapM (tableRowToLaTeX widths) rows
277 rows' <- mapM (tableRowToLaTeX widths) rows
277 let colDescriptors = concat $ zipWith toColDescriptor widths aligns
278 let colDescriptors = concat $ zipWith toColDescriptor widths aligns
@@ -306,10 +307,10 @@ tableRowToLaTeX :: [Double] -> [[Block]] -> State WriterState Doc
306tableRowToLaTeX widths cols = do
307tableRowToLaTeX widths cols = do
307 renderedCells <- mapM blockListToLaTeX cols
308 renderedCells <- mapM blockListToLaTeX cols
308 let toCell 0 c = c
309 let toCell 0 c = c
309− toCell w c = "\\parbox{" <> text (printf "%.2f" w) <>
310+ toCell w c = "\\parbox[t]{" <> text (printf "%.2f" w) <>
310 "\\columnwidth}{" <> c <> cr <> "}"
311 "\\columnwidth}{" <> c <> cr <> "}"
311 let cells = zipWith toCell widths renderedCells
312 let cells = zipWith toCell widths renderedCells
312− return $ (hcat $ intersperse (" & ") cells) <> "\\\\"
313+ return $ (hcat $ intersperse (" & ") cells) <> "\\\\\\noalign{\\medskip}"
313
314
314listItemToLaTeX :: [Block] -> State WriterState Doc
315listItemToLaTeX :: [Block] -> State WriterState Doc
315listItemToLaTeX lst = blockListToLaTeX lst >>= return . (text "\\item" $$) .
316listItemToLaTeX lst = blockListToLaTeX lst >>= return . (text "\\item" $$) .