16

Say I have $x\xrightarrow{\rm mb}y$ as in the first line below, but I want a negation symbol like the one defined in \nrightarrow, as in the second line, but extendable. Does anyone know how I can do that?

sample

Alan Munn
  • 218,180
Anh Vo
  • 163
  • Hi Welcome to TeX.sx you can format inline code by enclosing it with backticks (`). For larger bits of code, you can select the code an click on the 101010 icon. – Alan Munn Mar 20 '11 at 17:50
  • I added an image for you of what you want. – Alan Munn Mar 20 '11 at 18:21
  • 1
    Hi Andrew, that seemed to work, but how do I make the slash smaller? Notice that in the provided $\nrightarrow$ the slash is tiny and I would like to keep the slash that small in the $xslashedrightarrow$. Thanks! – Anh Vo Mar 20 '11 at 20:32
  • okay - another non-tex related question. How do I link this username to the other one? – Anh Vo Mar 20 '11 at 20:33
  • @Anh Vo: Your "answer" should rather be a comment to @Andrew's answer or an edit of your original question. To gain the power to comment/edit, please consider to register at tex.stackexchange. – lockstep Mar 20 '11 at 20:42
  • @Anh Vo: After registering, you may also ask a moderator to merge your various accounts. – lockstep Mar 20 '11 at 20:44
  • I can comment on this post, but somehow I can't comment on Andrew's. I logged in using my google account, do I need a separate account at tex.stackexchange to comment on others' posts? Thanks – Anh Vo Mar 20 '11 at 20:45
  • @Anh Vo: I guess it doesn't work because you're an "Unregistered user". I have flagged this post so that a moderator will take care of it. – lockstep Mar 20 '11 at 20:47
  • Anh Vo, @lockstep: I merged the accounts together and converted the answer to a comment. – Martin Scharrer Mar 20 '11 at 21:01

1 Answers1

12

Yet another revision! Here are a few different ways to achieve the same end, including the promised TikZ solution (which, although seemingly longer and a bit of an overload if you're not already using TikZ in a document, does actually draw an arrow rather than sticking a load of hyphens on top of each other).

Code:

\documentclass{standalone}

\usepackage{amsmath}
\usepackage{amssymb} % for \diagup
\usepackage{mathtools}
\usepackage{tikz} % for tikz solution

\makeatletter
\def\slashedarrowfill@#1#2#3#4#5{%
  $\m@th\thickmuskip0mu\medmuskip\thickmuskip\thinmuskip\thickmuskip
   \relax#5#1\mkern-7mu%
   \cleaders\hbox{$#5\mkern-2mu#2\mkern-2mu$}\hfill
   \mathclap{#3}\mathclap{#2}%
   \cleaders\hbox{$#5\mkern-2mu#2\mkern-2mu$}\hfill
   \mkern-7mu#4$%
}

\def\rightslashedarrowfilla@{%
  \slashedarrowfill@\relbar\relbar{\raisebox{1.2pt}{$\scriptscriptstyle\diagup$}}\rightarrow}
\newcommand\xslashedrightarrowa[2][]{%
  \ext@arrow 0055{\rightslashedarrowfilla@}{#1}{#2}}

\def\rightslashedarrowfillb@{%
  \slashedarrowfill@\relbar\relbar/\rightarrow}
\newcommand\xslashedrightarrowb[2][]{%
  \ext@arrow 0055{\rightslashedarrowfillb@}{#1}{#2}}

\def\rightslashedarrowfillc@{%
  \slashedarrowfill@\relbar\relbar{\raisebox{.12em}{\tiny/}}\rightarrow}
\newcommand\xslashedrightarrowc[2][]{%
  \ext@arrow 0055{\rightslashedarrowfillc@}{#1}{#2}}

\pgfdeclareshape{slash underlined}
{
  \inheritsavedanchors[from=rectangle] % this is nearly a circle
  \inheritanchorborder[from=rectangle]
  \inheritanchor[from=rectangle]{north}
  \inheritanchor[from=rectangle]{north west}
  \inheritanchor[from=rectangle]{north east}
  \inheritanchor[from=rectangle]{center}
  \inheritanchor[from=rectangle]{west}
  \inheritanchor[from=rectangle]{east}
  \inheritanchor[from=rectangle]{mid}
  \inheritanchor[from=rectangle]{mid west}
  \inheritanchor[from=rectangle]{mid east}
  \inheritanchor[from=rectangle]{base}
  \inheritanchor[from=rectangle]{base west}
  \inheritanchor[from=rectangle]{base east}
  \inheritanchor[from=rectangle]{south}
  \inheritanchor[from=rectangle]{south west}
  \inheritanchor[from=rectangle]{south east}
  \inheritanchorborder[from=rectangle]
  \foregroundpath{
% store lower right in xa/ya and upper right in xb/yb
    \southwest \pgf@xa=\pgf@x \pgf@ya=\pgf@y
    \northeast \pgf@xb=\pgf@x \pgf@yb=\pgf@y
    \pgf@xc=\pgf@xa
    \advance\pgf@xc by .5\pgf@xb
    \pgf@yc=\pgf@ya
    \advance\pgf@xc by -1.3pt
    \advance\pgf@yc by -1.8pt
    \pgfpathmoveto{\pgfqpoint{\pgf@xc}{\pgf@yc}}
    \advance\pgf@xc by  2.6pt
    \advance\pgf@yc by  3.6pt
    \pgfpathlineto{\pgfqpoint{\pgf@xc}{\pgf@yc}}
    \pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@ya}}
    \pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgf@ya}}
 }
}
\tikzset{nomorepostaction/.code=\let\tikz@postactions\pgfutil@empty}

\newcommand\xslashedrightarrowd[2][]{%
  \mathrel{\tikz[baseline=-.7ex] \path node[slash underlined,draw,->,anchor=south] {\(\scriptstyle #2\)} node[anchor=north] {\(\scriptstyle #1\)};}}

\makeatother

\begin{document}

\(\begin{matrix}
A \nrightarrow C \\[6pt]
A \xslashedrightarrowa[abcdefg]{abcdefg} C\\[6pt]
A \xslashedrightarrowb[abcdefg]{abcdefg} C\\[6pt]
A \xslashedrightarrowc[abcdefg]{abcdefg} C\\[12pt]
A \xslashedrightarrowd[abcdefg]{abcdefg} C
\end{matrix}
\)
\end{document}

Results:

slashed arrows again

Andrew Stacey
  • 153,724
  • 43
  • 389
  • 751