REVISED SOLUTION (AUTOMATED EXTENSIBILITY):
There are two arguments: the overset and underset text (set in \scriptstyle
). You can play with the value 1.7
in my MWE, which will change the arrow length relative to the text length (smaller value will lengthen the arrow).
\documentclass{article}
\usepackage{stackengine}
\usepackage{scalerel}
\usepackage{fp}
\def\clipeq{\!\mathrm{=}\!}
\def\Lla{\Longleftarrow\!\!\!\!\!\!}
\def\Lra{\!\!\!\!\!\!\Longrightarrow}
\newcount\argwidth
\newcount\clipeqwidth
\savestack\tempstack{\stackon{$\clipeq$}{}}%
\clipeqwidth=\wd\tempstackcontent\relax
\newcommand\xleftrightarrows[2]{%
\savestack\tempstack{\stackon{$\scriptstyle#1$}{$\scriptstyle#2$}}%
\argwidth=\wd\tempstackcontent\relax%
\FPdiv\scalefactor{\the\argwidth}{\the\clipeqwidth}%
\FPsub\scalefactor{\scalefactor}{1.7}% <---CAN PLAY WITH THIS VALUE
\FPmax\scalefactor{\scalefactor}{.05}%
\mathrel{%
\stackunder[2pt]{\stackon[3pt]{$\Lla\hstretch{\scalefactor}{\clipeq}\Lra$}%
{$\scriptstyle#1$}}{$\scriptstyle#2$}%
}%
}
\parskip 1ex
\begin{document}
$Z \xleftrightarrows{ABC}{defghi} R$
$\xleftrightarrows{}{}$
$\xleftrightarrows{a}{}$
$\xleftrightarrows{ab}{}$
$\xleftrightarrows{abc}{}$
$\xleftrightarrows{abcd}{}$
$\xleftrightarrows{abcde}{}$
\end{document}
ORIGINAL SOLUTION (MANUAL EXTENSIBILITY):
I create the macro you asked for with two mandatory arguments and one optional argument. The mandatory args are the overset and underset text (set in \scriptstyle
). The optional argument is a real number which is indicative of the length scale of the arrow (roughly equal to how many characters longer you would like to make the default arrow).
Note: I wrapped a \mathrel{}
about the stacking commands, assuming that's the way you wanted to use it. Also, the width of the stack will conform to the width of the longest element of the stack. If you wanted the width of the stack to conform to the arrow width, regardless of the length of the over- and underset text, you could add \def\useanchorwidth{T}
to the beginning of the \xleftrightarrows
definition. You can also tweak the overset and underset separation distances (currently set to 3pt and 2pt, respectively.
\documentclass{article}
\usepackage{stackengine}
\usepackage{scalerel}
\def\clipeq{\!\mathrm{=}\!}
\def\Lla{\Longleftarrow\!\!\!\!}
\def\Lra{\!\!\!\!\Longrightarrow}
\newcommand\xleftrightarrows[3][0]{%
\mathrel{%
\ifthenelse{\equal{#1}{0}}%
{\stackunder[2pt]{\stackon[3pt]{$\Lla\Lra$}%
{$\scriptstyle#2$}}{$\scriptstyle#3$}}%
{\stackunder[2pt]{\stackon[3pt]{$\Lla\hstretch{#1}{\clipeq}\Lra$}%
{$\scriptstyle#2$}}{$\scriptstyle#3$}}%
}%
}
\begin{document}
$Q \xleftrightarrows{ABC}{defghi} Z \xleftrightarrows[3]{ABC}{defghi} R$
\end{document}
Since you seem to be waiting for a tikz-cd
-solution (Thanks to Bernard for typing all the formulae from your drawing):
% arara: pdflatex
\documentclass{article}
\usepackage{tikz-cd}
\usepackage{mhchem}
\begin{document}
\begin{tikzcd}[row sep=0.6cm]
\ce{Cr} \arrow{r}{1} & \ce{Cr2O3} \arrow{r} \arrow{dr}[swap]{5} & \ce{CrCl3} \arrow{r}{3} & \ce{Cr(OH)3} \arrow{dl} \arrow{r}{4} \arrow{d}{7} & \ce{Cr2O3}\\
& &\ce{KCrO2} \arrow{r}{6} & \ce{Cr(NO3)3} &
\end{tikzcd}
\end{document}
If you want to rotate the number 5 to the same angle of the arrow, you may write \arrow{dr}[swap,sloped]{5}
.
Edit:
For your second picture:
\documentclass{article}
\usepackage{tikz-cd}
\usepackage{mhchem}
\begin{document}
\[
\begin{tikzcd}
\ce{Al2(SO4)3} \arrow[shift left]{r}{2} & \ce{Al(OH)3} \arrow[shift left]{l}{7}
\end{tikzcd}
\]
\end{document}
Best Answer
Messing around with the code found in
mathtools
, which defines several types of extensible arrows on, I got the following:EDIT: To get filled arrows with the same shape as the empty ones, I used the
\rhd
(▷) and\RHD
(▶) commands fromwasysym
:They have the same behavior as
\longrightarrow
and friends in that they don't scale as much (at all?) as the regular arrows.