@@ -647,23 +647,25 @@ blockToLaTeX (Header level (id',classes,_) lst) = do
647 modify $ \s -> s{stInHeading = False}
647 modify $ \s -> s{stInHeading = False}
648 return hdr
648 return hdr
649blockToLaTeX (Table caption aligns widths heads rows) = do
649blockToLaTeX (Table caption aligns widths heads rows) = do
650− headers <- if all null heads
653− contents <- (tableRowToLaTeX True aligns widths) heads
650+ let toHeaders hs = do contents <- (tableRowToLaTeX True aligns widths) hs
654− return ("\\toprule" $$ contents $$ "\\midrule")
651+ return ("\\toprule" $$ contents $$ "\\midrule")
655− let endhead = if all null heads
652+ let removeNote (Note _) = Span ("", [], []) []
656− then empty
653+ removeNote x = x
657− else text "\\endhead"
658− let endfirsthead = if all null heads
660− else text "\\endfirsthead"
661 captionText <- inlineListToLaTeX caption
654 captionText <- inlineListToLaTeX caption
655+ firsthead <- if isEmpty captionText || all null heads
657+ else ($$ text "\\endfirsthead") <$> toHeaders heads
658+ head' <- if all null heads
660+ -- avoid duplicate notes in head and firsthead:
661+ else ($$ text "\\endhead") <$>
662+ toHeaders (if isEmpty firsthead
664+ else walk removeNote heads)
662 let capt = if isEmpty captionText
665 let capt = if isEmpty captionText
663 then empty
666 then empty
667+ else text "\\caption" <>
664− else text "\\caption" <> braces captionText <> "\\tabularnewline"
668+ braces captionText <> "\\tabularnewline"
667 rows' <- mapM (tableRowToLaTeX False aligns widths) rows
669 rows' <- mapM (tableRowToLaTeX False aligns widths) rows
668 let colDescriptors = text $ concat $ map toColDescriptor aligns
670 let colDescriptors = text $ concat $ map toColDescriptor aligns
669 modify $ \s -> s{ stTable = True }
671 modify $ \s -> s{ stTable = True }
@@ -671,9 +673,9 @@ blockToLaTeX (Table caption aligns widths heads rows) = do
671 braces ("@{}" <> colDescriptors <> "@{}")
673 braces ("@{}" <> colDescriptors <> "@{}")
672 -- the @{} removes extra space at beginning and end
674 -- the @{} removes extra space at beginning and end
674 $$ (if all null heads then "\\toprule" else empty)
677 $$ (if all null heads then "\\toprule" else empty)
675− $$ headers
678+ $$ head'
677 $$ vcat rows'
679 $$ vcat rows'
678 $$ "\\bottomrule"
680 $$ "\\bottomrule"
679 $$ "\\end{longtable}"
681 $$ "\\end{longtable}"