mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-24 15:44:59 +08:00
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:
@@ -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
|
||||
|
||||
@@ -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 \\
|
||||
|
||||
Reference in New Issue
Block a user