LaTeX Cross Out: Strikethrough Text and Cancel Math

November 11, 2026 · 9 min read

LaTeX Cross Out: Strikethrough Text and Cancel Terms in Math

A LaTeX cross out comes in two kinds. To strike through words, load the ulem package and write \sout{text}. To cancel a term in an equation, load the cancel package and write \cancel{x}. This guide gives you the right command for each job, with examples you can copy and notes on what renders on the web.

Which LaTeX Cross Out Command Should You Use?

Pick the command by what you want to cross out in LaTeX. Words in a sentence need a strikethrough package. Terms inside an equation need the cancel package. The last column shows whether the command also works in KaTeX, the math renderer many websites and Markdown editors use.

GoalPackageCommandWith mathIn KaTeX?
Strike a line through textulem\sout{text}Wraps inline mathYes
Cover text with //////ulem\xout{text}Wraps inline mathNo
Strike text that needs hyphenationsoul\st{text}Wraps inline mathNo
Cancel a term with a slashcancel\cancel{x}Inside math or textYes
Cancel with a backslashcancel\bcancel{x}Inside math or textYes
Draw an X through a termcancel\xcancel{x}Inside math or textYes
Cancel with an arrow to a valuecancel\cancelto{0}{x}Math onlyNo
Negate one relation symbolnone\not\subseteqMath onlyYes

The \not row is a different idea: it negates a single symbol such as a subset sign, rather than crossing out an expression. A line over a symbol, such as \bar{x} or \overline{x}, isn't a cross out either. We compiled every row with pdfLaTeX and checked the KaTeX column against KaTeX 0.16.33.

How Do You Put a Strikethrough Through Text in LaTeX?

Load ulem with the normalem option and wrap the words in \sout. Here's a minimal document that compiles with pdfLaTeX:

\documentclass{article}
\usepackage[normalem]{ulem}
\begin{document}
The answer is \sout{42} 41.
This draft is \xout{finished} in progress.
\end{document}

\sout draws a single line through the middle of the text. \xout covers it with a run of forward slashes, which reads as "deleted" on a printed proof. Both can break across lines between words.

The normalem option matters. By default, ulem turns every \emph in your document into underlined upright text, as the comments at the top of ulem.sty explain. With [normalem], \emph stays italic. You can also write \normalem after loading the package. ulem also handles underlining in LaTeX, using \uline for text that wraps.

ulem vs soul vs lua-ul for Crossing Out Text

Three packages can cross out text in LaTeX, and each fits a different situation:

  • ulem gives you \sout and \xout. It handles references and most nested commands without fuss.
  • soul gives you \st. According to its CTAN page, it uses TeX's hyphenation algorithm, so long struck passages can hyphenate like normal text. Since version 3.0 it also includes the old soulutf8 package, so UTF-8 input works. The current release is 3.2 (March 2026).
  • lua-ul gives you \strikeThrough for LuaLaTeX only. Its package page lists LuaTeX 1.12.0 or newer as a requirement.

soul is pickier about what goes inside its argument. In our pdfLaTeX test, \st{see Section~\ref{sec:one}} stopped with an error, while the same text inside \sout compiled. Wrapping the reference as \mbox{\ref{sec:one}} fixed the soul version.

We prefer ulem with [normalem] for most documents, and reach for soul only when long struck passages need proper hyphenation. If you write in Markdown and convert with Pandoc, note that Pandoc 3.8 turns ~~text~~ into \st and loads soul, or lua-ul's soul mode under LuaLaTeX. Our Markdown to LaTeX guide covers that workflow.

Cross Out Terms in an Equation With \cancel

The cancel package draws diagonal lines through math. Load it with \usepackage{cancel} and use one of four commands:

\[ \frac{\cancel{3}x}{\cancel{3}y} = \frac{x}{y} \]
\[ \bcancel{a} + \xcancel{b} \]
\[ \lim_{x \to 0} \cancelto{0}{x} \]

The first line shows the classic textbook move: a slash through the common factor in a fraction. \bcancel slopes the other way, and \xcancel draws both lines as an X. \cancelto{0}{x} draws an arrow through x that points to a small 0.

A few details from the package source:

  • \cancel, \bcancel and \xcancel work in math and text mode. \cancelto is math only.
  • The marks don't add horizontal space, so they can overprint neighbours. The [makeroom] option widens the space for the \cancelto value.
  • [thicklines] draws heavier lines, which helps when you colour them in a light shade.

