While achieving strikethrough in word processors may be easy, implementing this effect in LaTeX requires specific commands and packages. This blog post will explore how to add strikethrough text in LaTeX.
Using “ulem” package
In LaTeX, you can easily use the ulem
package to add strikethrough text. Step-by-step instructions are provided here.
Firstly, include the ulem
package in your LaTeX document preamble by adding the following line:
\usepackage{ulem}
Using \sout{} command
To strikethrough text, use the \sout{}
command. Place the text you want to strike through inside the curly braces. Here’s an example:
\documentclass{article}
\usepackage{ulem}
\begin{document}
I wrote a letter to my \sout{friend} but forgot to check the \sout{spelling}.
\end{document}
Output
Note: There are some situations when the \sout{}
command underlines the content inside the curly braces in the ulem
package. It can be resolved by employing the normalem
option in the preamble. This is achieved by including the line:
\usepackage[normalem]{ulem}
Let us take another example:
\documentclass{article}
\usepackage{ulem}
\begin{document}
Consider the equation: \sout{$2x + 3y = 6$}
\end{document}
Output
Using \xout{} command
\xout
is another command the ulem
package provides to create a strikeout effect, crossing out text with diagonal lines.
To use the \xout
command, you must include the ulem
package in your LaTeX document. You can do this by adding the following line in the preamble of your document:
\usepackage{ulem}
Once you have included the package, you can use the \xout{}
command to strike out text. Place the text you want to strike out within the curly braces {}. For example:
\documentclass{article}
\usepackage{ulem}
\begin{document}
I wrote a letter to my \xout{friend} but forgot to check the \xout{spelling}.
\end{document}
Output
\sout vs \xout: What is the Difference?
In LaTeX, both \sout
and \xout
commands are provided by the ulem
package and are used for striking out text. While they serve similar purposes, there are subtle differences between them:
\sout Command:
- The
\sout
command creates a single-line strikeout effect. - It typically draws a solid line through the middle of the text to be struck out.
\sout
is the traditional command provided by theulem
package for striking out text.
\xout Command:
- The
\xout
command, on the other hand, creates a multi-line strikeout effect. - It draws diagonal lines through the text to be struck out, resembling a hand-drawn crossing-out effect.
\xout
offers a more decorative or stylized strikeout appearance compared to\sout
.
Example:
Here’s an example demonstrating the difference between \sout
and \xout
:
\documentclass{article}
\usepackage{ulem}
\begin{document}
\sout{This is a strikeout text} using \texttt{\textbackslash sout}.
\xout{This is a strikeout text} using \texttt{\textbackslash xout}.
\end{document}
Output
Both \sout
and \xout
are useful commands for striking out text in LaTeX documents. Your choice between them depends on the desired visual effect. If you prefer a simple single-line strikeout, use \sout
. For multi-line strikeout, \xout
provides a suitable option.
Why do people use strikethrough text?
People use strikethrough text for various reasons, and it serves different purposes based on the context of its usage. Here are some common reasons why people use strikethrough text:
Correction or Amendment: Strikethrough text often shows that a word or phrase has been edited or corrected. It allows the reader to see the original content while being aware of the updated information.
Rejection or Removal: When collaborating on documents or working on projects, strikethrough text indicates that specific content has been rejected or removed. It serves as a visual cue to show that the crossed-out information is no longer valid or relevant.
Highlighting Errors or Mistakes: Strikethrough text is commonly used to highlight errors or mistakes in a document or text. It can draw attention to the incorrect information while allowing the corrected version to be visible.