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?
-
6Very much related: Crossing out sentencesMartin Scharrer– Martin Scharrer2011-07-26 21:23:16 +00:00Commented Jul 26, 2011 at 21:23
-
4For showing the Sieve of Eratosthenes in tikz this might be useful.Peter Grill– Peter Grill2012-06-04 20:05:46 +00:00Commented Jun 4, 2012 at 20:05
-
2This is the best resource for strikethrough textRitwik– Ritwik2021-11-22 13:17:53 +00:00Commented Nov 22, 2021 at 13:17
-
Related question for using \st{} with accented letters: tex.stackexchange.com/questions/160220/…giusti– giusti2022-07-16 16:34:13 +00:00Commented Jul 16, 2022 at 16:34
4 Answers
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.
-
27Soul 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!user448810– user4488102011-07-21 12:57:40 +00:00Commented Jul 21, 2011 at 12:57
-
48Just 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 (mirrors.med.harvard.edu/ctan/macros/latex/contrib/ulem/ulem.pdf)obfuscation– obfuscation2013-02-11 13:29:18 +00:00Commented Feb 11, 2013 at 13:29
-
20The
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– David Richerby2014-10-21 12:21:00 +00:00Commented Oct 21, 2014 at 12:21 -
14This didn't work for me...
\sout{}is just underlining the text.MichaelChirico– MichaelChirico2016-03-17 19:42:39 +00:00Commented Mar 17, 2016 at 19:42 -
48I am amazed you need an extra package for such a basic function.luchonacho– luchonacho2020-05-26 15:44:52 +00:00Commented May 26, 2020 at 15:44
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.
-
60Is it possible to do strikeout without importing a package?tommy.carstensen– tommy.carstensen2015-03-19 16:38:55 +00:00Commented Mar 19, 2015 at 16:38
-
5@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– Peter Grill2015-04-06 01:36:39 +00:00Commented Apr 6, 2015 at 1:36
-
58I am amazed you need an extra package for such a basic function.luchonacho– luchonacho2020-05-26 15:44:58 +00:00Commented May 26, 2020 at 15:44
-
1
\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– Luís de Sousa2023-05-23 09:35:37 +00:00Commented May 23, 2023 at 9: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– Peter Grill2023-05-23 20:16:33 +00:00Commented May 23, 2023 at 20:16
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$}}
-
3
-
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– KeyC0de2015-10-09 10:09:19 +00:00Commented Oct 9, 2015 at 10:09
-
1@Nikos You can use
~between the text you want to strikeout, or\cancelwhen striking out equations.Oion Akif– Oion Akif2020-08-15 00:58:21 +00:00Commented Aug 15, 2020 at 0:58
Obviously you should use ulem or soul (or soulpos or lua-ul).
That said, if you're working with some terrible platform where you cannot modify the preamble and none of the above package is loaded, you can also do this (horrible hack):
\raisebox{1ex}{\underline{\smash{\raisebox{-1ex}{hello world}}}}
The advantage is you don't need extra package. The disadvantage is of course you can't linebreak within it.
Aside: this doesn't work in MathJax out of the box, but you can replace \raisebox with \raise.
