Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to frame a set of nodes with the option [fit] ​​and change the overall size of the drawing with [scale = xx, transform shape] but I have unexpected behavior. the frame is no longer valid

the code:

\documentclass[a4paper]{article}                

\usepackage{pgf,tikz}
\usetikzlibrary{fit,calc,positioning}

\begin{document}

\begin{tikzpicture}
\node[draw](A){A};
\node[right=3em of A,draw](B){B};
\node[left=3em of A,draw](C){C};
\node[above=3em of A,draw](D){D};
\node[below=3em of A,draw](E){E};
\node[fit=(A) (B) (C) (D) (E), draw]{};
\end{tikzpicture}
\hfill
\begin{tikzpicture}[scale=0.8,transform shape]
\node[draw](A){A};
\node[right=3em of A,draw](B){B};
\node[left=3em of A,draw](C){C};
\node[above=3em of A,draw](D){D};
\node[below=3em of A,draw](E){E};
\node[fit=(A) (B) (C) (D) (E), draw]{};
\end{tikzpicture}

\end{document}

enter image description here

what can I do?, is this a bug?

share|improve this question
1  
This doesn't happen for me: the entire picture is scaled correctly. What version of PGF/TikZ are you using? –  Jake Jun 6 at 8:28
    
@Jake I get that via v3 –  percusse Jun 6 at 8:33
    
@percusse: Ha, interesting! I wonder if that's a feature or a regression... –  Jake Jun 6 at 8:41
    
@Jake That's probably something due to using global switches. I would say this is consistent behavior with undesired result. Scoping as Claudio mentioned in the comment would be the proper way to do it I guess. –  percusse Jun 6 at 8:45

1 Answer 1

up vote 7 down vote accepted

You have to exclude the fitting node to be scaled since it first fits the contents and then applies the scaling to it again. Easiest is to turn off the transfrom shape effect.

\documentclass[a4paper]{article}                

\usepackage{tikz}
\usetikzlibrary{fit,calc,positioning}

\begin{document}

\begin{tikzpicture}
\node[draw](A){A};
\node[right=3em of A,draw](B){B};
\node[left=3em of A,draw](C){C};
\node[above=3em of A,draw](D){D};
\node[below=3em of A,draw](E){E};
\node[fit=(A) (B) (C) (D) (E), draw]{};
\end{tikzpicture}
\begin{tikzpicture}[scale=0.5,transform shape]
\node[draw](A){A};
\node[right=3em of A,draw](B){B};
\node[left=3em of A,draw](C){C};
\node[above=3em of A,draw](D){D};
\node[below=3em of A,draw](E){E};
\node[fit=(A) (B) (C) (D) (E), transform shape=false,draw]{};
\end{tikzpicture}

\end{document}

enter image description here

share|improve this answer
2  
Another way is passing to a scope environment the scaling options, include relevant code and leave outside the node used for fitting. –  Claudio Fiandrino Jun 6 at 8:39
    
@ClaudioFiandrino Agreed. –  percusse Jun 6 at 8:46
    
ok, I'll do that, but it seems to be a regression, I do not remember having this problem with the previous version –  rpapa Jun 10 at 16:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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