aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlbert Krewinkel <[email protected]>2022-09-21 11:27:06 +0200
committerAlbert Krewinkel <[email protected]>2022-09-21 12:03:41 +0200
commitb38292c2346ebea690eada91a5ac1e0addaa3c0b (patch)
tree85c29297aa45cd0b409b4b94827be67c6ad9c713 /src
parent47d09df6a583587c5d8aadd4b3fc7c009957b219 (diff)
LaTeX writer: do not repeat caption on headless tables
The caption of headless tables was repeated on each page that contained part of the table. It is now made part of the "first head", i.e. the table head that is printed only once.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/LaTeX/Table.hs23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX/Table.hs b/src/Text/Pandoc/Writers/LaTeX/Table.hs
index aca408d5d..ceed60f88 100644
--- a/src/Text/Pandoc/Writers/LaTeX/Table.hs
+++ b/src/Text/Pandoc/Writers/LaTeX/Table.hs
@@ -54,17 +54,17 @@ tableToLaTeX inlnsToLaTeX blksToLaTeX tbl = do
-- repeated on all pages that contain a part of the table. We avoid this by
-- making the caption part of the first head. The downside is that we must
-- duplicate the header rows for this.
- firsthead <- if isEmpty capt || isEmptyHead thead
- then return empty
- else (\firstrows -> capt $$ firstrows $$ "\\endfirsthead") <$>
- headToLaTeX blksToLaTeX colCount thead
- head' <- if isEmptyHead thead
- then return "\\toprule()"
- -- avoid duplicate notes in head and firsthead:
- else headToLaTeX blksToLaTeX colCount
- (if isEmpty firsthead
- then thead
- else walk removeNote thead)
+ head' <- do
+ let mkHead = headToLaTeX blksToLaTeX colCount
+ case (not $ isEmpty capt, not $ isEmptyHead thead) of
+ (False, False) -> return "\\toprule()"
+ (False, True) -> mkHead thead
+ (True, False) -> return (capt $$ "\\toprule()" $$ "\\endfirsthead")
+ (True, True) -> do
+ -- avoid duplicate notes in head and firsthead:
+ firsthead <- mkHead thead
+ repeated <- mkHead (walk removeNote thead)
+ return $ capt $$ firsthead $$ "\\endfirsthead" $$ repeated
rows' <- mapM (rowToLaTeX blksToLaTeX colCount BodyCell) $
mconcat (map bodyRows tbodies) <> footRows tfoot
modify $ \s -> s{ stTable = True }
@@ -73,7 +73,6 @@ tableToLaTeX inlnsToLaTeX blksToLaTeX tbl = do
$ "\\begin{longtable}[]" <>
braces ("@{}" <> colDescriptors tbl <> "@{}")
-- the @{} removes extra space at beginning and end
- $$ firsthead
$$ head'
$$ "\\endhead"
$$ vcat rows'