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 アクセント・修飾子 →

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 poweredAIでLaTeXを書く

最高のAI LaTeXエディタ、Overleaf代替

Octreeは15以上の大学の研究者がAIを使って論文をより速く書くのを支援

  • AIで美しいTikZダイアグラムを生成
  • 画像をアップロードしてシームレスにLaTeXに変換
  • 論文の執筆とフォーマットに即座にサポートを取得