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.
This commit is contained in:
John MacFarlane
2023-10-17 21:11:16 -07:00
parent fa3513b104
commit f4baa88f42
2 changed files with 16 additions and 12 deletions
+13 -9
View File
@@ -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
+3 -3
View File
@@ -20,15 +20,15 @@ Name
\endhead
\bottomrule\noalign{}
\endlastfoot
\multicolumn{2}{@{}l@{}}{%
\multicolumn{2}{@{}>{\raggedright\arraybackslash}p{(\columnwidth - 2\tabcolsep) * \real{1.0000} + 2\tabcolsep}@{}}{%
Computer Science} \\
3741255 & Jones, Martha \\
4077830 & Pierce, Benjamin \\
5151701 & Kirk, James \\
\multicolumn{2}{@{}l@{}}{%
\multicolumn{2}{@{}>{\raggedright\arraybackslash}p{(\columnwidth - 2\tabcolsep) * \real{1.0000} + 2\tabcolsep}@{}}{%
Russian Literature} \\
3971244 & Nim, Victor \\
\multicolumn{2}{@{}l@{}}{%
\multicolumn{2}{@{}>{\raggedright\arraybackslash}p{(\columnwidth - 2\tabcolsep) * \real{1.0000} + 2\tabcolsep}@{}}{%
Astrophysics} \\
4100332 & Petrov, Alexandra \\
4100332 & Toyota, Hiroko \\