summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/tikz-ext/tikz-ext-manual-en-library-scalepicture.tex
blob: b14c4c4f0fbd9158e37cc2ea9d048b34c1941767 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
% !TeX spellcheck = en_US
% !TeX root = tikz-ext-manual.tex
% Copyright 2022 by Qrrbrbirlbel
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Free Documentation License.
%
\clearpage
\section{Scaling Pictures to a Specific Size}
\label{library:scalepicture}

\begin{tikzlibrary}{ext.scalepicture}
  This library scales \tikzname\ pictures to a specific width or height
  by scaling the whole picture.
\end{tikzlibrary}

\begin{multicols}{2}
If one of the keys below are used on a \tikzname\ picture, i.\,e.
as an option to |\tikzpicture| or \texttt{\textbackslash begin\{tikzpicture\}}
the size of the picture\footnote{This is the size of the pseudo-node \texttt{current bounding box}.}
will be measured and written to the \filetype{aux} file
so that it will be available at the next compilation run
and an appropriate scaling for the picture can be installed.

\begin{command}{\tikzextpicturewidth}
  Returns the last measured width of the picture.
  
  This will expand to |0pt| if the picture hasn't been measured before.
\end{command}
\begin{command}{\tikzextpictureheight}
  Returns the last measured height of the picture.
  
  This will expand to |0pt| if the picture hasn't been measured before.
\end{command}

\begin{stylekey}{/tikz/save picture size}
  This key is usually used by the keys provided by this library.
  Normally, this is not needed to be explicitly given.
\end{stylekey}
\subsection{Keeping the aspect ratio}
The following \emph{unstarred} keys do not change the aspect ratio of the picture.

\begin{key}{/tikz/picture width=\meta{dimension}}
  Scales the picture so that the width of the picture will be \meta{dimension}.
  This will keep the aspect ratio the same.
\end{key}

\begin{key}{/tikz/minimum picture width=\meta{dimension}}
  As above but will not change the size of the picture
  if its width is greater than \meta{dimension}.
\end{key}

\begin{key}{/tikz/maximum picture width=\meta{dimension}}
  As above but will not change the size of the picture
  if its width is less than \meta{dimension}.
\end{key}

\begin{key}{/tikz/picture height=\meta{dimension}}
  Scales the picture so that the height of the picture will be \meta{dimension}.
  This will keep the aspect ratio the same.
\end{key}

\begin{key}{/tikz/minimum picture height=\meta{dimension}}
  As above but will not change the size of the picture
  if its height is greater than \meta{dimension}.
\end{key}

\begin{key}{/tikz/maximum picture height=\meta{dimension}}
  As above but will not change the size of the picture
  if its height is less than \meta{dimension}.
\end{key}

\begin{key}{/tikz/minimum picture size=\marg{width}\marg{height}}
  Scales the picture so that its height will be at least \meta{width}
  and its height will be at least \meta{height}.
\end{key}

\begin{key}{/tikz/maximum picture size=\marg{width}\marg{height}}
  Scales the picture so that its height will be at most \meta{width}
  and its height will be at most \meta{height}.
\end{key}

\subsection{Changing the aspect ratio.}
The following \emph{starred} keys do change the aspect ratio.
\begin{key}{/tikz/picture width*=\meta{dimension}}
  Scales the picture so that the width of the picture will be \meta{dimension}.
  This will only scale the $x$ axis.
\end{key}

\begin{key}{/tikz/minimum picture width*=\meta{dimension}}
  As above but will not change the size of the picture
  if its width is greater than \meta{dimension}.
\end{key}

\begin{key}{/tikz/maximum picture width*=\meta{dimension}}
  As above but will not change the size of the picture
  if its width is less than \meta{dimension}.
\end{key}

\begin{key}{/tikz/picture height*=\meta{dimension}}
  Scales the picture so that the height of the picture will be \meta{dimension}.
  This will only scale the $y$ axis.
\end{key}

\begin{key}{/tikz/picture size*=\marg{width}\marg{height}}
  Scales the picture so that its width will be \meta{width}
  and its height will be \meta{height}.
  
  This will scale both axes but independent from each other.
\end{key}
\end{multicols}