[Tex/LaTex] TikZ: multiple decorations on a path.

decorationstikz-pgf

I would like to draw a squiggly line with an arrow somewhere in the middle of it. TikZ has a pathmorphing decoration that draws a squiggly line and a markings decoration to place an arrow tip. So a solution would be to use them together:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations,decorations.pathmorphing,decorations.markings}
\begin{document}

\begin{tikzpicture}
 \draw[
         decoration={snake},
         decorate,
         postaction={decoration={markings,mark=at position 0.6 with {\arrow{>}}},decorate}
     ]
        (0,0) -- (2,0);
\end{tikzpicture}

\end{document}

Unfortunately this does not work and results in

! Dimension too large.
<to be read again> 
                   \relax 
l.11         (0,0) -- (2,0);

I suspect there is an infinite recursion going on somewhere.

Is there a workaround? If not, is there a different simple solution to the problem?

(Note: This is probably related to my previous question “Applying a postaction to every path in TikZ”)

Best Answer

The problem is not caused by wrong syntax or a recursion. If you for instance change the position to 1:

postaction={decoration={markings,mark=at position 1 with {\arrow{>}}},decorate}

your file compiles without errors and you get:

alt text

Similar for position 0. This doesn't place the arrow where it's desired but it shows that that way of nesting decorations is ok, though the calculation for TikZ seems to be too hard.