tikz : Arrow heads does not scale with the rest of the picture

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
4
down vote

favorite












I'm trying to include a scaled graph into another picture (yes I need to use nested tikz pictures, but I can't find any better way), and the problem is that the arrow heads are not scaled properly, so the scaled graph looks weird. Any idea to scale properly a graph?



I tried scalebox.6... which works great for tikzpicture alone, but in nested tikzpicture, the bounding box used is as if the graph wouldn't have been scaled, which makes the positionning ugly.



Also, I could generate first a pdf and include it, but it's not really practical because I want to use it in a beamer slide and I need to include some onslide<...> command inside, so it means that I would need to create one tex/pdf for each slide...



Bonus: you get a bonus if the method also allow links to nested tikzpicture with remember options.



MWE:



documentclass[a4paper]article

usepackagetikz

begindocument
Not scaled:
begintikzpicture[
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q1) at (0,0);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture


Scaled:
begintikzpicture[scale=.5, every node/.style=scale=.5,
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q1) at (0,0);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture
enddocument


enter image description here



-- EDIT --
Here is a MWE with the included nested tikzpicture:



documentclassarticle

usepackagetikz
usetikzlibrarycalc,positioning

begindocument
Not scaled:
begintikzpicture[
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q1) at (0,0);
node[qubit,right=of q1] (q2) ;
draw[-] (q1) -- (q2);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture

Scale + transform shape:\
begintikzpicture
node[circle,draw,fill=green] (A) A;
node[circle,draw,fill=green,right=of A] (B) B;
node[circle,draw,fill=green,above=of A] (C) C;
node[above=of B.center,anchor=south east] (graph)
begintikzpicture[scale=0.5, every node/.style=transform shape,
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q1) at (0,0);
node[qubit,right=of q1] (q2) ;
draw[-] (q1) -- (q2);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture
;
node[fill=green,inner sep=0pt,minimum size=3pt] at (graph.north east) ;
node[fill=red,inner sep=0pt,minimum size=3pt] at (graph.north west) ;
node[fill=yellow,inner sep=0pt,minimum size=3pt] at (graph.south east) ;
node[fill=orange,inner sep=0pt,minimum size=3pt] at (graph.south west) ;
endtikzpicture

transform canvas, good arrow size, bad position:\
begintikzpicture
node[circle,draw,fill=green] (A) A;
node[circle,draw,fill=green,right=of A] (B) B;
node[circle,draw,fill=green,above=of A] (C) C;
node[above=of B.center,anchor=south east] (graph2)
begintikzpicture[transform canvas=scale=0.5,
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q3) at (0,0);
node[qubit,right=of q3] (q4) ;
draw[-] (q3) -- (q4);
draw[red,-stealth] (q3.center) -- (q3.north);
endtikzpicture
;
node[fill=green,inner sep=0pt,minimum size=3pt] at (graph2.north east) ;
node[fill=red,inner sep=0pt,minimum size=3pt] at (graph2.north west) ;
node[fill=yellow,inner sep=0pt,minimum size=3pt] at (graph2.south east) ;
node[fill=orange,inner sep=0pt,minimum size=3pt] at (graph2.south west) ;
endtikzpicture

enddocument


enter image description here



-- EDIT 2 --
I tried with xsavebox as proposed in comments, and it works pretty well, except that it does not deal with beamer overlay, which is quite a big issue in my case...



documentclassbeamer
usepackagexsavebox
usepackagetikz
usetikzlibrarycalc,positioning

begindocument

beginframe
Not scaled:
begintikzpicture[
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q1) at (0,0);
node[qubit,right=of q1] (q2) ;
draw[-] (q1) -- (q2);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture
endframe

beginframe
Scale + transform shape, good position, bad arrow size:\
begintikzpicture
node[circle,draw,fill=green] (A) A;
node[circle,draw,fill=green,right=of A] (B) B;
node[circle,draw,fill=green,above=of A] (C) C;
node[above=of B.center,anchor=south east] (graph)
begintikzpicture[scale=0.5, every node/.style=transform shape,
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q1) at (0,0);
node[qubit,right=of q1] (q2) ;
draw[-] (q1) -- (q2);
draw[red,-stealth] (q1.center) -- (q1.north);
node<2>[qubit,above=of q2] (q2bis) ;
endtikzpicture
;
node[fill=green,inner sep=0pt,minimum size=3pt] at (graph.north east) ;
node[fill=red,inner sep=0pt,minimum size=3pt] at (graph.north west) ;
node[fill=yellow,inner sep=0pt,minimum size=3pt] at (graph.south east) ;
node[fill=orange,inner sep=0pt,minimum size=3pt] at (graph.south west) ;
endtikzpicture
endframe

beginframe
transform canvas, good arrow size, bad position:\
begintikzpicture
node[circle,draw,fill=green] (A) A;
node[circle,draw,fill=green,right=of A] (B) B;
node[circle,draw,fill=green,above=of A] (C) C;
node[above=of B.center,anchor=south east] (graph2)
begintikzpicture[transform canvas=scale=0.5,
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q3) at (0,0);
node[qubit,right=of q3] (q4) ;
draw[-] (q3) -- (q4);
draw[red,-stealth] (q3.center) -- (q3.north);
node<2>[qubit,above=of q4] (q5) ;
endtikzpicture
;
node[fill=green,inner sep=0pt,minimum size=3pt] at (graph2.north east) ;
node[fill=red,inner sep=0pt,minimum size=3pt] at (graph2.north west) ;
node[fill=yellow,inner sep=0pt,minimum size=3pt] at (graph2.south east) ;
node[fill=orange,inner sep=0pt,minimum size=3pt] at (graph2.south west) ;
endtikzpicture
endframe


beginxlrboxmybox
begintikzpicture[
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q3) at (0,0);
node[qubit,right=of q3] (q4) ;
draw[-] (q3) -- (q4);
draw[red,-stealth] (q3.center) -- (q3.north);
node<2>[qubit,above=of q4] (q5) ;
endtikzpicture
endxlrbox

beginframe
xlrbox, good resize, no beamer overlay:\
begintikzpicture
node[circle,draw,fill=green] (A) A;
node[circle,draw,fill=green,right=of A] (B) B;
node[circle,draw,fill=green,above=of A] (C) C;
node[above=of B.center,anchor=south east] (graph2) scalebox0.5themybox;
node[fill=green,inner sep=0pt,minimum size=3pt] at (graph2.north east) ;
node[fill=red,inner sep=0pt,minimum size=3pt] at (graph2.north west) ;
node[fill=yellow,inner sep=0pt,minimum size=3pt] at (graph2.south east) ;
node[fill=orange,inner sep=0pt,minimum size=3pt] at (graph2.south west) ;
endtikzpicture
endframe

enddocument









