Scaling and fitting a box

Peter Smit asked on TeX.SX:

 
Why does fit not scale?
 

I have a problem with the fit library in TikZ.

When I scale the figure (with the TikZ scale command), the fit box doesn’t!

Why is that? Could I somehow change it?

Example:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fit}
\begin{document}
\begin{tikzpicture}[state/.style={circle,draw,thick,
  loop above,inner sep=0,minimum width=10}]
\node[state] (a) at (0,1) {} edge [loop above, thick]
  coordinate (al) ();
\node[state] (b) at (1,1) {} edge [loop above, thick]
  coordinate (bl) ();
\node[draw,rectangle,fit=(a) (b) (al) (bl)] {};
\end{tikzpicture}
 
\begin{tikzpicture}[scale=2,state/.style={circle,draw,thick,
  loop above,inner sep=0,minimum width=10}]
\node[state] (a) at (0,1) {} edge [loop above, thick]
  coordinate (al) ();
\node[state] (b) at (1,1) {} edge [loop above, thick]
  coordinate (bl) ();
\node[draw,rectangle,fit=(a) (b) (al) (bl)] {};
\end{tikzpicture}
\end{document}
scaled image

Answer:

Add the option transform shape to scale also the box resp. shapes:

\begin{tikzpicture}[scale=2,transform shape,
    state/.style={circle,draw,thick,loop above,inner sep=0,
    minimum width=10}]

Output:

scaled box
Stefan Kottwitz

03. December 2010 by stefan
Categories: Uncategorized | Leave a comment

Leave a Reply