Debian Codegraph @

texmf-dist/doc/latex/tikz-ext/tikz-ext-manual-en-library-positioning-plus.tex

raw
1 % !TeX spellcheck = en_US
2 % !TeX root = tikz-ext-manual.tex
3 % Copyright 2022 by Qrrbrbirlbel
4 %
5 % This file may be distributed and/or modified
6 %
7 % 1. under the LaTeX Project Public License and/or
8 % 2. under the GNU Free Documentation License.
9 %
10 \clearpage
11 \section{Positioning Plus}
12 \label{library:positioning-plus}
13 \tikzsetnextfilename{posplus}
14 \begin{tikzlibrary}{ext.positioning-plus}
15 With the help of the \referenceLibraryandIndexO{positioning} and the \referenceLibraryandIndexO{fit} library this extends the placement of nodes.
16 \end{tikzlibrary}
17
18 \subsection{Useful corner anchors}
19 The anchors |ext_corner north east|, |ext_corner north west|, |ext_corner south west| and |ext_corner south east|
20 are defined as ``generic anchors'', i.\,e. they are defined for all shapes.
21 This is mostly useful for the placement of circular shapes.
22 \begin{codeexample}[width=.45\linewidth,preamble=\usetikzlibrary{ext.positioning-plus}]
23 \Huge
24 \begin{tikzpicture}
25 \node[name=s,shape=circle,shape example,scale=.75,outer sep=auto]
26 {Circle\vrule width 1pt height 2cm};
27 \foreach \anchor/\placement in {
28 north west/below right, north/above, north east/below left,
29 west/left, center/above, east/right,
30 mid west/right, mid/above, mid east/left,
31 base west/left, base/below, base east/right,
32 south west/above right, south/below, south east/above left,
33 text/left, 10/right, 130/above}
34 \draw[node font=\scriptsize, shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
35 node[\placement] {\texttt{(s.\anchor)}};
36 \draw (s.ext_corner north west) rectangle (s.ext_corner south east);
37 \foreach \anchor/\placement in {
38 corner north west/above, corner north east/above,
39 corner south west/below, corner south east/below}
40 \draw[node font=\scriptsize, red, shift=(s.ext_\anchor)] plot[mark=x] coordinates{(0,0)}
41 node[\placement] {\texttt{(s.ext\textunderscore\anchor)}};
42 \end{tikzpicture}
43 \end{codeexample}
44
45 \clearpage
46 \subsection{Useful placement keys for vertical and horizontal alignment}
47 \begin{multicols}{2}
48 \begin{keylist}[/\tikzext]{%
49 left=\opt{\meta{specification}} (default 0pt),
50 right=\opt{\meta{specification}} (default 0pt),
51 above=\opt{\meta{specification}} (default 0pt),
52 below=\opt{\meta{specification}} (default 0pt),
53 above left=\opt{\meta{specification}} (default 0pt),
54 below left=\opt{\meta{specification}} (default 0pt),
55 above right=\opt{\meta{specification}} (default 0pt),
56 below right=\opt{\meta{specification}} (default 0pt),
57 mid left=\opt{\meta{specification}} (default 0pt),
58 mid right=\opt{\meta{specification}} (default 0pt),
59 base left=\opt{\meta{specification}} (default 0pt),
60 base right=\opt{\meta{specification}} (default 0pt)%
61 }
62 While the \meta{specification} of all these keys still accept the same form as with \tikzname,
63 the |ext.positioning-plus| library extends this even more.
64
65 The specification after |of| can contain a list of coordinates (like the |fit| key of the |fit| library).
66 This means that the new node will be placed in relation to a rectangular bounding box
67 that fits around all this nodes in the list.
68
69 If this list is prefixed with \verb!|!, |-| or |+|,
70 the new node will also have the same height (\verb!|!),
71 the same width (|-|) or both as this bounding box.
72
73 \begin{codeexample}[preamble=\usetikzlibrary{ext.positioning-plus}, width=.3\linewidth]
74 \begin{tikzpicture}[nodes=draw]
75 \node (A) {A} node[below=of A] (BCD) {BCD};
76 \node[ext/right= of |(A)(BCD)] (c) {};
77 \node[ext/below=.5:of -(A)(BCD)] (d) {};
78 \draw[help lines] (BCD.south west) -- (c.south east)
79 (BCD.north east) -- (d.south east);
80 \end{tikzpicture}
81 \end{codeexample}
82
83 As you maybe noticed in the example above, the \meta{specification} also allows a prefix
84 delimited by |:| which the |node distance| will be multiplied to with for the placement.%
85 \footnote{This is probably more useful when \referenceKeyandIndexO{on grid} is used.}
86 \end{keylist}
87
88 \newcolumn
89 The |fit|ting functionality is also available without the placement.
90 \begin{keylist}[/\tikzext]{%
91 fit bounding box=\meta{list of coordinates},
92 span vertical=\meta{list of coordinates},
93 span horizontal=\meta{list of coordinates},
94 span=\meta{list of coordinates}}
95 These all create a rectangular node with the name |ext_fit bounding box|
96 that encompasses the \meta{list of coordinates}.
97
98 The |span vertical| key will also set \referenceKeyandIndexO[/pgf/]{minimum height}
99 to the height of this bounding box
100
101 The |span horizontal| key will also set \referenceKeyandIndexO[/pgf/]{minimum width}
102 to the width of this bounding box
103
104 The last one combines |span vertical| and |span horizontal|.
105 \end{keylist}
106
107 \begin{keylist}[/\tikzext]{%
108 north left=\opt{\meta{specification}} (default 0pt),
109 south left=\opt{\meta{specification}} (default 0pt),
110 north right=\opt{\meta{specification}} (default 0pt),
111 south right=\opt{\meta{specification}} (default 0pt),
112 west above=\opt{\meta{specification}} (default 0pt),
113 west below=\opt{\meta{specification}} (default 0pt),
114 east above=\opt{\meta{specification}} (default 0pt),
115 east below=\opt{\meta{specification}} (default 0pt)%
116 }
117 These work similarly to |left|, |right|, |above| and |below|
118 but they are north- or south-aligned.
119
120 \begin{codeexample}[preamble=\usetikzlibrary{ext.positioning-plus}]
121 \begin{tikzpicture}[nodes=draw]
122 \node[minimum height=2cm] (a) {};
123 \node[minimum height=3cm, ext/north right=of a] {};
124 \end{tikzpicture}
125 \end{codeexample}
126 \end{keylist}
127
128 The same exist for the recently introduces corner anchors, too.
129 \begin{keylist}[/\tikzext]{%
130 corner above left=\opt{\meta{specification}} (default 0pt),
131 corner below left=\opt{\meta{specification}} (default 0pt),
132 corner above right=\opt{\meta{specification}} (default 0pt),
133 corner below right=\opt{\meta{specification}} (default 0pt),
134 corner north left=\opt{\meta{specification}} (default 0pt),
135 corner south left=\opt{\meta{specification}} (default 0pt),
136 corner north right=\opt{\meta{specification}} (default 0pt),
137 corner south right=\opt{\meta{specification}} (default 0pt),
138 corner west above=\opt{\meta{specification}} (default 0pt),
139 corner west below=\opt{\meta{specification}} (default 0pt),
140 corner east above=\opt{\meta{specification}} (default 0pt),
141 corner east below=\opt{\meta{specification}} (default 0pt)%
142 }
143 These work the same as |above left|, |below left|, \dots\
144 but they use the new generic corner anchors
145 \end{keylist}
146 \end{multicols}
147 \endinput
148
149
150
151
152
153