# cancel package downward arrow

Let's say that I want to cancel the denominator of a fraction and also assign him a value. Something like that \cancel{2}\cdot\dfrac{9}{\cancelto{2}{4}}. The problem here is that the fraction doesn't look good at all after that. So I need a cancelto command that creates a downward arrow. Is there any way to do it?

-

Here's another proposal based on Gonzalo's answer to this question.
The following code gives you four new commands to be able to diagonally cross out and point to (cancel to) from all four possible directions:

• canceltoSwNe{From}{To}: Cross out diagonally from South-West to North-East
(Bottom-Left to Top-Right)
• canceltoNeSw{From}{To}: Cross out diagonally from North-East to South-West
(Top-Right to Bottom-Left)
• canceltoSeNw{From}{To}: Cross out diagonally from South-East to North-West
(Bottom-Right to Top-Left)
• canceltoNwSe{From}{To}: Cross out diagonally from North-West to South-East
(Top-Left to Bottom-Right)

Some remarks:

• The order of the two arguments is inverse in comparison to the cancelto command from the cancel package, but I find it more logical this way.
• The bounding box differs from the cancel package, see the background color and the fraction examples. This might or might not suit your needs.
The presented cancelto's accept text or math as an argument and can be used in text or in math mode.
The presented cancelto's can be nested, contrary to the ones from the cancelto package.
• As can be seen in the fraction example, the font resizing is not working properly and I couldn't quickly find an easy solution for this problem.
Suggestions are more than welcome!

Here's the code with a couple of examples:

\documentclass{article}

\usepackage{amsmath}
\usepackage{pgfplots}
\pgfplotsset{compat = 1.3}
\usetikzlibrary{arrows}
\usetikzlibrary{calc}

\usepackage{cancel}

% ==================================================================================

\usepackage{relsize}

\newcommand\canceltoSwNe[2]{%
\begin{tikzpicture}[baseline = (B.base)]
\node[anchor = center, inner sep = 0pt] (B) {#1};
\draw[arrows = {}-{latex}]%
($(B.south west)+(-1pt, -1pt)$) -- ($(B.north east)+(+4pt, +1pt)$)%
node [anchor = south west, xshift = +1pt, yshift = -1pt,%
inner sep = 0pt]%
{\smaller\smaller{#2}};
\end{tikzpicture}%
}

\newcommand\canceltoNeSw[2]{%
\begin{tikzpicture}[baseline = (B.base)]
\node[anchor = center, inner sep = 0pt] (B) {#1};
\draw[arrows = {}-{latex}]%
($(B.north east)+(+1pt, +1pt)$) -- ($(B.south west)+(-4pt, -1pt)$)%
node [anchor = north east, xshift = -1pt, yshift = +1pt,%
inner sep = 0pt]%
{\smaller\smaller{#2}};
\end{tikzpicture}%
}

\newcommand\canceltoSeNw[2]{%
\begin{tikzpicture}[baseline = (B.base)]
\node[anchor = center, inner sep = 0pt] (B) {#1};
\draw[arrows = {}-{latex}]%
($(B.south east)+(+1pt, -1pt)$) -- ($(B.north west)+(-4pt, +1pt)$)%
node [anchor = south east, xshift = -1pt, yshift = -1pt,%
inner sep = 0pt]%
{\smaller\smaller{#2}};
\end{tikzpicture}%
}

\newcommand\canceltoNwSe[2]{%
\begin{tikzpicture}[baseline = (B.base)]
\node[anchor = center, inner sep = 0pt] (B) {#1};
\draw[arrows = {}-{latex}]%
($(B.north west)+(-1pt, +1pt)$) -- ($(B.south east)+(+4pt, -1pt)$)%
node [anchor = north west, xshift = +1pt, yshift = +1pt,%
inner sep = 0pt]%
{\smaller\smaller{#2}};
\end{tikzpicture}%
}

% ==================================================================================

\begin{document}

\noindent%
%
%
Baseline\:%
\colorbox{yellow!30!white}{%
\canceltoSwNe{Text to cancel}{Text to write}
}\hspace*{5mm}\colorbox{blue!30!white}{%
$\cancelto{\text{Text to write}}{\text{Text to cancel}}$
}\\
%
Baseline\:%
\colorbox{yellow!30!white}{%
\canceltoSwNe{Text to cancel}{$x^{2}_{z}$}
}\hspace*{5mm}\colorbox{blue!30!white}{%
$\cancelto{x^{2}_{z}}{\text{Text to cancel}}$
}\hspace*{25mm}%
%
\colorbox{yellow!30!white}{%
\canceltoSwNe{$a + 3 \cdot \frac{x}{\alpha}$}{$123$}
}\hspace*{5mm}\colorbox{blue!30!white}{%
$\cancelto{123}{a + 3 \cdot \frac{x}{\alpha}}$

$\frac{1}{\Dcancelto[2]{4}}$

$\frac{89}{\Dcancelto[0]{4367}}$

$\cancel{2}\cdot\dfrac{9}{\Dcancelto[2]{4}}$

\end{document}


Here's the result:

-
thanks for the great answer, I´ve also modified {#2} to {$#2$} in \node[anchor=east,inner sep=2pt] (a) {#2}; to work properly with math expressions like fractions – escalator Apr 11 '14 at 10:46

To change the arrow direction you need to rewrite most of the internals of the cancel package. I would NOT recommend that, because it is very complicated code. May be you can try some other options such as

$$\bcancel{2}\cdot\dfrac{9}{{\bcancel{4}}^2_{}}$$


or

$$\cancel{2}\cdot\dfrac{9}{{\cancel{4}\rule{0pt}{2.ex}}^{\;2}_{}}$$

-