# No \xrightrightarrow[a]{b}?

It seems that the commands \xrightarrow, etc. in mathtools package don't allow me to put text above or below two arrows (\rightrightarrows). Is there any way to do this with extensible arrows? A crude way would be

\overset{b}{\underset{a}{\rightrightarrows}}


but the arrows are not extensible. For that matter, it also doesn't support \twoheadrightarrow, etc.

• For example you might want to explain where \rightrightarrow comes from? It is not a standard command, so of course mathtools does not support it. – daleif May 14 '13 at 14:45
• \rightrightarrow is an AMS arrow, two right arrows one above the other. – ashpool May 14 '13 at 14:54
• @daleif -- \rightrightarrows (note plural) and \twoheadrightarrow are both defined in amssymb. the latter is potentially extensible in the same manner as \xrightarrow; the former isn't, since the equal sign can't be used as an extender (as it can for \Rightarrow). – barbara beeton May 14 '13 at 14:58
• @barbarabeeton-- you are right. I corrected to the plural form. Thanks. – ashpool May 14 '13 at 15:21
• That would explain why I couldn't make it compile – daleif May 14 '13 at 20:18

The following example defines \xtwoheadrightarrow and \xtwoheadleftarrow similar to the definitions of \xrightarrow and \xleftarrow:

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

\makeatletter
}
}
}
}
\makeatother

\begin{document}
$A \xrightarrow[under]{over} B \xtwoheadrightarrow[under]{over} C \xtwoheadleftarrow[under]{over} D$
\end{document}


The case \rightrightarrows/\leftleftarrows is much more complicate. Before there is a symbol \relbar that is used for the extensible part of the arrow. But there is no symbol for the double line case. Thus the vertical positions of the lines and their thickness is not known. The following example defines \relrelbar for this purpose that is composed of \relbar lowered and raised by the amount given in macro \relrelbarsep. Therefore this macro needs to be redefined for a different font. The example uses the AMS fonts:

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

\makeatletter
\newcommand*{\relrelbarsep}{.386ex}
\newcommand*{\relrelbar}{%
\mathrel{%
\mathpalette\@relrelbar\relrelbarsep
}%
}
\newcommand*{\@relrelbar}[2]{%
\raise#2\hbox to 0pt{$\m@th#1\relbar$\hss}%
\lower#2\hbox{$\m@th#1\relbar$}%
}
\providecommand*{\rightrightarrowsfill@}{%
\arrowfill@\relrelbar\relrelbar\rightrightarrows
}
\providecommand*{\leftleftarrowsfill@}{%
\arrowfill@\leftleftarrows\relrelbar\relrelbar
}
\providecommand*{\xrightrightarrows}[2][]{%
\ext@arrow 0359\rightrightarrowsfill@{#1}{#2}%
}
\providecommand*{\xleftleftarrows}[2][]{%
\ext@arrow 3095\leftleftarrowsfill@{#1}{#2}%
}
\makeatother

\begin{document}
$A \xrightrightarrows[under]{over} B \xleftleftarrows[under]{over} C$
\end{document}


The numbers 0579, ... are four arguments for \ext@arrow that is defined by package amsmath:

\def\ext@arrow#1#2#3#4#5#6#7{%
\mathrel{\mathop{%
\setbox\z@\hbox{#5\displaystyle}%
\setbox\tw@\vbox{\m@th
\hbox{$\scriptstyle\mkern#3mu{#6}\mkern#4mu$}%
\hbox{$\scriptstyle\mkern#3mu{#7}\mkern#4mu$}%
\copy\z@
}%
\hbox to\wd\tw@{\unhbox\z@}}%
\limits
\@ifnotempty{#7}{^{\if0#1\else\mkern#1mu\fi
#7\if0#2\else\mkern#2mu\fi}}%
\@ifnotempty{#6}{_{\if0#1\else\mkern#1mu\fi
#6\if0#2\else\mkern#2mu\fi}}}%
}


Some remarks:

• The width of box \tw@ contains the maximal width of the text below. above and the symbol without text.
• The latter two numbers specify the margins for the texts in the measurement phase.
• The first two numbers specify the margins for the texts that is finally set and allows to insert some asymmetry of the horizontal placement because of the arrows.
• very nice! you say that \relrelbar needs to be redefined for fonts other than computer modern. but it's true in any case that the definitions for extensible arrows, and especially for double-stem arrows, need to be examined carefully for any other fonts since cm arrows were fine-tuned so that the minus and equals signs could be used as extenders, and this is decidedly not true for most other fonts, even for some that were allegedly created with the intention of being used for math. – barbara beeton May 14 '13 at 15:50
• @barbarabeeton Even worse, the thickness and vertical positions might even depend on the font/design size of the same font. – Heiko Oberdiek May 14 '13 at 15:59
• @HeikoOberdiek Thanks! Could you explain what the numbers 0579, 0395, etc. do exactly? For example, if I want to adopt your code to \rightarrowtail, should I change those numbers? I looked at their definitions, but I'm totally lost. – ashpool May 14 '13 at 16:31

Adapting an answer from How do I put text over a squiggly arrow?. See that answer for a full description of the created macros, though, in the end, the commands to use are \rextlinearrow{string}{integer} for a right arrow and \lextlinearrow{string}{integer} for a left arrow. The integer is the arrow-shaft length defined in terms of multiples of a minus sign. The string is the text to be written over the arrow.

\documentclass[12pt]{article}
\parskip 1ex
\usepackage{amssymb}
\usepackage{ifthen}
\textwidth 2in
\begin{document}
Here are the commands to make extensible arrows, with no text above
them:

\newcommand{\extline}{$\scriptsize$-$\normalsize$\!}
\newcommand{\lextlineend}{$\scriptsize$\lhd\!$\normalsize$}
\newcommand{\rextlineend}{$\scriptsize\rule{.1ex}{0ex}$\rhd$\normalsize$}
\noindent
$2H_2 + O_2 ~\extline\extline\extline\rextlineend~ 2H_2O$\\
$2H_2 + O_2 ~\lextlineend\extline\extline\extline~ 2H_2O$

Now I will create commands to place text over them

\newcounter{index}

\newcommand\extlines[1]{%
\setcounter{index}{0}%
\whiledo {\value{index}< #1}
}

\newcommand\rextlinearrow[2]{$\setbox0\hbox{$\extlines{#2}\rextlineend$}% \tiny$%
\!\!\!\!\begin{array}{c}%
\mathrm{#1}\\%
\usebox0%
\end{array}%
$\normalsize$\!\!%
}

\newcommand\lextlinearrow[2]{$\setbox0\hbox{$\lextlineend\extlines{#2}$}% \tiny$%
\!\!\!\!\begin{array}{c}%
\mathrm{#1}\\%
\usebox0%
\end{array}%
$\normalsize$\!\!%
}

\noindent
$2H_2 + O_2 \rextlinearrow{exothermic}{7} 2H_2O$\\
$2H_2 + O_2 \lextlinearrow{heat}{3} ~ 2H_2O$

\end{document}