# \cancel: double strike

Is it possible to generate multiple \cancel stripes? Say for instance I have

$f(x,y) = 3x^2 +2xy +4y^2 - 3x^3 - 3x^2 - 2xy + 4xy^3$


and I want to cancel the 3x^2-term once and the 2xy-term twice.

$f(x,y) = 3x^2 +2xy +4y^2 - 3x^3 - 3x^2 - 2xy + 4xy^3$


Obviously,

$f(x,y) = \cancel{3x^2} +\cancel{\cancel{2xy}} +4y^2 - 3x^3 - \cancel{3x^2} - \cancel{\cancel{2xy}} + 4xy^3$


does not work...

• Welcome to TeX.SX! A tip: If you indent lines by 4 spaces or enclose words in backticks , they'll be marked as code, as can be seen in my edit. You can also highlight the code and click the "code" button (with "{}" on it). – ebosi Jun 15 '16 at 10:07
• – Steven B. Segletes Jun 15 '16 at 10:15
• If it is to distinguish between cancellations, you might use \bcancel. – Bernard Jun 15 '16 at 10:16
• @StevenB.Segletes I knew I recently saw a similar post, but didn't succeed in finding it! – ebosi Jun 15 '16 at 10:17
• \bcancel would work, but then the problem poses itself again if i want to cancel three pairs of terms. – Werner Jun 15 '16 at 10:18

I used my answer at How to cross-out a number several times? and modified to

1. make it in math mode,

2. auto-stretch the cancel to fit the term size.

Here is the revised MWE.

\documentclass{article}
\usepackage{stackengine,graphicx,amsmath,fp,scalerel}
\newcount\crosswd
\newcount\termwd
\newcommand\rawcrossout{\ensurestackMath{%
\setbox0=\hbox{$#2$}%
\crosswd=\wd0\relax%
\setbox0=\hbox{$#1$}%
\termwd=\wd0\relax%
\FPdiv\myscale{\the\termwd}{\the\crosswd}%
\stackengine{0pt}{#1}{\stretchrel*{\scalebox{\myscale}{#2}}{#1}}{O}{c}{F}{T}{L}}}
\def\XX{\kern-3pt/}
\def\YY{\kern-.5pt}
\newcommand\crossout{\rawcrossout{#1}{\YY/\YY}}
\newcommand\dcrossout{\rawcrossout{#1}{\YY/\XX\YY}}
\newcommand\tcrossout{\rawcrossout{#1}{\YY/\XX\XX\YY}}
\newcommand\qcrossout{\rawcrossout{#1}{\YY/\XX\XX\XX\YY}}
\begin{document}
$f(x,y) = 3x^2 +2xy +4y^2 - 3x^3 - \crossout{3x^2} - \tcrossout{2xy} + 4xy^3$

$f(x,y) = 3x^2 +2xy +4y^2 - 3x^3 - \dcrossout{3x^2} - \tcrossout{2\dfrac{\partial \psi^{\ast}}{\partial \theta}\dfrac{\sin\theta \cos\theta}{r^2}} + \qcrossout{4xy^3}$
\end{document} I used my answer at How to cross-out a number several times? and modified to

1. make it in math mode,

2. stretch the cancel horizontally by a default amount, and

3. allow an optional argument to respecify the horizontal stretch value. Thus, for example, \crossout{3x^2} could be used to make the 1-stroke cancel wider.

Here is the MWE.

\documentclass{article}
\usepackage{stackengine,graphicx}
\newcommand\rawcrossout{\ensurestackMath{%
\stackengine{0pt}{#2}{\scalebox{#1}{#3}}{O}{c}{F}{T}{L}}}
\def\XX{\kern-3pt/}
\newcommand\crossout[2.5]{\rawcrossout{#1}{#2}{/}}
\newcommand\dcrossout[2.5]{\rawcrossout{#1}{#2}{/\XX}}
\newcommand\tcrossout[2.5]{\rawcrossout{#1}{#2}{/\XX\XX}}
\newcommand\qcrossout[2.0]{\rawcrossout{#1}{#2}{/\XX\XX\XX}}
\begin{document}
$f(x,y) = 3x^2 +2xy +4y^2 - 3x^3 - \crossout{3x^2} - \dcrossout{2xy} + 4xy^3$
\end{document} • That's already a step in the right direction, but unfortunately it doesn't work well with 'larger' expressions. The example I gave here was somewhat artificial, I'd be more interested to be able to double cancel terms of this size: $f(x,y) = 3x^2 +2xy +4y^2 - 3x^3 - \dcrossout{3x^2} - \dcrossout{{2\dfrac{\partial \psi^{\ast}}{\partial \theta}\dfrac{\sin\theta \cos\theta}{r^2}}} + 4xy^3$ Oops, I can't get the code to work. I only have a small edit window at my disposal... – Werner Jun 15 '16 at 10:28
• @Werner I could work to make the crossout autoscale to the object size, but then, the appearance would change with the object width/height. Is that acceptable? – Steven B. Segletes Jun 15 '16 at 10:39
• Yes, that would be perfectly acceptable. – Werner Jun 15 '16 at 10:42
• @Werner Please see revision. – Steven B. Segletes Jun 15 '16 at 11:01
• @Werner You are welcome. The strokes can be made slightly thinner by modifiying \def\XX{\kern-0pt/}`. – Steven B. Segletes Jun 15 '16 at 11:43