diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 937729c12..1b1966e05 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -744,16 +744,13 @@ inlineListToLaTeX :: PandocMonad m inlineListToLaTeX lst = hcat <$> mapM inlineToLaTeX (fixLineInitialSpaces . fixInitialLineBreaks $ lst) -- nonbreaking spaces (~) in LaTeX don't work after line breaks, - -- so we turn nbsps after hard breaks to \hspace commands. - -- this is mostly used in verse. + -- so we insert a strut: this is mostly used in verse. where fixLineInitialSpaces [] = [] fixLineInitialSpaces (LineBreak : Str s : xs) | Just ('\160', _) <- T.uncons s - = LineBreak : fixNbsps s <> fixLineInitialSpaces xs + = LineBreak : RawInline "latex" "\\strut " : Str s + : fixLineInitialSpaces xs fixLineInitialSpaces (x:xs) = x : fixLineInitialSpaces xs - fixNbsps s = let (ys,zs) = T.span (=='\160') s - in replicate (T.length ys) hspace <> [Str zs] - hspace = RawInline "latex" "\\hspace*{0.333em}" -- We need \hfill\break for a line break at the start -- of a paragraph. See #5591. fixInitialLineBreaks (LineBreak:xs) = diff --git a/test/command/9088.md b/test/command/9088.md new file mode 100644 index 000000000..fca63003d --- /dev/null +++ b/test/command/9088.md @@ -0,0 +1,10 @@ +``` +% pandoc -t latex +| 0 - A +| 1 - B +| 2 - C +^D +~~~0 - A\\ +\strut ~~~1 - B\\ +\strut ~~~2 - C +```