summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/tikz-ext/doc/tikz-ext-manual-en-library-node-families.tex
blob: 04ebb7c7a0ce46ee64f71c33b6b02c1e782488d2 (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
% !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.
%
\section{Node Families}
\begin{tikzlibrary}{ext.node-families}
  With this library the user can instruct multiple nodes to have the same
  width, height, text width, text height or text width.
  This uses the hook \referenceKeyandIndexO{execute at end picture} to write the nodes'
  measurements to the \filetype{aux} file.
  
  Unfortunately, this does not work with the |external| library.\indexLibraryO{external}%
  \footnote{Not only would the \texttt{external} library not notice the change of the value between compilations runs,
    it also changes the way \texttt{\textbackslash pgfutil@writeout} works which suddenly writes to the \textsc{log} file instead.}
\end{tikzlibrary}

This library introduces two new shapes called |Circle| and |Rectangle|
that are basically copies of the original shapes |circle|\indexShapeO{circle} and |rectangle|\indexShapeO{rectangle}.
However, their dimension will be set to the same maximum |minimum width| and |minimum height|
when one of the following \meta{name}s are declared.
\begin{key}{/tikz/node family/width=\meta{name} (initially |\{\}|)}
Nodes with the same \meta{name} will have the same \referenceKeyandIndexO[/pgf/]{minimum width}.
An empty \meta{name} disables the evaluation by the library.
\begin{codeexample}[preamble=\usetikzlibrary{positioning,ext.node-families},/tikz/node distance=.5cm]
\tikzexternaldisable % ext.node-families does not work with active externalization
\begin{tikzpicture}[nodes={Rectangle, draw, node family/width=manual}]
\node (a) {Foo};
\node[below=of a] (b) {Foobar};
\end{tikzpicture}
\end{codeexample}
\end{key}
\begin{key}{/tikz/node family/height=\meta{name} (initially |\{\}|)}
Nodes with the same \meta{name} will have the same \referenceKeyandIndexO[/pgf/]{minimum height}.
An empty \meta{name} disables the evaluation by the library.
\end{key}
\begin{key}{/tikz/node family/size=\meta{name}}
Sets both |height| and |width|.
\end{key}

While |node family/width| and |node family/height| only work for the new shapes |Circle| and |Rectangle|,
the following keys~-- when setup, see below~-- work with every shape with one single node part.
Initially though, only |circle|, |rectangle|, |Circle| and |Rectangle| are set up that way.
\begin{key}{/tikz/node family/text height=\meta{name} (initially |\{\}|)}
Nodes with the same \meta{name} will have the same text height.
An empty \meta{name} disables the evaluation by the library.
\end{key}

\begin{key}{/tikz/node family/text depth=\meta{name} (initially |\{\}|)}
Nodes with the same \meta{name}  will have the same text depth.
An empty \meta{name} disables the evaluation by the library.
\end{key}

\begin{key}{/tikz/node family/text width=\meta{name} (initially |\{\}|)}
Nodes with the same \meta{name} will have the same text width.
An empty \meta{name} disables the evaluation by the library.
\end{key}

\begin{key}{/tikz/node family/text=\meta{name}}
Sets |text height|, |text depth| and |text width|.
\end{key}

Since the width of the node's content's box is setup much earlier,
the previous key only extends the width of that box which would make the text
seem as if it where aligned to the left.
With |text width family align| this can changed.
\begin{key}{/tikz/node family/text width align=\meta{alignment}(initially |center|)}
\meta{alignment} is one of |left|, |center| or |right|.

\begin{codeexample}[preamble=\usetikzlibrary{positioning,ext.node-families},/tikz/node distance=.5cm]
\tikzexternaldisable % ext.node-families does not work with active externalization
\begin{tikzpicture}[nodes={Rectangle, draw, node family={text width=manual, text width align=right}}]
\node (a) {Foo};
\node[below=of a] (b) {Foobar};
\end{tikzpicture}
\end{codeexample}
\end{key}

\begin{key}{/tikz/node family/prefix=\meta{prefix}(initially \expandafter|\string\pgfpictureid-|)}
The family names are prefixed with the value of |/tikz/node family/prefix|.
\end{key}

\begin{key}{/tikz/node family/setup shape=\meta{shape}}
This adds instructions to the \meta{shape}'s definition which
adjust the text box's dimensions according to the family.

This should be only used once per shape.
\end{key}
\begin{codeexample}[width=9cm,preamble=\usetikzlibrary{ext.node-families,shapes.geometric}]
\tikzexternaldisable % ext.node-families does not work with active externalization
\begin{tikzpicture}[node family/setup shape=diamond]
\foreach \cnt[count=\Cnt] in {a,...,h}
  \node[draw, diamond, node family/text=aTOh] (\cnt)
    at (right:\Cnt) {\cnt};
\draw[help lines] (a.south) -- (h.south) (a.north) -- (h.north) (a.base-|a.west) -- (h.base-|h.east);
\end{tikzpicture}
\end{codeexample}
\endinput