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

9
  • 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, 2011 at 17:50
  • I added an image for you of what you want.
    – Alan Munn
    Mar 20, 2011 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, 2011 at 20:32
  • okay - another non-tex related question. How do I link this username to the other one?
    – Anh Vo
    Mar 20, 2011 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, 2011 at 20:42

1 Answer 1

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

7
  • 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, 2011 at 20:32
  • nvm - i found the comment up there
    – Anh Vo
    Mar 20, 2011 at 21:02
  • @Anh Vo: I moved the comment now (also) to this answer so that Andrew gets notified. Mar 20, 2011 at 21:04
  • 1
    Alternatively you could use \raisebox{.12em}{\tiny/} for the slash. No extra package needed.
    – Alan Munn
    Mar 20, 2011 at 21:15
  • Andrew, this works out perfectly. Thanks a lot!
    – Anh Vo
    Mar 20, 2011 at 21:16

You must log in to answer this question.

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