share|improve this question



















  • 2




    Please check this answer, this answer and this answer.
    – Ruixi Zhang
    Aug 13 at 12:37






  • 1




    Not to advertise one of my own questions, but you might find what is the best way to combine tikzpictures and beamer overlays interesting for your application. The proposed answer allows to create 1 pdf document that handles overlays. You could create every specific symbol in a standalone image then include it with overlay specifications ...
    – BambOo
    Aug 13 at 12:51






  • 1




    @RuixiZhang The only two methods that really scale correctly are resizebox and transform canvas=scale=0.5. All the other ones (scale=0.5, every node/.style=transform shape, scale=.5, every node/.style=scale=.5...) fails to resize line width and arrow width correctly. The problem of resizebox and transform canvas=scale=0.5 is that they break the bounding box : resizebox does not scale the bounding box, and transform canvas sets the bounding box to the empty box, so the positionning gets ugly when I include the graph in a nested tikzpicture... I'll try to create MWE with nested
    – tobiasBora
    Aug 13 at 13:05










  • @BambOo : this question is really interesting, and for now it's the best solution I have so far (and it also solve the problem of compilation time). The only issue is that I need to create one file for each nested picture, and that I can't refer to nodes inside the nested tikzpicture with remember option.
    – tobiasBora
    Aug 13 at 14:00






  • 2




    Why didn't anyone comment so far that one should not nest tikzpictures?
    – marmot
    Aug 13 at 16:37














up vote
4
down vote

favorite












I'm trying to include a scaled graph into another picture (yes I need to use nested tikz pictures, but I can't find any better way), and the problem is that the arrow heads are not scaled properly, so the scaled graph looks weird. Any idea to scale properly a graph?



I tried scalebox.6... which works great for tikzpicture alone, but in nested tikzpicture, the bounding box used is as if the graph wouldn't have been scaled, which makes the positionning ugly.



Also, I could generate first a pdf and include it, but it's not really practical because I want to use it in a beamer slide and I need to include some onslide<...> command inside, so it means that I would need to create one tex/pdf for each slide...



Bonus: you get a bonus if the method also allow links to nested tikzpicture with remember options.



MWE:



documentclass[a4paper]article

usepackagetikz

begindocument
Not scaled:
begintikzpicture[
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q1) at (0,0);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture


Scaled:
begintikzpicture[scale=.5, every node/.style=scale=.5,
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q1) at (0,0);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture
enddocument


enter image description here



-- EDIT --
Here is a MWE with the included nested tikzpicture:



documentclassarticle

usepackagetikz
usetikzlibrarycalc,positioning

begindocument
Not scaled:
begintikzpicture[
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q1) at (0,0);
node[qubit,right=of q1] (q2) ;
draw[-] (q1) -- (q2);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture

Scale + transform shape:\
begintikzpicture
node[circle,draw,fill=green] (A) A;
node[circle,draw,fill=green,right=of A] (B) B;
node[circle,draw,fill=green,above=of A] (C) C;
node[above=of B.center,anchor=south east] (graph)
begintikzpicture[scale=0.5, every node/.style=transform shape,
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q1) at (0,0);
node[qubit,right=of q1] (q2) ;
draw[-] (q1) -- (q2);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture
;
node[fill=green,inner sep=0pt,minimum size=3pt] at (graph.north east) ;
node[fill=red,inner sep=0pt,minimum size=3pt] at (graph.north west) ;
node[fill=yellow,inner sep=0pt,minimum size=3pt] at (graph.south east) ;
node[fill=orange,inner sep=0pt,minimum size=3pt] at (graph.south west) ;
endtikzpicture

transform canvas, good arrow size, bad position:\
begintikzpicture
node[circle,draw,fill=green] (A) A;
node[circle,draw,fill=green,right=of A] (B) B;
node[circle,draw,fill=green,above=of A] (C) C;
node[above=of B.center,anchor=south east] (graph2)
begintikzpicture[transform canvas=scale=0.5,
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q3) at (0,0);
node[qubit,right=of q3] (q4) ;
draw[-] (q3) -- (q4);
draw[red,-stealth] (q3.center) -- (q3.north);
endtikzpicture
;
node[fill=green,inner sep=0pt,minimum size=3pt] at (graph2.north east) ;
node[fill=red,inner sep=0pt,minimum size=3pt] at (graph2.north west) ;
node[fill=yellow,inner sep=0pt,minimum size=3pt] at (graph2.south east) ;
node[fill=orange,inner sep=0pt,minimum size=3pt] at (graph2.south west) ;
endtikzpicture

enddocument


enter image description here



-- EDIT 2 --
I tried with xsavebox as proposed in comments, and it works pretty well, except that it does not deal with beamer overlay, which is quite a big issue in my case...



documentclassbeamer
usepackagexsavebox
usepackagetikz
usetikzlibrarycalc,positioning

begindocument

beginframe
Not scaled:
begintikzpicture[
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q1) at (0,0);
node[qubit,right=of q1] (q2) ;
draw[-] (q1) -- (q2);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture
endframe

beginframe
Scale + transform shape, good position, bad arrow size:\
begintikzpicture
node[circle,draw,fill=green] (A) A;
node[circle,draw,fill=green,right=of A] (B) B;
node[circle,draw,fill=green,above=of A] (C) C;
node[above=of B.center,anchor=south east] (graph)
begintikzpicture[scale=0.5, every node/.style=transform shape,
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q1) at (0,0);
node[qubit,right=of q1] (q2) ;
draw[-] (q1) -- (q2);
draw[red,-stealth] (q1.center) -- (q1.north);
node<2>[qubit,above=of q2] (q2bis) ;
endtikzpicture
;
node[fill=green,inner sep=0pt,minimum size=3pt] at (graph.north east) ;
node[fill=red,inner sep=0pt,minimum size=3pt] at (graph.north west) ;
node[fill=yellow,inner sep=0pt,minimum size=3pt] at (graph.south east) ;
node[fill=orange,inner sep=0pt,minimum size=3pt] at (graph.south west) ;
endtikzpicture
endframe

beginframe
transform canvas, good arrow size, bad position:\
begintikzpicture
node[circle,draw,fill=green] (A) A;
node[circle,draw,fill=green,right=of A] (B) B;
node[circle,draw,fill=green,above=of A] (C) C;
node[above=of B.center,anchor=south east] (graph2)
begintikzpicture[transform canvas=scale=0.5,
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q3) at (0,0);
node[qubit,right=of q3] (q4) ;
draw[-] (q3) -- (q4);
draw[red,-stealth] (q3.center) -- (q3.north);
node<2>[qubit,above=of q4] (q5) ;
endtikzpicture
;
node[fill=green,inner sep=0pt,minimum size=3pt] at (graph2.north east) ;
node[fill=red,inner sep=0pt,minimum size=3pt] at (graph2.north west) ;
node[fill=yellow,inner sep=0pt,minimum size=3pt] at (graph2.south east) ;
node[fill=orange,inner sep=0pt,minimum size=3pt] at (graph2.south west) ;
endtikzpicture
endframe


beginxlrboxmybox
begintikzpicture[
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q3) at (0,0);
node[qubit,right=of q3] (q4) ;
draw[-] (q3) -- (q4);
draw[red,-stealth] (q3.center) -- (q3.north);
node<2>[qubit,above=of q4] (q5) ;
endtikzpicture
endxlrbox

beginframe
xlrbox, good resize, no beamer overlay:\
begintikzpicture
node[circle,draw,fill=green] (A) A;
node[circle,draw,fill=green,right=of A] (B) B;
node[circle,draw,fill=green,above=of A] (C) C;
node[above=of B.center,anchor=south east] (graph2) scalebox0.5themybox;
node[fill=green,inner sep=0pt,minimum size=3pt] at (graph2.north east) ;
node[fill=red,inner sep=0pt,minimum size=3pt] at (graph2.north west) ;
node[fill=yellow,inner sep=0pt,minimum size=3pt] at (graph2.south east) ;
node[fill=orange,inner sep=0pt,minimum size=3pt] at (graph2.south west) ;
endtikzpicture
endframe

