git.iko.soy/typeable/pandoc
on master help sign in
LaTeX writer: Avoid double toprule in headerless table with caption.

Closes #2742.

commite821b05125c8b18a1c09a5d4fd62ee7483704bbb authorJohn MacFarlane <jgm@berkeley.edu> dateFri 18 Mar 2016, 16:16 (11 years ago) parent8d1c018
1 file changed+10−7
src/Text/Pandoc/Writers/LaTeX.hs+10−7
src/Text/Pandoc/Writers/LaTeX.hs+10−7
@@ -571,18 +571,21 @@ blockToLaTeX (Header level (id',classes,_) lst) = do
571571blockToLaTeX (Table caption aligns widths heads rows) = do
572572 headers <- if all null heads
573573 then return empty
574− else ($$ "\\midrule\n") `fmap`
575− (tableRowToLaTeX True aligns widths) heads
574+ else do
575+ contents <- (tableRowToLaTeX True aligns widths) heads
576+ return ("\\toprule" $$ contents $$ "\\midrule")
576577 let endhead = if all null heads
577578 then empty
578579 else text "\\endhead"
580+ let endfirsthead = if all null heads
581+ then empty
582+ else text "\\endfirsthead"
579583 captionText <- inlineListToLaTeX caption
580584 let capt = if isEmpty captionText
581585 then empty
582− else text "\\caption" <> braces captionText
583− <> "\\tabularnewline\n\\toprule\n"
584− <> headers
585− <> "\\endfirsthead"
586+ else text "\\caption" <> braces captionText <> "\\tabularnewline"
587+ $$ headers
588+ $$ endfirsthead
586589 rows' <- mapM (tableRowToLaTeX False aligns widths) rows
587590 let colDescriptors = text $ concat $ map toColDescriptor aligns
588591 modify $ \s -> s{ stTable = True }
@@ -590,7 +593,7 @@ blockToLaTeX (Table caption aligns widths heads rows) = do
590593 braces ("@{}" <> colDescriptors <> "@{}")
591594 -- the @{} removes extra space at beginning and end
592595 $$ capt
593− $$ "\\toprule"
596+ $$ (if all null heads then "\\toprule" else empty)
594597 $$ headers
595598 $$ endhead
596599 $$ vcat rows'