# How do I put text over a squiggly arrow?

I am currently trying to write text over a squiggly arrow (\rightsquigarrow). For normal arrows, I use the extarrows package, which provides commands like \xlongrightarrow and \xLongrightarrow which dynamically stretch the arrow depending on the text length. However, the package does not provide commands for squiggly arrows and I was not able to find another one which does so.

-
Possible Duplicate: How to create a squiggle arrow with some text on it in TikZ?. –  Peter Grill Oct 7 '12 at 8:07

This gives the gist of how you might do it. The key is finding a symbol that is periodic. I used the \sim character, but there might be better. Also, I used the \! symbol for backspacing, but there may be more precise ways of doing it (you'll note the overlap is not perfect in my example).

I created three commands, for the squiggle, the left squig end, and the right squig end. One can just repeat invocations of \squig to make the squiggle longer.

Or one can use \squigs with an argument to get the desired number of squiggles. Next step was to create the commands that allow text to go over the squiggle.

So the real commands you would in general use are \rsquigarrow and \lsquigarrow, each with two arguments: the text to go atop the squiggle, and the squiggle length.

\documentclass[12pt]{article}
\parskip 1ex
\usepackage{amssymb}
\usepackage{ifthen}
\textwidth 2in
\begin{document}
Here are the commands to make periodic squiggles, with no text above
them:

\newcommand{\squig}{$\scriptsize$\sim$\normalsize$\!}
\newcommand{\lsquigend}{$\scriptsize$\lhd\!$\normalsize$}
\newcommand{\rsquigend}{$\scriptsize\rule{.1ex}{0ex}$\rhd$\normalsize$}
\noindent
$2H_2 + O_2 ~\squig\squig\squig\rsquigend~ 2H_2O$\\
$2H_2 + O_2 ~\lsquigend\squig\squig\squig~ 2H_2O$

Now I will create commands to place text over them

\newcounter{index}

\newcommand\squigs[1]{%
\setcounter{index}{0}%
\whiledo {\value{index}< #1}
}

\newcommand\rsquigarrow[2]{$\setbox0\hbox{$\squigs{#2}\rsquigend$}% \tiny$%
\!\!\!\!\begin{array}{c}%
\mathrm{#1}\\%
\usebox0%
\end{array}%
$\normalsize$\!\!%
}

\newcommand\lsquigarrow[2]{$\setbox0\hbox{$\lsquigend\squigs{#2}$}% \tiny$%
\!\!\!\!\begin{array}{c}%
\mathrm{#1}\\%
\usebox0%
\end{array}%
$\normalsize$\!\!%
}

\noindent
$2H_2 + O_2 \rsquigarrow{exothermic}{7} 2H_2O$\\
$2H_2 + O_2 \lsquigarrow{heat}{3} ~ 2H_2O$

\end{document}


-