enddocument









share|improve this question



















  • 2




    Please check this answer, this answer and this answer.
    – Ruixi Zhang
    Aug 13 at 12:37






  • 1




    Not to advertise one of my own questions, but you might find what is the best way to combine tikzpictures and beamer overlays interesting for your application. The proposed answer allows to create 1 pdf document that handles overlays. You could create every specific symbol in a standalone image then include it with overlay specifications ...
    – BambOo
    Aug 13 at 12:51






  • 1




    @RuixiZhang The only two methods that really scale correctly are resizebox and transform canvas=scale=0.5. All the other ones (scale=0.5, every node/.style=transform shape, scale=.5, every node/.style=scale=.5...) fails to resize line width and arrow width correctly. The problem of resizebox and transform canvas=scale=0.5 is that they break the bounding box : resizebox does not scale the bounding box, and transform canvas sets the bounding box to the empty box, so the positionning gets ugly when I include the graph in a nested tikzpicture... I'll try to create MWE with nested
    – tobiasBora
    Aug 13 at 13:05










  • @BambOo : this question is really interesting, and for now it's the best solution I have so far (and it also solve the problem of compilation time). The only issue is that I need to create one file for each nested picture, and that I can't refer to nodes inside the nested tikzpicture with remember option.
    – tobiasBora
    Aug 13 at 14:00






  • 2




    Why didn't anyone comment so far that one should not nest tikzpictures?
    – marmot
    Aug 13 at 16:37












up vote
4
down vote

favorite









up vote
4
down vote

favorite











I'm trying to include a scaled graph into another picture (yes I need to use nested tikz pictures, but I can't find any better way), and the problem is that the arrow heads are not scaled properly, so the scaled graph looks weird. Any idea to scale properly a graph?



I tried scalebox.6... which works great for tikzpicture alone, but in nested tikzpicture, the bounding box used is as if the graph wouldn't have been scaled, which makes the positionning ugly.



Also, I could generate first a pdf and include it, but it's not really practical because I want to use it in a beamer slide and I need to include some onslide<...> command inside, so it means that I would need to create one tex/pdf for each slide...



Bonus: you get a bonus if the method also allow links to nested tikzpicture with remember options.



MWE:



documentclass[a4paper]article

usepackagetikz

begindocument
Not scaled:
begintikzpicture[
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q1) at (0,0);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture


Scaled:
begintikzpicture[scale=.5, every node/.style=scale=.5,
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q1) at (0,0);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture
enddocument


enter image description here



-- EDIT --
Here is a MWE with the included nested tikzpicture:



documentclassarticle

usepackagetikz
usetikzlibrarycalc,positioning

begindocument
Not scaled:
begintikzpicture[
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q1) at (0,0);
node[qubit,right=of q1] (q2) ;
draw[-] (q1) -- (q2);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture

Scale + transform shape:\
begintikzpicture
node[circle,draw,fill=green] (A) A;
node[circle,draw,fill=green,right=of A] (B) B;
node[circle,draw,fill=green,above=of A] (C) C;
node[above=of B.center,anchor=south east] (graph)
begintikzpicture[scale=0.5, every node/.style=transform shape,
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q1) at (0,0);
node[qubit,right=of q1] (q2) ;
draw[-] (q1) -- (q2);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture
;
node[fill=green,inner sep=0pt,minimum size=3pt] at (graph.north east) ;
node[fill=red,inner sep=0pt,minimum size=3pt] at (graph.north west) ;
node[fill=yellow,inner sep=0pt,minimum size=3pt] at (graph.south east) ;
node[fill=orange,inner sep=0pt,minimum size=3pt] at (graph.south west) ;
endtikzpicture

transform canvas, good arrow size, bad position:\
begintikzpicture
node[circle,draw,fill=green] (A) A;
node[circle,draw,fill=green,right=of A] (B) B;
node[circle,draw,fill=green,above=of A] (C) C;
node[above=of B.center,anchor=south east] (graph2)
begintikzpicture[transform canvas=scale=0.5,
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q3) at (0,0);
node[qubit,right=of q3] (q4) ;
draw[-] (q3) -- (q4);
draw[red,-stealth] (q3.center) -- (q3.north);
endtikzpicture
;
node[fill=green,inner sep=0pt,minimum size=3pt] at (graph2.north east) ;
node[fill=red,inner sep=0pt,minimum size=3pt] at (graph2.north west) ;
node[fill=yellow,inner sep=0pt,minimum size=3pt] at (graph2.south east) ;
node[fill=orange,inner sep=0pt,minimum size=3pt] at (graph2.south west) ;
endtikzpicture

enddocument


enter image description here



-- EDIT 2 --
I tried with xsavebox as proposed in comments, and it works pretty well, except that it does not deal with beamer overlay, which is quite a big issue in my case...



documentclassbeamer
usepackagexsavebox
usepackagetikz
usetikzlibrarycalc,positioning

begindocument

beginframe
Not scaled:
begintikzpicture[
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q1) at (0,0);
node[qubit,right=of q1] (q2) ;
draw[-] (q1) -- (q2);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture
endframe

beginframe
Scale + transform shape, good position, bad arrow size:\
begintikzpicture
node[circle,draw,fill=green] (A) A;
node[circle,draw,fill=green,right=of A] (B) B;
node[circle,draw,fill=green,above=of A] (C) C;
node[above=of B.center,anchor=south east] (graph)
begintikzpicture[scale=0.5, every node/.style=transform shape,
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q1) at (0,0);
node[qubit,right=of q1] (q2) ;
draw[-] (q1) -- (q2);
draw[red,-stealth] (q1.center) -- (q1.north);
node<2>[qubit,above=of q2] (q2bis) ;
endtikzpicture
;
node[fill=green,inner sep=0pt,minimum size=3pt] at (graph.north east) ;
node[fill=red,inner sep=0pt,minimum size=3pt] at (graph.north west) ;
node[fill=yellow,inner sep=0pt,minimum size=3pt] at (graph.south east) ;
node[fill=orange,inner sep=0pt,minimum size=3pt] at (graph.south west) ;
endtikzpicture
endframe

beginframe
transform canvas, good arrow size, bad position:\
begintikzpicture
node[circle,draw,fill=green] (A) A;
node[circle,draw,fill=green,right=of A] (B) B;
node[circle,draw,fill=green,above=of A] (C) C;
node[above=of B.center,anchor=south east] (graph2)
begintikzpicture[transform canvas=scale=0.5,
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q3) at (0,0);
node[qubit,right=of q3] (q4) ;
draw[-] (q3) -- (q4);
draw[red,-stealth] (q3.center) -- (q3.north);
node<2>[qubit,above=of q4] (q5) ;
endtikzpicture
;
node[fill=green,inner sep=0pt,minimum size=3pt] at (graph2.north east) ;
node[fill=red,inner sep=0pt,minimum size=3pt] at (graph2.north west) ;
node[fill=yellow,inner sep=0pt,minimum size=3pt] at (graph2.south east) ;
node[fill=orange,inner sep=0pt,minimum size=3pt] at (graph2.south west) ;
endtikzpicture
endframe


beginxlrboxmybox
begintikzpicture[
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q3) at (0,0);
node[qubit,right=of q3] (q4) ;
draw[-] (q3) -- (q4);
draw[red,-stealth] (q3.center) -- (q3.north);
node<2>[qubit,above=of q4] (q5) ;
endtikzpicture
endxlrbox

