Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

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

\begin{equation}
\bcancel{2}\cdot\dfrac{9}{{\bcancel{4}}^2_{}}
\end{equation}

or

\begin{equation}
\cancel{2}\cdot\dfrac{9}{{\cancel{4}\rule{0pt}{2.ex}}^{\;2}_{}}
\end{equation}
share|improve this answer

With the help of TikZ you can define a command to cancel an expression using a downward arrow:

\documentclass{scrartcl}
\usepackage{amsmath}
\usepackage{cancel}
\usepackage{tikz}
\usetikzlibrary{calc}

\newcommand*\canc[1]{%
  \mathchoice
    {\scriptstyle#1}
    {\scriptstyle#1}
    {\scriptscriptstyle#1}
    {\scriptscriptstyle#1}
}

\newcommand*\Dcancelto[2][0]{%
  \kern9pt%
  \begin{tikzpicture}[baseline=(current bounding box.center).anchor=west]
    \node[anchor=east,inner sep=2pt] (a) {#2};
    \draw[->] ($(a.north west)+(1pt,-2pt)$) -- ($(a.south east)+(0pt,2pt)$) node at ($(a.south east)+(4pt,1pt)$) {$\canc{#1}$};
\end{tikzpicture}
}

\begin{document} 

\[ \Dcancelto[1]{7} \]

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

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

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

\end{document}

Here's the result:

share|improve this answer
    
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 at 10:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.