diff options
| author | John MacFarlane <[email protected]> | 2022-11-19 12:17:46 -0800 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2022-11-19 12:28:41 -0800 |
| commit | 144bf90ab92b517dd721baf80f121f86187ccd61 (patch) | |
| tree | 4f3616e8b11dce2e6f4191ae22eaf89842fa146f | |
| parent | 202eacb6860967e6c74e8bc73eb8a4a677748243 (diff) | |
LaTeX writer: Use soul instead of ulem for strikeout, underline.
This handles things like hyphenation, line breaks, and nonbreaking
spaces better.
Closes #8411.
| -rw-r--r-- | data/templates/default.latex | 2 | ||||
| -rw-r--r-- | src/Text/Pandoc/Writers/LaTeX.hs | 6 | ||||
| -rw-r--r-- | test/Tests/Writers/LaTeX.hs | 4 | ||||
| -rw-r--r-- | test/command/5529.md | 4 | ||||
| -rw-r--r-- | test/writer.latex | 4 |
5 files changed, 10 insertions, 10 deletions
diff --git a/data/templates/default.latex b/data/templates/default.latex index f7362eb18..bb752a680 100644 --- a/data/templates/default.latex +++ b/data/templates/default.latex @@ -283,7 +283,7 @@ $if(svg)$ $endif$ $if(strikeout)$ $-- also used for underline -\usepackage[normalem]{ulem} +\usepackage{soul} $endif$ \setlength{\emergencystretch}{3em} % prevent overfull lines \providecommand{\tightlist}{% diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index ed5b1973d..d82838e0d 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -771,8 +771,8 @@ inlineToLaTeX (Span (id',classes,kvs) ils) = do else foldr inCmd contents cmds) inlineToLaTeX (Emph lst) = inCmd "emph" <$> inlineListToLaTeX lst inlineToLaTeX (Underline lst) = do - modify $ \st -> st{ stStrikeout = True } -- this gives us the ulem package - inCmd "uline" <$> inlineListToLaTeX lst + modify $ \st -> st{ stStrikeout = True } -- this gives us the soul package + inCmd "ul" <$> inlineListToLaTeX lst inlineToLaTeX (Strong lst) = inCmd "textbf" <$> inlineListToLaTeX lst inlineToLaTeX (Strikeout lst) = do -- we need to protect VERB in an mbox or we get an error @@ -781,7 +781,7 @@ inlineToLaTeX (Strikeout lst) = do -- incorrect results if there is a space, see #5529 contents <- inlineListToLaTeX $ walk (concatMap protectCode) lst modify $ \s -> s{ stStrikeout = True } - return $ inCmd "sout" contents + return $ inCmd "st" contents inlineToLaTeX (Superscript lst) = inCmd "textsuperscript" <$> inlineListToLaTeX lst inlineToLaTeX (Subscript lst) = diff --git a/test/Tests/Writers/LaTeX.hs b/test/Tests/Writers/LaTeX.hs index 3496fccbc..35693d478 100644 --- a/test/Tests/Writers/LaTeX.hs +++ b/test/Tests/Writers/LaTeX.hs @@ -76,11 +76,11 @@ tests = [ testGroup "code blocks" [ "struck out and highlighted" =: strikeout (codeWith ("",["haskell"],[]) "foo" <> space <> str "bar") =?> - "\\sout{\\mbox{\\VERB|\\NormalTok{foo}|} bar}" + "\\st{\\mbox{\\VERB|\\NormalTok{foo}|} bar}" , "struck out and not highlighted" =: strikeout (code "foo" <> space <> str "bar") =?> - "\\sout{\\mbox{\\texttt{foo}} bar}" + "\\st{\\mbox{\\texttt{foo}} bar}" , "single quotes" =: code "dog's" =?> "\\texttt{dog\\textquotesingle{}s}" , "backtick" =: diff --git a/test/command/5529.md b/test/command/5529.md index fcecd9b1f..01c639954 100644 --- a/test/command/5529.md +++ b/test/command/5529.md @@ -4,7 +4,7 @@ ~~_`hello world`_~~ ^D -\sout{\mbox{\texttt{hello\ world}}} +\st{\mbox{\texttt{hello\ world}}} -\sout{\emph{\mbox{\texttt{hello\ world}}}} +\st{\emph{\mbox{\texttt{hello\ world}}}} ``` diff --git a/test/writer.latex b/test/writer.latex index b286d3da9..6a7abfca9 100644 --- a/test/writer.latex +++ b/test/writer.latex @@ -50,7 +50,7 @@ \makeatletter \def\fps@figure{htbp} \makeatother -\usepackage[normalem]{ulem} +\usepackage{soul} \setlength{\emergencystretch}{3em} % prevent overfull lines \providecommand{\tightlist}{% \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} @@ -704,7 +704,7 @@ So is \textbf{\emph{this}} word. This is code: \texttt{\textgreater{}}, \texttt{\$}, \texttt{\textbackslash{}}, \texttt{\textbackslash{}\$}, \texttt{\textless{}html\textgreater{}}. -\sout{This is \emph{strikeout}.} +\st{This is \emph{strikeout}.} Superscripts: a\textsuperscript{bc}d a\textsuperscript{\emph{hello}} a\textsuperscript{hello~there}. |