beginframe
xlrbox, good resize, no beamer overlay:\
begintikzpicture
node[circle,draw,fill=green] (A) A;
node[circle,draw,fill=green,right=of A] (B) B;
node[circle,draw,fill=green,above=of A] (C) C;
node[above=of B.center,anchor=south east] (graph2) scalebox0.5themybox;
node[fill=green,inner sep=0pt,minimum size=3pt] at (graph2.north east) ;
node[fill=red,inner sep=0pt,minimum size=3pt] at (graph2.north west) ;
node[fill=yellow,inner sep=0pt,minimum size=3pt] at (graph2.south east) ;
node[fill=orange,inner sep=0pt,minimum size=3pt] at (graph2.south west) ;
endtikzpicture
endframe

enddocument









share|improve this question















I'm trying to include a scaled graph into another picture (yes I need to use nested tikz pictures, but I can't find any better way), and the problem is that the arrow heads are not scaled properly, so the scaled graph looks weird. Any idea to scale properly a graph?



I tried scalebox.6... which works great for tikzpicture alone, but in nested tikzpicture, the bounding box used is as if the graph wouldn't have been scaled, which makes the positionning ugly.



Also, I could generate first a pdf and include it, but it's not really practical because I want to use it in a beamer slide and I need to include some onslide<...> command inside, so it means that I would need to create one tex/pdf for each slide...



Bonus: you get a bonus if the method also allow links to nested tikzpicture with remember options.



MWE:



documentclass[a4paper]article

usepackagetikz

begindocument
Not scaled:
begintikzpicture[
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q1) at (0,0);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture


Scaled:
begintikzpicture[scale=.5, every node/.style=scale=.5,
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q1) at (0,0);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture
enddocument


enter image description here



-- EDIT --
Here is a MWE with the included nested tikzpicture:



documentclassarticle

usepackagetikz
usetikzlibrarycalc,positioning

begindocument
Not scaled:
begintikzpicture[
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q1) at (0,0);
node[qubit,right=of q1] (q2) ;
draw[-] (q1) -- (q2);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture

Scale + transform shape:\
begintikzpicture
node[circle,draw,fill=green] (A) A;
node[circle,draw,fill=green,right=of A] (B) B;
node[circle,draw,fill=green,above=of A] (C) C;
node[above=of B.center,anchor=south east] (graph)
begintikzpicture[scale=0.5, every node/.style=transform shape,
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q1) at (0,0);
node[qubit,right=of q1] (q2) ;
draw[-] (q1) -- (q2);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture
;
node[fill=green,inner sep=0pt,minimum size=3pt] at (graph.north east) ;
node[fill=red,inner sep=0pt,minimum size=3pt] at (graph.north west) ;
node[fill=yellow,inner sep=0pt,minimum size=3pt] at (graph.south east) ;
node[fill=orange,inner sep=0pt,minimum size=3pt] at (graph.south west) ;
endtikzpicture

transform canvas, good arrow size, bad position:\
begintikzpicture
node[circle,draw,fill=green] (A) A;
node[circle,draw,fill=green,right=of A] (B) B;
node[circle,draw,fill=green,above=of A] (C) C;
node[above=of B.center,anchor=south east] (graph2)
begintikzpicture[transform canvas=scale=0.5,
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q3) at (0,0);
node[qubit,right=of q3] (q4) ;
draw[-] (q3) -- (q4);
draw[red,-stealth] (q3.center) -- (q3.north);
endtikzpicture
;
node[fill=green,inner sep=0pt,minimum size=3pt] at (graph2.north east) ;
node[fill=red,inner sep=0pt,minimum size=3pt] at (graph2.north west) ;
node[fill=yellow,inner sep=0pt,minimum size=3pt] at (graph2.south east) ;
node[fill=orange,inner sep=0pt,minimum size=3pt] at (graph2.south west) ;
endtikzpicture

enddocument


enter image description here



-- EDIT 2 --
I tried with xsavebox as proposed in comments, and it works pretty well, except that it does not deal with beamer overlay, which is quite a big issue in my case...



documentclassbeamer
usepackagexsavebox
usepackagetikz
usetikzlibrarycalc,positioning

begindocument

beginframe
Not scaled:
begintikzpicture[
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q1) at (0,0);
node[qubit,right=of q1] (q2) ;
draw[-] (q1) -- (q2);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture
endframe

beginframe
Scale + transform shape, good position, bad arrow size:\
begintikzpicture
node[circle,draw,fill=green] (A) A;
node[circle,draw,fill=green,right=of A] (B) B;
node[circle,draw,fill=green,above=of A] (C) C;
node[above=of B.center,anchor=south east] (graph)
begintikzpicture[scale=0.5, every node/.style=transform shape,
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q1) at (0,0);
node[qubit,right=of q1] (q2) ;
draw[-] (q1) -- (q2);
draw[red,-stealth] (q1.center) -- (q1.north);
node<2>[qubit,above=of q2] (q2bis) ;
endtikzpicture
;
node[fill=green,inner sep=0pt,minimum size=3pt] at (graph.north east) ;
node[fill=red,inner sep=0pt,minimum size=3pt] at (graph.north west) ;
node[fill=yellow,inner sep=0pt,minimum size=3pt] at (graph.south east) ;
node[fill=orange,inner sep=0pt,minimum size=3pt] at (graph.south west) ;
endtikzpicture
endframe

beginframe
transform canvas, good arrow size, bad position:\
begintikzpicture
node[circle,draw,fill=green] (A) A;
node[circle,draw,fill=green,right=of A] (B) B;
node[circle,draw,fill=green,above=of A] (C) C;
node[above=of B.center,anchor=south east] (graph2)
begintikzpicture[transform canvas=scale=0.5,
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q3) at (0,0);
node[qubit,right=of q3] (q4) ;
draw[-] (q3) -- (q4);
draw[red,-stealth] (q3.center) -- (q3.north);
node<2>[qubit,above=of q4] (q5) ;
endtikzpicture
;
node[fill=green,inner sep=0pt,minimum size=3pt] at (graph2.north east) ;
node[fill=red,inner sep=0pt,minimum size=3pt] at (graph2.north west) ;
node[fill=yellow,inner sep=0pt,minimum size=3pt] at (graph2.south east) ;
node[fill=orange,inner sep=0pt,minimum size=3pt] at (graph2.south west) ;
endtikzpicture
endframe


beginxlrboxmybox
begintikzpicture[
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q3) at (0,0);
node[qubit,right=of q3] (q4) ;
draw[-] (q3) -- (q4);
draw[red,-stealth] (q3.center) -- (q3.north);
node<2>[qubit,above=of q4] (q5) ;
endtikzpicture
endxlrbox

beginframe
xlrbox, good resize, no beamer overlay:\
begintikzpicture
node[circle,draw,fill=green] (A) A;
node[circle,draw,fill=green,right=of A] (B) B;
node[circle,draw,fill=green,above=of A] (C) C;
node[above=of B.center,anchor=south east] (graph2) scalebox0.5themybox;
node[fill=green,inner sep=0pt,minimum size=3pt] at (graph2.north east) ;
node[fill=red,inner sep=0pt,minimum size=3pt] at (graph2.north west) ;
node[fill=yellow,inner sep=0pt,minimum size=3pt] at (graph2.south east) ;
node[fill=orange,inner sep=0pt,minimum size=3pt] at (graph2.south west) ;
endtikzpicture
endframe

