diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2023-10-17 21:09:31 -0700 |
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2023-10-17 21:11:16 -0700 |
| commit | f4baa88f4267e2056269efa71ce78ee290b0e9aa (patch) | |
| tree | 72f8bec824751b6b23565b4edee3c8a65e6b4e7c /src | |
| parent | fa3513b104e089a8969f3ae0dab98eba78b1a942 (diff) | |
LaTeX writer: don't treat table as "simple" if they have col widths.
This should help fix a problem wherein some grid tables with
colspans were overly wide. See #9140.
The example given there still produces suboptimal
output (overlapping text), so not closing yet.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Text/Pandoc/Writers/LaTeX/Table.hs | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX/Table.hs b/src/Text/Pandoc/Writers/LaTeX/Table.hs index 1d9b117ca..ee5c62a3b 100644 --- a/src/Text/Pandoc/Writers/LaTeX/Table.hs +++ b/src/Text/Pandoc/Writers/LaTeX/Table.hs @@ -47,11 +47,13 @@ tableToLaTeX :: PandocMonad m tableToLaTeX inlnsToLaTeX blksToLaTeX tbl = do let (Ann.Table (ident, _, _) caption specs thead tbodies tfoot) = tbl CaptionDocs capt captNotes <- captionToLaTeX inlnsToLaTeX caption ident - let isSimpleTable = all (all isSimpleCell) $ mconcat - [ headRows thead - , concatMap bodyRows tbodies - , footRows tfoot - ] + let isSimpleTable = + all ((== ColWidthDefault) . snd) specs && + all (all isSimpleCell) + (mconcat [ headRows thead + , concatMap bodyRows tbodies + , footRows tfoot + ]) let removeNote (Note _) = Span ("", [], []) [] removeNote x = x let colCount = ColumnCount $ length specs @@ -111,12 +113,14 @@ tableToLaTeX inlnsToLaTeX blksToLaTeX tbl = do isSimpleCell :: Ann.Cell -> Bool isSimpleCell (Ann.Cell _ _ (Cell _attr _align _rowspan _colspan blocks)) = case blocks of - [Para _] -> True - [Plain _] -> True + [Para _] -> not (hasLineBreak blocks) + [Plain _] -> not (hasLineBreak blocks) [] -> True _ -> False - - + where + hasLineBreak = getAny . query isLineBreak + isLineBreak LineBreak = Any True + isLineBreak _ = Any False -- | Total number of columns in a table. newtype ColumnCount = ColumnCount Int |
