Sign up ×
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.

Sometime, for example in a solution to a recent question, one wants to apply a postaction (like a decoration) to a group of paths. A naive solution is to use every path/.style={}. Unfortunately this also this then applies the postaction to every path drawn in the postaction, leading to an infinite regress.

Is there any way to avoid this?

A somewhat stupid minimal example of the problem:

\begin{tikzpicture}[every path/.style={postaction={draw}}]
    \draw (0,0)--(1,0);

with error message

! TeX capacity exceeded, sorry [grouping levels=255].
\pgfutil@g@addto@macro #1#2->\begingroup 
                                         \toks@ \expandafter {#1#2}\xdef #1{...
l.12     \draw (0,0)--(1,0);
share|improve this question
Let's see if a bounty can get this question answered. – Seamus Nov 12 '10 at 13:29
@seamus: much to me surprise it did. :) – Caramdir Nov 14 '10 at 16:44
(I only did it to get the badge for posting a bounty on someone else's question, but I actually feel like I've helped make the site better, a little bit...) – Seamus Nov 16 '10 at 11:31
@Seamus: fair enough, it did work. :) – Ulrich Schwarz Nov 16 '10 at 18:45

3 Answers 3

up vote 21 down vote accepted

Please check if the following solves your problem, in particular with regard to scoping, this seems far too easy. nomorepostactions is intended to locally empty out the postactions, so they don't get applied after that.

It did fix your toy problem.

\begin{tikzpicture}[every path/.style={postaction={nomorepostaction,draw}}]
    \draw (0,0)--(1,0);
share|improve this answer
works fine, indeed:… – Grigory M Nov 14 '10 at 10:13
Thanks a lot. I didn’t know about .code. That might be useful in other situations too. – Caramdir Nov 14 '10 at 16:54
Fantastic! I also didn't know about the .code and have just looked it up in the manual (p383 in v2.00). I can think of lots of things to do with this! (Having small kids, I also like the example for the .store in handler). – Loop Space Nov 14 '10 at 18:01
@Andrew With small children it may be better to evaluate what happened first, which is why .estore in may be the preferred option. – Marc van Dongen Jan 14 '12 at 22:40

Maybe this answer on "How to draw an arrow in the middle of the line?" might help you. This way you do not run into a recursion.

share|improve this answer
The point was that in my answer to the question you reference, one needs to add [postaction={decorate}] to every path by hand which in larger examples adds a lot of copy&pasted code. And copy&pasting code is usually bad design. – Caramdir Oct 10 '10 at 16:03

(Not an answer.)

Usually one can override properties, but is there a way to remove 'postaction' completely? I mean, there should be a way to write something like [every path/.style={postaction={nopostaction}},nopostaction/.style={draw, <some way to override postaction option>}], probably.

(Related: Is it possible to clear tikz/pgf options?)

share|improve this answer
Interesting approach. I don’t know what to write in place of <some way to override postaction option> though. Setting a postaction inside a postaction seems to get ignored. – Caramdir Nov 13 '10 at 17:15
In the original example even replacing postaction={draw} by postaction={} leads to an infinite recursion. – Caramdir Nov 13 '10 at 17:20
(Re: ..even replacing..) Of course: postaction={<options>} creates a copy of the original path with these <options> added -- in this case without any additional options -- but a path is created anyway. So one really have to remove the key, not just make it empty. (Or so it seems.) – Grigory M Nov 13 '10 at 17:28

Your Answer


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.