enddocument






tikz-pgf tikz-arrows scaling






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 13 at 14:01

























asked Aug 13 at 12:33









tobiasBora

1,128213




1,128213







  • 2




    Please check this answer, this answer and this answer.
    – Ruixi Zhang
    Aug 13 at 12:37






  • 1




    Not to advertise one of my own questions, but you might find what is the best way to combine tikzpictures and beamer overlays interesting for your application. The proposed answer allows to create 1 pdf document that handles overlays. You could create every specific symbol in a standalone image then include it with overlay specifications ...
    – BambOo
    Aug 13 at 12:51






  • 1




    @RuixiZhang The only two methods that really scale correctly are resizebox and transform canvas=scale=0.5. All the other ones (scale=0.5, every node/.style=transform shape, scale=.5, every node/.style=scale=.5...) fails to resize line width and arrow width correctly. The problem of resizebox and transform canvas=scale=0.5 is that they break the bounding box : resizebox does not scale the bounding box, and transform canvas sets the bounding box to the empty box, so the positionning gets ugly when I include the graph in a nested tikzpicture... I'll try to create MWE with nested
    – tobiasBora
    Aug 13 at 13:05










  • @BambOo : this question is really interesting, and for now it's the best solution I have so far (and it also solve the problem of compilation time). The only issue is that I need to create one file for each nested picture, and that I can't refer to nodes inside the nested tikzpicture with remember option.
    – tobiasBora
    Aug 13 at 14:00






  • 2




    Why didn't anyone comment so far that one should not nest tikzpictures?
    – marmot
    Aug 13 at 16:37












  • 2




    Please check this answer, this answer and this answer.
    – Ruixi Zhang
    Aug 13 at 12:37






  • 1




    Not to advertise one of my own questions, but you might find what is the best way to combine tikzpictures and beamer overlays interesting for your application. The proposed answer allows to create 1 pdf document that handles overlays. You could create every specific symbol in a standalone image then include it with overlay specifications ...
    – BambOo
    Aug 13 at 12:51






  • 1




    @RuixiZhang The only two methods that really scale correctly are resizebox and transform canvas=scale=0.5. All the other ones (scale=0.5, every node/.style=transform shape, scale=.5, every node/.style=scale=.5...) fails to resize line width and arrow width correctly. The problem of resizebox and transform canvas=scale=0.5 is that they break the bounding box : resizebox does not scale the bounding box, and transform canvas sets the bounding box to the empty box, so the positionning gets ugly when I include the graph in a nested tikzpicture... I'll try to create MWE with nested
    – tobiasBora
    Aug 13 at 13:05










  • @BambOo : this question is really interesting, and for now it's the best solution I have so far (and it also solve the problem of compilation time). The only issue is that I need to create one file for each nested picture, and that I can't refer to nodes inside the nested tikzpicture with remember option.
    – tobiasBora
    Aug 13 at 14:00






  • 2




    Why didn't anyone comment so far that one should not nest tikzpictures?
    – marmot
    Aug 13 at 16:37







2




2




Please check this answer, this answer and this answer.
– Ruixi Zhang
Aug 13 at 12:37




Please check this answer, this answer and this answer.
– Ruixi Zhang
Aug 13 at 12:37




1




1




Not to advertise one of my own questions, but you might find what is the best way to combine tikzpictures and beamer overlays interesting for your application. The proposed answer allows to create 1 pdf document that handles overlays. You could create every specific symbol in a standalone image then include it with overlay specifications ...
– BambOo
Aug 13 at 12:51




Not to advertise one of my own questions, but you might find what is the best way to combine tikzpictures and beamer overlays interesting for your application. The proposed answer allows to create 1 pdf document that handles overlays. You could create every specific symbol in a standalone image then include it with overlay specifications ...
– BambOo
Aug 13 at 12:51




1




1




@RuixiZhang The only two methods that really scale correctly are resizebox and transform canvas=scale=0.5. All the other ones (scale=0.5, every node/.style=transform shape, scale=.5, every node/.style=scale=.5...) fails to resize line width and arrow width correctly. The problem of resizebox and transform canvas=scale=0.5 is that they break the bounding box : resizebox does not scale the bounding box, and transform canvas sets the bounding box to the empty box, so the positionning gets ugly when I include the graph in a nested tikzpicture... I'll try to create MWE with nested
– tobiasBora
Aug 13 at 13:05




@RuixiZhang The only two methods that really scale correctly are resizebox and transform canvas=scale=0.5. All the other ones (scale=0.5, every node/.style=transform shape, scale=.5, every node/.style=scale=.5...) fails to resize line width and arrow width correctly. The problem of resizebox and transform canvas=scale=0.5 is that they break the bounding box : resizebox does not scale the bounding box, and transform canvas sets the bounding box to the empty box, so the positionning gets ugly when I include the graph in a nested tikzpicture... I'll try to create MWE with nested
– tobiasBora
Aug 13 at 13:05












@BambOo : this question is really interesting, and for now it's the best solution I have so far (and it also solve the problem of compilation time). The only issue is that I need to create one file for each nested picture, and that I can't refer to nodes inside the nested tikzpicture with remember option.
– tobiasBora
Aug 13 at 14:00




@BambOo : this question is really interesting, and for now it's the best solution I have so far (and it also solve the problem of compilation time). The only issue is that I need to create one file for each nested picture, and that I can't refer to nodes inside the nested tikzpicture with remember option.
– tobiasBora
Aug 13 at 14:00




2




2




Why didn't anyone comment so far that one should not nest tikzpictures?
– marmot
Aug 13 at 16:37




Why didn't anyone comment so far that one should not nest tikzpictures?
– marmot
Aug 13 at 16:37










2 Answers
2






active

oldest

votes

















up vote
6
down vote













With the xsavebox package you can save the tikzpicture in a xlrbox, and scale it when using:



documentclass[a4paper]article

usepackagetikz
usepackagexsavebox

beginxlrboxmybox
begintikzpicture[
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q1) at (0,0);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture%
endxlrbox

begindocument
Not scaled: themybox

Scaled: scalebox0.5themybox
enddocument


This also solves the nesting of tikzpictures.



enter image description here



EDIT (by marmot who is happy to take the blame for all errors;-): You should never nest tikzpictures. You can work with scopes, which you can assign name with the local bounding box trick, these scopes will then behave pretty much like nodes (as far as the remembering and placing stuff relative to them is concerned). Clearly, inside the scope you can work with all overlays in the usual way. The perhaps easiest way to go is to load the arrows.meta library and downscale the arrow. (pgflowlevelsynccm does not work here in a straightforward way because of the additional translations, otherwise it scales the arrow automatically to the right size, but this command should anyway be used with great care.)



documentclassbeamer
usepackagetikz
usetikzlibrarycalc,positioning,arrows.meta

begindocument


beginframe
Scale + transform shape, good position, bad arrow size:\
begintikzpicture
node[circle,draw,fill=green] (A) A;
node[circle,draw,fill=green,right=of A] (B) B;
node[circle,draw,fill=green,above=of A] (C) C;
coordinate[above=of B.center] (X);

