Cancel in LaTeX (\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.
\documentclass{article}
\usepackage{cancel}
\begin{document}
Cancel: $\cancel{x}$
\[ \frac{\cancel{(x-1)}(x+1)}{\cancel{(x-1)}} = x + 1 \]
\end{document}Related symbols
- Boxed Formula
\boxed{x} - Underbrace
\underbrace{x+y}_{\text{sum}} - Overbrace
\overbrace{x+y}^{\text{sum}} - Ring
\mathring{x} - Check
\check{x} - Breve
\breve{x}
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.
Beste AI LaTeX Editor, Overleaf Alternatief
Octree helpt onderzoekers van 15+ universiteiten sneller onderzoeksartikelen schrijven met AI
- Genereer mooie TikZ-diagrammen met AI
- Upload afbeelding en converteer naadloos naar LaTeX
- Krijg directe hulp bij het schrijven en opmaken van onderzoeksartikelen