Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.
share|improve this question
    
\rightleftarrows needs amssymb. –  Harish Kumar Apr 7 at 10:11

1 Answer 1

up vote 7 down vote accepted

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.