10

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

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

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

4

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

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.