点线或虚线 xrightarrow

点线或虚线 xrightarrow

我需要一个带有类似文字的虚线或虚线箭头\xrightarrow

我知道这个MnSymbol包,但\dashedrightarrow不允许我在箭头上写文字。有没有一个包可以完成我想要做的事情?

答案1

以下示例使用\dashrightarrow来自\dashleftarrowAMS 字体(包amsfonts):

\documentclass{article}
\usepackage{amsfonts}
\usepackage{amsmath}

\makeatletter
\newcommand*{\da@rightarrow}{\mathchar"0\hexnumber@\symAMSa 4B }
\newcommand*{\da@leftarrow}{\mathchar"0\hexnumber@\symAMSa 4C }
\newcommand*{\xdashrightarrow}[2][]{%
  \mathrel{%
    \mathpalette{\da@xarrow{#1}{#2}{}\da@rightarrow{\,}{}}{}%
  }%
}
\newcommand{\xdashleftarrow}[2][]{%
  \mathrel{%
    \mathpalette{\da@xarrow{#1}{#2}\da@leftarrow{}{}{\,}}{}%
  }%
}
\newcommand*{\da@xarrow}[7]{%
  % #1: below
  % #2: above
  % #3: arrow left
  % #4: arrow right
  % #5: space left 
  % #6: space right
  % #7: math style 
  \sbox0{$\ifx#7\scriptstyle\scriptscriptstyle\else\scriptstyle\fi#5#1#6\m@th$}%
  \sbox2{$\ifx#7\scriptstyle\scriptscriptstyle\else\scriptstyle\fi#5#2#6\m@th$}%
  \sbox4{$#7\dabar@\m@th$}%
  \dimen@=\wd0 %
  \ifdim\wd2 >\dimen@
    \dimen@=\wd2 %   
  \fi
  \count@=2 %
  \def\da@bars{\dabar@\dabar@}%
  \@whiledim\count@\wd4<\dimen@\do{%
    \advance\count@\@ne
    \expandafter\def\expandafter\da@bars\expandafter{%
      \da@bars
      \dabar@ 
    }%
  }%  
  \mathrel{#3}%
  \mathrel{%   
    \mathop{\da@bars}\limits
    \ifx\\#1\\%
    \else
      _{\copy0}%
    \fi
    \ifx\\#2\\%
    \else
      ^{\copy2}%
    \fi
  }%   
  \mathrel{#4}%
}
\makeatother

\begin{document}

\[ X \xrightarrow{} Y \xrightarrow[\text{below}]{\text{above}} Z \]

\[ X \xdashrightarrow{} Y \xdashrightarrow[\text{below}]{\text{above}} Z \]

\[ X \xleftarrow{} Y \xleftarrow[\text{below}]{\text{above}} Z \]

\[ X \xdashleftarrow{} Y \xdashleftarrow[\text{below}]{\text{above}} Z \]

\end{document}

结果

评论:

  • \dashrightarrow并且\dashleftarrow内部由破折号\dabar@和箭头组成。这用于根据需要延长破折号。
  • \mathpalette根据当前的数学风格,需要进行尺寸调整。

相关内容