12

I would like a double-headed extensible right-arrow similar to \xrightarrow from amsmath.

I tried using \xtwoheadrightarrow from extpfeil, but the result differs from \xrightarrow in three respects:

  • the arrow head has a different style
  • the arrow itself is longer than I would like it
  • the text above the arrow is too high

enter image description here

What's the most straightforward way of achieving a two-headed version of \xrightarrow?

\documentclass{article}
\usepackage{extpfeil}

\begin{document}
\begin{align*}
  & \xrightarrow{ABCD} \\
  & \xtwoheadrightarrow{ABCD}
\end{align*}
\end{document}

2 Answers 2

21

I'd typeset \xrightarrow, back up a little and add \rightarrow:

\documentclass{article}
\usepackage{amsmath,amssymb}

\newcommand{\rightarrowdbl}{\rightarrow\mathrel{\mkern-14mu}\rightarrow}

\newcommand{\xrightarrowdbl}[2][]{%
  \xrightarrow[#1]{#2}\mathrel{\mkern-14mu}\rightarrow
}

\begin{document}
$A \rightarrowdbl B$

$A \xrightarrow[\beta]{\alpha} B$

$A \xrightarrowdbl[\beta]{\alpha} B$

$A \xrightarrowdbl{\text{overlong text}} B$
\end{document}

enter image description here

2
  • out of curiosity: Why is it important to treat the \mkern-14mu as a math relation? Commented Mar 1, 2023 at 9:04
  • 1
    @PeterGuthmann TeX doesn't add space between relations. Well, maybe this is not so relevant here, but that's what's always done (see \longrightarrow and similar constructions with \joinrel).
    – egreg
    Commented Mar 1, 2023 at 9:11
8

Same principle as in egreg's answer, only using the low level command \ooalign to place the arrows.

\documentclass{article}
\usepackage{amsmath,amssymb}

\newcommand\dhrightarrow{%
  \mathrel{\ooalign{$\rightarrow$\cr%
  $\mkern3.5mu\rightarrow$}}
}

\newcommand\dhxrightarrow[2][]{%
  \mathrel{\ooalign{$\xrightarrow[#1\mkern4mu]{#2\mkern4mu}$\cr%
  \hidewidth$\rightarrow\mkern4mu$}}
}

\begin{document}
\begin{alignat*}{3}
  A \rightarrow B    &&\qquad A \xrightarrow[C]{D} B    &&\qquad A \xrightarrow{\text{long text}} B    & \\
  A \dhrightarrow B  &&\qquad A \dhxrightarrow[C]{D} B  &&\qquad A \dhxrightarrow{\text{long text}} B  &
\end{alignat*}
\end{document}

enter image description here

4
  • I think I fractionally prefer this answer, as the text seems to be centered with respect the arrow as a whole. Thanks.
    – Roly
    Commented Aug 9, 2015 at 20:09
  • Apologies, I've changed my mind (again) and after some experimentation prefer the positioning of the text in @egreg's answer.
    – Roly
    Commented Aug 9, 2015 at 20:27
  • @Roly Thanks for pointing out the issue with text placement. I've implemented a fix, so that the text is placed correctly above and below the arrow, as well as corrected the spacing before and after the arrows.
    – sodd
    Commented Aug 9, 2015 at 20:42
  • Actually it wasn't obvious to me that there was a problem (I preferred yours originally) but after some experimentation I realised it makes more sense for the text to be centred along the arrow shaft. Thanks. Both answers are good.
    – Roly
    Commented Aug 9, 2015 at 20:44

You must log in to answer this question.

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