Here's a longer worked example, a telescoping product where each numerator cancels the next denominator:

\usepackage[makeroom]{cancel}
...
\[ \frac{2}{\cancel{3}} \cdot \frac{\cancel{3}}{\cancel{4}} \cdot \frac{\cancel{4}}{5} = \frac{2}{5} \]
\[ \cancelto{0}{(x - x)} \, y = 0 \]

With [makeroom], the small 0 from \cancelto gets its own space instead of colliding with the y that follows. Without the option, the 0 crowded the y in our pdfLaTeX test.

One honest caveat: the package's own author calls slashes through math "poor design" in the source comments and, if you use colour, recommends lightly shaded blocks instead. For lecture notes and worked solutions, though, the slash is what students expect to see.

Striking Through a Whole Formula in Display Math

Text strikethrough commands don't belong in display math. In our pdfLaTeX test, \[ \sout{a+b=c} \] compiled, but the line landed below the formula like an underline instead of through it. \st inside \[ \] stopped with an error.

Use \xcancel or \cancel around the whole formula instead:

\[ \xcancel{a^2 + b^2 = c} \]

This draws a clean X across the expression and keeps it centred. For short inline math inside a sentence, put the math inside the text command, as in \sout{$x+1$}. Turning it around, $\sout{x+1}$, put the line under the formula in our pdfLaTeX test.

Which Cross-Out Commands Work in KaTeX and Markdown?

KaTeX has no packages to load. \cancel, \bcancel, \xcancel, \not and \textcolor work out of the box. \cancelto is listed as not supported in the KaTeX support table, and \st, \xout and \usepackage are undefined. MathJax's \require doesn't exist in KaTeX either.

\sout needs a note. KaTeX's docs show it as \text{\sout{abc}}, but text-mode support only arrived in KaTeX 0.16.41 (March 2026). Older builds reject that form with a parse error, so write \sout{...} directly in math, which works in both. That's the opposite of pdfLaTeX, where \sout belongs outside the math. Newer builds may log a console warning for the math form, but still render it.

In our editor, math goes between $...$ for inline and $$...$$ for display. The \(...\) and \[...\] delimiters aren't supported. Our Markdown equation guide covers the basics. For plain text, Markdown has its own syntax, ~~text~~, explained in our Markdown strikethrough guide. For Word or Google Docs, see the strikethrough key shortcut for each app.

Edit the demo below and watch the preview update:

Cancel a common factor:

3x3y=xy\frac{\cancel{3}x}{\cancel{3}y} = \frac{x}{y}

Three cancel styles: a\cancel{a}, b\bcancel{b}, c\xcancel{c}

A red cancel mark: x+1\textcolor{red}{\cancel{x+1}}

Strike a wrong step: 2x=5\sout{2x = 5} then 2x=62x = 6

A Markdown strike for comparison: old value new value

38 words302 characters11 lines
Markdown

Coloured Cross-Outs for Corrections and Worked Solutions

Red marks make corrections easy to spot. In full LaTeX, each package colours its line differently:

\usepackage{xcolor}
% cancel: colour only the slash
\usepackage{cancel}
\renewcommand{\CancelColor}{\color{red}}

% soul: colour only the strike line
\usepackage{soul}
\setstcolor{red}

% ulem: define a red strike command
\usepackage[normalem]{ulem}
\newcommand{\redsout}{\bgroup\markoverwith{\textcolor{red}{\rule[0.5ex]{2pt}{0.4pt}}}\ULon}

\CancelColor colours only the cancel marks, and the term stays black. soul's \setstcolor needs the color or xcolor package. Without one, our pdfLaTeX test stopped with an undefined control sequence error. The \redsout macro builds a red line from ulem's \markoverwith, while \textcolor{red}{\sout{...}} colours the text and the line together.

KaTeX has no \CancelColor. \textcolor{red}{\cancel{x}} colours both the term and the mark, which is what the demo above shows. There's also no \cancelto, so an arrow to zero has to be faked, for example with \cancel{x}^{0}, or left for the PDF version.

LaTeX Cross Out: Quick Answers

Whether you're correcting prose or cancelling factors, a LaTeX cross out comes down to two packages: ulem for text and cancel for math. On the web, KaTeX covers \cancel, \bcancel, \xcancel and \sout without any setup. Try your expressions in the editor, or build a cancelled equation in the LaTeX equation editor and export it as a PNG or SVG.