[Tex/LaTex] Using scalable sizes for rectangles, circles and nodes in TikZ

scalingtikz-pgf

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.

Best Answer

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?

Related Question