# How to pair a xrightarrow with text on the top) to a sort of xleftarrow (with text on the bottom)?

I want to to show a two-way relations between A and B, where the arrow from A to B should have some text on top of it, while the relation (arrow) from B back to A should have some text on its bottom.

Which symbols are available that could be used for that?

• What about something like this? Alternatively, this. – Werner Dec 14 '19 at 17:45
• @Werner Second is fine, although I would fill more natural to have the left to right direction on top. With the first image I can not relate the text with one specific direction. – Antonello Dec 14 '19 at 19:09
• Sorry to not having had specified earlier, would a solution be available in the context of MathJax (LaTex Embedded in Markdown) ? From the answers I assume there is no "native" command for the two arrows in "base" LaTex.. – Antonello Dec 16 '19 at 8:23
• Correct. MathJax doesn't possess all the capabilities of pure (La)TeX. – Werner Dec 16 '19 at 17:02

I'd suggest using extensible harpoons:

\documentclass{article}

\usepackage{mathtools}

\begin{document}

$A \xleftrightharpoons[\text{bottom}]{\text{top}} B \qquad A \xrightleftharpoons[\text{bottom}]{\text{top}} B$

\end{document}


Some low level programming:

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newcommand{\rightleftarrows}[2]{%
\mathrel{\mathop{%
\vcenter{\offinterlineskip\m@th
\ialign{\hfil##\hfil\cr
\hphantom{$\scriptstyle\mspace{8mu}{#1}\mspace{8mu}$}\cr
\rightarrowfill\cr
\vrule height0pt width 2em\cr
\leftarrowfill\cr
\hphantom{$\scriptstyle\mspace{8mu}{#2}\mspace{8mu}$}\cr
\noalign{\kern-0.3ex}
}%
}%
}\limits^{#1}_{#2}}%
}
\makeatother

\begin{document}

\begin{gather*}
A\rightleftarrows{}{}B \\
A\rightleftarrows{f}{g}B \\
A\rightleftarrows{\text{top}}{\text{bottom}}B
\end{gather*}

\end{document}


The minimum width is 2em, set using the \vrule in the middle of the alignment. This won't scale in subscripts or superscripts, but such a complicated structure should not appear there.

• Spectacular as ever. The image is perfect. – Sebastiano Dec 14 '19 at 21:39

In case one prefers to use full arrows instead of harpoons, a new command \xrightleftarrows can be defined based on the command \xrightleftharpoons from mathtools.

\documentclass{article}
\usepackage{mathtools}

\makeatletter
\MHInternalSyntaxOn
\def\MT_leftarrow_fill:{%
\arrowfill@\leftarrow\relbar\relbar}
\def\MT_rightarrow_fill:{%
\arrowfill@\relbar\relbar\rightarrow}
\newcommand{\xrightleftarrows}[2][]{\mathrel{%
\raise.55ex\hbox{%
$\ext@arrow 0359\MT_rightarrow_fill:{\phantom{#1}}{#2}$}%
\setbox0=\hbox{%
$\ext@arrow 3095\MT_leftarrow_fill:{#1}{\phantom{#2}}$}%
\kern-\wd0 \lower.55ex\box0}}
\MHInternalSyntaxOff
\makeatother

\begin{document}

$A \xrightleftarrows[\text{bottom}]{\text{top}} B$

\end{document}


Another suggestion using tikz-cd to make the same images of the other users related to your question. You can see my previous answer here: 1-1 correspondence in Category Theory.

\documentclass[a4paper,12pt]{article}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}
A \arrow[r,leftharpoonup, yshift=0.2ex, "\mathrm{up}"] \arrow[r,rightharpoondown, yshift=-0.2ex, "\mathrm{down}"']
& B ,\quad C \arrow[r, rightharpoonup, yshift=0.2ex, "\mathrm{up}"] \arrow[r,leftharpoondown, yshift=-0.2ex, "\mathrm{down}"']
& D
\end{tikzcd}

\begin{tikzcd}
A \arrow[r,rightarrow, yshift=0.3ex, "\mathrm{up}"] \arrow[r,leftarrow, yshift=-0.3ex, "\mathrm{down}"']
& B ,\quad C \arrow[r, leftarrow, yshift=0.3ex, "\mathrm{up}"] \arrow[r,rightarrow, yshift=-0.3ex, "\mathrm{down}"']
& D
\end{tikzcd}
\end{document}