如何在 \xrightarrow 上创建负箭头?

如何在 \xrightarrow 上创建负箭头?

假设我有$x\xrightarrow{\rm mb}y$如下第一行中的符号,但我想要一个像在中定义的否定符号\nrightarrow,如第二行中所示,但可以扩展。有人知道我该怎么做吗?

样本

答案1

又一次修订!这里有几种不同的方法可以达到同样的效果,包括承诺的 TikZ 解决方案(虽然如果你还没有在文档中使用 TikZ,它看起来会更长,而且有点负担过重,但实际上箭头,而不是将一堆连字符粘在一起)。

代码:

\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}

结果:

再次射出箭

相关内容