Strikethrough in LaTeX

posted in: LaTeX, Technicalities | 8

Today I found a second way to achieve a strikethrough in LaTeX (what is done by »line-through« in css: strike out text). If you want to put a line across text, your choices are »ulem« and »cancel«:

Strikethough in LaTeX using »ulem«

\usepackage{ulem} in the preamble gives you two ways to strike out text (and a couple more for underlining):

1. \sout{text to be striked out} for a horizontal line through text to be striked out (exactly like »line through«).
2. \xout{text to be crossed out} for many short diagonal lines crossing out the letters of the text to be crossed out

The problem that ulem affects some bibliography styles where otherwise italicised text is then underlined can be remedied through the »normalem«-option in the preamble: \usepackage[normalem]{ulem} (Thanks Fredrik!).

Ulem is part of MiKTeX and TeX Live but also available at ctan.

Strikethrough in LaTeX using »cancel«

\usepackage{cancel} in the preamble gives you four different modes of striking through

1. \cancel{text to cancel} draws a diagonal line (slash) through its argument
2. \bcancel{text to cancel} uses the negative slope (a backslash)
3. \xcancel{text to cancel} draws an X (actually \cancel plus \bcancel)
4. \cancelto{〈value〉}{〈expression〉} draws a diagonal arrow through the 〈expression〉pointing to the 〈value〉 (math-mode only)

You can get cancel at ctan.

Results

Click on the image for pdf or download the source file – which looks like this:

 \documentclass[a4paper,11pt]{article} \usepackage[utf8]{inputenc} \usepackage{setspace} \usepackage{ulem} \usepackage{cancel} \begin{document} \sffamily \doublespace \textbf{Ulem:} \verb+\sout{striked out text}+ renders \sout{striked out text} \verb+\xout{crossed out text}+ renders \xout{crossed out text} \textbf{Cancel:} \verb+\cancel{canceled text}+ renders \cancel{canceled text} \verb+\bcancel{b-canceled text}+ renders \bcancel{b-canceled text} \verb+\xcancel{x-canceled text}+ renders \xcancel{x-canceled text} \verb+\cancelto{<value>}{<expression>}+ renders $\cancelto{value}{expression}$ Cancelto also works with more complicated expressions: \verb+\cancelto{\frac{num2}{den2}}{\frac{num1}{den1}}+ renders $\cancelto{\frac{num2}{den2}}{\frac{num1}{den1}}$ 

\end{document} 

8 Responses

1. Car Hire

Thank you for the work you have put into this article, it helps clear up a few questions I had.

2. Fredrik Vestermark

I ran into the same problem when using the emph command in combination with the ulem package. However, it can be solved by using the ‘normalem’ option. \usepackage[normalem]{ulem}

3. beli

Thanks for the tip! And it’s a great blog.

4. Mark B.

Thanks so much for the nice simple writeup on using the cancel and ulem packages. It has helped me a great deal!

5. Poet

Muchas gracias, Jan! Your write-up was super clear and very hepful. Thank you!

6. Gonzalo Rodríguez Prieto

Thanks a lot for the job!

It helped me to make my exams clearer…

7. Jan

Welcome everyone, thanks for letting me know it was useful and Fredrik, thanks for telling me about the option.