git.iko.soy/typeable/pandoc
on master help sign in
LaTeX writer: always use a minipage for cells with line breaks...

if width information is available. Otherwise the way we treat them can lead to content that overflows a cell. Closes #7393.

commited3974a254c3e0c4e7a34d5d25ddef90c25d2092 authorJohn MacFarlane <jgm@berkeley.edu> dateMon 21 Jun 2021, 18:25 (5 years ago) parenteee6484
2 files changed+11−3
src/Text/Pandoc/Writers/LaTeX/Table.hs+7−2 test/command/7272.md+4−1
src/Text/Pandoc/Writers/LaTeX/Table.hs+7−2
@@ -26,7 +26,8 @@ import Text.DocLayout
2626 ( Doc, braces, cr, empty, hcat, hsep, isEmpty, literal, nest
2727 , text, vcat, ($$) )
2828import Text.Pandoc.Shared (blocksToInlines, splitBy, tshow)
29−import Text.Pandoc.Walk (walk)
29+import Text.Pandoc.Walk (walk, query)
30+import Data.Monoid (Any(..))
3031import Text.Pandoc.Writers.LaTeX.Caption (getCaption)
3132import Text.Pandoc.Writers.LaTeX.Notes (notesToLaTeX)
3233import Text.Pandoc.Writers.LaTeX.Types
@@ -261,8 +262,12 @@ cellToLaTeX blockListToLaTeX celltype annotatedCell = do
261262 Para{} -> True
262263 Plain{} -> True
263264 _ -> False
265+ let hasLineBreak LineBreak = Any True
266+ hasLineBreak _ = Any False
264267 result <-
265− if not hasWidths || (celltype /= HeaderCell && all isPlainOrPara blocks)
268+ if not hasWidths || (celltype /= HeaderCell
269+ && all isPlainOrPara blocks
270+ && not (getAny (query hasLineBreak blocks)))
266271 then
267272 blockListToLaTeX $ walk fixLineBreaks $ walk displayMathToInline blocks
268273 else do
test/command/7272.md+4−1
@@ -18,7 +18,10 @@
1818 >{\raggedright\arraybackslash}p{(\columnwidth - 0\tabcolsep) * \real{1.00}}@{}}
1919\toprule
2020\endhead
21−{\vtop{\hbox{\strut text}\hbox{\strut text2 }}} \\
21+\begin{minipage}[t]{\linewidth}\raggedright
22+{ text\\
23+text2 }
24+\end{minipage} \\
2225\bottomrule
2326\end{longtable}
2427```