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.

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.

share|improve this question
2  
Please explain what you mean in more detail. I have issues understanding exactly what you mean. (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 using minimum size, minimum width or minimum height. –  Martin Scharrer Sep 27 '11 at 12:26
1  
Sorry, it should have said "scalable", not "relative". Don't know how that got in there. What I want is to be able to specify the size of a rectangle to be 2, for instance, and then be able to scale it along with the coordinates when I set scale=3. –  gablin Sep 27 '11 at 12:38
    
Please give an example of a diagram that you are trying to scale. In particular, are your rectangles and circles nodes or figures? If nodes, then the answer is a little more complicated. Also, take a look at the answers linked by Peter Grill and Count Zero as they may contain all the answers that you need for this. –  Loop Space Sep 28 '11 at 9:51

1 Answer 1

up vote 2 down vote accepted

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}

enter image description here

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?

share|improve this answer
    
Just 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
1  
The location of the nodes also gets scaled. I have updated the answer to show this. –  Peter Grill Sep 27 '11 at 14:18

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.