âevery pathâ style affects node âpathâ when decorating
Clash Royale CLAN TAG#URR8PPP
up vote
7
down vote
favorite
Here's a MWE:
documentclassstandalone
usepackagetikz
usetikzlibrarydecorations.pathmorphing
begindocument
begintikzpicture
draw[decorate, decoration=random steps] (0,0) -- (10,0);
node[decorate, decoration=random steps, draw, fill=yellow, inner sep=0.5cm] at (5,-2) ;
endtikzpicture
enddocument
For a more complex picture, I wanted to apply the same decoration to all lines and nodes, and so I used "every path":
documentclassstandalone
usepackagetikz
usetikzlibrarydecorations.pathmorphing
begindocument
begintikzpicture[every path/.style=decorate, decoration=random steps]
draw (0,0) -- (10,0);
node[draw, fill=yellow, inner sep=0.5cm] at (5,-2) ;
endtikzpicture
enddocument
However, this results in an error: "I cannot decorate an empty path". I think I understand what the problem is: node ...
is replaced with path node ...
and we thus have an empty path.
But how can I achieve what I want, namely applying the same decoration to all lines AND nodes (let's assume there a lots of them) without having to specify it explicitly for each draw
and node
command?
tikz-pgf tikz-styles
add a comment |Â
up vote
7
down vote
favorite
Here's a MWE:
documentclassstandalone
usepackagetikz
usetikzlibrarydecorations.pathmorphing
begindocument
begintikzpicture
draw[decorate, decoration=random steps] (0,0) -- (10,0);
node[decorate, decoration=random steps, draw, fill=yellow, inner sep=0.5cm] at (5,-2) ;
endtikzpicture
enddocument
For a more complex picture, I wanted to apply the same decoration to all lines and nodes, and so I used "every path":
documentclassstandalone
usepackagetikz
usetikzlibrarydecorations.pathmorphing
begindocument
begintikzpicture[every path/.style=decorate, decoration=random steps]
draw (0,0) -- (10,0);
node[draw, fill=yellow, inner sep=0.5cm] at (5,-2) ;
endtikzpicture
enddocument
However, this results in an error: "I cannot decorate an empty path". I think I understand what the problem is: node ...
is replaced with path node ...
and we thus have an empty path.
But how can I achieve what I want, namely applying the same decoration to all lines AND nodes (let's assume there a lots of them) without having to specify it explicitly for each draw
and node
command?
tikz-pgf tikz-styles
add a comment |Â
up vote
7
down vote
favorite
up vote
7
down vote
favorite
Here's a MWE:
documentclassstandalone
usepackagetikz
usetikzlibrarydecorations.pathmorphing
begindocument
begintikzpicture
draw[decorate, decoration=random steps] (0,0) -- (10,0);
node[decorate, decoration=random steps, draw, fill=yellow, inner sep=0.5cm] at (5,-2) ;
endtikzpicture
enddocument
For a more complex picture, I wanted to apply the same decoration to all lines and nodes, and so I used "every path":
documentclassstandalone
usepackagetikz
usetikzlibrarydecorations.pathmorphing
begindocument
begintikzpicture[every path/.style=decorate, decoration=random steps]
draw (0,0) -- (10,0);
node[draw, fill=yellow, inner sep=0.5cm] at (5,-2) ;
endtikzpicture
enddocument
However, this results in an error: "I cannot decorate an empty path". I think I understand what the problem is: node ...
is replaced with path node ...
and we thus have an empty path.
But how can I achieve what I want, namely applying the same decoration to all lines AND nodes (let's assume there a lots of them) without having to specify it explicitly for each draw
and node
command?
tikz-pgf tikz-styles
Here's a MWE:
documentclassstandalone
usepackagetikz
usetikzlibrarydecorations.pathmorphing
begindocument
begintikzpicture
draw[decorate, decoration=random steps] (0,0) -- (10,0);
node[decorate, decoration=random steps, draw, fill=yellow, inner sep=0.5cm] at (5,-2) ;
endtikzpicture
enddocument
For a more complex picture, I wanted to apply the same decoration to all lines and nodes, and so I used "every path":
documentclassstandalone
usepackagetikz
usetikzlibrarydecorations.pathmorphing
begindocument
begintikzpicture[every path/.style=decorate, decoration=random steps]
draw (0,0) -- (10,0);
node[draw, fill=yellow, inner sep=0.5cm] at (5,-2) ;
endtikzpicture
enddocument
However, this results in an error: "I cannot decorate an empty path". I think I understand what the problem is: node ...
is replaced with path node ...
and we thus have an empty path.
But how can I achieve what I want, namely applying the same decoration to all lines AND nodes (let's assume there a lots of them) without having to specify it explicitly for each draw
and node
command?
tikz-pgf tikz-styles
tikz-pgf tikz-styles
asked Aug 13 at 16:46
Frunobulax
37226
37226
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
7
down vote
accepted
This problem has been solved some time ago by Jake, I think, in this stellar answer. It is sort of the opposite of what you suggest: if you use path (<coordinates>) node...
, it works.
documentclassstandalone
usepackagetikz
usetikzlibrarydecorations.pathmorphing
begindocument
begintikzpicture[every path/.style=decorate,decoration=random steps]
draw (0,0) -- (10,0);
path (5,-2) node[decorate,draw, fill=yellow, inner sep=0.5cm] ;
endtikzpicture
enddocument
EDIT: The picture looks a bit as if the left edge of the node was straight. However, that's just an accident, as can be seen from the following animation in which the random seed varies.
documentclass[tikz,border=3.14mm]standalone
usetikzlibrarydecorations.pathmorphing
begindocument
foreach X in 1,...,50
begintikzpicture[every path/.style=decorate,decoration=random steps]
pgfmathsetseedX
draw (0,0) -- (10,0);
path (5,-2) node[decorate,draw, fill=yellow, inner sep=0.5cm] ;
endtikzpicture
enddocument
EDIT: And if you don't want to write draw,decorate
over and over, you could just append this to the node styles.
documentclassstandalone
usepackagetikz
usetikzlibrarydecorations.pathmorphing
begindocument
begintikzpicture[every path/.style=decorate,decoration=random steps,
every node/.append style=draw,decorate]
draw (0,0) -- (10,0);
path (5,-2) node[fill=yellow, inner sep=0.5cm] ;
endtikzpicture
enddocument
Thanks! Who would have thought? But shouldn't this then be considered kind of a bug in TikZ? In both cases there is an empty path, but only in case do we get an error message... BTW, I looked at Jake's answer and found it very interesting, but I couldn't find any reference to this problem here.
â Frunobulax
Aug 13 at 20:39
1
@Frunobulax Jake didn't mention the problem but the way he wrote his code suggests that he encountered and just solved it. I prefer to give credit to somebody in case of doubt, and I would hesitate to call it a bug. TikZ is IMHO a really amazing tool that allows us to do many wonderful things, and in this case it just requires you to slightly change the syntax. Similar things happen here. That is, sometimes commands that appear to be equivalent are not.
â marmot
Aug 13 at 20:50
add a comment |Â
up vote
5
down vote
apparently every path
doesn't work as you expected. you still need to explicit say, which lines, shapes has decorate path:
documentclassstandalone
usepackagetikz
usetikzlibrarydecorations.pathmorphing
begindocument
begintikzpicture[every path/.style=decoration=random steps]
draw[decorate] (0,0) -- (10,0);
node[decorate, draw, fill=yellow, inner sep=0.5cm] at (5,-2) ;
endtikzpicture
enddocument
so, it maybe more handy (for shorter writing) to define path style for example as
DP/.style=%decorated path
decorate, decoration=random steps
and than use as follows:
documentclass[tikz, margin=3mm]standalone
usetikzlibrarydecorations.pathmorphing
begindocument
begintikzpicture[DP/.style=%decorated path
decorate, decoration=random steps]
draw[DP] (0,0) -- (10,0);
node[DP, draw, fill=yellow, inner sep=0.5cm] at (5,-2) ;
endtikzpicture
enddocument
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
7
down vote
accepted
This problem has been solved some time ago by Jake, I think, in this stellar answer. It is sort of the opposite of what you suggest: if you use path (<coordinates>) node...
, it works.
documentclassstandalone
usepackagetikz
usetikzlibrarydecorations.pathmorphing
begindocument
begintikzpicture[every path/.style=decorate,decoration=random steps]
draw (0,0) -- (10,0);
path (5,-2) node[decorate,draw, fill=yellow, inner sep=0.5cm] ;
endtikzpicture
enddocument
EDIT: The picture looks a bit as if the left edge of the node was straight. However, that's just an accident, as can be seen from the following animation in which the random seed varies.
documentclass[tikz,border=3.14mm]standalone
usetikzlibrarydecorations.pathmorphing
begindocument
foreach X in 1,...,50
begintikzpicture[every path/.style=decorate,decoration=random steps]
pgfmathsetseedX
draw (0,0) -- (10,0);
path (5,-2) node[decorate,draw, fill=yellow, inner sep=0.5cm] ;
endtikzpicture
enddocument
EDIT: And if you don't want to write draw,decorate
over and over, you could just append this to the node styles.
documentclassstandalone
usepackagetikz
usetikzlibrarydecorations.pathmorphing
begindocument
begintikzpicture[every path/.style=decorate,decoration=random steps,
every node/.append style=draw,decorate]
draw (0,0) -- (10,0);
path (5,-2) node[fill=yellow, inner sep=0.5cm] ;
endtikzpicture
enddocument
Thanks! Who would have thought? But shouldn't this then be considered kind of a bug in TikZ? In both cases there is an empty path, but only in case do we get an error message... BTW, I looked at Jake's answer and found it very interesting, but I couldn't find any reference to this problem here.
â Frunobulax
Aug 13 at 20:39
1
@Frunobulax Jake didn't mention the problem but the way he wrote his code suggests that he encountered and just solved it. I prefer to give credit to somebody in case of doubt, and I would hesitate to call it a bug. TikZ is IMHO a really amazing tool that allows us to do many wonderful things, and in this case it just requires you to slightly change the syntax. Similar things happen here. That is, sometimes commands that appear to be equivalent are not.
â marmot
Aug 13 at 20:50
add a comment |Â
up vote
7
down vote
accepted
This problem has been solved some time ago by Jake, I think, in this stellar answer. It is sort of the opposite of what you suggest: if you use path (<coordinates>) node...
, it works.
documentclassstandalone
usepackagetikz
usetikzlibrarydecorations.pathmorphing
begindocument
begintikzpicture[every path/.style=decorate,decoration=random steps]
draw (0,0) -- (10,0);
path (5,-2) node[decorate,draw, fill=yellow, inner sep=0.5cm] ;
endtikzpicture
enddocument
EDIT: The picture looks a bit as if the left edge of the node was straight. However, that's just an accident, as can be seen from the following animation in which the random seed varies.
documentclass[tikz,border=3.14mm]standalone
usetikzlibrarydecorations.pathmorphing
begindocument
foreach X in 1,...,50
begintikzpicture[every path/.style=decorate,decoration=random steps]
pgfmathsetseedX
draw (0,0) -- (10,0);
path (5,-2) node[decorate,draw, fill=yellow, inner sep=0.5cm] ;
endtikzpicture
enddocument
EDIT: And if you don't want to write draw,decorate
over and over, you could just append this to the node styles.
documentclassstandalone
usepackagetikz
usetikzlibrarydecorations.pathmorphing
begindocument
begintikzpicture[every path/.style=decorate,decoration=random steps,
every node/.append style=draw,decorate]
draw (0,0) -- (10,0);
path (5,-2) node[fill=yellow, inner sep=0.5cm] ;
endtikzpicture
enddocument
Thanks! Who would have thought? But shouldn't this then be considered kind of a bug in TikZ? In both cases there is an empty path, but only in case do we get an error message... BTW, I looked at Jake's answer and found it very interesting, but I couldn't find any reference to this problem here.
â Frunobulax
Aug 13 at 20:39
1
@Frunobulax Jake didn't mention the problem but the way he wrote his code suggests that he encountered and just solved it. I prefer to give credit to somebody in case of doubt, and I would hesitate to call it a bug. TikZ is IMHO a really amazing tool that allows us to do many wonderful things, and in this case it just requires you to slightly change the syntax. Similar things happen here. That is, sometimes commands that appear to be equivalent are not.
â marmot
Aug 13 at 20:50
add a comment |Â
up vote
7
down vote
accepted
up vote
7
down vote
accepted
This problem has been solved some time ago by Jake, I think, in this stellar answer. It is sort of the opposite of what you suggest: if you use path (<coordinates>) node...
, it works.
documentclassstandalone
usepackagetikz
usetikzlibrarydecorations.pathmorphing
begindocument
begintikzpicture[every path/.style=decorate,decoration=random steps]
draw (0,0) -- (10,0);
path (5,-2) node[decorate,draw, fill=yellow, inner sep=0.5cm] ;
endtikzpicture
enddocument
EDIT: The picture looks a bit as if the left edge of the node was straight. However, that's just an accident, as can be seen from the following animation in which the random seed varies.
documentclass[tikz,border=3.14mm]standalone
usetikzlibrarydecorations.pathmorphing
begindocument
foreach X in 1,...,50
begintikzpicture[every path/.style=decorate,decoration=random steps]
pgfmathsetseedX
draw (0,0) -- (10,0);
path (5,-2) node[decorate,draw, fill=yellow, inner sep=0.5cm] ;
endtikzpicture
enddocument
EDIT: And if you don't want to write draw,decorate
over and over, you could just append this to the node styles.
documentclassstandalone
usepackagetikz
usetikzlibrarydecorations.pathmorphing
begindocument
begintikzpicture[every path/.style=decorate,decoration=random steps,
every node/.append style=draw,decorate]
draw (0,0) -- (10,0);
path (5,-2) node[fill=yellow, inner sep=0.5cm] ;
endtikzpicture
enddocument
This problem has been solved some time ago by Jake, I think, in this stellar answer. It is sort of the opposite of what you suggest: if you use path (<coordinates>) node...
, it works.
documentclassstandalone
usepackagetikz
usetikzlibrarydecorations.pathmorphing
begindocument
begintikzpicture[every path/.style=decorate,decoration=random steps]
draw (0,0) -- (10,0);
path (5,-2) node[decorate,draw, fill=yellow, inner sep=0.5cm] ;
endtikzpicture
enddocument
EDIT: The picture looks a bit as if the left edge of the node was straight. However, that's just an accident, as can be seen from the following animation in which the random seed varies.
documentclass[tikz,border=3.14mm]standalone
usetikzlibrarydecorations.pathmorphing
begindocument
foreach X in 1,...,50
begintikzpicture[every path/.style=decorate,decoration=random steps]
pgfmathsetseedX
draw (0,0) -- (10,0);
path (5,-2) node[decorate,draw, fill=yellow, inner sep=0.5cm] ;
endtikzpicture
enddocument
EDIT: And if you don't want to write draw,decorate
over and over, you could just append this to the node styles.
documentclassstandalone
usepackagetikz
usetikzlibrarydecorations.pathmorphing
begindocument
begintikzpicture[every path/.style=decorate,decoration=random steps,
every node/.append style=draw,decorate]
draw (0,0) -- (10,0);
path (5,-2) node[fill=yellow, inner sep=0.5cm] ;
endtikzpicture
enddocument
edited Aug 13 at 18:56
answered Aug 13 at 17:57
marmot
58.1k463124
58.1k463124
Thanks! Who would have thought? But shouldn't this then be considered kind of a bug in TikZ? In both cases there is an empty path, but only in case do we get an error message... BTW, I looked at Jake's answer and found it very interesting, but I couldn't find any reference to this problem here.
â Frunobulax
Aug 13 at 20:39
1
@Frunobulax Jake didn't mention the problem but the way he wrote his code suggests that he encountered and just solved it. I prefer to give credit to somebody in case of doubt, and I would hesitate to call it a bug. TikZ is IMHO a really amazing tool that allows us to do many wonderful things, and in this case it just requires you to slightly change the syntax. Similar things happen here. That is, sometimes commands that appear to be equivalent are not.
â marmot
Aug 13 at 20:50
add a comment |Â
Thanks! Who would have thought? But shouldn't this then be considered kind of a bug in TikZ? In both cases there is an empty path, but only in case do we get an error message... BTW, I looked at Jake's answer and found it very interesting, but I couldn't find any reference to this problem here.
â Frunobulax
Aug 13 at 20:39
1
@Frunobulax Jake didn't mention the problem but the way he wrote his code suggests that he encountered and just solved it. I prefer to give credit to somebody in case of doubt, and I would hesitate to call it a bug. TikZ is IMHO a really amazing tool that allows us to do many wonderful things, and in this case it just requires you to slightly change the syntax. Similar things happen here. That is, sometimes commands that appear to be equivalent are not.
â marmot
Aug 13 at 20:50
Thanks! Who would have thought? But shouldn't this then be considered kind of a bug in TikZ? In both cases there is an empty path, but only in case do we get an error message... BTW, I looked at Jake's answer and found it very interesting, but I couldn't find any reference to this problem here.
â Frunobulax
Aug 13 at 20:39
Thanks! Who would have thought? But shouldn't this then be considered kind of a bug in TikZ? In both cases there is an empty path, but only in case do we get an error message... BTW, I looked at Jake's answer and found it very interesting, but I couldn't find any reference to this problem here.
â Frunobulax
Aug 13 at 20:39
1
1
@Frunobulax Jake didn't mention the problem but the way he wrote his code suggests that he encountered and just solved it. I prefer to give credit to somebody in case of doubt, and I would hesitate to call it a bug. TikZ is IMHO a really amazing tool that allows us to do many wonderful things, and in this case it just requires you to slightly change the syntax. Similar things happen here. That is, sometimes commands that appear to be equivalent are not.
â marmot
Aug 13 at 20:50
@Frunobulax Jake didn't mention the problem but the way he wrote his code suggests that he encountered and just solved it. I prefer to give credit to somebody in case of doubt, and I would hesitate to call it a bug. TikZ is IMHO a really amazing tool that allows us to do many wonderful things, and in this case it just requires you to slightly change the syntax. Similar things happen here. That is, sometimes commands that appear to be equivalent are not.
â marmot
Aug 13 at 20:50
add a comment |Â
up vote
5
down vote
apparently every path
doesn't work as you expected. you still need to explicit say, which lines, shapes has decorate path:
documentclassstandalone
usepackagetikz
usetikzlibrarydecorations.pathmorphing
begindocument
begintikzpicture[every path/.style=decoration=random steps]
draw[decorate] (0,0) -- (10,0);
node[decorate, draw, fill=yellow, inner sep=0.5cm] at (5,-2) ;
endtikzpicture
enddocument
so, it maybe more handy (for shorter writing) to define path style for example as
DP/.style=%decorated path
decorate, decoration=random steps
and than use as follows:
documentclass[tikz, margin=3mm]standalone
usetikzlibrarydecorations.pathmorphing
begindocument
begintikzpicture[DP/.style=%decorated path
decorate, decoration=random steps]
draw[DP] (0,0) -- (10,0);
node[DP, draw, fill=yellow, inner sep=0.5cm] at (5,-2) ;
endtikzpicture
enddocument
add a comment |Â
up vote
5
down vote
apparently every path
doesn't work as you expected. you still need to explicit say, which lines, shapes has decorate path:
documentclassstandalone
usepackagetikz
usetikzlibrarydecorations.pathmorphing
begindocument
begintikzpicture[every path/.style=decoration=random steps]
draw[decorate] (0,0) -- (10,0);
node[decorate, draw, fill=yellow, inner sep=0.5cm] at (5,-2) ;
endtikzpicture
enddocument
so, it maybe more handy (for shorter writing) to define path style for example as
DP/.style=%decorated path
decorate, decoration=random steps
and than use as follows:
documentclass[tikz, margin=3mm]standalone
usetikzlibrarydecorations.pathmorphing
begindocument
begintikzpicture[DP/.style=%decorated path
decorate, decoration=random steps]
draw[DP] (0,0) -- (10,0);
node[DP, draw, fill=yellow, inner sep=0.5cm] at (5,-2) ;
endtikzpicture
enddocument
add a comment |Â
up vote
5
down vote
up vote
5
down vote
apparently every path
doesn't work as you expected. you still need to explicit say, which lines, shapes has decorate path:
documentclassstandalone
usepackagetikz
usetikzlibrarydecorations.pathmorphing
begindocument
begintikzpicture[every path/.style=decoration=random steps]
draw[decorate] (0,0) -- (10,0);
node[decorate, draw, fill=yellow, inner sep=0.5cm] at (5,-2) ;
endtikzpicture
enddocument
so, it maybe more handy (for shorter writing) to define path style for example as
DP/.style=%decorated path
decorate, decoration=random steps
and than use as follows:
documentclass[tikz, margin=3mm]standalone
usetikzlibrarydecorations.pathmorphing
begindocument
begintikzpicture[DP/.style=%decorated path
decorate, decoration=random steps]
draw[DP] (0,0) -- (10,0);
node[DP, draw, fill=yellow, inner sep=0.5cm] at (5,-2) ;
endtikzpicture
enddocument
apparently every path
doesn't work as you expected. you still need to explicit say, which lines, shapes has decorate path:
documentclassstandalone
usepackagetikz
usetikzlibrarydecorations.pathmorphing
begindocument
begintikzpicture[every path/.style=decoration=random steps]
draw[decorate] (0,0) -- (10,0);
node[decorate, draw, fill=yellow, inner sep=0.5cm] at (5,-2) ;
endtikzpicture
enddocument
so, it maybe more handy (for shorter writing) to define path style for example as
DP/.style=%decorated path
decorate, decoration=random steps
and than use as follows:
documentclass[tikz, margin=3mm]standalone
usetikzlibrarydecorations.pathmorphing
begindocument
begintikzpicture[DP/.style=%decorated path
decorate, decoration=random steps]
draw[DP] (0,0) -- (10,0);
node[DP, draw, fill=yellow, inner sep=0.5cm] at (5,-2) ;
endtikzpicture
enddocument
edited Aug 13 at 23:37
answered Aug 13 at 17:08
Zarko
112k861150
112k861150
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f445912%2fevery-path-style-affects-node-path-when-decorating%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password