[Tex/LaTex] Scaling a TikZ figure from an external file

external filesscalingtikz-pgf

I would like to insert figures which were created with TikZ to my LaTeX document.

I suppose that if I create the TikZ figure inside the document, that wouldn't be a problem – I'd just play with the scale value which comes right after \begin{tikzpicture}. However, sometimes the figure is too complicated for it to be written explicitly in the LaTeX document, so I create the figure in a different file and use \input{foo.tikz}. The problem with that is that I don't see how to scale it to fit the rest of the document.

Best Answer

You can set the every picture locally in a group around the input file to set any option which should be used for the tikzpicture in that file.

\tikzset{every picture/.style={scale=0.3}}%

However, if you have other tikzpictures inside nodes of the main picture they will also be affected (twice I mean). In this case, \tikzset{every picture/.style={scale=0.3,every picture/.style={}}} might work better.

Note that scale scales only coordinates. Text is not affected. You might want to scale the whole picture all together. For this use \scalebox{<factor>}{\input{<file>}} or
\resizebox{<width>}{!}{\input{<file>}}. This both macros come from graphics which is loaded already by tikz.

Also have a look at the standalone class, especially the new \includestandalone[<options>]{<file>} from v1.0beta which will include subfiles and scales them if requested, like \includegraphics does for images.