How do you define the size of a rectangle, circle or node in TikZ to be scalable, like when you position objects using (1, 2) and then apply scale=2? What I'm looking for is to be able to scale the objects like circles and boxes along with the coordinates.
Asked
Active
Viewed 3,431 times
1
gablin
- 17,006
1 Answers
2
You should do your diagram as at the scale you think you want, and then if you want to scale the figur, say to half its size, apply [scale=0.5] option:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[blue]
\draw [ultra thick] (0,0) rectangle (1,1);
\draw [ultra thick] (2,0.5) circle (0.5) node {$o$};
\node at (3,0) {$x$};
\end{tikzpicture}
\begin{tikzpicture}[scale=0.5,red]
\draw [ultra thick] (0,0) rectangle (1,1);
\draw [ultra thick] (2,0.5) circle (0.5) node {$o$};
\node at (3,0) {$x$};
\end{tikzpicture}
\end{document}

The blue is the original with a default scale=1.0, and the red is scaled by 50%. Note that the coordinate of the center of the circle, and the location of the nodes is also scaled, and the size of the text is not scaled, which is usually the desired behavior.
If you want to scale the text as well you should have a look at How to scale Tikz drawings and text together?
Peter Grill
- 223,288
-
1Just a short remark: this does not apply to nodes, they have to be treated differently. – Count Zero Sep 27 '11 at 14:03
-
Peter Grill's answer is correct, but for more information/subtleties and handling nodes check your other question What are the guidelines for making TikZ pictures properly scalable?, I just wanted to avoid double-posting. – Count Zero Sep 27 '11 at 14:16
-
1The location of the nodes also gets scaled. I have updated the answer to show this. – Peter Grill Sep 27 '11 at 14:18
(1, 2)isn't a relative position,+(1,2)would be one. Do you mean a rectangle, circular node or a manual drawn shape? You can select the size of a node usingminimum size,minimum widthorminimum height. – Martin Scharrer Sep 27 '11 at 12:262, for instance, and then be able to scale it along with the coordinates when I setscale=3. – gablin Sep 27 '11 at 12:38