39

When to use which package for strikeout?

I see answers :

\usepackage{ulem}
\sout{Hello World}

or

\usepackage{soul}
\st{Hello world}

or

\usepackage{cancel}
\cancel{Hello world}

In what situations is it best to use which one?

Maybe there are other packages I am not aware of?

Shouldn't be there one standard way to strikeout?

5
  • To me the largest difference is that ulem feels like a tool for underlining etc. whereas the SOUL package feels more like a general toolkit for creating text decoration macros that comes with a few pre-defined commands that show you how to use it.
    – Scott H.
    Commented Oct 1, 2012 at 16:42
  • Maybe someone that knows could comment on this: mail-archive.com/[email protected]/msg147217.html
    – Scott H.
    Commented Oct 1, 2012 at 16:46
  • 1
    You should also consider soulpos that combines soul with the savepos mechanism so that you can arbitrary underlining and decorations, including rules, leaders and even pictures. Unlike soul underlines, which are built by repeating small elements, here each chunk of text to be underlined is a single element.
    – skan
    Commented Nov 8, 2017 at 19:50
  • Remark, the way soul works as far as I can see requires the overlay to be "horizontally uniform", so for wavy lines such as tex.stackexchange.com/questions/67064/a-thicker-wave-underline, you have to stick to ulem (as mentioned below does not allow automatic hyphenation) or soulpos (needs two compilation passes).
    – user202729
    Commented Sep 23, 2022 at 8:01
  • Another note is with characters with diacritics, see tex.stackexchange.com/a/142359/250119 for an example.
    – user202729
    Commented May 12, 2023 at 5:56

1 Answer 1

39

cancel is intended for indicating mathematic cancellation, and consequently only works in math mode; it also strikes out diagnoally.

soul and ulem seem pretty similar. One basic semantic difference between them is that ulem per default changes the definition of \emph{...} to underline its argument instead of putting it in italics. This seems to aim at the reproduction of typewriter typesetting, when underlining often was the only means of indicating emphasis. Since using underlining for emphasis is mostly deprecated nowadays, I've always used soul when I did need to underline something.

The one big reason in favor of soul, however, is that it's able to deal with line breaks and hyphenation:

\documentclass{article}

\textwidth=1cm % just to force hyphenation to happen

\usepackage[T1]{fontenc}

\usepackage{cancel,soul,ulem}

\begin{document}
\[
\frac{\cancel{5}*17}{\cancel{5}*23}
\]

X \sout{supercalifragilisticexpialidocious}

X \st{supercalifragilisticexpialidocious}

X \emph{supercalifragilisticexpialidocious}

X \ul{supercalifragilisticexpialidocious}
\end{document}

(The X are necessary because LaTeX won't hyphenate the first word in a paragraph.)

output

6
  • 8
    It should probably also be mentioned that ulem has the package option normalem, which does not make \emph underline its argument. This way you can get the \sout command without changing the behavior of \emph.
    – phfaist
    Commented Feb 15, 2016 at 16:34
  • 4
    Just an addition: It is possible to set explicit hyphenation points in ulem using \-. Those work.
    – Skillmon
    Commented Jan 25, 2018 at 10:50
  • "typewriter typesetting, when underlining often was the only means of indicating emphasis" All manual typewriters had bold because you could type over the text a second time which was a real test of accurate typing. That was also how you created composite characters like diacritics or slashed zero. You could also overtype a / or X to represent crossed out but I was taught it was quicker to draw a ruled line with a pen and remember to do the same for the carbon copy.
    – Doc Octal
    Commented Jul 12, 2022 at 22:12
  • 1
    From the 12-Apr-2013 version of cancel '[\cancel \bcancel and xcancel] work in math and text mode, but \cancelto is only for math mode.'
    – Doc Octal
    Commented Jul 12, 2022 at 22:18
  • AFAIK, soul can't double underline.
    – Gqqnbig
    Commented Nov 23, 2022 at 4:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .