Cancel in LaTeX (\cancel{x})

x\cancel{x}
LaTeX command
\cancel{x}
Package
Add to your preamble:\usepackage{cancel}
Mode
Text and math mode

Where it is used

Strikes through an expression with a diagonal line to show terms cancelling in a derivation.

Teachers and lecture notes use \cancel to show simplification, for example a factor cancelling in a fraction or opposite terms vanishing in a sum. The same package offers \bcancel (back-slash direction), \xcancel (an X through the term) and \cancelto{0}{x}, which draws an arrow to the value the term goes to. The stroke color can be changed separately from the text color, which helps in slides. \cancel works in text mode too, but it is mostly used in math. Formal papers rarely show cancellation this way; it is a teaching device.

Minimal compilable example

Paste this into an empty .tex file and compile it with pdfLaTeX, XeLaTeX or LuaLaTeX.

(x−1)(x+1)(x−1)=x+1\frac{\cancel{(x-1)}(x+1)}{\cancel{(x-1)}} = x + 1
\documentclass{article}
\usepackage{cancel}
\begin{document}
Cancel: $\cancel{x}$

\[ \frac{\cancel{(x-1)}(x+1)}{\cancel{(x-1)}} = x + 1 \]
\end{document}

Related symbols

All Accents at Modifiers →

Frequently asked questions

How do I write Cancel in LaTeX?
Type \cancel{x} in math mode, for example $\frac{\cancel{(x-1)}(x+1)}{\cancel{(x-1)}} = x + 1$. Load cancel first with \usepackage{cancel}.
Which package do I need for \cancel{x}?
\cancel{x} needs cancel: add \usepackage{cancel} to your preamble before the document starts.
Can I use \cancel{x} in text mode, or only in math mode?
Both. \cancel{x} compiles in running text as well as inside $...$; in a formula keep it in math mode so it gets math fonts and spacing.
Math poweredSumulat ng LaTeX gamit ang AI

Pinakamahusay na AI LaTeX Editor, Alternatibo sa Overleaf

Tinutulungan ng Octree ang mga researcher mula sa 15+ na unibersidad na sumulat ng research papers nang mas mabilis gamit ang AI

  • Gumawa ng magagandang TikZ diagrams gamit ang AI
  • Mag-upload ng larawan at i-convert ito sa LaTeX nang walang problema
  • Makakuha ng instant na tulong sa pagsulat at pag-format ng research papers