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);
  • 3
    Let's see if a bounty can get this question answered.
    – Seamus
    Commented Nov 12, 2010 at 13:29
  • @seamus: much to me surprise it did. :)
    – Caramdir
    Commented Nov 14, 2010 at 16:44
  • 2
    (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
    Commented Nov 16, 2010 at 11:31
  • @Seamus: fair enough, it did work. :) Commented Nov 16, 2010 at 18:45

3 Answers 3


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);
  • works fine, indeed: tex.stackexchange.com/questions/3161/…
    – Grigory M
    Commented Nov 14, 2010 at 10:13
  • 1
    Thanks a lot. I didn’t know about .code. That might be useful in other situations too.
    – Caramdir
    Commented Nov 14, 2010 at 16:54
  • 1
    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). Commented Nov 14, 2010 at 18:01
  • 1
    @Andrew With small children it may be better to evaluate what happened first, which is why .estore in may be the preferred option.
    – user10274
    Commented Jan 14, 2012 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.

  • 6
    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
    Commented Oct 10, 2010 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?)

  • 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
    Commented Nov 13, 2010 at 17:15
  • In the original example even replacing postaction={draw} by postaction={} leads to an infinite recursion.
    – Caramdir
    Commented Nov 13, 2010 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
    Commented Nov 13, 2010 at 17:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .