diff options
author | Karl Berry <karl@freefriends.org> | 2015-08-08 22:54:29 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-08-08 22:54:29 +0000 |
commit | 531d43fafa269c546d587eaca6cd14adcd11914f (patch) | |
tree | 1883933af984c60254e6d9d1bd955a76748cb827 /Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-shapes.tex | |
parent | 877e963d44f039783cb9227d90c911866c780961 (diff) |
pgf (8aug15)
git-svn-id: svn://tug.org/texlive/trunk@38079 c570f23f-e606-0410-a88d-b1316a301751
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.tex | 106 |
1 files changed, 78 insertions, 28 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 e5fe70f35c7..612ca23d1c4 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 @@ -63,7 +63,7 @@ path where it would expect a normal path operation (like |-- (1,1)| or The node operation is typically followed by some options, which apply only to the node. Then, you can optionally \emph{name} the node by -providing a name in round braces. Lastly, for the |node| operation you +providing a name in parentheses. Lastly, for the |node| operation you must provide some label text for the node in curly braces, while for the |coordinate| operation you may not. The node is placed at the current position of the path either \emph{after the path has been @@ -80,7 +80,7 @@ encountered. \tikz \fill [fill=yellow!80!black] (0,0) node {first node} -- (1,1) node[behind path] {second node} - -- (0,2) node {third node}; + -- (2,0) node {third node}; \end{codeexample} \subsubsection{Syntax of the Node Command} @@ -116,7 +116,7 @@ The syntax for specifying nodes is the following: curly braces, you can also use the following key: \begin{key}{/tikz/node contents=\meta{node contents}} \label{option-node-contents}% - This key sets that contents of the node to the given text as if + This key sets the contents of the node to the given text as if you had given it at the end in curly braces. When the option is used inside the options of a node, the parsing of the node stops immediately after the end of the option block. In particular, the @@ -468,7 +468,7 @@ shapes: Specifies the inner separation in the $y$-direction, only. \end{key} -\begin{key}{/pgf/outer sep=\meta{dimension} (initially .5\string\pgflinewidth)} +\begin{key}{/pgf/outer sep=\meta{dimension or ``auto''}} \keyalias{tikz} This option adds an additional (invisible) separation space of \meta{dimension} outside the background path. The main effect of @@ -480,24 +480,63 @@ shapes: The default for this option is half the line width. When the default is used and when the background path is draw, the anchors will lie exactly on the ``outside border'' of the path (not on the path - itself). When the shape is filled, but not drawn, this may not be - desirable. In this case, the |outer sep| should be set to zero - points. + itself). \begin{codeexample}[] \begin{tikzpicture} \draw[line width=5pt] - (0,0) node[outer sep=0pt,fill=yellow!80!black] (f) {filled} - (2,0) node[inner sep=.5\pgflinewidth+2pt,draw] (d) {drawn}; + (0,0) node[fill=yellow!80!black] (f) {filled} + (2,0) node[draw] (d) {drawn} + (1,-2) node[draw,scale=2] (s) {scaled}; \draw[->] (1,-1) -- (f); \draw[->] (1,-1) -- (d); + \draw[->] (1,-1) -- (s); +\end{tikzpicture} +\end{codeexample} + + As the above example demonstrates, the standard settings for the + outer sep are not always ``correct.'' First, when a shape is filled, + but not drawn, the outer sep should actually be |0|. Second, when a + node is scaled, for instance by a factor of 5, the outer separation + also gets scaled by a factor of 5, while the line width stays at its + original width; again causing problems. + + In such cases, you can say |outer sep=auto| to make \tikzname\ + \emph{try} to compensate for the effects described above. This is + done by, firstly, setting the outer sep to |0| when no drawing is + done and, secondly, setting the outer separations to half the line + width (as before) times two adjustment factors, one for the + horizontal separations and one for the vertical + separations (see Section~\ref{section-adjustment-transformations} + for details on these factors). Note, however, that these factors can + compensate only for transformations that are either scalings plus + rotations or scalings with different magnitudes in the horizontal + and the vertical direction. If you apply slanting, the factors will + only approximate the correct values. + + In general, it is a good idea to say |outer sep=auto| at some early + stage. It is not the default mainly for compatibility with earlier + versions. +\begin{codeexample}[] +\begin{tikzpicture}[outer sep=auto] + \draw[line width=5pt] + (0,0) node[fill=yellow!80!black] (f) {filled} + (2,0) node[draw] (d) {drawn} + (1,-2) node[draw,scale=2] (s) {scaled}; + + \draw[->] (1,-1) -- (f); + \draw[->] (1,-1) -- (d); + \draw[->] (1,-1) -- (s); \end{tikzpicture} \end{codeexample} \end{key} + \begin{key}{/pgf/outer xsep=\meta{dimension} (initially .5\string\pgflinewidth)} \keyalias{tikz} - Specifies the outer separation in the $x$-direction, only. + Specifies the outer separation in the $x$-direction, only. This + value will be overwritten when |outer sep| is set, either to the + value given there or a computed value in case of |auto|. \end{key} \begin{key}{/pgf/outer ysep=\meta{dimension} (initially .5\string\pgflinewidth)} @@ -505,6 +544,7 @@ shapes: Specifies the outer separation in the $y$-direction, only. \end{key} + \begin{key}{/pgf/minimum height=\meta{dimension} (initially 0pt)} \keyalias{tikz} This option ensures that the height of the shape (including the @@ -799,7 +839,7 @@ lines of text. There are three different ways of achieving this: \item Inside the node, you can put some standard environment that produces multi-line, aligned text. For instance, you can use a |{tabular}| inside a node: -\begin{codeexample}[] +\begin{codeexample}[width=5cm] \tikz \node [draw] { \begin{tabular}{cc} upper left & upper right\\ @@ -934,7 +974,9 @@ Let us now first have a look at the |text width| command. you specify a large line width and the node text fits on a single line and is, in fact, much shorter than the specified |text width|, an underfull horizontal box will - result. Unfortunately, this cannot be avoided, due to the way \TeX\ works. + result. Unfortunately, this cannot be avoided, due to the way + \TeX\ works (more precisely, I have thought long and hard about this + and have not been able to figure out a sensible way to avoid this). For this reason, \tikzname\ switches off horizontal badness warnings inside boxes with |align=center|. Since this will also suppress some ``wanted'' warnings, there is also an option for @@ -1212,6 +1254,10 @@ more intuitively: Similar to |above left|. \end{key} +\begin{key}{/tikz/centered} + A shorthand for |anchor=center|. +\end{key} + % 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: @@ -1589,16 +1635,14 @@ keys: -\subsubsection{Arranging Nodes Using Chains and Matrices} +\subsubsection{Advanced Arrangements of Nodes} The simple |above| and |right| options may not always suffice for arranging a large number of nodes. For such situations \tikzname\ -offers two libraries that make positioning easier: The |chains| -library and the |matrix| library. The first is mostly useful for -creating ``chains of nodes'' and, more generally, ``flows.'' The -second allows you to arrange multiple nodes in rows and columns. These -methods for positioning nodes are described in two separate -Sections~\ref{section-matrices} and~\ref{section-chains}. +offers libraries that make positioning easier: The |graphdrawing| +library and the |matrix| library. These libraries for positioning +nodes are described in two separate Sections~\ref{section-matrices} +and~\ref{section-intro-gd}. \subsection{Fitting Nodes to a Set of Coordinates} @@ -1646,10 +1690,10 @@ on a background layer. child { node (e) {e} } } child { node (c) {c} }; - \begin{pgfonlayer}{background} + \begin{scope}[on background layer] \node[fill=red!20,inner sep=0pt,ellipse,fit=(root) (b) (d) (e)] {}; \node[fill=blue!20,inner sep=0pt,ellipse,fit=(b) (c) (e)] {}; - \end{pgfonlayer} + \end{scope} \end{tikzpicture} \end{codeexample} @@ -2076,7 +2120,7 @@ having to use the cumbersome |node| syntax: an angle of |0| refers to the point on the border that lies on a straight line from the |main node|'s center to the right (relative to the paper, not relative to the local coordinate - system or either the node or the scope). + system of either the node or the scope). The difference can be seen in the following example: \begin{codeexample}[] @@ -2106,8 +2150,9 @@ having to use the cumbersome |node| syntax: from the major angle), the anchor for the major angle is used. Thus, a label at a border point for $2^\circ$ will have the anchor |west|, while a label for $3^\circ$ will have the anchor - |south west|, resulting in a ``jump'' of the anchor. If this is - not desired, you will have to set the anchor yourself. + |south west|, resulting in a ``jump'' of the anchor. You can set + the anchor ``by hand'' using the |anchor| key or indirect keys + like |left|. \begin{codeexample}[] \tikz \node [circle, draw, @@ -2115,7 +2160,9 @@ having to use the cumbersome |node| syntax: label=60:$60^\circ$, label=below:$-90^\circ$, label=3:$3^\circ$, - label=2:$2^\circ$] {my circle}; + label=2:$2^\circ$, + label={[below]180:$180^\circ$}, + label={[centered]135:$115^\circ$}] {my circle}; \end{codeexample} \item One \meta{angle} is special: If you set the \meta{angle} to @@ -2164,6 +2211,8 @@ having to use the cumbersome |node| syntax: \end{stylekey} \end{key} +See Section~\ref{section-label-quotes} for an easier +syntax for specifying nodes. \subsubsection{The Pin Option} @@ -2275,8 +2324,9 @@ more complicated options in curly braces: \matrix [row sep=5mm] { \node [draw, "label"] {A}; \\ \node [draw, "label" left] {B}; \\ - \node [draw, "label" color=red] {C}; \\ - \node [draw, "label" {red,draw,thick}] {D}; \\ + \node [draw, "label" centered] {C}; \\ + \node [draw, "label" color=red] {D}; \\ + \node [draw, "label" {red,draw,thick}] {E}; \\ }; \end{tikzpicture} \end{codeexample} @@ -2714,7 +2764,7 @@ Let us have a look at the effect of these options. pictures at all. \end{key} -\begin{key}{/tikz/overlay} +\begin{key}{/tikz/overlay=\meta{boolean} (default true)} 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 |