beginscope[shift=($(X)+(-1,0)$),
transform shape,scale=0.5,
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm,local bounding box=graph]
node[qubit] (q1) at (0,0);
node[qubit,right=of q1] (q2) ;
draw[-] (q1) -- (q2);
node<2>[qubit,above=of q2] (q2bis) ;
draw[red,-Stealth[scale=0.5]] (q1.center) -- (q1.north);
endscope
% comparison
draw[red,-stealth] ([xshift=2mm,yshift=-1cm]q1.center) -- ([xshift=2mm]q1.north);
node[fill=green,inner sep=0pt,minimum size=3pt] at (graph.north east) ;
node[fill=red,inner sep=0pt,minimum size=3pt] at (graph.north west) ;
node[fill=yellow,inner sep=0pt,minimum size=3pt] at (graph.south east) ;
node[fill=orange,inner sep=0pt,minimum size=3pt] at (graph.south west) ;
endtikzpicture
endframe

enddocument





share|improve this answer






















  • Thank you for the trick, which is a great solution in "fixed" pictures (so you get a +1), but as far as I know it does not handle beamer overlays, which is a big issue in my case.
    – tobiasBora
    Aug 13 at 13:57










  • @tobiasBora What exactly does/doesn't it do that you would expect otherwise?
    – Max
    Aug 13 at 14:01










  • I uploaded a MWE that shows that this solution cannot use beamer overlays like node<2>[qubit,above=of q4] (q5) ;, or only<2>....
    – tobiasBora
    Aug 13 at 14:03






  • 1




    @tobiasBora Ah so you want nested tikzpictures to comply to beamer overlays. That's a different story entirely.
    – Max
    Aug 13 at 14:06






  • 1




    @Max I added something with a scope and local bounding box, please feel free to roll that back.
    – marmot
    Aug 13 at 17:24

















up vote
4
down vote













Arrowheads are scaled by the line width (more or less), which is not scaled. Mostly because very thin lines are hard to see.



documentclass[varwidth]standalone

usepackagetikz

begindocument
Not scaled:
begintikzpicture[
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm,
line width=pgflinewidth % default value
]
node[qubit] (q1) at (0,0);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture


Scaled:
begintikzpicture[scale=.5, every node/.style=scale=.5,
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm,
line width=0.5pgflinewidth
]
node[qubit] (q1) at (0,0);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture
enddocument


demo




Defaults:



pgfdeclarearrow{
name = Stealth,
defaults =
length = +3pt 4.5 .8,
width' = +0pt .75,
inset' = +0pt 0.325,
line width = +0pt 1 1,
,





share|improve this answer






















  • Thanks for the pgflinewidth trick. Do you know what is the default value for arrow length, so that I can use -Stealth[width=...,height=...] to have perfect scale?
    – tobiasBora
    Aug 13 at 15:33











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',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f445874%2ftikz-arrow-heads-does-not-scale-with-the-rest-of-the-picture%23new-answer', 'question_page');

);

Post as a guest






























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
6
down vote













With the xsavebox package you can save the tikzpicture in a xlrbox, and scale it when using:



documentclass[a4paper]article

usepackagetikz
usepackagexsavebox

beginxlrboxmybox
begintikzpicture[
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q1) at (0,0);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture%
endxlrbox

begindocument
Not scaled: themybox

Scaled: scalebox0.5themybox
enddocument


This also solves the nesting of tikzpictures.



enter image description here



EDIT (by marmot who is happy to take the blame for all errors;-): You should never nest tikzpictures. You can work with scopes, which you can assign name with the local bounding box trick, these scopes will then behave pretty much like nodes (as far as the remembering and placing stuff relative to them is concerned). Clearly, inside the scope you can work with all overlays in the usual way. The perhaps easiest way to go is to load the arrows.meta library and downscale the arrow. (pgflowlevelsynccm does not work here in a straightforward way because of the additional translations, otherwise it scales the arrow automatically to the right size, but this command should anyway be used with great care.)



documentclassbeamer
usepackagetikz
usetikzlibrarycalc,positioning,arrows.meta

begindocument


beginframe
Scale + transform shape, good position, bad arrow size:\
begintikzpicture
node[circle,draw,fill=green] (A) A;
node[circle,draw,fill=green,right=of A] (B) B;
node[circle,draw,fill=green,above=of A] (C) C;
coordinate[above=of B.center] (X);

beginscope[shift=($(X)+(-1,0)$),
transform shape,scale=0.5,
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm,local bounding box=graph]
node[qubit] (q1) at (0,0);
node[qubit,right=of q1] (q2) ;
draw[-] (q1) -- (q2);
node<2>[qubit,above=of q2] (q2bis) ;
draw[red,-Stealth[scale=0.5]] (q1.center) -- (q1.north);
endscope
% comparison
draw[red,-stealth] ([xshift=2mm,yshift=-1cm]q1.center) -- ([xshift=2mm]q1.north);
node[fill=green,inner sep=0pt,minimum size=3pt] at (graph.north east) ;
node[fill=red,inner sep=0pt,minimum size=3pt] at (graph.north west) ;
node[fill=yellow,inner sep=0pt,minimum size=3pt] at (graph.south east) ;
node[fill=orange,inner sep=0pt,minimum size=3pt] at (graph.south west) ;
endtikzpicture
endframe

enddocument





share|improve this answer






















  • Thank you for the trick, which is a great solution in "fixed" pictures (so you get a +1), but as far as I know it does not handle beamer overlays, which is a big issue in my case.
    – tobiasBora
    Aug 13 at 13:57










  • @tobiasBora What exactly does/doesn't it do that you would expect otherwise?
    – Max
    Aug 13 at 14:01










  • I uploaded a MWE that shows that this solution cannot use beamer overlays like node<2>[qubit,above=of q4] (q5) ;, or only<2>....
    – tobiasBora
    Aug 13 at 14:03






  • 1




    @tobiasBora Ah so you want nested tikzpictures to comply to beamer overlays. That's a different story entirely.
    – Max
    Aug 13 at 14:06






  • 1




    @Max I added something with a scope and local bounding box, please feel free to roll that back.
    – marmot
    Aug 13 at 17:24














up vote
6
down vote













With the xsavebox package you can save the tikzpicture in a xlrbox, and scale it when using:



documentclass[a4paper]article

usepackagetikz
usepackagexsavebox

beginxlrboxmybox
begintikzpicture[
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q1) at (0,0);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture%
endxlrbox

begindocument
Not scaled: themybox

Scaled: scalebox0.5themybox
enddocument


This also solves the nesting of tikzpictures.



enter image description here



EDIT (by marmot who is happy to take the blame for all errors;-): You should never nest tikzpictures. You can work with scopes, which you can assign name with the local bounding box trick, these scopes will then behave pretty much like nodes (as far as the remembering and placing stuff relative to them is concerned). Clearly, inside the scope you can work with all overlays in the usual way. The perhaps easiest way to go is to load the arrows.meta library and downscale the arrow. (pgflowlevelsynccm does not work here in a straightforward way because of the additional translations, otherwise it scales the arrow automatically to the right size, but this command should anyway be used with great care.)



documentclassbeamer
usepackagetikz
usetikzlibrarycalc,positioning,arrows.meta

begindocument


beginframe
Scale + transform shape, good position, bad arrow size:\
begintikzpicture
node[circle,draw,fill=green] (A) A;
node[circle,draw,fill=green,right=of A] (B) B;
node[circle,draw,fill=green,above=of A] (C) C;
coordinate[above=of B.center] (X);

