[Tex/LaTex] No \xrightrightarrow[a]{b}

arrowsmathtools

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.

Best Answer

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

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

\makeatletter
\providecommand*{\twoheadrightarrowfill@}{%
  \arrowfill@\relbar\relbar\twoheadrightarrow
}
\providecommand*{\twoheadleftarrowfill@}{%
  \arrowfill@\twoheadleftarrow\relbar\relbar
}
\providecommand*{\xtwoheadrightarrow}[2][]{%
  \ext@arrow 0579\twoheadrightarrowfill@{#1}{#2}%
}
\providecommand*{\xtwoheadleftarrow}[2][]{%
  \ext@arrow 5097\twoheadleftarrowfill@{#1}{#2}%
}
\makeatother

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

Result

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}

Result

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.