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 Aksen & Pengubah →

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 poweredTulis LaTeX menggunakan AI

Editor LaTeX AI Terbaik, Alternatif Overleaf

Octree membantu penyelidik dari 15+ universiti menulis kertas penyelidikan dengan lebih cepat menggunakan AI

  • Jana diagram TikZ yang cantik menggunakan AI
  • Muat naik imej dan tukar ke LaTeX dengan lancar
  • Dapatkan bantuan segera untuk menulis dan memformat kertas penyelidikan