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.

Is it possible to scale all TikZ pictures in a document by the same factor globally?

Something like \usepackage[scale=0.9]{tikz} doesn't work.

share|improve this question
1  
You could do \newcommand*{\ScaleFactor}{0.9}% in your preamble, and wherever you have a tikzpicture use \providecommand*{\ScaleFactor}{1.0}%, (so that they can compile by themselves if needed), and use \begin{tikzpicture}[scale=\ScaleFactor]. Or to automate thie even further, redefine the tikzpicture environment to automatically apply the ScaleFactor if it is defined. –  Peter Grill Jun 11 '12 at 19:37
add comment

2 Answers

up vote 12 down vote accepted

Every tikzpicture uses the style every picture. So if you put \tikzset{every picture/.append style={scale=0.9}} near the start of your document, all tikzpictures will be scaled by that amount (in addition to any scales you might already be applying to individual tikzpictures).

\documentclass{article}
\usepackage{tikz}
\begin{document}
\tikzset{every picture/.append style={scale=2}}
First picture:
\begin{tikzpicture}[baseline]
\node [transform shape,anchor=base, draw] {Node 1};
\end{tikzpicture}

Second picture: 
\begin{tikzpicture}[baseline]
\node [transform shape,anchor=base, draw] {Node 2};
\end{tikzpicture}
\end{document}
share|improve this answer
2  
If everything in all pictures should be scaled, I would apply the transform shape also globally (e.g., every node/.append style={transform shape}) –  Daniel Jun 11 '12 at 20:00
2  
@Daniel: Good point. Personally, I wouldn't want that, though. For me, one of the great things about creating figures right within the document is that the text size always matches that of the document exactly. –  Jake Jun 11 '12 at 20:07
add comment

If one wants that the text scales too, one can do something like this:

\documentclass{article}


\usepackage{graphicx}
\usepackage{pgfplots}
\usepackage{environ}
\usepackage{tikz}

\newcommand*{\scalefactor}{0.8}

\NewEnviron{mytikz}[1][]{
\scalebox{\scalefactor}{
\begin{tikzpicture}[{#1}]
\BODY
\end{tikzpicture}}}

\begin{document}

First picture:
\begin{mytikz}[baseline]
\node [transform shape,anchor=base, draw] {Node 1};
\end{mytikz}

Second picture: 
\begin{mytikz}[baseline]
\node [transform shape,anchor=base, draw] {Node 2};
\end{mytikz}


\end{document}
share|improve this answer
    
Why use a \scalebox and not just pass the scale= option to tikzpicture? Also, using \scalebox will result in the text being scaled which is not usually desirable. Also, you could just redefine the tikzpicture environment to apply the scale= option. –  Peter Grill Jun 11 '12 at 20:51
add comment

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.