12

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}

output

1
  • I see now that minimum size of node also doesn't scale, anyone knows why that is?
    – Peter Smit
    Dec 3, 2010 at 13:55

2 Answers 2

12

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}]

alt text

5

A possibility without transform shape. You can scale with x=2cm y=2cm

\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}[x=2cm,y=2cm,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}  

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .