I am writing an article in LaTeX 2e. Part of the article describes the Sieve of Eratosthenes, and I want to show examples of how multiples of a prime are removed from the sieve by showing them in a strikethrough font. How do I create a strikethrough font in LaTeX 2e?
Asked
Active
Viewed 8.6e+01k times
442
-
6Very much related: Crossing out sentences – Martin Scharrer Jul 26 '11 at 21:23
-
4For showing the Sieve of Eratosthenes in tikz this might be useful. – Peter Grill Jun 04 '12 at 20:05
-
This is the best resource for strikethrough text – Ritwik Nov 22 '21 at 13:17
-
Related question for using \st{} with accented letters: https://tex.stackexchange.com/questions/160220/french-accents-in-hl-from-soul-package – giusti Jul 16 '22 at 16:34
3 Answers
531
I'm not quite sure what you mean with creating a strikethrough font. However, for striking through text horizontally see:
https://stackoverflow.com/questions/2663944/how-to-strike-out-inside-latex-equations
So with the ulem package this is:
\usepackage[normalem]{ulem}
\sout{Hello World}
With the soul package this is:
\usepackage{soul}
\st{Hello World}

The ulem package seems more up to date so I would use that.
Michael Ohlrogge
- 219
-
24Soul is not available on my machine. I tried ulem. It worked, producing strikethrough text, but also converted emphasized text from italic to underline, which I do not want. So I added a \normalem declaration, and now everything works properly. Thanks! – Jul 21 '11 at 12:57
-
45Just to clarify on the above comment- using the command "\usepackage[normalem]{ulem}" will prevent \emph from being changed, as stated in Section 1 of the documentation (http://mirrors.med.harvard.edu/ctan/macros/latex/contrib/ulem/ulem.pdf) – obfuscation Feb 11 '13 at 13:29
-
5Strangely enough soul seems to have trouble with non-ASCII characters (for instance UTF-8 French). – tiktak Jan 09 '14 at 20:41
-
19The
ulempackage has the highly undesirable side-effect of redefining\emph{}to produce underlined text, rather than italic. (I guess "ulem" stands for something like "underlined emph".) – David Richerby Oct 21 '14 at 12:21 -
13This didn't work for me...
\sout{}is just underlining the text. – MichaelChirico Mar 17 '16 at 19:42 -
-
41
-
@MichaelChirico happened for me, too, until I noticed, that I used \sout in between dollar signs. Once removed, the underline changed to a proper strikethrough. – devbf Nov 17 '23 at 06:33
-
3The
ulempackage no longer seems to be more up-to-date thansoul.ulemwas last updated in 2019.soulwas last updated in 2023. Also, for what it's worth,soulis on the approved list for the ACM Publishing System (TAPS) andulemisn't. – yig Jan 16 '24 at 02:12
66
There is also the cancel package:
\usepackage{cancel}
...
\cancel{text}
The solution to Diagonal strikeout starting too low and ending too high is another option to consider.
Peter Grill
- 223,288
-
52
-
4@tommy.carstensen: Well a package is just a set of macros, so if you define the necessary macros then you don't need to import the complete package. I'd suggest you post a separate question as some others who are more familiar with Plain TeX can probably do a much better job. – Peter Grill Apr 06 '15 at 01:36
-
48
-
\cancel{}fails with an error message: "! You can't use\/' in vertical mode.".\st{}` functions with the same inputs. I work with pdfTeX 3.141592653-2.6-1.40.22 (TeX Live 2022/dev/Debian) – Luís de Sousa May 23 '23 at 09:35 -
@LuísdeSousa: I suggest you port a new question with a fully compilable MWE that duplicates the problem including the
\documentclassand the appropriate packages. – Peter Grill May 23 '23 at 20:16 -
I use $\cancel{x}$ with \usepackage{cancel} but it showed me error which is "! LaTeX Error: File `cancel.sty' not found. Type X to quit or
to proceed, or enter new name. (Default extension: sty)" help please. BTW i am using documentclass
– RIPAN DAS Nov 20 '23 at 14:10 -
@RIPANDAS: That error means that the package is missing. I suggest you update your packages. If you don't want to do that and only install the
cancelpackage. – Peter Grill Nov 20 '23 at 23:49
31
This is for within an equation (I got it off of another forum) and requires amsmath and ulem to be active. The strike is quite long, so using it next to an arrow is troublesome.
\text{\sout{$TEXT$}}
Count Zero
- 17,424
Sara P
- 319
-
2And to make it work properly in math environment, use
\text{\sout{\ensuremath{...}}}, which may be what you meant by$TEXT$. Reference. – Rubens Oct 28 '14 at 06:45 -
3This was very helpful. It works on my Texmaker. Thanks. Do you know how to make such a thing work for Math Stack Exchange? – KeyC0de Oct 09 '15 at 10:09
-
1@Nikos You can use
~between the text you want to strikeout, or\cancelwhen striking out equations. – Skeleton Bow Aug 15 '20 at 00:58