18

Is there a

\dashrightarrow

equivalent of:

\xrightarrow{\hspace*{4mm}} or \longrightarrow 

or a similar way to fudge it?

15

Here is an option:

enter image description here

\documentclass{article}

\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\makeatletter
\newcommand{\xleftrightarrow}[2][]{\ext@arrow 3359\leftrightarrowfill@{#1}{#2}}
\newcommand{\xdashrightarrow}[2][]{\ext@arrow 0359\rightarrowfill@@{#1}{#2}}
\newcommand{\xdashleftarrow}[2][]{\ext@arrow 3095\leftarrowfill@@{#1}{#2}}
\newcommand{\xdashleftrightarrow}[2][]{\ext@arrow 3359\leftrightarrowfill@@{#1}{#2}}
\def\rightarrowfill@@{\arrowfill@@\relax\relbar\rightarrow}
\def\leftarrowfill@@{\arrowfill@@\leftarrow\relbar\relax}
\def\leftrightarrowfill@@{\arrowfill@@\leftarrow\relbar\rightarrow}
\def\arrowfill@@#1#2#3#4{%
  $\m@th\thickmuskip0mu\medmuskip\thickmuskip\thinmuskip\thickmuskip
   \relax#4#1
   \xleaders\hbox{$#4#2$}\hfill
   #3$%
}
\makeatother

\begin{document}
$A \xrightarrow{\text{something}} B$

$A \xdashrightarrow{\text{something}} B$

$A \xleftarrow{\text{something}} B$

$A \xdashleftarrow{\text{something}} B$

$A \xleftrightarrow{\text{something}} B$

$A \xdashleftrightarrow{\text{something}} B$

\end{document}

The above defines a new \arrowfill@@ style (analogous to the original \arrowfill@ already defined by amsmath. The new style removes any negative \mkern between elements used to build the extensible arrow. Also, instead of \cleaders, it uses \xleaders to spread out the dashes as best possible (see Want to fill line with repeating string).

Strange, by amsmath does not define \xleftrightarrow, even though it provides a fill for the arrow through leftrightarrowfill@...

|improve this answer|||||
9

A possible, overkilling solution with TikZ.

It defines \xdasharrow which takes as arguments the text above the arrow and the arrow direction. The latter one is optional. Having an optional argument allows to select the arrow tip as well as colors.

The code:

\documentclass{article}

\usepackage{amsmath}
\usepackage{tikz}

% code by Werner:
% http://tex.stackexchange.com/a/152489/13304
\makeatletter
\newcommand{\xleftrightarrow}[2][]{\ext@arrow 3359\leftrightarrowfill@{#1}{#2}}
\makeatother

\newcommand{\xdasharrow}[2][->]{
% correct vertical setting by egreg:
% http://tex.stackexchange.com/a/59660/13304
\tikz[baseline=-\the\dimexpr\fontdimen22\textfont2\relax]{
\node[anchor=south,font=\scriptsize, inner ysep=1.5pt,outer xsep=2.2pt](x){#2};
\draw[shorten <=3.4pt,shorten >=3.4pt,dashed,#1](x.south west)--(x.south east);
}
}


\begin{document}
$A \xrightarrow{\text{something}} B$

$A \xdasharrow{\text{something}} B$

$A \xleftarrow{\text{something}} B$

$A \xdasharrow[<-,>=latex]{\text{something}} B$ % change of arrow tip

$A \xleftrightarrow{\text{something}} B$

$A \xdasharrow[<->]{\text{something}} B$

\end{document}

The result:

enter image description here

|improve this answer|||||
3

If you want just the basic arrow you can avoid loading heavy packages (which risk unexpected interactions). We just use {color} to erase a portion of the stem. The result has the same arrowtip as \rightarrow:

\usepackage{color}

\newcommand\dashto{\mathrel{
  -\mkern-6mu{\to}\mkern-20mu{\color{white}\bullet}\mkern12mu
}}

This works in sub/superscripts too.

|improve this answer|||||
0

A bit late, but there's also \xymatrix:

\documentclass[12pt]{amsart}
\usepackage[all]{xy}
\begin{document}
$
\xymatrix{
A\ar@{-->}[r]&B
}
$
\end{document}
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.