3

If I scale the TikZ picture environment, everything should scale by a factor of x correct?

If that is the case, why would some code not scale or scale incorrectly when it is in the environment?

For instance,

 \begin{tikzpicture}[scale = 3]
   code
 \end{tikzpicture}

The reason I ask is some code that Qrrbrbirlbel helped with doesn't scale when I enter the scaled value as an environment option.

When I scale the picture, I receive the following error:

ERROR: Package pgf Error: No shape named F'-2 is known.

--- TeX said ---

See the pgf package documentation for explanation.
Type  H <return>  for immediate help.
 ...

l.62       }
                                     %!?
--- HELP ---
From the .log file...

Here is the code:

\documentclass[convert = false]{standalone}

\usepackage{tikz}
\usetikzlibrary{calc, intersections}

\begin{document}
\tikzset{circle with radius/.style = {shape = circle, inner sep = 0pt,
      outer sep = 0pt, minimum size = {2 * (#1)}}}
  \begin{tikzpicture}[scale = .5
    ]
  \coordinate (O) at (0, 0);

  \pgfmathsetmacro{\as}{3}
  \pgfmathsetmacro{\bs}{2.25}
  \pgfmathsetmacro{\c}{sqrt(\as^2 - \bs^2)}
  \pgfmathsetmacro{\al}{3.75}
  \pgfmathsetmacro{\bl}{2.9}
  \pgfmathsetmacro{\cl}{sqrt(\al^2 - \bl^2)}
  \pgfmathsetmacro{\xs}{abs(\c - \cl)}

  \coordinate (O) at (0, 0);

  \coordinate (F) at (\c, 0) {};

  \path[name path global = line1] (\c, 0) -- ++(60:{\as} and \bs);
  \path[name path global = line2] (\c, 0) -- ++(150:6cm);

    \draw[name path global = ell1] (O) ellipse
    (\as cm and \bs cm);

    \draw[name path global = ell2] (-\xs, 0)
    ellipse (\al cm and \bl cm);

  \path[name intersections = {of = line1 and ell1, by = P1}];
  \coordinate (A) at (P1) {};

  \path[name intersections = {of = line2 and ell2, by = P2}];
  \coordinate (B) at (P2) {};
  \begin{scope}[declare function = {doubleA = 5.8cm;}]
    \clip ($(A.center) + (1, 0)$) rectangle ($(B.center) + (0, 1)$);
    \begin{pgfinterruptboundingbox}
      \path let
      \p1 = ($(A) - (F)$),
      \p2 = ($(B) - (F)$),
      \n1 = {veclen(\x1, \y1)},
      \n2 = {veclen(\x2, \y2)}
      in
      (A) node[name path global = aCircle, circle with radius = doubleA-\n1]
      {}
      (B) node[name path global = bCircle, circle with radius = doubleA-\n2]
      {}
      (F) node[name path global = fCircle,
      circle with radius = .5 * doubleA] {};

      \tikzset{name intersections = {of = aCircle and bCircle, name = F'} }
      \foreach \solA in {2} {
        \path ($(F)!.5!(F'-\solA)$) coordinate (C'-\solA)
        ($(C'-\solA)!doubleA/2!(F)$) coordinate (xDir-\solA)
        (F'-\solA) node[name path global/.expanded = f'Circle-\solA,
        circle with radius = .5 * doubleA] {};
      }                         %!?                                                 
      \foreach \solA in {2} { %!?                                                   
        \path[name intersections = {of = fCircle and f'Circle-\solA,
          by = {yDir-\solA}}]
        ($(xDir-\solA)-(C'-\solA)$) coordinate (xDir'-\solA)
        ($(yDir-\solA)-(C'-\solA)$) coordinate (yDir'-\solA)
        ;
      }
    \end{pgfinterruptboundingbox}
    \foreach \solA in {2}
    \draw[x = (xDir'-\solA), y = (yDir'-\solA),
    name path global = traj]
    (C'-\solA) circle [radius = 1];
  \end{scope}
\end{tikzpicture}
\end{document}

Without scaling:

enter image description here

With scaling:

enter image description here

Is there a way for me to scale this tikzpicture environment?


Edit 2:

Since I only produced a MWE, fixing the problem in code only created another unforeseen issue. Therefore, I have posted the whole code with the transform shape and the new issue it brought to the table.

From Peter's and Qrrbrbirlbel's suggestion, I was able to fix the scaling issue but a new problem cropped up (see the image below):

enter image description here

The 1 shouldn't be upside down, those nodes, and line shouldnt be in the location they show. Why would transform shape cause this issue?

I just read Andrew Stacey's post here How to scale a tikzpicture including texts?. He talks about transform shape will apply rotation to the node.

So I just tried adding:

\tikzset{global scale/.style={
    scale=#1,
    every node/.style={scale=#1}
  }
}

the above code to the picture as Andrew suggested but nothing changed.

I am adding the code that isnt MWE because not having doesn't help here. This is because when I implemented one change, something else was affected. Therefore, the people helping don't know what else is going on in the code.

\documentclass[convert = false]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc, intersections, backgrounds, decorations.markings, arrows}
\begin{document}
\begin{tikzpicture}[line join = round, line cap = round, >=triangle 45,
    every label/.append style = {font = \scriptsize},
    dot/.style = {inner sep = +0pt, shape = circle,
      draw = black, label = {#1}},
    small dot/.style = {minimum size = .05cm, dot = {#1}},
    big dot/.style = {minimum size = .1cm, dot = {#1}},
    transform shape, scale = .75
    ]
    \tikzset{circle with radius/.style = {shape = circle, inner sep = 0pt,
        outer sep = 0pt, minimum size = {2 * (#1)}
      }
    }
    \tikzset{global scale/.style = {
        scale = #1,
        every node/.style = {scale = #1}
      }
    }

    \coordinate (O) at (0, 0);

    \pgfmathsetmacro{\as}{3}
    \pgfmathsetmacro{\bs}{2.25}
    \pgfmathsetmacro{\c}{sqrt(\as^2 - \bs^2)}
    \pgfmathsetmacro{\al}{3.75}
    \pgfmathsetmacro{\bl}{2.9}
    \pgfmathsetmacro{\cl}{sqrt(\al^2 - \bl^2)}
    \pgfmathsetmacro{\xs}{abs(\c - \cl)}

    \coordinate (O) at (0, 0);

    \clip (-1, .25) rectangle (-6, 4);

    \node[fill = black, big dot = {below left: \(F\)}] (F) at (\c, 0) {};

    \path[name path global = line1] (\c, 0) -- ++(60:{\as} and \bs);
    \path[name path global = line2] (\c, 0) -- ++(150:6cm);

    \begin{scope}[decoration = {markings,
        mark = at position 0.25 with {\arrow{>}},
        mark = at position 0.375 with {\node[draw, shape = circle,
          inner sep = .04cm, fill = white, font = \tiny] {\(1\)};},
        mark = at position 0.75 with {\arrow{>}},
      } ]
      \draw[postaction = decorate, name path global = ell1, blue] (O) ellipse
      (\as cm and \bs cm);
    \end{scope}

    \begin{scope}[decoration = {markings,
        mark = at position 0.25 with {\arrow{>}},
        mark = at position 0.6 with {\node[draw, shape = circle,
          inner sep = .04cm, fill = white, font = \tiny] {\(2\)};},
        mark = at position 0.75 with {\arrow{>}},
      },
      on background layer                                                          
      ]
      \draw[postaction = decorate, name path global = ell2, red] (-\xs, 0)
      ellipse (\al cm and \bl cm);
    \end{scope}

    \path[name intersections = {of = line1 and ell1, by = P1}];
    \node[fill = black, big dot = {right: \(A\)}] (A) at (P1) {};

    \path[name intersections = {of = line2 and ell2, by = P2}];
    \node[fill = black, big dot = {above: \(B\)}] (B) at (P2) {};

    \draw[blue] (F) -- (A);
    \draw[red] (F) -- (B) node[font = \scriptsize, fill = white,
    inner sep = 0cm, pos = .5] {\(r_B\)};

    \begin{scope}[on background layer]                                              
      \draw[dashed, -latex] ($(-\al , 0) - (1, 0)$) -- ($(\al, 0) + (.5, 0)$)
      coordinate (P3);
      \draw[dashed, -latex] ($(F) - (0, 3)$) -- ($(F) + (0, 3)$);
    \end{scope}

    \begin{scope}[declare function = {doubleA = 5.8cm;},
      decoration = {markings,
        mark = at position 0.175 with {\arrow{>}},
        mark = at position 0.225 with {\node[draw, shape = circle,
          inner sep = .04cm, fill = white, font = \tiny] {\(3\)};}
      } ]
      \clip ($(A.center) + (1, 0)$) rectangle ($(B.center) + (0, 1)$);
      \begin{pgfinterruptboundingbox}
        \path let
          \p1 = ($(A) - (F)$),
          \p2 = ($(B) - (F)$),
          \n1 = {veclen(\x1, \y1)},
          \n2 = {veclen(\x2, \y2)}
        in
        (A) node[name path global = aCircle, circle with radius = doubleA-\n1]
        {}
        (B) node[name path global = bCircle, circle with radius = doubleA-\n2]
        {}
        (F) node[name path global = fCircle,
        circle with radius = .5 * doubleA] {};

        \tikzset{name intersections = {of = aCircle and bCircle, name = F'} }
        \foreach \solA in {2} {
          \path ($(F)!.5!(F'-\solA)$) coordinate (C'-\solA)
          ($(C'-\solA)!doubleA/2!(F)$) coordinate (xDir-\solA)
          (F'-\solA) node[name path global/.expanded = f'Circle-\solA,
          circle with radius = .5 * doubleA] {};
        }                         %!?                                                
        \foreach \solA in {2} { %!?                                                  
          \path[name intersections = {of = fCircle and f'Circle-\solA,               
            by = {yDir-\solA}}]                                                      
          ($(xDir-\solA)-(C'-\solA)$) coordinate (xDir'-\solA)                       
          ($(yDir-\solA)-(C'-\solA)$) coordinate (yDir'-\solA)                       
          ;                                                                          
        }                                                                            
      \end{pgfinterruptboundingbox}     
      \foreach \solA in {2}                                                          
      \draw[x = (xDir'-\solA), y = (yDir'-\solA), postaction = decorate,             
      name path global = traj]                                                       
      (C'-\solA) circle [radius = 1];                                                
    \end{scope}                                                                 

    \draw[on background layer, red] let                                              
      \p0 = (F),                                                                     
      \p1 = (B),                                                                     
      \p2 = (P3),                                                                    
      \n1 = {atan2(\x1 - \x0, \y1 - \y0)},                                           
      \n2 = {atan2(\x2 - \x0, \y2 - \y0)},                                           
      \n3 = {.75cm},                                                                 
      \n4 = {(\n2 + \n1) / 2}                                                        
    in (F) +(\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2]          
    node[font = \tiny, fill = white, inner sep = 0cm] at                             
    ([shift = (F)] \n4:\n3) {\(\nu_B\)};                                             

    \draw[blue] let                                                                  
      \p0 = (F),                                                                     
      \p1 = (A),                                                                     
      \p2 = (P3),                                                                    
      \n1 = {atan2(\x1 - \x0, \y1 - \y0)},                                           
      \n2 = {atan2(\x2 - \x0, \y2 - \y0)},                                           
      \n3 = {.5cm},                                                                  
      \n4 = {(\n2 + \n1) / 2}                                                        
    in (F) +(\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2]          
    node[font = \tiny, fill = white, inner sep = 0cm] at                             
    ([shift = (F)] \n4:.75cm) {\(\nu_A\)};                                                                    

    \path[name path = circ] (B) circle [radius = 1bp];                                                                                                                    
    \draw[name intersections = {of = circ and traj}, -latex] (B) --                  
    ($(intersection-1)!1.25cm!(intersection-2)$) node[pos = .4, font = \tiny,        
    below, fill = white, inner sep = 0cm] {\(\mathbf{v}_1\)} coordinate (P3);        
    \draw[name intersections = {of = circ and ell2}, -latex, red] (B) --             
    ($(intersection-1)!2cm!(intersection-2)$) node[pos = .5, font = \tiny,           
    above] {\(\mathbf{v}_2\)} coordinate (P4);                                       
    \draw[-latex, name path = line3] (P3) -- (P4) node[pos = .5, font = \tiny,       
    fill = white, inner sep = 0cm] {\(\Delta\mathbf{v}\)};                           
    \draw[name path = line4] (B) -- ($(B)!2.1cm!-90:(F)$) coordinate (P5);           

    \path[name path = circ2] (P3) circle [radius = 1bp];                             
    \path[name intersections = {of = circ2 and line3}, name path = line5]            
    (P3) -- ($(intersection-1)!2cm!(P3)$);                                           
    \path[name intersections = {of = line5 and line4, by = P6}];                     

    \draw[dotted] (P3) -- (P6);                                                      

    \path[name intersections = {of = circ and traj}] (B) --                          
    ($(intersection-1)!1.5cm!(intersection-2)$) coordinate (P7);                     

    \draw (P3) -- (P7);                                                              

    \path[name intersections = {of = circ and ell2}] (B) --                          
    ($(intersection-1)!2.5cm!(intersection-2)$) coordinate (P8);                     

    \draw (P4) -- (P8);                                                              

    \draw let                                                                        
      \p0 = (B),                                                                     
      \p1 = (P5),                                                                    
      \p2 = (P3),                                                                    
      \n1 = {atan2(\x1 - \x0, \y1 - \y0)},                                           
      \n2 = {atan2(\x2 - \x0, \y2 - \y0)},
      \n3 = {1.4cm},
      \n4 = {(\n2 + \n1) / 2}
    in (B) +(\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2]
    coordinate (P9) at ([shift = (B)] \n4:\n3);

    \draw (P9) .. controls ($(P9) - (.15, .15)$) .. ($($(P9) - (.15, .15)$) +        
    (.25, -.3)$) node[font = \tiny, fill = white, inner sep = 0cm]
    {\(\gamma_1\)};

    \draw[-latex] let
      \p0 = (B),
      \p1 = (P5),
      \p2 = (P8),
      \n1 = {atan2(\x1 - \x0, \y1 - \y0)},
      \n2 = {atan2(\x2 - \x0, \y2 - \y0)},
      \n3 = {2.1cm},
      \n4 = {(\n2 + \n1) / 2}
    in (B) +(\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2]
    node[fill = white, inner sep = 0cm, font = \tiny] at ([shift = (B)]
    \n4:\n3) {\(\gamma_2\)};

    \draw let
      \p0 = (B),
      \p1 = (P3),
      \p2 = (P4),
      \n1 = {atan2(\x1 - \x0, \y1 - \y0)},
      \n2 = {atan2(\x2 - \x0, \y2 - \y0)},
      \n3 = {1cm},
      \n4 = {(\n1 + \n2) / 2}
    in (B) +(\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2]
    node[fill = white, inner sep = 0cm, font = \tiny] at
    ([shift = (B)] \n4:\n3) {\(\Delta\gamma\)} coordinate (DG);

    \begin{scope}[on background layer]
      \draw[-latex] let
        \p0 = (P6),
        \p1 = (P5),
        \p2 = (P4),
        \n1 = {atan2(\x1 - \x0, \y1 - \y0)},
        \n2 = {atan2(\x2 - \x0, \y2 - \y0) - 360},
        \n3 = {.75cm},
        \n4 = {(\n2 + \n1) / 2}
      in (P6) +(\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2]
      node[fill = white, inner sep = 0cm, font = \tiny] at ([shift = (P6)]
      \n4:\n3) {\(\phi\)};
  \end{scope}                                                                    
\end{tikzpicture}
\end{document}
  • 3
    Add transform shape option to the tikzpicture environment. – Peter Grill Jul 9 '13 at 21:57
  • 4
    I think the real problem here is that—as the error message says—the coordinate F'-2 cannot be found. The reason is that the aCircle and the fCircle do not intersect (to check this, remove the pgfinterruptboundingbox (to see everything) and let TikZ draw the nodes aCircle and bCircle. If you add transform shape to the nodes they also will scale, though I don’t know whether this affects the node size correctly in regarding if the minimum size (which is set by circle with radius). – Qrrbrbirlbel Jul 9 '13 at 21:58
  • @dustin Nodes are usually not scaled (as they usually are used for text/description). As you use the intersections library you might also simply use circle paths and not nodes (my fault). – Qrrbrbirlbel Jul 9 '13 at 22:06
  • @Qrrbrbirlbel So I added this to the code but some nodes and code are still messed up. I will add another picture to the post to show what I mean. – dustin Jul 9 '13 at 22:11
  • 1
    If I remove the scaling the code still doesn't compile. Can you place the full unscaled and working code as there is no hope for a MWE. – percusse Jul 10 '13 at 11:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.