beginscope[shift=($(X)+(-1,0)$),
transform shape,scale=0.5,
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm,local bounding box=graph]
node[qubit] (q1) at (0,0);
node[qubit,right=of q1] (q2) ;
draw[-] (q1) -- (q2);
node<2>[qubit,above=of q2] (q2bis) ;
draw[red,-Stealth[scale=0.5]] (q1.center) -- (q1.north);
endscope
% comparison
draw[red,-stealth] ([xshift=2mm,yshift=-1cm]q1.center) -- ([xshift=2mm]q1.north);
node[fill=green,inner sep=0pt,minimum size=3pt] at (graph.north east) ;
node[fill=red,inner sep=0pt,minimum size=3pt] at (graph.north west) ;
node[fill=yellow,inner sep=0pt,minimum size=3pt] at (graph.south east) ;
node[fill=orange,inner sep=0pt,minimum size=3pt] at (graph.south west) ;
endtikzpicture
endframe

enddocument





share|improve this answer






















  • Thank you for the trick, which is a great solution in "fixed" pictures (so you get a +1), but as far as I know it does not handle beamer overlays, which is a big issue in my case.
    – tobiasBora
    Aug 13 at 13:57










  • @tobiasBora What exactly does/doesn't it do that you would expect otherwise?
    – Max
    Aug 13 at 14:01










  • I uploaded a MWE that shows that this solution cannot use beamer overlays like node<2>[qubit,above=of q4] (q5) ;, or only<2>....
    – tobiasBora
    Aug 13 at 14:03






  • 1




    @tobiasBora Ah so you want nested tikzpictures to comply to beamer overlays. That's a different story entirely.
    – Max
    Aug 13 at 14:06






  • 1




    @Max I added something with a scope and local bounding box, please feel free to roll that back.
    – marmot
    Aug 13 at 17:24












up vote
6
down vote










up vote
6
down vote









With the xsavebox package you can save the tikzpicture in a xlrbox, and scale it when using:



documentclass[a4paper]article

usepackagetikz
usepackagexsavebox

beginxlrboxmybox
begintikzpicture[
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q1) at (0,0);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture%
endxlrbox

begindocument
Not scaled: themybox

Scaled: scalebox0.5themybox
enddocument


This also solves the nesting of tikzpictures.



enter image description here



EDIT (by marmot who is happy to take the blame for all errors;-): You should never nest tikzpictures. You can work with scopes, which you can assign name with the local bounding box trick, these scopes will then behave pretty much like nodes (as far as the remembering and placing stuff relative to them is concerned). Clearly, inside the scope you can work with all overlays in the usual way. The perhaps easiest way to go is to load the arrows.meta library and downscale the arrow. (pgflowlevelsynccm does not work here in a straightforward way because of the additional translations, otherwise it scales the arrow automatically to the right size, but this command should anyway be used with great care.)



documentclassbeamer
usepackagetikz
usetikzlibrarycalc,positioning,arrows.meta

begindocument


beginframe
Scale + transform shape, good position, bad arrow size:\
begintikzpicture
node[circle,draw,fill=green] (A) A;
node[circle,draw,fill=green,right=of A] (B) B;
node[circle,draw,fill=green,above=of A] (C) C;
coordinate[above=of B.center] (X);

beginscope[shift=($(X)+(-1,0)$),
transform shape,scale=0.5,
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm,local bounding box=graph]
node[qubit] (q1) at (0,0);
node[qubit,right=of q1] (q2) ;
draw[-] (q1) -- (q2);
node<2>[qubit,above=of q2] (q2bis) ;
draw[red,-Stealth[scale=0.5]] (q1.center) -- (q1.north);
endscope
% comparison
draw[red,-stealth] ([xshift=2mm,yshift=-1cm]q1.center) -- ([xshift=2mm]q1.north);
node[fill=green,inner sep=0pt,minimum size=3pt] at (graph.north east) ;
node[fill=red,inner sep=0pt,minimum size=3pt] at (graph.north west) ;
node[fill=yellow,inner sep=0pt,minimum size=3pt] at (graph.south east) ;
node[fill=orange,inner sep=0pt,minimum size=3pt] at (graph.south west) ;
endtikzpicture
endframe

enddocument





share|improve this answer














With the xsavebox package you can save the tikzpicture in a xlrbox, and scale it when using:



documentclass[a4paper]article

usepackagetikz
usepackagexsavebox

beginxlrboxmybox
begintikzpicture[
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm
]
node[qubit] (q1) at (0,0);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture%
endxlrbox

begindocument
Not scaled: themybox

Scaled: scalebox0.5themybox
enddocument


This also solves the nesting of tikzpictures.



enter image description here



EDIT (by marmot who is happy to take the blame for all errors;-): You should never nest tikzpictures. You can work with scopes, which you can assign name with the local bounding box trick, these scopes will then behave pretty much like nodes (as far as the remembering and placing stuff relative to them is concerned). Clearly, inside the scope you can work with all overlays in the usual way. The perhaps easiest way to go is to load the arrows.meta library and downscale the arrow. (pgflowlevelsynccm does not work here in a straightforward way because of the additional translations, otherwise it scales the arrow automatically to the right size, but this command should anyway be used with great care.)



documentclassbeamer
usepackagetikz
usetikzlibrarycalc,positioning,arrows.meta

begindocument


beginframe
Scale + transform shape, good position, bad arrow size:\
begintikzpicture
node[circle,draw,fill=green] (A) A;
node[circle,draw,fill=green,right=of A] (B) B;
node[circle,draw,fill=green,above=of A] (C) C;
coordinate[above=of B.center] (X);

beginscope[shift=($(X)+(-1,0)$),
transform shape,scale=0.5,
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm,local bounding box=graph]
node[qubit] (q1) at (0,0);
node[qubit,right=of q1] (q2) ;
draw[-] (q1) -- (q2);
node<2>[qubit,above=of q2] (q2bis) ;
draw[red,-Stealth[scale=0.5]] (q1.center) -- (q1.north);
endscope
% comparison
draw[red,-stealth] ([xshift=2mm,yshift=-1cm]q1.center) -- ([xshift=2mm]q1.north);
node[fill=green,inner sep=0pt,minimum size=3pt] at (graph.north east) ;
node[fill=red,inner sep=0pt,minimum size=3pt] at (graph.north west) ;
node[fill=yellow,inner sep=0pt,minimum size=3pt] at (graph.south east) ;
node[fill=orange,inner sep=0pt,minimum size=3pt] at (graph.south west) ;
endtikzpicture
endframe

enddocument






share|improve this answer














share|improve this answer



share|improve this answer








edited Aug 13 at 17:23









marmot

58.1k463124




58.1k463124










answered Aug 13 at 13:29









Max

6,18311728




