Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there a

\dashrightarrow

equivalent of:

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

or a similar way to fudge it?

share|improve this question

2 Answers 2

up vote 10 down vote accepted

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@...

share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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