1

So I know the cancel package lets you put a diagonal arrow through text in Math mode, but how could I achieve the same result but with a horizontal arrow?

2
  • The result doesn't seem pretty: the arrow tip will confuse with the text underneath.
    – egreg
    Commented Nov 24, 2015 at 21:59
  • @egreg I'm imaging an image that, if I try to approximate it with ASCII, would look like: x -f-u-n-c-t-i-o-n-> y. Of course I don't always want the text that is overlapping with arrow to be 'function' but this gives a sense of what I want it to look like. But the arrow-head should stick out some distance to the right of the text so that there isn't that confusion.
    – Addem
    Commented Nov 24, 2015 at 23:13

1 Answer 1

1

Maybe something like this, using \xrightarrow:

\documentclass{article}
\usepackage{amsmath}

\newcommand{\arrowcancel}[1]{%
  \mathrel{%
    \sbox0{$\mspace{3mu}{#1}\mspace{6mu}$}%
    {\vphantom{#1}
     \ooalign{%
       $\xrightarrow{\hspace{\wd0}}$\cr
       \hidewidth\box0 \hidewidth\cr
     }%
    }%
  }%
}

\begin{document}

$x\arrowcancel{abc}y$

\end{document}

enter image description here

2
  • I'm playing around with it and can't figure out how I might automatically make the arrow head extend just a little farther to the right. I know I can do it if I use the command \arrowcancel{abc\,\,} but is there a way to automate this effect?
    – Addem
    Commented Nov 24, 2015 at 23:31
  • 1
    @Addem Change \mspace{6mu} into \mspace{9mu} or so.
    – egreg
    Commented Nov 24, 2015 at 23:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .