How to use strikethrough(strikeout), cross out and cancel out for text and math mode in LaTeX?

This tutorial will remind you of your childhood. When doing cross out algebra. Where you intersect the numerator and denominator with diagonal strikethrough. Along with that, horizontal strikethrough is a popular method for text Formatting.

It is true that there is more than one type of strikethrough(strikeout) that we use in text and math. Of course, we will represent each usage by LaTeX.

Use strike through in text mode

First we will look at the use of text. But, there is no default command, external packages have to complete this task. I will take help of ulem and soul packages in case of text.

Use sout command from ulem package

sout command which represents horizontal strike through. With this you can cancel out multiline paragraph very easily.

Also, this package contain xout command which will diagonaly cancel each character.

\documentclass[12pt]{article}
\usepackage[margin=1.5cm]{geometry}
\usepackage{ulem,xcolor,tikz}
\newcommand{\colorstrikethrough}[2]{\textcolor{#1}{\sout{#2}}}

\begin{document}
\pagecolor{olive!14!white}
\section*{Single Word Strikethrough}

Donec ac luctus dolor. \sout{Vestibulum vitae mattis erat}, in ullamcorper mauris. Morbi ut felis ut velit mattis dictum. Aenean ut luctus leo. Duis nunc mi, \sout{convallis non lectus vitae}, molestie sollicitudin tortor. Sed quis varius erat. Maecenas placerat mauris eget risus congue consequat. Donec iaculis mattis dui, \sout{et semper libero tempus sit amet}. Sed a nibh ut elit fringilla volutpat tempor at elit. 

\section*{Multi line Horizontal strikethrough}

Nulla vel velit sollicitudin, bibendum eros sit amet, euismod metus. \sout{Maecenas sed lorem ut magna viverra pharetra non ac ante. Proin non ante a ante luctus ultrices. Vivamus facilisis ornare risus, non porttitor lorem viverra sed. Aenean in mauris vitae augue euismod ultrices ut eget urna. Vivamus at faucibus libero. Aliquam venenatis orci magna, nec ultrices diam sagittis non. Sed et eros id odio pulvinar bibendum a non leo}. Duis vel lacus mauris. Sed varius maximus turpis, vitae ultrices nunc molestie in. Fusce fringilla sapien a dui ultrices, vitae vestibulum erat malesuada. Morbi ac nisi et massa egestas pellentesque sed quis augue.

\section*{Diagonal Strikethrough on each latter}

Duis nunc mi, convallis non \xout{lectus vitae, molestie sollicitudin tortor}. Nulla vel velit sollicitudin, bibendum eros sit amet, euismod metus. Maecenas sed lorem ut magna viverra pharetra non ac ante. Proin non ante a ante luctus ultrices. Ut elementum vitae sapien eu rutrum.D onec ante eros, lacinia eu lorem eget, fringilla feugiat nisi. Vivamus facilisis ornare risus, non porttitor lorem viverra sed. \xout{Aenean in mauris vitae augue euismod ultrices ut eget urna. Pellentesque dui nisl, elementum quis massa vel, pretium ultrices eros. Aenean feugiat ut nunc ac rutrum. Duis venenatis nisl et lobortis varius}.

\section*{Colored Strikethrough}

Sed in ipsum tempus, posuere nunc ac, maximus sapien. \colorstrikethrough{red}{Nulla egestas}, felis quis semper hendrerit, libero mauris commodo tellus, facilisis malesuada erat erat eu leo. Fusce in risus accumsan, placerat nibh sit amet, placerat magna. Donec congue tincidunt leo, eget tincidunt libero varius non. Integer fermentum, justo nec finibus placerat, mauris tellus gravida purus, \colorstrikethrough{red}{eu luctus tortor tortor lacinia libero}. 


\end{document}

Output :

When changing color of strike through, the color of text is also changing. This is not best practice. But, the following soul package has best solution for this problem.

Use st command from soul package

setstcolor{color_name} command is present in this package along with st command. In which, you can pass the color code as you like.

\documentclass[12pt]{article}
\usepackage[margin=2cm]{geometry}
\usepackage{soul,xcolor}
\begin{document}
\pagecolor{olive!14!white}
\section*{On word and paragraph}

Lorem ipsum dolor sit amet, \st{consectetur} adipiscing elit. Aenean iaculis venenatis nisl iaculis vehicula. \st{Cras rutrum, sem eget pulvinar congue}, augue quam viverra libero, hendrerit scelerisque lectus arcu a massa. In elementum vestibulum justo, id lacinia ex ornare non. Donec ac lacinia arcu. \st{Nullam dapibus lobortis leo}, eu tincidunt lorem pulvinar sit amet. Curabitur quis erat at ligula sodales posuere quis et purus. \st{Vestibulum fermentum lorem augue, et aliquet est porta ut}. Fusce gravida vestibulum eros, in varius quam mollis quis. 

\vspace{1cm}

\st{Nulla egestas, felis quis semper hendrerit, libero mauris commodo tellus, facilisis malesuada erat erat eu leo. Fusce in risus accumsan, placerat nibh sit amet, placerat magna. Donec congue tincidunt leo, eget tincidunt libero varius non. Integer fermentum, justo nec finibus placerat, mauris tellus gravida purus, eu luctus tortor tortor lacinia libero}. 
\setstcolor{red}
\section*{Use color by \textit{setstcolo} cmd}
\st{Nulla facilisi}. Curabitur iaculis tortor et tellus egestas sagittis.\st {Vivamus mi nulla, ultrices ut convallis id, vestibulum vel orci}. Vivamus urna orci, posuere vel nibh a, lacinia semper sapien. Suspendisse fringilla, purus nec hendrerit congue, massa nisl tempor augue, non faucibus ex lectus ut massa. Aliquam facilisis euismod lorem nec posuere. \st{Aliquam sagittis pharetra quam, vitae pharetra tellus ultrices vel.} 
\setstcolor{blue}
\section*{Use color by \textit{setstcolo} cmd}
\st{Nulla facilisi}. Curabitur iaculis tortor et tellus egestas sagittis.\st {Vivamus mi nulla, ultrices ut convallis id, vestibulum vel orci}. Vivamus urna orci, posuere vel nibh a, lacinia semper sapien. Suspendisse fringilla, purus nec hendrerit congue, massa nisl tempor augue, non faucibus ex lectus ut massa. Aliquam facilisis euismod lorem nec posuere. \st{Aliquam sagittis pharetra quam, vitae pharetra tellus ultrices vel.} 

\end{document}

Output :

Use strike through or cancel out in math mode

ulem and soul packages will not work in math mode. For example.

\documentclass[11pt]{article}
\usepackage{ulem,sou}
\begin{document}
\noindent sout and st commands work on text. But, it doesn't work in \sout{math} \st{mode}. See the example below. \\[5pt]
\[ a^2 + \sout{nab} + b^2 = \st{nab} \]

\noindent But, xout command works properly in math mode which is applicable on single character like \xout{math mode}. \\[5pt]

\[ \frac{\xout{a}\, \xout{b}\, \xout{c}}{\xout{a}\, \xout{b}\, \xout{c}} \]
\end{document}

Output :

Ulem and soul not work for math mode.

For this we will explore the cancel package which properly defines all commands for math mode.

cancel command for cancel out equation

If you want to cancel out parts of an equation, you can use \cancel along with other math expressions. Its shape is like a forward slash.

\documentclass[11pt]{article}
\usepackage{cancel}
\begin{document}
 \[ x^2 + \cancel{2xy} + y^2 = \cancel{2xy} + c \]
 
 \[ \frac{\cancel{(x-n)}\cancel{(x-k)}}{\cancel{(x-n)}a} = \frac{\cancel{(x-k)}}{n} \]

\[ \frac{n!}{n} = \frac{\cancel{n}\,(n-1)!}{\cancel{n}} \]
\end{document}

Output :

Use example of cancel cmd.

bcancel command for cancel out equation

Structurally, output of bcancel is exact opposite of cancel command. Like backslash

\documentclass[11pt]{article}
\usepackage{cancel}
\begin{document}
\end{document}
\[ x^2 + \bcancel{4x} + 4 = \bcancel{4x} + 8\]
\[ \frac{\bcancel{(x-a)}\bcancel{(x-b)}}{\bcancel{(x-a)}\bcancel{(x-b)}(x-c)} \]
\[\frac{\bcancel{a}\cdot\bcancel{b}}{\bcancel{ab}\,c}\]
\end{document}

Output :

Use of bcancel.

xcancel command for cross out equation

xcancel command returns cross out or x cancel out. Which is shaped like an X.

\documentclass[11pt]{article}
\usepackage{cancel}
\begin{document}
\[ \frac{(n-1)\xcancel{(n-k)}}{\xcancel{(n-k)}}\]
\[\frac{\xcancel{x}\cdot(x-1)}{2\xcancel{x}}=\frac{x-1}{2}\]
\[\frac{a \cdot \xcancel{b} \cdot \xcancel{c}}{\xcancel{b} \cdot \xcancel{c}}\]
\end{document}

Output :

Use of cancel command.

cancelto command for daigonal arrow

cancelto is used to draw an daigonal arrow from the canceled expression to a specified replacement. Although the remaining three commands of this package work in text mode. but, cancelto command not work for text.

\documentclass[11pt]{article}
\usepackage{cancel}
\begin{document}
\[ \frac{\cancelto{\,(x-1)^{n-1}}{(x-1)^n}}{x-1} =(x-1)^{n-1} \]
\[ \frac{\cancelto{m^4}{m^6}}{\cancel{m^2}} \qquad \frac{\cancelto{\,m^3}{m^6}}{\cancel{m^3}} \qquad\frac{\cancelto{\;m^2}{m^6}}{\cancel{m^4}} \]
\end{document}

Output :

Use cancelto command.

Conclusion

Soul package is best practice for horizontal line. Because you can easily change the color of horizontal line. And for diagonal cancel out or cross out, there is nothing better than the cancel package.

Share tutorial

Don't forget to share if I have added any value to your education life. See you again in another tutorial. thank you!

Facebook iconTwitter iconWhatsapp iconPinterest icon

Md Jidan Mondal

LaTeX expert with over 10 years of experience in document preparation and typesetting. Specializes in creating professional documents, reports, and presentations using LaTeX.

Leave a Comment

Your email address will not be published. Required fields are marked *