summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-shapes.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-shapes.tex')
-rw-r--r--Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-shapes.tex688
1 files changed, 651 insertions, 37 deletions
diff --git a/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-shapes.tex b/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-shapes.tex
index 4655e63c9a9..6fa844a8875 100644
--- a/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-shapes.tex
+++ b/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-shapes.tex
@@ -1,24 +1,60 @@
-% Copyright 2005 by Till Tantau <tantau@cs.tu-berlin.de>.
+% Copyright 2006 by Till Tantau
%
-% This program can be redistributed and/or modified under the terms
-% of the LaTeX Project Public License Distributed from CTAN
-% archives in directory macros/latex/base/lppl.txt.
-
+% This file may be distributed and/or modified
+%
+% 1. under the LaTeX Project Public License and/or
+% 2. under the GNU Free Documentation License.
+%
+% See the file doc/generic/pgf/licenses/LICENSE for more details.
-\section{Nodes}
+\section{Nodes and Edges}
\label{section-nodes}
+\subsection{Overview}
+
+In the present section, the usage of \emph{nodes} in
+\tikzname\ is explained. A node is typically a rectangle or circle or
+another simple shape with some text on it.
+
+Nodes are added to paths using the special path
+operation |node|. Nodes \emph{are not part of the path
+ itself}. Rather, they are added to the picture after the path has
+been drawn.
+
+In Section~\ref{section-nodes-basic} the basic syntax of the node
+operation is explained, followed in Section~\ref{section-nodes-multi}
+by the syntax for multi-part nodes, which are nodes that contain
+several different text parts. After this, the different options for
+the text in nodes are explained. In
+Section~\ref{section-nodes-anchors} the concept of \emph{anchors} is
+introduced along with their usage. In
+Section~\ref{section-nodes-transformations} the different ways
+transformations affect nodes are
+studied. Sections~\ref{section-nodes-placing-1}
+and~\ref{section-nodes-placing-2} are about placing nodes on or next
+to straight lines and curves. In
+Section~\ref{section-nodes-connecting} it is explained how a node can
+be used as a ``pseudo-coordinate.'' Section~\ref{section-nodes-edges}
+introduces the |edge| operation, which
+works similar to the |to| operation and also similar to the |node|
+operation. Section~\ref{section-nodes-predefined} lists the predefined
+shapes. Finally, Section~\ref{section-nodes-executing} explains the
+special |after node path| options.
+
+
\subsection{Nodes and Their Shapes}
-\tikzname\ offers an easy way of adding so-called \emph{nodes} to your
-pictures. In the simplest case, a node is just some text that is
+\label{section-nodes-basic}
+
+In the simplest case, a node is just some text that is
placed at some coordinate. However, a node can also have a border
drawn around it or have a more complex background and
foreground. Indeed, some nodes do not have a text at all, but consist
solely of the background. You can name nodes so that you can reference
-their coordinates later in the picture. However, \emph{nodes cannot be
- referenced across different pictures}.
+their coordinates later in the same picture or, if certain precautions
+are taken as explained in Section~\ref{section-cross-picture-tikz},
+also in different pictures.
There are no special \TeX\ commands for adding a node to a picture; rather,
there is path operation called |node| for this. Nodes are created
@@ -66,6 +102,9 @@ The syntax for specifying nodes is the following:
|y_1|. Your node name should \emph{not} contain any punctuation like
a dot, a comma, or a colon since these are used to detect what kind
of coordinate you mean when you reference a node.
+
+ \itemoption{at}|=|\meta{coordinate}
+ is another way of specifying ath |at| coordinate.
\end{itemize}
The \meta{options} is an optional list of options that \emph{apply
@@ -99,10 +138,9 @@ The syntax for specifying nodes is the following:
\end{codeexample}
In the future, there might be much more complicated shapes available
- such as, say, a shape for a resistor or a shape for a state of a
- finite automaton or a shape for a \textsc{uml} class. Unfortunately,
- creating new shapes is a bit tricky and makes it necessary to use the
- basic layer directly. Life is hard.
+ such as, say, a shape for a resistor or a shape for a \textsc{uml}
+ class. Unfortunately, creating new shapes is a bit tricky and makes
+ it necessary to use the basic layer directly. Life is hard.
To select the shape of a node, the following option is used:
\begin{itemize}
@@ -163,6 +201,8 @@ The is a special syntax for specifying ``light-weighed'' nodes:
\subsection{Multi-Part Nodes}
+\label{section-nodes-multi}
+
Most nodes just have a single simple text label. However, nodes of a
more complicated shapes might be made up from several \emph{node
parts}. For example, in automata theory a so-called Moore state has
@@ -188,12 +228,12 @@ different node parts by using the following command:
\begin{codeexample}[]
\begin{tikzpicture}
- \node [state with output,draw,double,fill=red!20]
+ \node [circle split,draw,double,fill=red!20]
{
% No \nodepart has been used, yet. So, the following is put in the
% ``text'' node part by default.
$q_1$
- \nodepart{output} % Ok, end ``text'' part, start ``output'' part
+ \nodepart{lower} % Ok, end ``text'' part, start ``output'' part
$00$
}; % output part ended.
\end{tikzpicture}
@@ -207,8 +247,8 @@ different node parts by using the following command:
This style is installed at the beginning of every node part named
\meta{part name}.
\begin{codeexample}[]
-\tikzstyle{every output node part}=[red]
-\tikz \node [state with output,draw] {$q_1$ \nodepart{output} $00$};
+\tikzstyle{every lower node part}=[red]
+\tikz \node [circle split,draw] {$q_1$ \nodepart{lower} $00$};
\end{codeexample}
\end{itemize}
\end{command}
@@ -217,6 +257,8 @@ different node parts by using the following command:
\subsection{Options for the Text in Nodes}
+\label{section-nodes-options}
+
The simplest option for the text in nodes is its color. Normally, this
color is just the last color installed using |color=|, possibly
inherited from another scope. However, it is possible to specificly
@@ -266,9 +308,8 @@ following option for this:
\begin{codeexample}[]
\tikzstyle{every text node part}=[font=\itshape]
-\tikzstyle{every output node part}=[font=\footnotesize]
-\tikzstyle{every state with output node}=[draw]
-\tikz \node [state with output] {state \nodepart{output} output};
+\tikzstyle{every lower node part}=[font=\footnotesize]
+\tikz \node [circle split,draw] {state \nodepart{lower} output};
\end{codeexample}
\end{itemize}
@@ -343,10 +384,46 @@ height).
\end{codeexample}
\end{itemize}
+In addition to changing the width of nodes, you can also change the
+height of nodes. This can be done in two ways: First, you can use the
+option |minimum height|, which ensures that the height of the whole
+node is at least the given height (this option is described in more
+detail later). Second, you can use the option |text height|, which
+sets the height of the text itself, more precisely, of the \TeX\ text
+box of the text. Note that the |text height| typically is not the
+height of the shape's box: In addition to the |text height|, an
+internal |inner sep| is added as extra space and the text depth is
+also taken into account.
+
+I recommend using |minimum size| instead of |text height| except for
+special situations.
+
+\begin{itemize}
+ \itemoption{text height}|=|\meta{dimension}
+ Sets the height of the text boxes in shapes. Thus, when you write
+ something like |node {text}|, the |text| is first typeset, resulting
+ in some box of a certain height. This height is then replaced by the
+ height |text height|. The resulting box is then used to determine
+ the size of the shape, which will typically be larger. When you
+ write |text height=| without specifying anything, the ``natural''
+ size of the text box remains unchanged.
+\begin{codeexample}[]
+\tikz \node[draw] {y};
+\tikz \node[draw,text height=10pt] {y};
+\end{codeexample}
+ \itemoption{text depth}|=|\meta{dimension}
+ This option works like |text height|, only for the depth of the text
+ box. This option is mostly useful when you need to ensure a uniform
+ depth of text boxes that need to be aligned.
+\end{itemize}
+
+
\subsection{Placing Nodes Using Anchors}
+\label{section-nodes-anchors}
+
When you place a node at some coordinate, the node is centered on this
coordinate by default. This is often undesirable and it would be
better to have the node to the right or above the actual coordinate.
@@ -461,9 +538,48 @@ more intuitively:
does the same as |anchor=north west|.
\end{itemize}
+A second set of options behaves similarly, namely the |above of|,
+|below of|, and so on options. They cause the same anchors to be set
+as the options without |of|, however, their parameter is different:
+You must provide the name of another node. The current node will then
+be placed, say, above this specified node at a distance given by the
+option |node distance|.
+\begin{itemize}
+ \itemoption{above of}\opt{|=|\meta{node}}
+ This option causes the node to be placed at the distance
+ |node distance| above of \meta{node}. The anchor is |center|.
+\begin{codeexample}[]
+\begin{tikzpicture}[node distance=1cm]
+ \draw[help lines] (0,0) grid (3,2);
+ \node (a) {a};
+ \node (b) [above of=a] {b};
+ \node (c) [above of=b] {c};
+ \node (d) [right of=c] {d};
+ \node (e) [below right of=d] {e};
+\end{tikzpicture}
+\end{codeexample}
+ \itemoption{above left of}\opt{|=|\meta{node}}
+ Works like |above of|, only the node is now put above and left. The
+ |node distance| is the Euclidean distance between the two nodes, not
+ the $L_1$-distance.
+ \itemoption{above right of}\opt{|=|\meta{node}} works similarly.
+ \itemoption{left of}\opt{|=|\meta{node}} works similarly.
+ \itemoption{right of}\opt{|=|\meta{node}} works similarly.
+ \itemoption{below of}\opt{|=|\meta{node}} works similarly.
+ \itemoption{below left of}\opt{|=|\meta{node}} works similarly.
+ \itemoption{below right of}\opt{|=|\meta{node}} works similarly.
+ \itemoption{node distance}\opt{|=|\meta{dimension}} sets the
+ distance between nodes that are placed using the |... of|
+ options. Note that this distance is the distance between the
+ centers of the nodes, not the distance between their borders.
+\end{itemize}
+
\subsection{Transformations}
+\label{section-nodes-transformations}
+
+
It is possible to transform nodes, but, by default, transformations do
not apply to nodes. The reason is that you usually do \emph{not} want
your text to be scaled or rotated even if the main graphic is
@@ -502,7 +618,10 @@ example, it certainly sometimes makes sense to rotate a node by
-\subsection{Placing Nodes on a Line or Curve}
+
+\subsection{Placing Nodes on a Line or Curve Explicitly}
+
+\label{section-nodes-placing-1}
Until now, we always placed node on a coordinate that is mentioned in
the path. Often, however, we wish to place nodes on ``the middle'' of
@@ -513,10 +632,6 @@ specifying this: Either explicitly by using the |pos| option or
implicitly by placing the node ``inside'' a path operation. These two
ways are described in the following.
-
-
-\subsubsection{Explicit Use of the Position Option}
-
\label{section-pos-option}
\begin{itemize}
@@ -572,11 +687,78 @@ ways are described in the following.
For all other path construction operations, \emph{the position
placement does not work}, currently. This will hopefully change in
the future (especially for the arc operation).
+
+ \itemoption{auto}\opt{|=|\meta{direction}}
+ This option causes an anchor positions to be calculated
+ automatically according to the following rule. Consider a line
+ between to points. If the \meta{direction} is |left|, then the
+ anchor is chosen such that the node is to the left of this line. If
+ the \meta{direction} is |right|, then the node is to the right of
+ this line. Leaving out \meta{direction} causes automatic placement
+ to be enabled with the last value of |left| or |right| used. A
+ \meta{direction} of |false| disables automatic placement. This
+ happens also whenever an anchor is given explicitly by the
+ |anchor| option or by one of the |above|, |below|, etc.\ options.
+
+ This option only has an effect for nodes that are placed on lines or
+ curves.
+
+\begin{codeexample}[]
+\begin{tikzpicture}[scale=.8,auto=left]
+ \tikzstyle{every node}=[circle,fill=blue!20]
+ \node (a) at (-1,-2) {a};
+ \node (b) at ( 1,-2) {b};
+ \node (c) at ( 2,-1) {c};
+ \node (d) at ( 2, 1) {d};
+ \node (e) at ( 1, 2) {e};
+ \node (f) at (-1, 2) {f};
+ \node (g) at (-2, 1) {g};
+ \node (h) at (-2,-1) {h};
+
+ \tikzstyle{every node}=[fill=red!20]
+ \foreach \from/\to in {a/b,b/c,c/d,d/e,e/f,f/g,g/h,h/a}
+ \draw [->] (\from) -- (\to) node[midway] {\from--\to};
+\end{tikzpicture}
+\end{codeexample}
+ \itemoption{swap}
+ This option exchanges the roles of |left| and |right| in automatic
+ placement. That is, if |left| is the current |auto| placement,
+ |right| is set instead and the other way round.
+\begin{codeexample}[]
+\begin{tikzpicture}[auto]
+ \draw[help lines,use as bounding box] (0,-.5) grid (4,5);
+
+ \draw (0.5,0) .. controls (9,6) and (-5,6) .. (3.5,0)
+ \foreach \pos in {0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1}
+ {node [pos=\pos,swap,fill=red!20] {\pos}}
+ \foreach \pos in {0.025,0.2,0.4,0.6,0.8,0.975}
+ {node [pos=\pos,fill=blue!20] {\pos}};
+\end{tikzpicture}
+\end{codeexample}
+\begin{codeexample}[]
+\begin{tikzpicture}[shorten >=1pt,node distance=2cm,auto]
+ \draw[help lines] (0,0) grid (3,2);
+
+ \node[state] (q_0) {$q_0$};
+ \node[state] (q_1) [above right of=q_0] {$q_1$};
+ \node[state] (q_2) [below right of=q_0] {$q_2$};
+ \node[state] (q_3) [below right of=q_1] {$q_3$};
+
+ \path[->] (q_0) edge node {0} (q_1)
+ edge node [swap] {1} (q_2)
+ (q_1) edge node {1} (q_3)
+ edge [loop above] node {0} ()
+ (q_2) edge node [swap] {0} (q_3)
+ edge [loop below] node {1} ();
+\end{tikzpicture}
+\end{codeexample}
+
\itemoption{sloped}
This option causes the node to be rotated such that a horizontal
- line becomes a tangent to the curve. The rotation will always be
- done in such a way that text is never ``upside down.'' If you really
- need upside down text, use |[rotate=180]|.
+ line becomes a tangent to the curve. The rotation is normally
+ done in such a way that text is never ``upside down.'' To get
+ upside-down text, use can use |[rotate=180]| or
+ |[allow upside down]|, see below.
\begin{codeexample}[]
\tikz \draw (0,0) .. controls +(up:2cm) and +(left:2cm) .. (1,3)
\foreach \p in {0,0.25,...,1} {node[sloped,above,pos=\p]{\p}};
@@ -587,6 +769,19 @@ ways are described in the following.
\draw (2,-.5) -- (0,0) node[midway,sloped,below] {$y$};
\end{tikzpicture}
\end{codeexample}
+ \itemoption{allow upside down}\opt{|=|\meta{true or false}}
+ If set to |true|, \tikzname\ will not ``righten'' upside down text.
+\begin{codeexample}[]
+\tikz [allow upside down]
+ \draw (0,0) .. controls +(up:2cm) and +(left:2cm) .. (1,3)
+ \foreach \p in {0,0.25,...,1} {node[sloped,above,pos=\p]{\p}};
+\end{codeexample}
+\begin{codeexample}[]
+\begin{tikzpicture}[->,allow upside down]
+ \draw (0,0) -- (2,0.5) node[midway,sloped,above] {$x$};
+ \draw (2,-.5) -- (0,0) node[midway,sloped,below] {$y$};
+\end{tikzpicture}
+\end{codeexample}
\end{itemize}
@@ -619,7 +814,9 @@ There exist styles for specifying positions a bit less ``technically'':
\end{itemize}
-\subsubsection{Implicit Use of the Position Option}
+\subsection{Placing Nodes on a Line or Curve Implicitly}
+
+\label{section-nodes-placing-2}
When you wish to place a node on the line |(0,0) -- (1,1)|,
it is natural to specify the node not following the |(1,1)|, but
@@ -668,7 +865,127 @@ the |--| operation, these will be collected and then reinserted after
the operation with the |pos| option set.
-\subsection{Connecting Nodes}
+\subsection{The Label and Pin Options}
+
+In addition to the |node| path operation, nodes can also be added
+using the |label| and the |pin| option. This is mostly useful
+for simple nodes.
+
+\begin{itemize}
+ \itemoption{label}|=|\opt{|[|\meta{options}|]|}\meta{angle}|:|\meta{text}
+ When this option is given to a |node| operation, it causes
+ \emph{another} node to be added to the path after the current node
+ has been finished. This extra node will have the text
+ \meta{text}. It is placed according to the following rule: Suppose
+ the |node| currently under construction is called |main node| and let us
+ call the label node |label node|. Then the anchor of |label node| is
+ placed at |main node.|\meta{angle}. The anchor that is chosen
+ depends on the \meta{angle}. If the \meta{angle} lies between
+ $-3^\circ$ and $+3^\circ$, then the anchor |west| is chosen, which
+ causes |label node| to be placed right of the right end
+ |main node|. If \meta{angle} lies between $4^\circ$ and $86^\circ$,
+ the anchor |south west| is chosen, causing the |label node| to be
+ placed above and right of the |main node|; and so on.
+\begin{codeexample}[]
+\tikz
+ \node [circle,draw,label=60:$60^\circ$,label=below:$-90^\circ$] {my circle};
+\end{codeexample}
+
+ As can be seen in the above example, instead of specifying
+ \meta{angle} as a number, it is also possible to use |left|,
+ |right|, |above|, |above left|, and so on.
+
+ You can pass \meta{options} to the node |label node|. For this, you
+ provide the options in square brackets before the \meta{angle}. If you
+ do so, you need to add braces around the whole argument of the
+ |label| option and this is also the case if you have brackets or
+ commas or semicolons or anything special in the \meta{text}.
+\begin{codeexample}[]
+\tikz \node [circle,draw,label={[red]above:X}] {my circle};
+\end{codeexample}
+
+\begin{codeexample}[]
+\begin{tikzpicture}
+ \node [circle,draw,label={[name=label node]above left:$a,b$}] {};
+ \draw (label node) -- +(1,1);
+\end{tikzpicture}
+\end{codeexample}
+
+ If you provide multiple |label| options, then multiple extra label
+ nodes are added in the order they are given.
+
+ The following styles influence how labels are drawn:
+ \begin{itemize}
+ \itemoption{label distance}|=|\meta{distance}
+ The \meta{distance} is additionally inserted between the main node
+ and the label node. The default is |0pt|.
+\begin{codeexample}[]
+\tikz[label distance=5mm]
+ \node [circle,draw,label=right:X,
+ label=above right:Y,
+ label=above:Z] {my circle};
+\end{codeexample}
+ \itemstyle{every label}
+ This style is used in every node created by the |label|
+ option. The default is |draw=none,fill=none|.
+ \end{itemize}
+ \itemoption{pin}|=|\opt{|[|\meta{options}|]|}\meta{angle}|:|\meta{text}
+ This is option is quite similar to the |label| option, but there is
+ one difference: In addition to adding a extra node to the picture,
+ it also adds an edge from this node to the main node. This causes
+ the node to look like a pin that has been added to the main node:
+\begin{codeexample}[]
+\tikz \node [circle,fill=blue!50,minimum size=1cm,pin=60:$q_0$] {};
+\end{codeexample}
+
+ The meaning of the \meta{options} and the \meta{angle} and the
+ \meta{text} is exactly the same as for the |node| option. Only, the
+ options and styles the influence the way pins look are different:
+ \begin{itemize}
+ \itemoption{pin distance}|=|\meta{distance}
+ This \meta{distance} is used instead of the |label distance| for
+ the distance between the main node and the label node. The default
+ is |3ex|.
+\begin{codeexample}[]
+\tikz[pin distance=1cm]
+ \node [circle,draw,pin=right:X,
+ pin=above right:Y,
+ pin=above:Z] {my circle};
+\end{codeexample}
+ \itemstyle{every pin}
+ This style is used in every node created by the |pin|
+ option. The default is |draw=none,fill=none|.
+ \itemstyle{every pin edge}
+ This style is used in every edge created by the |pin| optins. The
+ default is |help lines|.
+\begin{codeexample}[]
+\tikzstyle{every pin edge}=[<-,shorten <=1pt,snake=snake,line before snake=4pt]
+\tikz[pin distance=15mm]
+ \node [circle,draw,pin=right:X,
+ pin=above right:Y,
+ pin=above:Z] {my circle};
+\end{codeexample}
+ \itemoption{pin edge}|=|\meta{options}
+ This option can be used to set the options that are to be used
+ in the edge created by the |pin| option. The default is empty.
+\begin{codeexample}[]
+\tikz[pin distance=10mm]
+ \node [circle,draw,pin={[pin edge={blue,thick}]right:X},
+ pin=above:Z] {my circle};
+\end{codeexample}
+\begin{codeexample}[]
+\tikzstyle{every pin edge}=[]
+\tikzstyle{initial}=[pin={[pin distance=5mm,
+ pin edge={<-,shorten <=1pt}]left:start}]
+\tikz \node [circle,draw,initial] {my circle};
+\end{codeexample}
+ \end{itemize}
+\end{itemize}
+
+
+\subsection{Connecting Nodes: Using Nodes as Coordinates}
+
+\label{section-nodes-connecting}
Once you have defined a node and given it a name, you can use this
name to reference it. This can be done in two ways, see also
@@ -716,8 +1033,262 @@ Section~\ref{section-node-coordinates}. Suppose you have said
+\subsection{Connecting Nodes: Using the Edge Operation}
+
+\label{section-nodes-edges}
+
+The |edge| operation works like a |to| operation that is added after
+the main path has been drawn, much like a node is added after the main
+path has been drawn. This allows you to have each |edge| to have a
+different appearance. As the |node| operation, an |edge| temporarily
+suspends the construction of the current path and a new path $p$ is
+constructed. This new path $p$ will be drawn after the main path has
+been drawn. Note that $p$ can be totally different from the main
+path with respect to its options. Also note that if there are
+several |to| and/or |node| operations in the main path, each
+creates its own path(s) and they are drawn in the order that they
+are encountered on the path.
+
+\begin{pathoperation}{edge}{\opt{|[|\meta{options}|]|}
+ \opt{\meta{nodes}} |(|\meta{coordinate}|)|}
+ The effect of the |edge| operation is that after the main path the
+ following path is added to the picture:
+ \begin{quote}
+ |\path[every edge,|\meta{options}|] (\tikztostart) |\meta{path}|;|
+ \end{quote}
+ Here, \meta{path} is the |to path|. Note that, unlike the path added
+ by the |to| operation, the |(\tikztostart)| is added before the
+ \meta{path} (which is unnecessary for the |to| operation, since this
+ coordinate is already part of the main path).
+
+ The |\tikztostart| is the last coordinate on the path just before
+ the |edge| operation, just as for the |node| or |to| operations.
+ However, there is one exception to this rule: If the |edge|
+ operation is directly preceded by a |node| operation, then this
+ just-declared node is the start coordinate (and not, as would
+ normally be the case, the coordinate where this just-declared node
+ is placed -- a small, but subtle difference). In this regard, |edge|
+ differs from both |node| and |to|.
+
+ If there are several |edge| operations in a row, the start coordinate
+ is the same for all of them as their target coordiantes are not,
+ after all, part of the main path. The start coordinate is, thus, the
+ coordinate preceding the first |edge| operation. This is
+ similar to nodes insofar as the |edge| operation does not modify the
+ current path at all. In particular, it does not change the last
+ coordinate visited, see the following example:
+
+\begin{codeexample}[]
+\begin{tikzpicture}
+ \node (a) at (0:1) {$a$};
+ \node (b) at (90:1) {$b$} edge [->] (a);
+ \node (c) at (180:1) {$c$} edge [->] (a)
+ edge [<-] (b);
+ \node (d) at (270:1) {$d$} edge [->] (a)
+ edge [dotted] (b)
+ edge [<-] (c);
+\end{tikzpicture}
+\end{codeexample}
+
+ A different way of specifying the above graph using the |edge|
+ operation is the following:
+
+\begin{codeexample}[]
+\begin{tikzpicture}
+ \foreach \name/\angle in {a/0,b/90,c/180,d/270}
+ \node (\name) at (\angle:1) {$\name$};
+
+ \path[->] (b) edge (a)
+ edge (c)
+ edge [-,dotted] (d)
+ (c) edge (a)
+ edge (d)
+ (d) edge (a);
+\end{tikzpicture}
+\end{codeexample}
+
+ As can be seen, the path of the |edge| operation inherits the
+ options from the main path, but you can locally overrule them.
+
+\begin{codeexample}[]
+\begin{tikzpicture}
+ \foreach \name/\angle in {a/0,b/90,c/180,d/270}
+ \node (\name) at (\angle:1.5) {$\name$};
+
+ \path[->] (b) edge node[above right] {$5$} (a)
+ edge (c)
+ edge [-,dotted] node[below,sloped] {missing} (d)
+ (c) edge (a)
+ edge (d)
+ (d) edge [red] node[above,sloped] {very}
+ node[below,sloped] {bad} (a);
+\end{tikzpicture}
+\end{codeexample}
+
+ Instead of |every to|, the style |every edge| is installed at the
+ beginning of the main path.
+ \begin{itemize}
+ \itemstyle{every edge} this is is |draw| by default.
+\begin{codeexample}[]
+\begin{tikzpicture}
+ \tikzstyle{every to}=[draw,dashed]
+ \path (0,0) to (3,2);
+\end{tikzpicture}
+\end{codeexample}
+ \end{itemize}
+\end{pathoperation}
+
+
+\subsection{Referencing Nodes Outside the Current Pictures}
+
+\label{section-cross-picture-tikz}
+
+\subsubsection{Referencing a Node in a Different Picture}
+
+It is possible (but not quite trivial) to reference nodes in pictures
+other than the current one. This means that you can create a picture
+and a node therein and, later, you can draw a line from some other
+position to this node.
+
+To reference nodes in different pictures, proceed as follows:
+\begin{enumerate}
+\item You need to add the |remember picture| option to all pictures
+ that contain nodes that you wish to reference and also to all
+ pictures from which you wish to reference a node in another
+ picture.
+\item You need to add the |overlay| option to paths or to whole
+ pictures that contain references to nodes in different
+ pictures. (This option switches the computation of the
+ bounding box off.)
+\item You need to use a driver that supports picture remembering
+ (currently, this is only pdf\TeX). With the pdf\TeX\ driver you also
+ need to run \TeX\ twice.
+\end{enumerate}
+(For more details on what is going on behind the scenes, see
+Section~\ref{section-cross-pictures-pgf}.)
+
+Let us have a look at the effect of these options.
+\begin{itemize}
+ \itemoption{remember picture}\opt{|=|\meta{true or false}} This option
+ tells \tikzname\ that it should attempt to remember the position of
+ the current picture on the page. This attempt may fail depending on
+ which backend driver is used. Also, even if remembering works, the
+ position may only be available on a second run of \TeX.
+
+ Provided that remebering works, you may consider saying
+\begin{codeexample}[code only]
+\tikzsytle{every picture}+=[remember picture]
+\end{codeexample}
+ to make \tikzname\ remember all pictures. This will add one line in
+ the |.aux| file for each picture in your document -- which typically
+ is not very much. Then, you do not have to worry about remembered
+ pictures at all.
+ \itemoption{overlay}
+ This option is mainly intended for use when nodes in other pictures
+ are referenced, but you can also use it in other situations. The
+ effect of this option is that everything within the current scope is
+ not taken into consideration when the bounding box of the current
+ picture is computed.
+
+ You need to specify this option on all paths (or at least on all
+ parts of paths) that contain a reference to a node in another
+ picture. The reason is that, otherwise, \tikzname\ will attempt to
+ make the current picture large enough to encompass \emph{the node in
+ the other picture}. However, on a second run of \TeX\ this will
+ create an even bigger picture, leading to larger and larger
+ pictures. Unless you know what you are doing, I suggest specifying
+ the |overlay| option with all pictures that contain references to
+ other pictures.
+\end{itemize}
+
+Let us now have a look at a few examples. These examples work only if
+this document is processed with a driver that supports picture
+remembering.
+
+\noindent\begin{minipage}{\textwidth}
+Inside the current text we place two pictures, containing nodes named
+|n1| and |n2|, using
+\begin{codeexample}[code only]
+\tikz[remember picture] \node[circle,fill=red!50] (n1) {};
+\end{codeexample}
+which yields \tikz[remember picture] \node[circle,fill=red!50] (n1)
+{};, and
+\begin{codeexample}[code only]
+\tikz[remember picture] \node[fill=blue!50] (n2) {};
+\end{codeexample}
+yielding the node \tikz[remember picture] \node[fill=blue!50] (n2)
+{};. To connect these nodes, we create another picture using the
+|overlay| option and also the |remember picture| option.
+\begin{codeexample}[]
+\begin{tikzpicture}[remember picture,overlay]
+ \draw[->,very thick] (n1) -- (n2);
+\end{tikzpicture}
+\end{codeexample}
+Note that the last picture is seemingly empty. What happens is that it
+has zero size and contains an arrow that lies well outside its bounds.
+As a last example, we connect a node in another picture to the first
+two nodes. Here, we provide the |overlay| option only with the line
+that we do not wish to count as part of the picture.
+\begin{codeexample}[]
+\begin{tikzpicture}[remember picture]
+ \node (c) [circle,draw] {Big circle};
+
+ \draw [overlay,->,very thick,red,opacity=.5]
+ (c) to[bend left] (n1) (n1) -| (n2);
+\end{tikzpicture}
+\end{codeexample}
+\end{minipage}
+
+
+\subsubsection{Referencing the Current Page Node -- Absolute Positioning}
+
+There is a special node called |current page| that can be used to
+access the current page. It is a node of shape rectangle whose
+|south west| anchor is the lower left corner of the page and whose
+|north east| anchor is the upper right corner of the page. While this
+node is handled in a special way internally, you can reference it as
+if it were defined in some remembered picture other than the current
+one. Thus, by giving the |remembered picture| and the |overlay|
+options to a picture, you can position nodes \emph{absolutely} on a
+page.
+
+The first example places some text in the lower left corner of the
+current page:
+\begin{codeexample}[]
+\begin{tikzpicture}[remember picture,overlay]
+ \node [xshift=1cm,yshift=1cm] at (current page.south west)
+ [text width=7cm,fill=red!20,rounded corners,above right]
+ {
+ This is an absolutely positioned text in the
+ lower left corner. No shipout-hackery is used.
+ };
+\end{tikzpicture}
+\end{codeexample}
+
+The next example adds a circle in the middle of the page.
+\begin{codeexample}[]
+\begin{tikzpicture}[remember picture,overlay]
+ \draw [line width=1mm,opacity=.25]
+ (current page.center) circle (3cm);
+\end{tikzpicture}
+\end{codeexample}
+
+The final example overlays some text over the page (depending on where
+this example is found on the page, the text may also be behind the
+page).
+\begin{codeexample}[]
+\begin{tikzpicture}[remember picture,overlay]
+ \node [rotate=60,scale=10,text opacity=0.2]
+ at (current page.center) {Example};
+\end{tikzpicture}
+\end{codeexample}
+
+
\subsection{Predefined Shapes}
+
+\label{section-nodes-predefined}
+
\label{section-the-shapes}
\pgfname\ and \tikzname\ define three shapes, by default:
@@ -729,12 +1300,8 @@ Section~\ref{section-node-coordinates}. Suppose you have said
\item
|coordinate|.
\end{itemize}
-By loading library packages, you can define more shapes. Currently,
-the package |pgflibraryshapes| defines
-\begin{itemize}
-\item
- |ellipse|.
-\end{itemize}
+By loading library packages, you can define more shapes like ellipses
+or diamonds; see the library section for the complete list of shapes.
The exact behaviour of these shapes differs, shapes defined for more
special purposes (like a, say, transistor shape) will have even more
@@ -817,6 +1384,16 @@ shapes:
\draw (0,-2) node[minimum size=2cm,draw,circle] {circle};
\end{tikzpicture}
\end{codeexample}
+
+ \itemoption{aspect}|=|\meta{aspect ratio}
+ sets a desired aspect ratio for the shape. For the |diamond| shape,
+ this option sets the ratio between width and height of the shape.
+\begin{codeexample}[]
+\begin{tikzpicture}
+ \draw (0,0) node[aspect=1,diamond,draw] {aspect 1};
+ \draw (0,-2) node[aspect=2,diamond,draw] {aspect 2};
+\end{tikzpicture}
+\end{codeexample}
\end{itemize}
\label{section-tikz-coordinate-shape}
@@ -843,6 +1420,43 @@ demonstrates the difference:
\end{codeexample}
+\subsection{Executing Code After Nodes}
+
+\label{section-nodes-executing}
+
+It is possible to add a path right after a node using the option
+|after node path|. The idea is that a style might use this option to
+add some additional stuff to the node that has just been typeset.
+
+\begin{itemize}
+ \itemoption{after node path}|=|\meta{path}
+ The \meta{path} is added to the main path right after the node, as
+ if you had given the path thereafter. This option can only be given
+ inside the option list of a node and multiple calls of this option
+ accumulate.
+
+ Inside the \meta{path} you have access to the node that has just
+ been created via the macro \declare{|\tikzlastnode|}.
+\begin{codeexample}[]
+\tikz
+ \draw node [draw,after node path={(\tikzlastnode) circle (2cm)}]
+ {hello};
+\end{codeexample}
+
+ Note that in the above example, if we had written |\path| instead of
+ |\draw|, the circle would not have been drawn since the circle is
+ part of the main path, not part of the node itself.
+\end{itemize}
+
+\begin{command}{\tikzaddafternodepathoption\marg{code}}
+ This command allows you to specify that the \meta{code} should be
+ executed at the beginning of the |after node path| of the current
+ node. The code will also be executed immediately, but also again at
+ the beginning of an |after node path|.
+\end{command}
+
+
+
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "pgfmanual"