6,18311728











  • Thank you for the trick, which is a great solution in "fixed" pictures (so you get a +1), but as far as I know it does not handle beamer overlays, which is a big issue in my case.
    – tobiasBora
    Aug 13 at 13:57










  • @tobiasBora What exactly does/doesn't it do that you would expect otherwise?
    – Max
    Aug 13 at 14:01










  • I uploaded a MWE that shows that this solution cannot use beamer overlays like node<2>[qubit,above=of q4] (q5) ;, or only<2>....
    – tobiasBora
    Aug 13 at 14:03






  • 1




    @tobiasBora Ah so you want nested tikzpictures to comply to beamer overlays. That's a different story entirely.
    – Max
    Aug 13 at 14:06






  • 1




    @Max I added something with a scope and local bounding box, please feel free to roll that back.
    – marmot
    Aug 13 at 17:24
















  • Thank you for the trick, which is a great solution in "fixed" pictures (so you get a +1), but as far as I know it does not handle beamer overlays, which is a big issue in my case.
    – tobiasBora
    Aug 13 at 13:57










  • @tobiasBora What exactly does/doesn't it do that you would expect otherwise?
    – Max
    Aug 13 at 14:01










  • I uploaded a MWE that shows that this solution cannot use beamer overlays like node<2>[qubit,above=of q4] (q5) ;, or only<2>....
    – tobiasBora
    Aug 13 at 14:03






  • 1




    @tobiasBora Ah so you want nested tikzpictures to comply to beamer overlays. That's a different story entirely.
    – Max
    Aug 13 at 14:06






  • 1




    @Max I added something with a scope and local bounding box, please feel free to roll that back.
    – marmot
    Aug 13 at 17:24















Thank you for the trick, which is a great solution in "fixed" pictures (so you get a +1), but as far as I know it does not handle beamer overlays, which is a big issue in my case.
– tobiasBora
Aug 13 at 13:57




Thank you for the trick, which is a great solution in "fixed" pictures (so you get a +1), but as far as I know it does not handle beamer overlays, which is a big issue in my case.
– tobiasBora
Aug 13 at 13:57












@tobiasBora What exactly does/doesn't it do that you would expect otherwise?
– Max
Aug 13 at 14:01




@tobiasBora What exactly does/doesn't it do that you would expect otherwise?
– Max
Aug 13 at 14:01












I uploaded a MWE that shows that this solution cannot use beamer overlays like node<2>[qubit,above=of q4] (q5) ;, or only<2>....
– tobiasBora
Aug 13 at 14:03




I uploaded a MWE that shows that this solution cannot use beamer overlays like node<2>[qubit,above=of q4] (q5) ;, or only<2>....
– tobiasBora
Aug 13 at 14:03




1




1




@tobiasBora Ah so you want nested tikzpictures to comply to beamer overlays. That's a different story entirely.
– Max
Aug 13 at 14:06




@tobiasBora Ah so you want nested tikzpictures to comply to beamer overlays. That's a different story entirely.
– Max
Aug 13 at 14:06




1




1




@Max I added something with a scope and local bounding box, please feel free to roll that back.
– marmot
Aug 13 at 17:24




@Max I added something with a scope and local bounding box, please feel free to roll that back.
– marmot
Aug 13 at 17:24










up vote
4
down vote













Arrowheads are scaled by the line width (more or less), which is not scaled. Mostly because very thin lines are hard to see.



documentclass[varwidth]standalone

usepackagetikz

begindocument
Not scaled:
begintikzpicture[
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm,
line width=pgflinewidth % default value
]
node[qubit] (q1) at (0,0);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture


Scaled:
begintikzpicture[scale=.5, every node/.style=scale=.5,
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm,
line width=0.5pgflinewidth
]
node[qubit] (q1) at (0,0);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture
enddocument


demo




Defaults:



pgfdeclarearrow{
name = Stealth,
defaults =
length = +3pt 4.5 .8,
width' = +0pt .75,
inset' = +0pt 0.325,
line width = +0pt 1 1,
,





share|improve this answer






















  • Thanks for the pgflinewidth trick. Do you know what is the default value for arrow length, so that I can use -Stealth[width=...,height=...] to have perfect scale?
    – tobiasBora
    Aug 13 at 15:33















up vote
4
down vote













Arrowheads are scaled by the line width (more or less), which is not scaled. Mostly because very thin lines are hard to see.



documentclass[varwidth]standalone

usepackagetikz

begindocument
Not scaled:
begintikzpicture[
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm,
line width=pgflinewidth % default value
]
node[qubit] (q1) at (0,0);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture


Scaled:
begintikzpicture[scale=.5, every node/.style=scale=.5,
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm,
line width=0.5pgflinewidth
]
node[qubit] (q1) at (0,0);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture
enddocument


demo




Defaults:



pgfdeclarearrow{
name = Stealth,
defaults =
length = +3pt 4.5 .8,
width' = +0pt .75,
inset' = +0pt 0.325,
line width = +0pt 1 1,
,





share|improve this answer






















  • Thanks for the pgflinewidth trick. Do you know what is the default value for arrow length, so that I can use -Stealth[width=...,height=...] to have perfect scale?
    – tobiasBora
    Aug 13 at 15:33













up vote
4
down vote










up vote
4
down vote









Arrowheads are scaled by the line width (more or less), which is not scaled. Mostly because very thin lines are hard to see.



documentclass[varwidth]standalone

usepackagetikz

begindocument
Not scaled:
begintikzpicture[
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm,
line width=pgflinewidth % default value
]
node[qubit] (q1) at (0,0);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture


Scaled:
begintikzpicture[scale=.5, every node/.style=scale=.5,
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm,
line width=0.5pgflinewidth
]
node[qubit] (q1) at (0,0);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture
enddocument


demo




Defaults:



pgfdeclarearrow{
name = Stealth,
defaults =
length = +3pt 4.5 .8,
width' = +0pt .75,
inset' = +0pt 0.325,
line width = +0pt 1 1,
,





share|improve this answer














Arrowheads are scaled by the line width (more or less), which is not scaled. Mostly because very thin lines are hard to see.



documentclass[varwidth]standalone

usepackagetikz

begindocument
Not scaled:
begintikzpicture[
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm,
line width=pgflinewidth % default value
]
node[qubit] (q1) at (0,0);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture


Scaled:
begintikzpicture[scale=.5, every node/.style=scale=.5,
qubit/.style=draw, circle, color=black, anchor=center,
fill=rgb,255:red,143;green,146;blue,237,
inner sep=0pt,minimum width=5mm,
line width=0.5pgflinewidth
]
node[qubit] (q1) at (0,0);
draw[red,-stealth] (q1.center) -- (q1.north);
endtikzpicture
enddocument


demo




Defaults:



pgfdeclarearrow{
name = Stealth,
defaults =
length = +3pt 4.5 .8,
width' = +0pt .75,
inset' = +0pt 0.325,
line width = +0pt 1 1,
,






share|improve this answer














share|improve this answer



share|improve this answer








edited Aug 13 at 17:09

























answered Aug 13 at 14:06









John Kormylo

41.1k12363




41.1k12363











  • Thanks for the pgflinewidth trick. Do you know what is the default value for arrow length, so that I can use -Stealth[width=...,height=...] to have perfect scale?
    – tobiasBora
    Aug 13 at 15:33

















  • Thanks for the pgflinewidth trick. Do you know what is the default value for arrow length, so that I can use -Stealth[width=...,height=...] to have perfect scale?
    – tobiasBora
    Aug 13 at 15:33
















Thanks for the pgflinewidth trick. Do you know what is the default value for arrow length, so that I can use -Stealth[width=...,height=...] to have perfect scale?
– tobiasBora
Aug 13 at 15:33





Thanks for the pgflinewidth trick. Do you know what is the default value for arrow length, so that I can use -Stealth[width=...,height=...] to have perfect scale?
– tobiasBora
Aug 13 at 15:33


















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f445874%2ftikz-arrow-heads-does-not-scale-with-the-rest-of-the-picture%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?