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?
1 Answer
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:
-
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 VoCommented Mar 20, 2011 at 20:32 -
-
@Anh Vo: I moved the comment now (also) to this answer so that Andrew gets notified. Commented Mar 20, 2011 at 21:04
-
1Alternatively you could use
\raisebox{.12em}{\tiny/}
for the slash. No extra package needed. Commented Mar 20, 2011 at 21:15 -
$\nrightarrow$
the slash is tiny and I would like to keep the slash that small in the$xslashedrightarrow$
. Thanks!