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.

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.

share|improve this question
1  
Possible Duplicate: How to create a squiggle arrow with some text on it in TikZ?. –  Peter Grill Oct 7 '12 at 8:07
add comment

1 Answer 1

up vote 4 down vote accepted

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}
  {\addtocounter{index}{1}\squig}
}

\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}

enter image description here

share|improve this answer
add comment

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.