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 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”)

share|improve this question
3  
I translated this with \tracingall on, and I got a log-file of about 6MB, wow. Does indeed look like an infinite recursion. –  Hendrik Vogt Oct 22 '10 at 11:11
3  
Interestingly, this doesn't show up with every pathmorphing decoration. If I replace snake with coil, things are still broken; but if I instead use zigzag, lineto, or bent, your code works. –  Antal S-Z Oct 23 '10 at 16:20
    
Seems that I'm working with an updated TeX system now that gives me an 8MB log file. But it's still 3.5MB if I comment out the line with "postaction"; with "position 1" (instead of 0.6) it's 6.5MB. TikZ is really quite demanding! –  Hendrik Vogt Oct 29 '10 at 7:23
    
Has anybody reported this as a bug? –  Mitar Apr 10 '11 at 22:21
add comment

2 Answers

Yes the calculation for TikZ seems to be too hard. A possibility but the time for the compilation is very long is to use fp with fixedpointarithmetic

\documentclass{article}
\usepackage{tikz,fp}
\usetikzlibrary{decorations.markings,fixedpointarithmetic}

\usetikzlibrary{decorations,decorations.pathmorphing}
\begin{document}

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

\end{document} 

enter image description here

share|improve this answer
    
pgf-math needs a Lua backend... –  Caramdir Jun 15 '11 at 16:34
    
yes ! but I think this is indispensable. I hope Mark Wibrow works on this topic –  Alain Matthes Jun 15 '11 at 16:39
add comment

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.

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.