[Tex/LaTex] \xleftrightarrows command in TikZ with arrows matching the LaTeX font

arrowstikz-arrowstikz-pgftikz-styles

There is the command \xrightarrow that inserts an arrow that extends with the text you put above and/or under it.
There is also the command \rightleftarrows (notice the "s" at the end) that display two arrows, one under the other, although they are not extensible and (if I'm not mistaken) require additionally the mathtools package.
(The above is of course also valid for the "dual" leftarrows)

As far as I know, there isn't a command \xrightarrows that extends with the text above/under it and creates and arrow like \rightleftarrows (I googled it and couldn't find any straightforward solution). Maybe it is contained in some obscure package – but if the package isn't already in my distribution I would prefer not haveing to install it (because if I want to compile my document somewhere else, problems might crop up!).

Therefore: How can one program this \xrightarrows command in TikZ such that

  • the arrow tips look exactly like the LaTeX arrow tips (and if I change the LaTeX font the arrow tips from the TikZ drawing also change accordingly)
  • the arrows themselves look exactly like the ones \xrightarrows produces, when the parameters for the text under or above are empty (i.e. not text is present) or there is so little text that the arrows don't have to extend.

Best Answer

Here it is. This should start as the starting point.

\documentclass{article}
\usepackage{mathtools,amssymb}     %% this is not needed. just for demo
\usepackage{tikz}
\usepackage{xparse}
\NewDocumentCommand{\xrightarrows}{ O{}O{} }{%
\mathrel{%
\vcenter{\hbox{%
\begin{tikzpicture}
  \node[minimum width=1cm,minimum height=1ex,anchor=south,align=center] (a){\text{\vphantom{hg}#1}\\[0.5ex] \vphantom{hg}#2};
  \draw[<-] ([yshift=0.35ex]a.west) -- ([yshift=0.35ex]a.east);
  \draw[->] ([yshift=-0.35ex]a.west) -- ([yshift=-0.35ex]a.east);
\end{tikzpicture}
}}%
}%
}
\begin{document}
  $\xleftarrow[under]{over}$

  $\xrightarrow[under]{over} \rightleftarrows$

  Now the new arrows

  $A \xrightarrows B$  \quad $A \xrightarrows[some ght][some text again] B$ 

  $A \xrightarrows[some text here] B$  \quad $A \xrightarrows[][some text again] B$
\end{document}

enter image description here

Related Question