Petrinet: Decoration and XShift not aligned in Tikz
When a new begin{tikzpicture}[xshift=2cm]
is used, it creates the TikZ picture 2 cm to the right of existing TikZ picture (X shift).
But, somehow that doesn't seem to work here and the decoration (snake line) is also not aligned properly.
I was expecting the following:
But I get this:
Note: I have used the same code in the first TikZ picture hence the right box also has the same diagram. I will change that later.
Code:
documentclass{article}
usepackage{tikz}
usetikzlibrary{positioning}
usetikzlibrary{arrows}
usetikzlibrary{backgrounds}
usetikzlibrary{fit}
usetikzlibrary{decorations.pathmorphing}
tikzset{squarenode/.style = {
shape = rectangle,
fill = gray!50,
draw = black,
thick,
minimum height = 1cm,
minimum width = 1cm
}}
tikzset{circlenode/.style = {
shape = circle,
fill = blue!20,
draw = blue,
thick,
minimum size = 1cm
}}
tikzset{help lines/.style=very thin}
tikzset{My Grid/.style={help lines,color=blue!50}}
begin{document}
begin{tikzpicture}
[>=stealth']
%draw[My Grid] (-5,-5) grid (15,15);
node (r1) at (-4,4) [squarenode] {r1};
node[right=4cm of r1] (r2) [squarenode] {r2};
node[below=3cm of r1] (r3) [squarenode] {r3};
node[right=4cm of r3] (r4) [squarenode] {r4};
node[right=1.5cm of r1] (s2) [circlenode] {s2};
node[above=1cm of s2] (s1) [circlenode] {}; %s1
node[below=1cm of s2] (s3) [circlenode] {s3}; %s3
node[above=1ex of s3,red] {$s leq 3$};
node[right=1.5cm of r3] (s4) [circlenode] {s4};
node[below=1cm of s4] (s5) [circlenode] {}; %s5
draw[fill=black] (s1.center) circle [radius=0.1cm];
draw[fill=black] (s5.center) circle [radius=0.1cm];
draw[->] (r1) -- (s2);
draw[->] (s2) -- (r2);
draw[->] (r3) -- (s4);
draw[->] (s4) -- (r4);
draw[->] (s1) to [out=180,in=90] (r1);
draw[->] (r1) to [out=-90,in=180] (s3);
draw[->] (s3) to [out=0,in=-90] (r2);
draw[->] (r2) to [bend right=45] node[auto,swap] {2} (s1);
draw[->] (r3) to [out=90,in=180] (s3);
draw[->] (s3) to [out=0,in=90] (r4);
draw[->] (r4) to [bend left=45] node[auto] {2} (s5);
draw[->] (s5) to [bend left=45] (r3);
begin{scope}[on background layer]
node [fill=gray!15,rounded corners,fit=(s1) (s3) (s5) (r1) (r2)] (R1) {};
end{scope}
end{tikzpicture}
begin{tikzpicture}[xshift=5cm]
[>=stealth']
%draw[My Grid] (-5,-5) grid (15,15);
node (r1) at (-4,4) [squarenode] {r1};
node[right=4cm of r1] (r2) [squarenode] {r2};
node[below=3cm of r1] (r3) [squarenode] {r3};
node[right=4cm of r3] (r4) [squarenode] {r4};
node[right=1.5cm of r1] (s2) [circlenode] {s2};
node[above=1cm of s2] (s1) [circlenode] {}; %s1
node[below=1cm of s2] (s3) [circlenode] {s3}; %s3
node[above=1ex of s3,red] {$s leq 3$};
node[right=1.5cm of r3] (s4) [circlenode] {s4};
node[below=1cm of s4] (s5) [circlenode] {}; %s5
draw[fill=black] (s1.center) circle [radius=0.1cm];
draw[fill=black] (s5.center) circle [radius=0.1cm];
draw[->] (r1) -- (s2);
draw[->] (s2) -- (r2);
draw[->] (r3) -- (s4);
draw[->] (s4) -- (r4);
draw[->] (s1) to [out=180,in=90] (r1);
draw[->] (r1) to [out=-90,in=180] (s3);
draw[->] (s3) to [out=0,in=-90] (r2);
draw[->] (r2) to [bend right=45] node[auto,swap] {2} (s1);
draw[->] (r3) to [out=90,in=180] (s3);
draw[->] (s3) to [out=0,in=90] (r4);
draw[->] (r4) to [bend left=45] node[auto] {2} (s5);
draw[->] (s5) to [bend left=45] (r3);
begin{scope}[on background layer]
node [fill=gray!15,rounded corners,fit=(s1) (s3) (s5) (r1) (r2)] (R2) {};
end{scope}
draw [thick,decorate,
decoration={snake,amplitude=.4mm,segment length=2mm,
pre=moveto,pre length=1mm,post length=2mm}]
(R1) -- (R2) node [above=1mm,midway,text width=3cm,align=center]
{replacement of the textcolor{red}{capacity} by textcolor{red}{two places}};
end{tikzpicture}
end{document}
tikz-pgf
add a comment |
When a new begin{tikzpicture}[xshift=2cm]
is used, it creates the TikZ picture 2 cm to the right of existing TikZ picture (X shift).
But, somehow that doesn't seem to work here and the decoration (snake line) is also not aligned properly.
I was expecting the following:
But I get this:
Note: I have used the same code in the first TikZ picture hence the right box also has the same diagram. I will change that later.
Code:
documentclass{article}
usepackage{tikz}
usetikzlibrary{positioning}
usetikzlibrary{arrows}
usetikzlibrary{backgrounds}
usetikzlibrary{fit}
usetikzlibrary{decorations.pathmorphing}
tikzset{squarenode/.style = {
shape = rectangle,
fill = gray!50,
draw = black,
thick,
minimum height = 1cm,
minimum width = 1cm
}}
tikzset{circlenode/.style = {
shape = circle,
fill = blue!20,
draw = blue,
thick,
minimum size = 1cm
}}
tikzset{help lines/.style=very thin}
tikzset{My Grid/.style={help lines,color=blue!50}}
begin{document}
begin{tikzpicture}
[>=stealth']
%draw[My Grid] (-5,-5) grid (15,15);
node (r1) at (-4,4) [squarenode] {r1};
node[right=4cm of r1] (r2) [squarenode] {r2};
node[below=3cm of r1] (r3) [squarenode] {r3};
node[right=4cm of r3] (r4) [squarenode] {r4};
node[right=1.5cm of r1] (s2) [circlenode] {s2};
node[above=1cm of s2] (s1) [circlenode] {}; %s1
node[below=1cm of s2] (s3) [circlenode] {s3}; %s3
node[above=1ex of s3,red] {$s leq 3$};
node[right=1.5cm of r3] (s4) [circlenode] {s4};
node[below=1cm of s4] (s5) [circlenode] {}; %s5
draw[fill=black] (s1.center) circle [radius=0.1cm];
draw[fill=black] (s5.center) circle [radius=0.1cm];
draw[->] (r1) -- (s2);
draw[->] (s2) -- (r2);
draw[->] (r3) -- (s4);
draw[->] (s4) -- (r4);
draw[->] (s1) to [out=180,in=90] (r1);
draw[->] (r1) to [out=-90,in=180] (s3);
draw[->] (s3) to [out=0,in=-90] (r2);
draw[->] (r2) to [bend right=45] node[auto,swap] {2} (s1);
draw[->] (r3) to [out=90,in=180] (s3);
draw[->] (s3) to [out=0,in=90] (r4);
draw[->] (r4) to [bend left=45] node[auto] {2} (s5);
draw[->] (s5) to [bend left=45] (r3);
begin{scope}[on background layer]
node [fill=gray!15,rounded corners,fit=(s1) (s3) (s5) (r1) (r2)] (R1) {};
end{scope}
end{tikzpicture}
begin{tikzpicture}[xshift=5cm]
[>=stealth']
%draw[My Grid] (-5,-5) grid (15,15);
node (r1) at (-4,4) [squarenode] {r1};
node[right=4cm of r1] (r2) [squarenode] {r2};
node[below=3cm of r1] (r3) [squarenode] {r3};
node[right=4cm of r3] (r4) [squarenode] {r4};
node[right=1.5cm of r1] (s2) [circlenode] {s2};
node[above=1cm of s2] (s1) [circlenode] {}; %s1
node[below=1cm of s2] (s3) [circlenode] {s3}; %s3
node[above=1ex of s3,red] {$s leq 3$};
node[right=1.5cm of r3] (s4) [circlenode] {s4};
node[below=1cm of s4] (s5) [circlenode] {}; %s5
draw[fill=black] (s1.center) circle [radius=0.1cm];
draw[fill=black] (s5.center) circle [radius=0.1cm];
draw[->] (r1) -- (s2);
draw[->] (s2) -- (r2);
draw[->] (r3) -- (s4);
draw[->] (s4) -- (r4);
draw[->] (s1) to [out=180,in=90] (r1);
draw[->] (r1) to [out=-90,in=180] (s3);
draw[->] (s3) to [out=0,in=-90] (r2);
draw[->] (r2) to [bend right=45] node[auto,swap] {2} (s1);
draw[->] (r3) to [out=90,in=180] (s3);
draw[->] (s3) to [out=0,in=90] (r4);
draw[->] (r4) to [bend left=45] node[auto] {2} (s5);
draw[->] (s5) to [bend left=45] (r3);
begin{scope}[on background layer]
node [fill=gray!15,rounded corners,fit=(s1) (s3) (s5) (r1) (r2)] (R2) {};
end{scope}
draw [thick,decorate,
decoration={snake,amplitude=.4mm,segment length=2mm,
pre=moveto,pre length=1mm,post length=2mm}]
(R1) -- (R2) node [above=1mm,midway,text width=3cm,align=center]
{replacement of the textcolor{red}{capacity} by textcolor{red}{two places}};
end{tikzpicture}
end{document}
tikz-pgf
1
xshift
never shifts the picture unless you work with overlay pictures and absolute positioning.
– marmot
yesterday
add a comment |
When a new begin{tikzpicture}[xshift=2cm]
is used, it creates the TikZ picture 2 cm to the right of existing TikZ picture (X shift).
But, somehow that doesn't seem to work here and the decoration (snake line) is also not aligned properly.
I was expecting the following:
But I get this:
Note: I have used the same code in the first TikZ picture hence the right box also has the same diagram. I will change that later.
Code:
documentclass{article}
usepackage{tikz}
usetikzlibrary{positioning}
usetikzlibrary{arrows}
usetikzlibrary{backgrounds}
usetikzlibrary{fit}
usetikzlibrary{decorations.pathmorphing}
tikzset{squarenode/.style = {
shape = rectangle,
fill = gray!50,
draw = black,
thick,
minimum height = 1cm,
minimum width = 1cm
}}
tikzset{circlenode/.style = {
shape = circle,
fill = blue!20,
draw = blue,
thick,
minimum size = 1cm
}}
tikzset{help lines/.style=very thin}
tikzset{My Grid/.style={help lines,color=blue!50}}
begin{document}
begin{tikzpicture}
[>=stealth']
%draw[My Grid] (-5,-5) grid (15,15);
node (r1) at (-4,4) [squarenode] {r1};
node[right=4cm of r1] (r2) [squarenode] {r2};
node[below=3cm of r1] (r3) [squarenode] {r3};
node[right=4cm of r3] (r4) [squarenode] {r4};
node[right=1.5cm of r1] (s2) [circlenode] {s2};
node[above=1cm of s2] (s1) [circlenode] {}; %s1
node[below=1cm of s2] (s3) [circlenode] {s3}; %s3
node[above=1ex of s3,red] {$s leq 3$};
node[right=1.5cm of r3] (s4) [circlenode] {s4};
node[below=1cm of s4] (s5) [circlenode] {}; %s5
draw[fill=black] (s1.center) circle [radius=0.1cm];
draw[fill=black] (s5.center) circle [radius=0.1cm];
draw[->] (r1) -- (s2);
draw[->] (s2) -- (r2);
draw[->] (r3) -- (s4);
draw[->] (s4) -- (r4);
draw[->] (s1) to [out=180,in=90] (r1);
draw[->] (r1) to [out=-90,in=180] (s3);
draw[->] (s3) to [out=0,in=-90] (r2);
draw[->] (r2) to [bend right=45] node[auto,swap] {2} (s1);
draw[->] (r3) to [out=90,in=180] (s3);
draw[->] (s3) to [out=0,in=90] (r4);
draw[->] (r4) to [bend left=45] node[auto] {2} (s5);
draw[->] (s5) to [bend left=45] (r3);
begin{scope}[on background layer]
node [fill=gray!15,rounded corners,fit=(s1) (s3) (s5) (r1) (r2)] (R1) {};
end{scope}
end{tikzpicture}
begin{tikzpicture}[xshift=5cm]
[>=stealth']
%draw[My Grid] (-5,-5) grid (15,15);
node (r1) at (-4,4) [squarenode] {r1};
node[right=4cm of r1] (r2) [squarenode] {r2};
node[below=3cm of r1] (r3) [squarenode] {r3};
node[right=4cm of r3] (r4) [squarenode] {r4};
node[right=1.5cm of r1] (s2) [circlenode] {s2};
node[above=1cm of s2] (s1) [circlenode] {}; %s1
node[below=1cm of s2] (s3) [circlenode] {s3}; %s3
node[above=1ex of s3,red] {$s leq 3$};
node[right=1.5cm of r3] (s4) [circlenode] {s4};
node[below=1cm of s4] (s5) [circlenode] {}; %s5
draw[fill=black] (s1.center) circle [radius=0.1cm];
draw[fill=black] (s5.center) circle [radius=0.1cm];
draw[->] (r1) -- (s2);
draw[->] (s2) -- (r2);
draw[->] (r3) -- (s4);
draw[->] (s4) -- (r4);
draw[->] (s1) to [out=180,in=90] (r1);
draw[->] (r1) to [out=-90,in=180] (s3);
draw[->] (s3) to [out=0,in=-90] (r2);
draw[->] (r2) to [bend right=45] node[auto,swap] {2} (s1);
draw[->] (r3) to [out=90,in=180] (s3);
draw[->] (s3) to [out=0,in=90] (r4);
draw[->] (r4) to [bend left=45] node[auto] {2} (s5);
draw[->] (s5) to [bend left=45] (r3);
begin{scope}[on background layer]
node [fill=gray!15,rounded corners,fit=(s1) (s3) (s5) (r1) (r2)] (R2) {};
end{scope}
draw [thick,decorate,
decoration={snake,amplitude=.4mm,segment length=2mm,
pre=moveto,pre length=1mm,post length=2mm}]
(R1) -- (R2) node [above=1mm,midway,text width=3cm,align=center]
{replacement of the textcolor{red}{capacity} by textcolor{red}{two places}};
end{tikzpicture}
end{document}
tikz-pgf
When a new begin{tikzpicture}[xshift=2cm]
is used, it creates the TikZ picture 2 cm to the right of existing TikZ picture (X shift).
But, somehow that doesn't seem to work here and the decoration (snake line) is also not aligned properly.
I was expecting the following:
But I get this:
Note: I have used the same code in the first TikZ picture hence the right box also has the same diagram. I will change that later.
Code:
documentclass{article}
usepackage{tikz}
usetikzlibrary{positioning}
usetikzlibrary{arrows}
usetikzlibrary{backgrounds}
usetikzlibrary{fit}
usetikzlibrary{decorations.pathmorphing}
tikzset{squarenode/.style = {
shape = rectangle,
fill = gray!50,
draw = black,
thick,
minimum height = 1cm,
minimum width = 1cm
}}
tikzset{circlenode/.style = {
shape = circle,
fill = blue!20,
draw = blue,
thick,
minimum size = 1cm
}}
tikzset{help lines/.style=very thin}
tikzset{My Grid/.style={help lines,color=blue!50}}
begin{document}
begin{tikzpicture}
[>=stealth']
%draw[My Grid] (-5,-5) grid (15,15);
node (r1) at (-4,4) [squarenode] {r1};
node[right=4cm of r1] (r2) [squarenode] {r2};
node[below=3cm of r1] (r3) [squarenode] {r3};
node[right=4cm of r3] (r4) [squarenode] {r4};
node[right=1.5cm of r1] (s2) [circlenode] {s2};
node[above=1cm of s2] (s1) [circlenode] {}; %s1
node[below=1cm of s2] (s3) [circlenode] {s3}; %s3
node[above=1ex of s3,red] {$s leq 3$};
node[right=1.5cm of r3] (s4) [circlenode] {s4};
node[below=1cm of s4] (s5) [circlenode] {}; %s5
draw[fill=black] (s1.center) circle [radius=0.1cm];
draw[fill=black] (s5.center) circle [radius=0.1cm];
draw[->] (r1) -- (s2);
draw[->] (s2) -- (r2);
draw[->] (r3) -- (s4);
draw[->] (s4) -- (r4);
draw[->] (s1) to [out=180,in=90] (r1);
draw[->] (r1) to [out=-90,in=180] (s3);
draw[->] (s3) to [out=0,in=-90] (r2);
draw[->] (r2) to [bend right=45] node[auto,swap] {2} (s1);
draw[->] (r3) to [out=90,in=180] (s3);
draw[->] (s3) to [out=0,in=90] (r4);
draw[->] (r4) to [bend left=45] node[auto] {2} (s5);
draw[->] (s5) to [bend left=45] (r3);
begin{scope}[on background layer]
node [fill=gray!15,rounded corners,fit=(s1) (s3) (s5) (r1) (r2)] (R1) {};
end{scope}
end{tikzpicture}
begin{tikzpicture}[xshift=5cm]
[>=stealth']
%draw[My Grid] (-5,-5) grid (15,15);
node (r1) at (-4,4) [squarenode] {r1};
node[right=4cm of r1] (r2) [squarenode] {r2};
node[below=3cm of r1] (r3) [squarenode] {r3};
node[right=4cm of r3] (r4) [squarenode] {r4};
node[right=1.5cm of r1] (s2) [circlenode] {s2};
node[above=1cm of s2] (s1) [circlenode] {}; %s1
node[below=1cm of s2] (s3) [circlenode] {s3}; %s3
node[above=1ex of s3,red] {$s leq 3$};
node[right=1.5cm of r3] (s4) [circlenode] {s4};
node[below=1cm of s4] (s5) [circlenode] {}; %s5
draw[fill=black] (s1.center) circle [radius=0.1cm];
draw[fill=black] (s5.center) circle [radius=0.1cm];
draw[->] (r1) -- (s2);
draw[->] (s2) -- (r2);
draw[->] (r3) -- (s4);
draw[->] (s4) -- (r4);
draw[->] (s1) to [out=180,in=90] (r1);
draw[->] (r1) to [out=-90,in=180] (s3);
draw[->] (s3) to [out=0,in=-90] (r2);
draw[->] (r2) to [bend right=45] node[auto,swap] {2} (s1);
draw[->] (r3) to [out=90,in=180] (s3);
draw[->] (s3) to [out=0,in=90] (r4);
draw[->] (r4) to [bend left=45] node[auto] {2} (s5);
draw[->] (s5) to [bend left=45] (r3);
begin{scope}[on background layer]
node [fill=gray!15,rounded corners,fit=(s1) (s3) (s5) (r1) (r2)] (R2) {};
end{scope}
draw [thick,decorate,
decoration={snake,amplitude=.4mm,segment length=2mm,
pre=moveto,pre length=1mm,post length=2mm}]
(R1) -- (R2) node [above=1mm,midway,text width=3cm,align=center]
{replacement of the textcolor{red}{capacity} by textcolor{red}{two places}};
end{tikzpicture}
end{document}
tikz-pgf
tikz-pgf
asked yesterday
subham sonisubham soni
4,07682981
4,07682981
1
xshift
never shifts the picture unless you work with overlay pictures and absolute positioning.
– marmot
yesterday
add a comment |
1
xshift
never shifts the picture unless you work with overlay pictures and absolute positioning.
– marmot
yesterday
1
1
xshift
never shifts the picture unless you work with overlay pictures and absolute positioning.– marmot
yesterday
xshift
never shifts the picture unless you work with overlay pictures and absolute positioning.– marmot
yesterday
add a comment |
2 Answers
2
active
oldest
votes
As mentioned above, xshift
never shifts the picture unless you work with overlay pictures and absolute positioning. And you do not need fit
here, it is easier to do that just with local bounding box
. You can shift these local bounding boxes.
documentclass{article}
usepackage{tikz}
usetikzlibrary{positioning}
usetikzlibrary{arrows}
usetikzlibrary{backgrounds}
usetikzlibrary{decorations.pathmorphing}
tikzset{squarenode/.style = {
shape = rectangle,
fill = gray!50,
draw = black,
thick,
minimum height = 1cm,
minimum width = 1cm
}}
tikzset{circlenode/.style = {
shape = circle,
fill = blue!20,
draw = blue,
thick,
minimum size = 1cm
}}
tikzset{help lines/.style=very thin}
tikzset{My Grid/.style={help lines,color=blue!50}}
begin{document}
begin{tikzpicture}[>=stealth']
begin{scope}[local bounding box=L]
%draw[My Grid] (-5,-5) grid (15,15);
node (r1) at (-4,4) [squarenode] {r1};
node[right=4cm of r1] (r2) [squarenode] {r2};
node[below=3cm of r1] (r3) [squarenode] {r3};
node[right=4cm of r3] (r4) [squarenode] {r4};
node[right=1.5cm of r1] (s2) [circlenode] {s2};
node[above=1cm of s2] (s1) [circlenode] {}; %s1
node[below=1cm of s2] (s3) [circlenode] {s3}; %s3
node[above=1ex of s3,red] {$s leq 3$};
node[right=1.5cm of r3] (s4) [circlenode] {s4};
node[below=1cm of s4] (s5) [circlenode] {}; %s5
draw[fill=black] (s1.center) circle [radius=0.1cm];
draw[fill=black] (s5.center) circle [radius=0.1cm];
draw[->] (r1) -- (s2);
draw[->] (s2) -- (r2);
draw[->] (r3) -- (s4);
draw[->] (s4) -- (r4);
draw[->] (s1) to[out=180,in=90] (r1);
draw[->] (r1) to[out=-90,in=180] (s3);
draw[->] (s3) to[out=0,in=-90] (r2);
draw[->] (r2) to[bend right=45] node[auto,swap] {2} (s1);
draw[->] (r3) to[out=90,in=180] (s3);
draw[->] (s3) to[out=0,in=90] (r4);
draw[->] (r4) to[bend left=45] node[auto] {2} (s5);
draw[->] (s5) to[bend left=45] (r3);
end{scope}
begin{scope}[on background layer]
fill[gray!15,rounded corners] (L.south west) rectangle (L.north east);
end{scope}
begin{scope}[xshift=8.5cm,local bounding box=R]
%draw[My Grid] (-5,-5) grid (15,15);
node (r1) at (-4,4) [squarenode] {r1};
node[right=4cm of r1] (r2) [squarenode] {r2};
node[below=3cm of r1] (r3) [squarenode] {r3};
node[right=4cm of r3] (r4) [squarenode] {r4};
node[right=1.5cm of r1] (s2) [circlenode] {s2};
node[above=1cm of s2] (s1) [circlenode] {}; %s1
node[below=1cm of s2] (s3) [circlenode] {s3}; %s3
node[above=1ex of s3,red] {$s leq 3$};
node[right=1.5cm of r3] (s4) [circlenode] {s4};
node[below=1cm of s4] (s5) [circlenode] {}; %s5
draw[fill=black] (s1.center) circle [radius=0.1cm];
draw[fill=black] (s5.center) circle [radius=0.1cm];
draw[->] (r1) -- (s2);
draw[->] (s2) -- (r2);
draw[->] (r3) -- (s4);
draw[->] (s4) -- (r4);
draw[->] (s1) to [out=180,in=90] (r1);
draw[->] (r1) to [out=-90,in=180] (s3);
draw[->] (s3) to [out=0,in=-90] (r2);
draw[->] (r2) to [bend right=45] node[auto,swap] {2} (s1);
draw[->] (r3) to [out=90,in=180] (s3);
draw[->] (s3) to [out=0,in=90] (r4);
draw[->] (r4) to [bend left=45] node[auto] {2} (s5);
draw[->] (s5) to [bend left=45] (r3);
end{scope}
begin{scope}[on background layer]
fill[gray!15,rounded corners] (R.south west) rectangle (R.north east);
end{scope}
draw [thick,decorate,
decoration={snake,amplitude=.4mm,segment length=2mm,
pre=moveto,pre length=1mm,post length=2mm}]
(L) -- (R) node [above=1mm,midway,text width=3cm,align=center]
{replacement of the textcolor{red}{capacity} by textcolor{red}{two places}};
end{tikzpicture}
end{document}
It is the tutorialA Petri-Net for Hagen
in the Tikz manual that uses thefit
library.
– AndréC
yesterday
@AndréC The point of answers is to go beyond what already existed before.
– marmot
yesterday
add a comment |
Moving with xshift
, yshift
or shift
only works within a single tikzpicture
environment.
Here, you have two tikzpicture environments, so it has no effect.
It is enough to include the figure in a scope
environment to be able to move it.
documentclass{article}
usepackage{tikz}
usetikzlibrary{positioning}
usetikzlibrary{arrows}
usetikzlibrary{backgrounds}
usetikzlibrary{fit}
usetikzlibrary{decorations.pathmorphing}
tikzset{squarenode/.style = {
shape = rectangle,
fill = gray!50,
draw = black,
thick,
minimum height = 1cm,
minimum width = 1cm
}}
tikzset{circlenode/.style = {
shape = circle,
fill = blue!20,
draw = blue,
thick,
minimum size = 1cm
}}
tikzset{help lines/.style=very thin}
tikzset{My Grid/.style={help lines,color=blue!50}}
begin{document}
begin{tikzpicture}
[>=stealth']
%draw[My Grid] (-5,-5) grid (15,15);
node (r1) at (-4,4) [squarenode] {r1};
node[right=4cm of r1] (r2) [squarenode] {r2};
node[below=3cm of r1] (r3) [squarenode] {r3};
node[right=4cm of r3] (r4) [squarenode] {r4};
node[right=1.5cm of r1] (s2) [circlenode] {s2};
node[above=1cm of s2] (s1) [circlenode] {}; %s1
node[below=1cm of s2] (s3) [circlenode] {s3}; %s3
node[above=1ex of s3,red] {$s leq 3$};
node[right=1.5cm of r3] (s4) [circlenode] {s4};
node[below=1cm of s4] (s5) [circlenode] {}; %s5
draw[fill=black] (s1.center) circle [radius=0.1cm];
draw[fill=black] (s5.center) circle [radius=0.1cm];
draw[->] (r1) -- (s2);
draw[->] (s2) -- (r2);
draw[->] (r3) -- (s4);
draw[->] (s4) -- (r4);
draw[->] (s1) to [out=180,in=90] (r1);
draw[->] (r1) to [out=-90,in=180] (s3);
draw[->] (s3) to [out=0,in=-90] (r2);
draw[->] (r2) to [bend right=45] node[auto,swap] {2} (s1);
draw[->] (r3) to [out=90,in=180] (s3);
draw[->] (s3) to [out=0,in=90] (r4);
draw[->] (r4) to [bend left=45] node[auto] {2} (s5);
draw[->] (s5) to [bend left=45] (r3);
begin{scope}[on background layer]
node [fill=gray!15,rounded corners,fit=(s1) (s3) (s5) (r1) (r2)] (R1) {};
end{scope}
begin{scope}[xshift=9cm]
[>=stealth']
%draw[My Grid] (-5,-5) grid (15,15);
node (r1) at (-4,4) [squarenode] {r1};
node[right=4cm of r1] (r2) [squarenode] {r2};
node[below=3cm of r1] (r3) [squarenode] {r3};
node[right=4cm of r3] (r4) [squarenode] {r4};
node[right=1.5cm of r1] (s2) [circlenode] {s2};
node[above=1cm of s2] (s1) [circlenode] {}; %s1
node[below=1cm of s2] (s3) [circlenode] {s3}; %s3
node[above=1ex of s3,red] {$s leq 3$};
node[right=1.5cm of r3] (s4) [circlenode] {s4};
node[below=1cm of s4] (s5) [circlenode] {}; %s5
draw[fill=black] (s1.center) circle [radius=0.1cm];
draw[fill=black] (s5.center) circle [radius=0.1cm];
draw[->] (r1) -- (s2);
draw[->] (s2) -- (r2);
draw[->] (r3) -- (s4);
draw[->] (s4) -- (r4);
draw[->] (s1) to [out=180,in=90] (r1);
draw[->] (r1) to [out=-90,in=180] (s3);
draw[->] (s3) to [out=0,in=-90] (r2);
draw[->] (r2) to [bend right=45] node[auto,swap] {2} (s1);
draw[->] (r3) to [out=90,in=180] (s3);
draw[->] (s3) to [out=0,in=90] (r4);
draw[->] (r4) to [bend left=45] node[auto] {2} (s5);
draw[->] (s5) to [bend left=45] (r3);
begin{scope}[on background layer]
node [fill=gray!15,rounded corners,fit=(s1) (s3) (s5) (r1) (r2)] (R2) {};
end{scope}
draw [thick,decorate,
decoration={snake,amplitude=.4mm,segment length=2mm,
pre=moveto,pre length=1mm,post length=2mm}]
(R1) -- (R2) node [above=1mm,midway,text width=3cm,align=center]
{replacement of the textcolor{red}{capacity} by textcolor{red}{two places}};
end{scope}
end{tikzpicture}
end{document}
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f477814%2fpetrinet-decoration-and-xshift-not-aligned-in-tikz%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
As mentioned above, xshift
never shifts the picture unless you work with overlay pictures and absolute positioning. And you do not need fit
here, it is easier to do that just with local bounding box
. You can shift these local bounding boxes.
documentclass{article}
usepackage{tikz}
usetikzlibrary{positioning}
usetikzlibrary{arrows}
usetikzlibrary{backgrounds}
usetikzlibrary{decorations.pathmorphing}
tikzset{squarenode/.style = {
shape = rectangle,
fill = gray!50,
draw = black,
thick,
minimum height = 1cm,
minimum width = 1cm
}}
tikzset{circlenode/.style = {
shape = circle,
fill = blue!20,
draw = blue,
thick,
minimum size = 1cm
}}
tikzset{help lines/.style=very thin}
tikzset{My Grid/.style={help lines,color=blue!50}}
begin{document}
begin{tikzpicture}[>=stealth']
begin{scope}[local bounding box=L]
%draw[My Grid] (-5,-5) grid (15,15);
node (r1) at (-4,4) [squarenode] {r1};
node[right=4cm of r1] (r2) [squarenode] {r2};
node[below=3cm of r1] (r3) [squarenode] {r3};
node[right=4cm of r3] (r4) [squarenode] {r4};
node[right=1.5cm of r1] (s2) [circlenode] {s2};
node[above=1cm of s2] (s1) [circlenode] {}; %s1
node[below=1cm of s2] (s3) [circlenode] {s3}; %s3
node[above=1ex of s3,red] {$s leq 3$};
node[right=1.5cm of r3] (s4) [circlenode] {s4};
node[below=1cm of s4] (s5) [circlenode] {}; %s5
draw[fill=black] (s1.center) circle [radius=0.1cm];
draw[fill=black] (s5.center) circle [radius=0.1cm];
draw[->] (r1) -- (s2);
draw[->] (s2) -- (r2);
draw[->] (r3) -- (s4);
draw[->] (s4) -- (r4);
draw[->] (s1) to[out=180,in=90] (r1);
draw[->] (r1) to[out=-90,in=180] (s3);
draw[->] (s3) to[out=0,in=-90] (r2);
draw[->] (r2) to[bend right=45] node[auto,swap] {2} (s1);
draw[->] (r3) to[out=90,in=180] (s3);
draw[->] (s3) to[out=0,in=90] (r4);
draw[->] (r4) to[bend left=45] node[auto] {2} (s5);
draw[->] (s5) to[bend left=45] (r3);
end{scope}
begin{scope}[on background layer]
fill[gray!15,rounded corners] (L.south west) rectangle (L.north east);
end{scope}
begin{scope}[xshift=8.5cm,local bounding box=R]
%draw[My Grid] (-5,-5) grid (15,15);
node (r1) at (-4,4) [squarenode] {r1};
node[right=4cm of r1] (r2) [squarenode] {r2};
node[below=3cm of r1] (r3) [squarenode] {r3};
node[right=4cm of r3] (r4) [squarenode] {r4};
node[right=1.5cm of r1] (s2) [circlenode] {s2};
node[above=1cm of s2] (s1) [circlenode] {}; %s1
node[below=1cm of s2] (s3) [circlenode] {s3}; %s3
node[above=1ex of s3,red] {$s leq 3$};
node[right=1.5cm of r3] (s4) [circlenode] {s4};
node[below=1cm of s4] (s5) [circlenode] {}; %s5
draw[fill=black] (s1.center) circle [radius=0.1cm];
draw[fill=black] (s5.center) circle [radius=0.1cm];
draw[->] (r1) -- (s2);
draw[->] (s2) -- (r2);
draw[->] (r3) -- (s4);
draw[->] (s4) -- (r4);
draw[->] (s1) to [out=180,in=90] (r1);
draw[->] (r1) to [out=-90,in=180] (s3);
draw[->] (s3) to [out=0,in=-90] (r2);
draw[->] (r2) to [bend right=45] node[auto,swap] {2} (s1);
draw[->] (r3) to [out=90,in=180] (s3);
draw[->] (s3) to [out=0,in=90] (r4);
draw[->] (r4) to [bend left=45] node[auto] {2} (s5);
draw[->] (s5) to [bend left=45] (r3);
end{scope}
begin{scope}[on background layer]
fill[gray!15,rounded corners] (R.south west) rectangle (R.north east);
end{scope}
draw [thick,decorate,
decoration={snake,amplitude=.4mm,segment length=2mm,
pre=moveto,pre length=1mm,post length=2mm}]
(L) -- (R) node [above=1mm,midway,text width=3cm,align=center]
{replacement of the textcolor{red}{capacity} by textcolor{red}{two places}};
end{tikzpicture}
end{document}
It is the tutorialA Petri-Net for Hagen
in the Tikz manual that uses thefit
library.
– AndréC
yesterday
@AndréC The point of answers is to go beyond what already existed before.
– marmot
yesterday
add a comment |
As mentioned above, xshift
never shifts the picture unless you work with overlay pictures and absolute positioning. And you do not need fit
here, it is easier to do that just with local bounding box
. You can shift these local bounding boxes.
documentclass{article}
usepackage{tikz}
usetikzlibrary{positioning}
usetikzlibrary{arrows}
usetikzlibrary{backgrounds}
usetikzlibrary{decorations.pathmorphing}
tikzset{squarenode/.style = {
shape = rectangle,
fill = gray!50,
draw = black,
thick,
minimum height = 1cm,
minimum width = 1cm
}}
tikzset{circlenode/.style = {
shape = circle,
fill = blue!20,
draw = blue,
thick,
minimum size = 1cm
}}
tikzset{help lines/.style=very thin}
tikzset{My Grid/.style={help lines,color=blue!50}}
begin{document}
begin{tikzpicture}[>=stealth']
begin{scope}[local bounding box=L]
%draw[My Grid] (-5,-5) grid (15,15);
node (r1) at (-4,4) [squarenode] {r1};
node[right=4cm of r1] (r2) [squarenode] {r2};
node[below=3cm of r1] (r3) [squarenode] {r3};
node[right=4cm of r3] (r4) [squarenode] {r4};
node[right=1.5cm of r1] (s2) [circlenode] {s2};
node[above=1cm of s2] (s1) [circlenode] {}; %s1
node[below=1cm of s2] (s3) [circlenode] {s3}; %s3
node[above=1ex of s3,red] {$s leq 3$};
node[right=1.5cm of r3] (s4) [circlenode] {s4};
node[below=1cm of s4] (s5) [circlenode] {}; %s5
draw[fill=black] (s1.center) circle [radius=0.1cm];
draw[fill=black] (s5.center) circle [radius=0.1cm];
draw[->] (r1) -- (s2);
draw[->] (s2) -- (r2);
draw[->] (r3) -- (s4);
draw[->] (s4) -- (r4);
draw[->] (s1) to[out=180,in=90] (r1);
draw[->] (r1) to[out=-90,in=180] (s3);
draw[->] (s3) to[out=0,in=-90] (r2);
draw[->] (r2) to[bend right=45] node[auto,swap] {2} (s1);
draw[->] (r3) to[out=90,in=180] (s3);
draw[->] (s3) to[out=0,in=90] (r4);
draw[->] (r4) to[bend left=45] node[auto] {2} (s5);
draw[->] (s5) to[bend left=45] (r3);
end{scope}
begin{scope}[on background layer]
fill[gray!15,rounded corners] (L.south west) rectangle (L.north east);
end{scope}
begin{scope}[xshift=8.5cm,local bounding box=R]
%draw[My Grid] (-5,-5) grid (15,15);
node (r1) at (-4,4) [squarenode] {r1};
node[right=4cm of r1] (r2) [squarenode] {r2};
node[below=3cm of r1] (r3) [squarenode] {r3};
node[right=4cm of r3] (r4) [squarenode] {r4};
node[right=1.5cm of r1] (s2) [circlenode] {s2};
node[above=1cm of s2] (s1) [circlenode] {}; %s1
node[below=1cm of s2] (s3) [circlenode] {s3}; %s3
node[above=1ex of s3,red] {$s leq 3$};
node[right=1.5cm of r3] (s4) [circlenode] {s4};
node[below=1cm of s4] (s5) [circlenode] {}; %s5
draw[fill=black] (s1.center) circle [radius=0.1cm];
draw[fill=black] (s5.center) circle [radius=0.1cm];
draw[->] (r1) -- (s2);
draw[->] (s2) -- (r2);
draw[->] (r3) -- (s4);
draw[->] (s4) -- (r4);
draw[->] (s1) to [out=180,in=90] (r1);
draw[->] (r1) to [out=-90,in=180] (s3);
draw[->] (s3) to [out=0,in=-90] (r2);
draw[->] (r2) to [bend right=45] node[auto,swap] {2} (s1);
draw[->] (r3) to [out=90,in=180] (s3);
draw[->] (s3) to [out=0,in=90] (r4);
draw[->] (r4) to [bend left=45] node[auto] {2} (s5);
draw[->] (s5) to [bend left=45] (r3);
end{scope}
begin{scope}[on background layer]
fill[gray!15,rounded corners] (R.south west) rectangle (R.north east);
end{scope}
draw [thick,decorate,
decoration={snake,amplitude=.4mm,segment length=2mm,
pre=moveto,pre length=1mm,post length=2mm}]
(L) -- (R) node [above=1mm,midway,text width=3cm,align=center]
{replacement of the textcolor{red}{capacity} by textcolor{red}{two places}};
end{tikzpicture}
end{document}
It is the tutorialA Petri-Net for Hagen
in the Tikz manual that uses thefit
library.
– AndréC
yesterday
@AndréC The point of answers is to go beyond what already existed before.
– marmot
yesterday
add a comment |
As mentioned above, xshift
never shifts the picture unless you work with overlay pictures and absolute positioning. And you do not need fit
here, it is easier to do that just with local bounding box
. You can shift these local bounding boxes.
documentclass{article}
usepackage{tikz}
usetikzlibrary{positioning}
usetikzlibrary{arrows}
usetikzlibrary{backgrounds}
usetikzlibrary{decorations.pathmorphing}
tikzset{squarenode/.style = {
shape = rectangle,
fill = gray!50,
draw = black,
thick,
minimum height = 1cm,
minimum width = 1cm
}}
tikzset{circlenode/.style = {
shape = circle,
fill = blue!20,
draw = blue,
thick,
minimum size = 1cm
}}
tikzset{help lines/.style=very thin}
tikzset{My Grid/.style={help lines,color=blue!50}}
begin{document}
begin{tikzpicture}[>=stealth']
begin{scope}[local bounding box=L]
%draw[My Grid] (-5,-5) grid (15,15);
node (r1) at (-4,4) [squarenode] {r1};
node[right=4cm of r1] (r2) [squarenode] {r2};
node[below=3cm of r1] (r3) [squarenode] {r3};
node[right=4cm of r3] (r4) [squarenode] {r4};
node[right=1.5cm of r1] (s2) [circlenode] {s2};
node[above=1cm of s2] (s1) [circlenode] {}; %s1
node[below=1cm of s2] (s3) [circlenode] {s3}; %s3
node[above=1ex of s3,red] {$s leq 3$};
node[right=1.5cm of r3] (s4) [circlenode] {s4};
node[below=1cm of s4] (s5) [circlenode] {}; %s5
draw[fill=black] (s1.center) circle [radius=0.1cm];
draw[fill=black] (s5.center) circle [radius=0.1cm];
draw[->] (r1) -- (s2);
draw[->] (s2) -- (r2);
draw[->] (r3) -- (s4);
draw[->] (s4) -- (r4);
draw[->] (s1) to[out=180,in=90] (r1);
draw[->] (r1) to[out=-90,in=180] (s3);
draw[->] (s3) to[out=0,in=-90] (r2);
draw[->] (r2) to[bend right=45] node[auto,swap] {2} (s1);
draw[->] (r3) to[out=90,in=180] (s3);
draw[->] (s3) to[out=0,in=90] (r4);
draw[->] (r4) to[bend left=45] node[auto] {2} (s5);
draw[->] (s5) to[bend left=45] (r3);
end{scope}
begin{scope}[on background layer]
fill[gray!15,rounded corners] (L.south west) rectangle (L.north east);
end{scope}
begin{scope}[xshift=8.5cm,local bounding box=R]
%draw[My Grid] (-5,-5) grid (15,15);
node (r1) at (-4,4) [squarenode] {r1};
node[right=4cm of r1] (r2) [squarenode] {r2};
node[below=3cm of r1] (r3) [squarenode] {r3};
node[right=4cm of r3] (r4) [squarenode] {r4};
node[right=1.5cm of r1] (s2) [circlenode] {s2};
node[above=1cm of s2] (s1) [circlenode] {}; %s1
node[below=1cm of s2] (s3) [circlenode] {s3}; %s3
node[above=1ex of s3,red] {$s leq 3$};
node[right=1.5cm of r3] (s4) [circlenode] {s4};
node[below=1cm of s4] (s5) [circlenode] {}; %s5
draw[fill=black] (s1.center) circle [radius=0.1cm];
draw[fill=black] (s5.center) circle [radius=0.1cm];
draw[->] (r1) -- (s2);
draw[->] (s2) -- (r2);
draw[->] (r3) -- (s4);
draw[->] (s4) -- (r4);
draw[->] (s1) to [out=180,in=90] (r1);
draw[->] (r1) to [out=-90,in=180] (s3);
draw[->] (s3) to [out=0,in=-90] (r2);
draw[->] (r2) to [bend right=45] node[auto,swap] {2} (s1);
draw[->] (r3) to [out=90,in=180] (s3);
draw[->] (s3) to [out=0,in=90] (r4);
draw[->] (r4) to [bend left=45] node[auto] {2} (s5);
draw[->] (s5) to [bend left=45] (r3);
end{scope}
begin{scope}[on background layer]
fill[gray!15,rounded corners] (R.south west) rectangle (R.north east);
end{scope}
draw [thick,decorate,
decoration={snake,amplitude=.4mm,segment length=2mm,
pre=moveto,pre length=1mm,post length=2mm}]
(L) -- (R) node [above=1mm,midway,text width=3cm,align=center]
{replacement of the textcolor{red}{capacity} by textcolor{red}{two places}};
end{tikzpicture}
end{document}
As mentioned above, xshift
never shifts the picture unless you work with overlay pictures and absolute positioning. And you do not need fit
here, it is easier to do that just with local bounding box
. You can shift these local bounding boxes.
documentclass{article}
usepackage{tikz}
usetikzlibrary{positioning}
usetikzlibrary{arrows}
usetikzlibrary{backgrounds}
usetikzlibrary{decorations.pathmorphing}
tikzset{squarenode/.style = {
shape = rectangle,
fill = gray!50,
draw = black,
thick,
minimum height = 1cm,
minimum width = 1cm
}}
tikzset{circlenode/.style = {
shape = circle,
fill = blue!20,
draw = blue,
thick,
minimum size = 1cm
}}
tikzset{help lines/.style=very thin}
tikzset{My Grid/.style={help lines,color=blue!50}}
begin{document}
begin{tikzpicture}[>=stealth']
begin{scope}[local bounding box=L]
%draw[My Grid] (-5,-5) grid (15,15);
node (r1) at (-4,4) [squarenode] {r1};
node[right=4cm of r1] (r2) [squarenode] {r2};
node[below=3cm of r1] (r3) [squarenode] {r3};
node[right=4cm of r3] (r4) [squarenode] {r4};
node[right=1.5cm of r1] (s2) [circlenode] {s2};
node[above=1cm of s2] (s1) [circlenode] {}; %s1
node[below=1cm of s2] (s3) [circlenode] {s3}; %s3
node[above=1ex of s3,red] {$s leq 3$};
node[right=1.5cm of r3] (s4) [circlenode] {s4};
node[below=1cm of s4] (s5) [circlenode] {}; %s5
draw[fill=black] (s1.center) circle [radius=0.1cm];
draw[fill=black] (s5.center) circle [radius=0.1cm];
draw[->] (r1) -- (s2);
draw[->] (s2) -- (r2);
draw[->] (r3) -- (s4);
draw[->] (s4) -- (r4);
draw[->] (s1) to[out=180,in=90] (r1);
draw[->] (r1) to[out=-90,in=180] (s3);
draw[->] (s3) to[out=0,in=-90] (r2);
draw[->] (r2) to[bend right=45] node[auto,swap] {2} (s1);
draw[->] (r3) to[out=90,in=180] (s3);
draw[->] (s3) to[out=0,in=90] (r4);
draw[->] (r4) to[bend left=45] node[auto] {2} (s5);
draw[->] (s5) to[bend left=45] (r3);
end{scope}
begin{scope}[on background layer]
fill[gray!15,rounded corners] (L.south west) rectangle (L.north east);
end{scope}
begin{scope}[xshift=8.5cm,local bounding box=R]
%draw[My Grid] (-5,-5) grid (15,15);
node (r1) at (-4,4) [squarenode] {r1};
node[right=4cm of r1] (r2) [squarenode] {r2};
node[below=3cm of r1] (r3) [squarenode] {r3};
node[right=4cm of r3] (r4) [squarenode] {r4};
node[right=1.5cm of r1] (s2) [circlenode] {s2};
node[above=1cm of s2] (s1) [circlenode] {}; %s1
node[below=1cm of s2] (s3) [circlenode] {s3}; %s3
node[above=1ex of s3,red] {$s leq 3$};
node[right=1.5cm of r3] (s4) [circlenode] {s4};
node[below=1cm of s4] (s5) [circlenode] {}; %s5
draw[fill=black] (s1.center) circle [radius=0.1cm];
draw[fill=black] (s5.center) circle [radius=0.1cm];
draw[->] (r1) -- (s2);
draw[->] (s2) -- (r2);
draw[->] (r3) -- (s4);
draw[->] (s4) -- (r4);
draw[->] (s1) to [out=180,in=90] (r1);
draw[->] (r1) to [out=-90,in=180] (s3);
draw[->] (s3) to [out=0,in=-90] (r2);
draw[->] (r2) to [bend right=45] node[auto,swap] {2} (s1);
draw[->] (r3) to [out=90,in=180] (s3);
draw[->] (s3) to [out=0,in=90] (r4);
draw[->] (r4) to [bend left=45] node[auto] {2} (s5);
draw[->] (s5) to [bend left=45] (r3);
end{scope}
begin{scope}[on background layer]
fill[gray!15,rounded corners] (R.south west) rectangle (R.north east);
end{scope}
draw [thick,decorate,
decoration={snake,amplitude=.4mm,segment length=2mm,
pre=moveto,pre length=1mm,post length=2mm}]
(L) -- (R) node [above=1mm,midway,text width=3cm,align=center]
{replacement of the textcolor{red}{capacity} by textcolor{red}{two places}};
end{tikzpicture}
end{document}
answered yesterday
marmotmarmot
106k5128242
106k5128242
It is the tutorialA Petri-Net for Hagen
in the Tikz manual that uses thefit
library.
– AndréC
yesterday
@AndréC The point of answers is to go beyond what already existed before.
– marmot
yesterday
add a comment |
It is the tutorialA Petri-Net for Hagen
in the Tikz manual that uses thefit
library.
– AndréC
yesterday
@AndréC The point of answers is to go beyond what already existed before.
– marmot
yesterday
It is the tutorial
A Petri-Net for Hagen
in the Tikz manual that uses the fit
library.– AndréC
yesterday
It is the tutorial
A Petri-Net for Hagen
in the Tikz manual that uses the fit
library.– AndréC
yesterday
@AndréC The point of answers is to go beyond what already existed before.
– marmot
yesterday
@AndréC The point of answers is to go beyond what already existed before.
– marmot
yesterday
add a comment |
Moving with xshift
, yshift
or shift
only works within a single tikzpicture
environment.
Here, you have two tikzpicture environments, so it has no effect.
It is enough to include the figure in a scope
environment to be able to move it.
documentclass{article}
usepackage{tikz}
usetikzlibrary{positioning}
usetikzlibrary{arrows}
usetikzlibrary{backgrounds}
usetikzlibrary{fit}
usetikzlibrary{decorations.pathmorphing}
tikzset{squarenode/.style = {
shape = rectangle,
fill = gray!50,
draw = black,
thick,
minimum height = 1cm,
minimum width = 1cm
}}
tikzset{circlenode/.style = {
shape = circle,
fill = blue!20,
draw = blue,
thick,
minimum size = 1cm
}}
tikzset{help lines/.style=very thin}
tikzset{My Grid/.style={help lines,color=blue!50}}
begin{document}
begin{tikzpicture}
[>=stealth']
%draw[My Grid] (-5,-5) grid (15,15);
node (r1) at (-4,4) [squarenode] {r1};
node[right=4cm of r1] (r2) [squarenode] {r2};
node[below=3cm of r1] (r3) [squarenode] {r3};
node[right=4cm of r3] (r4) [squarenode] {r4};
node[right=1.5cm of r1] (s2) [circlenode] {s2};
node[above=1cm of s2] (s1) [circlenode] {}; %s1
node[below=1cm of s2] (s3) [circlenode] {s3}; %s3
node[above=1ex of s3,red] {$s leq 3$};
node[right=1.5cm of r3] (s4) [circlenode] {s4};
node[below=1cm of s4] (s5) [circlenode] {}; %s5
draw[fill=black] (s1.center) circle [radius=0.1cm];
draw[fill=black] (s5.center) circle [radius=0.1cm];
draw[->] (r1) -- (s2);
draw[->] (s2) -- (r2);
draw[->] (r3) -- (s4);
draw[->] (s4) -- (r4);
draw[->] (s1) to [out=180,in=90] (r1);
draw[->] (r1) to [out=-90,in=180] (s3);
draw[->] (s3) to [out=0,in=-90] (r2);
draw[->] (r2) to [bend right=45] node[auto,swap] {2} (s1);
draw[->] (r3) to [out=90,in=180] (s3);
draw[->] (s3) to [out=0,in=90] (r4);
draw[->] (r4) to [bend left=45] node[auto] {2} (s5);
draw[->] (s5) to [bend left=45] (r3);
begin{scope}[on background layer]
node [fill=gray!15,rounded corners,fit=(s1) (s3) (s5) (r1) (r2)] (R1) {};
end{scope}
begin{scope}[xshift=9cm]
[>=stealth']
%draw[My Grid] (-5,-5) grid (15,15);
node (r1) at (-4,4) [squarenode] {r1};
node[right=4cm of r1] (r2) [squarenode] {r2};
node[below=3cm of r1] (r3) [squarenode] {r3};
node[right=4cm of r3] (r4) [squarenode] {r4};
node[right=1.5cm of r1] (s2) [circlenode] {s2};
node[above=1cm of s2] (s1) [circlenode] {}; %s1
node[below=1cm of s2] (s3) [circlenode] {s3}; %s3
node[above=1ex of s3,red] {$s leq 3$};
node[right=1.5cm of r3] (s4) [circlenode] {s4};
node[below=1cm of s4] (s5) [circlenode] {}; %s5
draw[fill=black] (s1.center) circle [radius=0.1cm];
draw[fill=black] (s5.center) circle [radius=0.1cm];
draw[->] (r1) -- (s2);
draw[->] (s2) -- (r2);
draw[->] (r3) -- (s4);
draw[->] (s4) -- (r4);
draw[->] (s1) to [out=180,in=90] (r1);
draw[->] (r1) to [out=-90,in=180] (s3);
draw[->] (s3) to [out=0,in=-90] (r2);
draw[->] (r2) to [bend right=45] node[auto,swap] {2} (s1);
draw[->] (r3) to [out=90,in=180] (s3);
draw[->] (s3) to [out=0,in=90] (r4);
draw[->] (r4) to [bend left=45] node[auto] {2} (s5);
draw[->] (s5) to [bend left=45] (r3);
begin{scope}[on background layer]
node [fill=gray!15,rounded corners,fit=(s1) (s3) (s5) (r1) (r2)] (R2) {};
end{scope}
draw [thick,decorate,
decoration={snake,amplitude=.4mm,segment length=2mm,
pre=moveto,pre length=1mm,post length=2mm}]
(R1) -- (R2) node [above=1mm,midway,text width=3cm,align=center]
{replacement of the textcolor{red}{capacity} by textcolor{red}{two places}};
end{scope}
end{tikzpicture}
end{document}
add a comment |
Moving with xshift
, yshift
or shift
only works within a single tikzpicture
environment.
Here, you have two tikzpicture environments, so it has no effect.
It is enough to include the figure in a scope
environment to be able to move it.
documentclass{article}
usepackage{tikz}
usetikzlibrary{positioning}
usetikzlibrary{arrows}
usetikzlibrary{backgrounds}
usetikzlibrary{fit}
usetikzlibrary{decorations.pathmorphing}
tikzset{squarenode/.style = {
shape = rectangle,
fill = gray!50,
draw = black,
thick,
minimum height = 1cm,
minimum width = 1cm
}}
tikzset{circlenode/.style = {
shape = circle,
fill = blue!20,
draw = blue,
thick,
minimum size = 1cm
}}
tikzset{help lines/.style=very thin}
tikzset{My Grid/.style={help lines,color=blue!50}}
begin{document}
begin{tikzpicture}
[>=stealth']
%draw[My Grid] (-5,-5) grid (15,15);
node (r1) at (-4,4) [squarenode] {r1};
node[right=4cm of r1] (r2) [squarenode] {r2};
node[below=3cm of r1] (r3) [squarenode] {r3};
node[right=4cm of r3] (r4) [squarenode] {r4};
node[right=1.5cm of r1] (s2) [circlenode] {s2};
node[above=1cm of s2] (s1) [circlenode] {}; %s1
node[below=1cm of s2] (s3) [circlenode] {s3}; %s3
node[above=1ex of s3,red] {$s leq 3$};
node[right=1.5cm of r3] (s4) [circlenode] {s4};
node[below=1cm of s4] (s5) [circlenode] {}; %s5
draw[fill=black] (s1.center) circle [radius=0.1cm];
draw[fill=black] (s5.center) circle [radius=0.1cm];
draw[->] (r1) -- (s2);
draw[->] (s2) -- (r2);
draw[->] (r3) -- (s4);
draw[->] (s4) -- (r4);
draw[->] (s1) to [out=180,in=90] (r1);
draw[->] (r1) to [out=-90,in=180] (s3);
draw[->] (s3) to [out=0,in=-90] (r2);
draw[->] (r2) to [bend right=45] node[auto,swap] {2} (s1);
draw[->] (r3) to [out=90,in=180] (s3);
draw[->] (s3) to [out=0,in=90] (r4);
draw[->] (r4) to [bend left=45] node[auto] {2} (s5);
draw[->] (s5) to [bend left=45] (r3);
begin{scope}[on background layer]
node [fill=gray!15,rounded corners,fit=(s1) (s3) (s5) (r1) (r2)] (R1) {};
end{scope}
begin{scope}[xshift=9cm]
[>=stealth']
%draw[My Grid] (-5,-5) grid (15,15);
node (r1) at (-4,4) [squarenode] {r1};
node[right=4cm of r1] (r2) [squarenode] {r2};
node[below=3cm of r1] (r3) [squarenode] {r3};
node[right=4cm of r3] (r4) [squarenode] {r4};
node[right=1.5cm of r1] (s2) [circlenode] {s2};
node[above=1cm of s2] (s1) [circlenode] {}; %s1
node[below=1cm of s2] (s3) [circlenode] {s3}; %s3
node[above=1ex of s3,red] {$s leq 3$};
node[right=1.5cm of r3] (s4) [circlenode] {s4};
node[below=1cm of s4] (s5) [circlenode] {}; %s5
draw[fill=black] (s1.center) circle [radius=0.1cm];
draw[fill=black] (s5.center) circle [radius=0.1cm];
draw[->] (r1) -- (s2);
draw[->] (s2) -- (r2);
draw[->] (r3) -- (s4);
draw[->] (s4) -- (r4);
draw[->] (s1) to [out=180,in=90] (r1);
draw[->] (r1) to [out=-90,in=180] (s3);
draw[->] (s3) to [out=0,in=-90] (r2);
draw[->] (r2) to [bend right=45] node[auto,swap] {2} (s1);
draw[->] (r3) to [out=90,in=180] (s3);
draw[->] (s3) to [out=0,in=90] (r4);
draw[->] (r4) to [bend left=45] node[auto] {2} (s5);
draw[->] (s5) to [bend left=45] (r3);
begin{scope}[on background layer]
node [fill=gray!15,rounded corners,fit=(s1) (s3) (s5) (r1) (r2)] (R2) {};
end{scope}
draw [thick,decorate,
decoration={snake,amplitude=.4mm,segment length=2mm,
pre=moveto,pre length=1mm,post length=2mm}]
(R1) -- (R2) node [above=1mm,midway,text width=3cm,align=center]
{replacement of the textcolor{red}{capacity} by textcolor{red}{two places}};
end{scope}
end{tikzpicture}
end{document}
add a comment |
Moving with xshift
, yshift
or shift
only works within a single tikzpicture
environment.
Here, you have two tikzpicture environments, so it has no effect.
It is enough to include the figure in a scope
environment to be able to move it.
documentclass{article}
usepackage{tikz}
usetikzlibrary{positioning}
usetikzlibrary{arrows}
usetikzlibrary{backgrounds}
usetikzlibrary{fit}
usetikzlibrary{decorations.pathmorphing}
tikzset{squarenode/.style = {
shape = rectangle,
fill = gray!50,
draw = black,
thick,
minimum height = 1cm,
minimum width = 1cm
}}
tikzset{circlenode/.style = {
shape = circle,
fill = blue!20,
draw = blue,
thick,
minimum size = 1cm
}}
tikzset{help lines/.style=very thin}
tikzset{My Grid/.style={help lines,color=blue!50}}
begin{document}
begin{tikzpicture}
[>=stealth']
%draw[My Grid] (-5,-5) grid (15,15);
node (r1) at (-4,4) [squarenode] {r1};
node[right=4cm of r1] (r2) [squarenode] {r2};
node[below=3cm of r1] (r3) [squarenode] {r3};
node[right=4cm of r3] (r4) [squarenode] {r4};
node[right=1.5cm of r1] (s2) [circlenode] {s2};
node[above=1cm of s2] (s1) [circlenode] {}; %s1
node[below=1cm of s2] (s3) [circlenode] {s3}; %s3
node[above=1ex of s3,red] {$s leq 3$};
node[right=1.5cm of r3] (s4) [circlenode] {s4};
node[below=1cm of s4] (s5) [circlenode] {}; %s5
draw[fill=black] (s1.center) circle [radius=0.1cm];
draw[fill=black] (s5.center) circle [radius=0.1cm];
draw[->] (r1) -- (s2);
draw[->] (s2) -- (r2);
draw[->] (r3) -- (s4);
draw[->] (s4) -- (r4);
draw[->] (s1) to [out=180,in=90] (r1);
draw[->] (r1) to [out=-90,in=180] (s3);
draw[->] (s3) to [out=0,in=-90] (r2);
draw[->] (r2) to [bend right=45] node[auto,swap] {2} (s1);
draw[->] (r3) to [out=90,in=180] (s3);
draw[->] (s3) to [out=0,in=90] (r4);
draw[->] (r4) to [bend left=45] node[auto] {2} (s5);
draw[->] (s5) to [bend left=45] (r3);
begin{scope}[on background layer]
node [fill=gray!15,rounded corners,fit=(s1) (s3) (s5) (r1) (r2)] (R1) {};
end{scope}
begin{scope}[xshift=9cm]
[>=stealth']
%draw[My Grid] (-5,-5) grid (15,15);
node (r1) at (-4,4) [squarenode] {r1};
node[right=4cm of r1] (r2) [squarenode] {r2};
node[below=3cm of r1] (r3) [squarenode] {r3};
node[right=4cm of r3] (r4) [squarenode] {r4};
node[right=1.5cm of r1] (s2) [circlenode] {s2};
node[above=1cm of s2] (s1) [circlenode] {}; %s1
node[below=1cm of s2] (s3) [circlenode] {s3}; %s3
node[above=1ex of s3,red] {$s leq 3$};
node[right=1.5cm of r3] (s4) [circlenode] {s4};
node[below=1cm of s4] (s5) [circlenode] {}; %s5
draw[fill=black] (s1.center) circle [radius=0.1cm];
draw[fill=black] (s5.center) circle [radius=0.1cm];
draw[->] (r1) -- (s2);
draw[->] (s2) -- (r2);
draw[->] (r3) -- (s4);
draw[->] (s4) -- (r4);
draw[->] (s1) to [out=180,in=90] (r1);
draw[->] (r1) to [out=-90,in=180] (s3);
draw[->] (s3) to [out=0,in=-90] (r2);
draw[->] (r2) to [bend right=45] node[auto,swap] {2} (s1);
draw[->] (r3) to [out=90,in=180] (s3);
draw[->] (s3) to [out=0,in=90] (r4);
draw[->] (r4) to [bend left=45] node[auto] {2} (s5);
draw[->] (s5) to [bend left=45] (r3);
begin{scope}[on background layer]
node [fill=gray!15,rounded corners,fit=(s1) (s3) (s5) (r1) (r2)] (R2) {};
end{scope}
draw [thick,decorate,
decoration={snake,amplitude=.4mm,segment length=2mm,
pre=moveto,pre length=1mm,post length=2mm}]
(R1) -- (R2) node [above=1mm,midway,text width=3cm,align=center]
{replacement of the textcolor{red}{capacity} by textcolor{red}{two places}};
end{scope}
end{tikzpicture}
end{document}
Moving with xshift
, yshift
or shift
only works within a single tikzpicture
environment.
Here, you have two tikzpicture environments, so it has no effect.
It is enough to include the figure in a scope
environment to be able to move it.
documentclass{article}
usepackage{tikz}
usetikzlibrary{positioning}
usetikzlibrary{arrows}
usetikzlibrary{backgrounds}
usetikzlibrary{fit}
usetikzlibrary{decorations.pathmorphing}
tikzset{squarenode/.style = {
shape = rectangle,
fill = gray!50,
draw = black,
thick,
minimum height = 1cm,
minimum width = 1cm
}}
tikzset{circlenode/.style = {
shape = circle,
fill = blue!20,
draw = blue,
thick,
minimum size = 1cm
}}
tikzset{help lines/.style=very thin}
tikzset{My Grid/.style={help lines,color=blue!50}}
begin{document}
begin{tikzpicture}
[>=stealth']
%draw[My Grid] (-5,-5) grid (15,15);
node (r1) at (-4,4) [squarenode] {r1};
node[right=4cm of r1] (r2) [squarenode] {r2};
node[below=3cm of r1] (r3) [squarenode] {r3};
node[right=4cm of r3] (r4) [squarenode] {r4};
node[right=1.5cm of r1] (s2) [circlenode] {s2};
node[above=1cm of s2] (s1) [circlenode] {}; %s1
node[below=1cm of s2] (s3) [circlenode] {s3}; %s3
node[above=1ex of s3,red] {$s leq 3$};
node[right=1.5cm of r3] (s4) [circlenode] {s4};
node[below=1cm of s4] (s5) [circlenode] {}; %s5
draw[fill=black] (s1.center) circle [radius=0.1cm];
draw[fill=black] (s5.center) circle [radius=0.1cm];
draw[->] (r1) -- (s2);
draw[->] (s2) -- (r2);
draw[->] (r3) -- (s4);
draw[->] (s4) -- (r4);
draw[->] (s1) to [out=180,in=90] (r1);
draw[->] (r1) to [out=-90,in=180] (s3);
draw[->] (s3) to [out=0,in=-90] (r2);
draw[->] (r2) to [bend right=45] node[auto,swap] {2} (s1);
draw[->] (r3) to [out=90,in=180] (s3);
draw[->] (s3) to [out=0,in=90] (r4);
draw[->] (r4) to [bend left=45] node[auto] {2} (s5);
draw[->] (s5) to [bend left=45] (r3);
begin{scope}[on background layer]
node [fill=gray!15,rounded corners,fit=(s1) (s3) (s5) (r1) (r2)] (R1) {};
end{scope}
begin{scope}[xshift=9cm]
[>=stealth']
%draw[My Grid] (-5,-5) grid (15,15);
node (r1) at (-4,4) [squarenode] {r1};
node[right=4cm of r1] (r2) [squarenode] {r2};
node[below=3cm of r1] (r3) [squarenode] {r3};
node[right=4cm of r3] (r4) [squarenode] {r4};
node[right=1.5cm of r1] (s2) [circlenode] {s2};
node[above=1cm of s2] (s1) [circlenode] {}; %s1
node[below=1cm of s2] (s3) [circlenode] {s3}; %s3
node[above=1ex of s3,red] {$s leq 3$};
node[right=1.5cm of r3] (s4) [circlenode] {s4};
node[below=1cm of s4] (s5) [circlenode] {}; %s5
draw[fill=black] (s1.center) circle [radius=0.1cm];
draw[fill=black] (s5.center) circle [radius=0.1cm];
draw[->] (r1) -- (s2);
draw[->] (s2) -- (r2);
draw[->] (r3) -- (s4);
draw[->] (s4) -- (r4);
draw[->] (s1) to [out=180,in=90] (r1);
draw[->] (r1) to [out=-90,in=180] (s3);
draw[->] (s3) to [out=0,in=-90] (r2);
draw[->] (r2) to [bend right=45] node[auto,swap] {2} (s1);
draw[->] (r3) to [out=90,in=180] (s3);
draw[->] (s3) to [out=0,in=90] (r4);
draw[->] (r4) to [bend left=45] node[auto] {2} (s5);
draw[->] (s5) to [bend left=45] (r3);
begin{scope}[on background layer]
node [fill=gray!15,rounded corners,fit=(s1) (s3) (s5) (r1) (r2)] (R2) {};
end{scope}
draw [thick,decorate,
decoration={snake,amplitude=.4mm,segment length=2mm,
pre=moveto,pre length=1mm,post length=2mm}]
(R1) -- (R2) node [above=1mm,midway,text width=3cm,align=center]
{replacement of the textcolor{red}{capacity} by textcolor{red}{two places}};
end{scope}
end{tikzpicture}
end{document}
answered yesterday
AndréCAndréC
9,90311547
9,90311547
add a comment |
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f477814%2fpetrinet-decoration-and-xshift-not-aligned-in-tikz%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
xshift
never shifts the picture unless you work with overlay pictures and absolute positioning.– marmot
yesterday