[Tex/LaTex] Squiggly line over equations

equationsmath-mode

I would like to draw special lines over parts of my equations, basically the functionality that overline provides. However, I do not want a straight line, but a squiggly line, as in rightsquigarrow.

I have also tried widetilde (not exactly squiggly, but at least it is something), but it cannot be made arbitrarily long, which is a requirement for me.

A typical usecase would be

\begin{align*}
\oversquigline{ABCD} \\
\oversquigline{A^i}
\end{align*}

It should look something like this:

enter image description here

How can I achieve what I want?

Best Answer

Based on How to create a squiggle arrow with some text on it in TikZ?, I have come up with this:

\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{tikz}
\usetikzlibrary{calc,decorations.pathmorphing,shapes}

\newcounter{sarrow}

\newcommand\oversquigline[1]{%
\stepcounter{sarrow}%
\begin{tikzpicture}[decoration={snake,amplitude=0.2ex},baseline={([yshift=-.8ex]current bounding box)}]
\node (\thesarrow) {$#1$};
\draw[->,decorate] ([xshift=1ex,yshift=-0.2ex]\thesarrow.north west) -- ([xshift=-1ex,,yshift=-0.2ex]\thesarrow.north east);
\end{tikzpicture}%
}

Here is an example:

\begin{document}

\begin{align*}
x=&\oversquigline{ABCD} \\
y=&\oversquigline{A^i} + \oversquigline{B_x^i} + \oversquigline{a}
\end{align*}

\end{document}

enter image description here

It works reasonably well, but is a bit ugly for "a"...

Related Question