TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was wondering which is the correct way to scale a tikzpicture.

I tried with


but what I obtain is that distances between elements are scaled but not their sizes or text size too. It's like if the picture collapses on itself, without correctly scaling (as I would imagine, like having a zoom factor)

Am I missing something? Should I use a different command or what?

share|improve this question
up vote 122 down vote accepted

You could try using the command \resizebox. You enclose the tikzpicture environment in one of those and then in is scaled. Like this:

\resizebox{<horizontal size>}{<vertical size>}{%


If you want the image to be scaled proportionally, you can give one of the sizes and put ! in the other. There is also a \scalebox{<factor>}{...} macro which allows scaling by a factor. This works well except when the tikzpicture has a matrix command, and the columns are separated by &, in that case, you can change the column separator using the option ampersand replacement in the matrix options as stated in the pgfmanual.

Alternatively use the adjustbox package which provides an adjustbox environment which also allows resizing and scaling while allowing for special content including catcode changes required for verbatim text and the aforementioned &.

share|improve this answer
This made the trick, I didn't have any matrix inside the tikz so no problem :) – Jack Oct 20 '10 at 17:24

Pgf has two different types of transformations: coordinate transformations and canvas transformations. When using \begin{tikzpicture}[scale=0.50], you are applying coordinate transformation. All coordinates will be scaled, whereas individual objects (text, line thickness, rounding of corners etc) will not scale. Most of the time that is what you want, you do not want to scale carefully typeset pieces of text, you do not want to make lines ridiculously thick, or too thin to actually print.

If you want to scale everything, you have to use a canvas transformation. For that, pgf has a command \pgftransformscale{}. You can also use the pgflowlevelscope environment:

  \draw (0,0) rectangle (6,6); %create a bounding box to reserve space
     \draw (0,0) -- (1,1) node[right]{$x$};

You can also use \pgflowlevelsynccm which synchronizes the canvas transformation matrix with the current coordinate transformation matrix, for example like this:

  \draw (0,0) rectangle (1.2,1.2); %create a bounding box to reserve space
  \draw (0,0) -- (1,1) node[right]{$x$};

Note that because pgf does not (cannot) keep track of the canvas transformations (they are performed by the backend), you will have to make sure there is enough space in your picture for the scaled objects. In the examples above, I try to reserve space by drawing a bounding box first, before applying the canvas transformation. There are other problems with canvas transformations, and I do not recommend using them without carefully reading appropriate parts of the pgf manual.

I include this answer more as an explanation of what is going on, another, preferable answer using \resizebox has already appeared.

share|improve this answer
+1 but maybe your first rectangle should be sized (6,6) to show that both examples lead to the same result – Christian Oct 20 '10 at 17:59

You can use the option "transform shape" for the whole picture, a scope or a single node. Example:

\begin{tikzpicture}[scale=2, transform shape]
  \draw rectangle (1,1) node {foo};

  \draw rectangle (1,1) node {bar};

But be careful, this will not solve all your cases with scaling tikz pictures, e.g."rounded corners" will not scale. The tikz authors (general) advice is not to scale graphics.

share|improve this answer
This is superb! – Chang Feb 14 '12 at 15:18
This is great, thanks! – Vincent Russo Jul 7 '15 at 23:10

With newer versions of TikZ, you can also use the transform canvas option, as detailed in section 25.4 of the TikZ 3.00 manual:

\begin{tikzpicture}[transform canvas={scale=2.0}]
share|improve this answer

One tends to define a base length and draw everything in terms of it. This seems to scale nicely and avoids some of the draw backs of post-scaling.

  basis/.code={\setlength{\b@sis}{#1}}, % TikZ assignment code
  basis/.default=1em,                   % Provide a default (\b@sis is undefined/unassigned)
  basis,                                % Set initial Value (\b@sis is defined/assigned)

Sometimes one needs to control this from their text as well. For this one proposes the following broken code. (I haven't required this functionality yet so never fixed it. One can set the value but retrieving it seems rather tricky.)

   % This part is broken
   %\b@sis     % Ideally one would return the measurement
   %\the\b@sis % One could return a string but this is not much use

Finally to test the code use the following in your

  code={\node[draw] at (0,-\b@sis) {\the\b@sis};
        \node[draw] at (0, \b@sis) {Basis :};}},
 \tikz \pic {test};

Provided \basis works correctly then one could also use the following within their text

\tikz \draw (-\basis,-\basis) -- (\basis,\basis);
share|improve this answer

Your Answer


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.