[Tex/LaTex] Correctly scaling a tikzpicture

tikz-pgf

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

I tried with

\begin{tikzpicture}[scale=0.50]

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?

Best Answer

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>}{%
    \begin{tikzpicture}

    \end{tikzpicture}
}

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 &.

Related Question