diff --git a/doc/generic/pgf/text-en/pgfmanual-en-base-quick.tex b/doc/generic/pgf/text-en/pgfmanual-en-base-quick.tex index b07c3a51c..a791c96fd 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-base-quick.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-base-quick.tex @@ -102,7 +102,7 @@ \subsection{Quick Path Construction Commands} Adds a radius around the origin of the given \meta{radius}. This command is orders of magnitude faster than |\pgfcircle{\pgfpointorigin}{|\meta{radius}|}|. % -\begin{codeexample}[] +\begin{codeexample}[pre={\colorlet{examplefill}{yellow!80!black}}] \begin{tikzpicture} \draw[help lines] (0,0) grid (1,1); \pgfpathqcircle{10pt} diff --git a/doc/generic/pgf/text-en/pgfmanual-en-base-transformations.tex b/doc/generic/pgf/text-en/pgfmanual-en-base-transformations.tex index fb52e698d..67525cd30 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-base-transformations.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-base-transformations.tex @@ -1119,9 +1119,10 @@ \subsubsection{Nonlinear Transformation Libraries} |\pgftransformnonlinear| for details. % \makeatletter -\begin{codeexample}[preamble={\usepgfmodule{nonlineartransformations} -\usetikzlibrary{curvilinear} -\makeatletter}] +\begin{codeexample}[ + preamble={\usepgfmodule{nonlineartransformations} +\usetikzlibrary{curvilinear}}, + pre=\makeatletter] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); { @@ -1138,9 +1139,10 @@ \subsubsection{Nonlinear Transformation Libraries} \end{tikzpicture} \end{codeexample} -\begin{codeexample}[preamble={\usepgfmodule{nonlineartransformations} -\usetikzlibrary{curvilinear} -\makeatletter}] +\begin{codeexample}[ + preamble={\usepgfmodule{nonlineartransformations} +\usetikzlibrary{curvilinear}}, + pre=\makeatletter] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); { @@ -1177,9 +1179,10 @@ \subsubsection{Nonlinear Transformation Libraries} lines. % \makeatletter -\begin{codeexample}[preamble={\usepgfmodule{nonlineartransformations} -\usetikzlibrary{curvilinear} -\makeatletter}] +\begin{codeexample}[ + preamble={\usepgfmodule{nonlineartransformations} +\usetikzlibrary{curvilinear}}, + pre=\makeatletter] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); { @@ -1198,9 +1201,10 @@ \subsubsection{Nonlinear Transformation Libraries} \end{tikzpicture} \end{codeexample} -\begin{codeexample}[preamble={\usepgfmodule{nonlineartransformations} -\usetikzlibrary{curvilinear} -\makeatletter}] +\begin{codeexample}[ + preamble={\usepgfmodule{nonlineartransformations} +\usetikzlibrary{curvilinear}}, + pre=\makeatletter] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); { diff --git a/doc/generic/pgf/text-en/pgfmanual-en-dv-axes.tex b/doc/generic/pgf/text-en/pgfmanual-en-dv-axes.tex index 0748e6d69..c8394d463 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-dv-axes.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-dv-axes.tex @@ -503,7 +503,7 @@ \subsubsection{Scaling: Logarithmic Axes} Note that this will work with any axis, including, say, the degrees on a polar axis: % -\begin{codeexample}[preamble=\usetikzlibrary{datavisualization.polar}}] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.polar}}] \tikz \datavisualization [new polar axes, angle axis={logarithmic, scaling=1 at 0 and 90 at 90}, @@ -1002,7 +1002,10 @@ \subsubsection{Reference: Scientific Axis Systems} $y$-axis is rotated by $90^\circ$ and placed left of the center of the $y$-axis. % -\begin{codeexample}[width=8cm] +\begin{codeexample}[ + width=8cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, +] \tikz \datavisualization [scientific axes={clean, standard labels}, visualize as smooth line, diff --git a/doc/generic/pgf/text-en/pgfmanual-en-dv-formats.tex b/doc/generic/pgf/text-en/pgfmanual-en-dv-formats.tex index 3ef16f015..00b3ee1e9 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-dv-formats.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-dv-formats.tex @@ -18,10 +18,6 @@ \subsection{Overview} command, but usually data is available in some special (text) format and one would like to visualize this data. The present section explains how data in some specific format can be fed to the data visualization system. -% -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{datavisualization.formats.functions} -\end{codeexample} This section starts with an explanation of the main concepts. Then, the standard formats are listed in the reference section. It is also possible to @@ -124,7 +120,7 @@ \subsection{Reference: Build-In Formats} that you must surround a comma by curly braces if you which to (re)set the separator character to a space. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] \begin{tikzpicture} \datavisualization [school book axes, visualize as line] data [separator=\space] { @@ -148,7 +144,7 @@ \subsection{Reference: Build-In Formats} is used as the headline and the first line of the data is treated as a normal line rather than as a headline. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] \begin{tikzpicture} \datavisualization [school book axes, visualize as line] data [headline={x, y}] { @@ -168,7 +164,7 @@ \subsection{Reference: Build-In Formats} attribute |/data point/x| to be set to |5| and |/data point/lo| to be set to |500|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] \begin{tikzpicture} \datavisualization [school book axes, visualize as line] data [format=named] { @@ -190,7 +186,10 @@ \subsection{Reference: Build-In Formats} attribute. In this case, a data point is created for each possible combination of values in the different lists: % -\begin{codeexample}[width=7cm] +\begin{codeexample}[ + width=7cm, + preamble={\usetikzlibrary{datavisualization}}, +] \tikz \datavisualization [scientific axes=clean, visualize as scatter/.list={a,b,c}, @@ -211,7 +210,7 @@ \subsection{Reference: Build-In Formats} may not be spread over several lines. However, not each line needs to produce a data point. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] \begin{tikzpicture} \datavisualization [school book axes, visualize as line] data [format=TeX code] { @@ -311,7 +310,7 @@ \subsection{Reference: Advanced Formats} specification. In this case, all of these functions will be evaluated for each setting of input variables. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz \datavisualization [school book axes, visualize as smooth line] data [format=function] { @@ -321,7 +320,10 @@ \subsection{Reference: Advanced Formats} }; \end{codeexample} % -\begin{codeexample}[width=6cm] +\begin{codeexample}[ + width=6cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, +] \tikz \datavisualization [ school book axes, all axes={unit length=5mm, ticks={step=2}}, @@ -334,7 +336,10 @@ \subsection{Reference: Advanced Formats} }; \end{codeexample} % -\begin{codeexample}[width=7cm] +\begin{codeexample}[ + width=7cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, +] \tikz \datavisualization [ scientific axes=clean, y axis={ticks={style={ diff --git a/doc/generic/pgf/text-en/pgfmanual-en-dv-introduction.tex b/doc/generic/pgf/text-en/pgfmanual-en-dv-introduction.tex index 0b2146615..58e612170 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-dv-introduction.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-dv-introduction.tex @@ -117,11 +117,7 @@ \subsection{Concept: Visualization Pipeline} |scientific axes|, which selects a certain visualization pipeline that is appropriate for this kind of plot: % -\begin{codeexample}[setup code] - \usetikzlibrary{datavisualization.formats.functions} -\end{codeexample} -% -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \begin{tikzpicture}[scale=.7] \datavisualization [school book axes, visualize as smooth line] data [format=function] { @@ -131,7 +127,7 @@ \subsection{Concept: Visualization Pipeline} \end{tikzpicture} \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \begin{tikzpicture}[scale=.7] \datavisualization [scientific axes, visualize as smooth line] data [format=function] { diff --git a/doc/generic/pgf/text-en/pgfmanual-en-dv-main.tex b/doc/generic/pgf/text-en/pgfmanual-en-dv-main.tex index f70269cbd..a0d57858f 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-dv-main.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-dv-main.tex @@ -26,10 +26,6 @@ \subsection{Overview} additional, more specialized libraries need to be loaded for more advanced features. \end{tikzlibrary} -% -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{datavisualization.formats.functions} -\end{codeexample} In order to visualize, you basically need to do three things: % @@ -79,7 +75,7 @@ \subsection{Concept: Data Points and Data Formats} Here are two examples, where similar data is given in different formats: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] \begin{tikzpicture} \datavisualization [school book axes, visualize as smooth line] data { @@ -95,7 +91,7 @@ \subsection{Concept: Data Points and Data Formats} \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \begin{tikzpicture} \datavisualization [school book axes, visualize as smooth line] data [format=function] { @@ -177,7 +173,7 @@ \subsection{Concept: Axes, Ticks, and Grids} Typically, you will not need to specify axes explicitly. Rather, predefined styles take care of this for you: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \begin{tikzpicture} \datavisualization [ scientific axes, @@ -191,7 +187,7 @@ \subsection{Concept: Axes, Ticks, and Grids} \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \begin{tikzpicture} \datavisualization [ scientific axes=clean, @@ -220,7 +216,7 @@ \subsection{Concept: Visualizers} the data points. More advanced visualizers include, say, box plot visualizers or pie chart visualizers. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \begin{tikzpicture} \datavisualization [ scientific axes=clean, @@ -234,7 +230,7 @@ \subsection{Concept: Visualizers} \end{tikzpicture} \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \begin{tikzpicture} \datavisualization [ scientific axes=clean, @@ -279,7 +275,7 @@ \subsection{Concept: Style Sheets and Legends} below. Two style sheets are used so that \emph{both} the coloring and the dashing is varied. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \begin{tikzpicture}[baseline] \datavisualization [ scientific axes=clean, y axis=grid, @@ -422,7 +418,7 @@ \subsection{Usage} data [/data point/experiment=23, read from file=experiment023.csv]; \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [school book axes, visualize as line] data [/data point/x=1] { @@ -479,7 +475,7 @@ \subsection{Usage} data point is created. This means that inside the \meta{options} you just specify the values of all attributes in key--value syntax. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [school book axes, visualize as line] data point [x=1, y=1] data point [x=1, y=2] data point [x=2, y=2] data point [x=2, y=0.5]; @@ -491,7 +487,7 @@ \subsection{Usage} This key is the ``key version'' of the previous command. The difference is that this key can be used internally inside styles. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] \tikzdatavisualizationset{ horizontal/.style={ data point={x=#1, y=1}, data point={x=#1, y=2}}, @@ -539,9 +535,7 @@ \subsection{Usage} ``dummy'' data visualization is empty and used only for the definition of the data group. % -% TODOsp: codeexamples: this is needed as `pre` for the following example -% (thus, `setup code` doesn't work here) -\begin{codeexample}[] +\begin{codeexample}[setup code] \tikz \datavisualization data group {points} = { data { x, y @@ -557,7 +551,7 @@ \subsection{Usage} We can now use this data in different plots: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [school book axes, visualize as line] data group {points}; \qquad \tikz \datavisualization [scientific axes=clean, visualize as line] data group {points}; @@ -599,7 +593,7 @@ \subsection{Usage} of the data visualization. In sharp contrast, \tikzname\ code given after a data visualization can no longer access this coordinate system. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \begin{tikzpicture}[baseline] \datavisualization [ school book axes, visualize as line ] data [format=function] { @@ -632,7 +626,7 @@ \subsection{Usage} before the visualization is done. This allows you to draw things \emph{behind} the visualization. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \begin{tikzpicture}[baseline] \datavisualization [ school book axes, visualize as line ] data [format=function] { diff --git a/doc/generic/pgf/text-en/pgfmanual-en-dv-polar.tex b/doc/generic/pgf/text-en/pgfmanual-en-dv-polar.tex index 11e387265..31167b720 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-dv-polar.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-dv-polar.tex @@ -17,10 +17,6 @@ \subsection{Overview} This library contains keys that allow you to create plots in a polar axis system is used. \end{tikzlibrary} -% -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{datavisualization.polar} -\end{codeexample} In a \emph{polar axis system} two attributes are visualized by displacing a data point as follows: One attribute is used to compute a an angle (a @@ -29,7 +25,10 @@ \subsection{Overview} % \begin{codeexample}[ width=8.5cm, - preamble={\usetikzlibrary{datavisualization.formats.functions}}, + preamble={\usetikzlibrary{ + datavisualization.formats.functions, + datavisualization.polar, +}}, ] \tikz \datavisualization [ scientific polar axes={0 to pi, clean}, @@ -63,7 +62,10 @@ \subsection{Overview} axis'' and the ``radius axis'' of a polar axis system. For instance, you can could make both axes logarithmic or style their ticks: % -\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] +\begin{codeexample}[preamble={\usetikzlibrary{ + datavisualization.formats.functions, + datavisualization.polar, +}}] \tikz[baseline] \datavisualization [ scientific axes={clean}, x axis={attribute=angle, ticks={minor steps between steps=4}}, @@ -126,7 +128,10 @@ \subsection{Scientific Polar Axis System} % \begin{codeexample}[ width=8.8cm, - preamble={\usetikzlibrary{datavisualization.formats.functions}}, + preamble={\usetikzlibrary{ + datavisualization.formats.functions, + datavisualization.polar, +}}, ] \tikz \datavisualization [ scientific polar axes, @@ -163,7 +168,10 @@ \subsubsection{Tick Placements} % \begin{codeexample}[ width=8.8cm, - preamble={\usetikzlibrary{datavisualization.formats.functions}}, + preamble={\usetikzlibrary{ + datavisualization.formats.functions, + datavisualization.polar, +}}, ] \tikz \datavisualization [ scientific polar axes={outer ticks, 0 to 180}, @@ -182,7 +190,10 @@ \subsubsection{Tick Placements} % \begin{codeexample}[ width=8.8cm, - preamble={\usetikzlibrary{datavisualization.formats.functions}}, + preamble={\usetikzlibrary{ + datavisualization.formats.functions, + datavisualization.polar, +}}, ] \tikz \datavisualization [ scientific polar axes={inner ticks, 0 to 180}, @@ -202,7 +213,10 @@ \subsubsection{Tick Placements} % \begin{codeexample}[ width=8.8cm, - preamble={\usetikzlibrary{datavisualization.formats.functions}}, + preamble={\usetikzlibrary{ + datavisualization.formats.functions, + datavisualization.polar, +}}, ] \tikz \datavisualization [ scientific polar axes={clean, 0 to 180}, @@ -260,7 +274,7 @@ \subsubsection{Angle Ranges} possible keys are only given in a table together with a small example for each key. The examples were created using the following code: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.polar}}] \tikz \datavisualization [ scientific polar axes={ clean, @@ -362,7 +376,7 @@ \subsection{Advanced: Creating a New Polar Axis System} a position on the page that is at a distance of $r$ from the origin and at an angle of~$a$. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.polar}}] \tikz \datavisualization [new polar axes={angle axis}{radius axis}, radius axis={length=2cm}, @@ -392,7 +406,7 @@ \subsection{Advanced: Creating a New Polar Axis System} Both the \meta{unit vector 0 degrees} and the \meta{unit vector 90 degrees} are \tikzname\ coordinates: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.polar}}] \tikz \datavisualization [new polar axes={angle axis}{radius axis}, radius axis={unit length=1cm}, @@ -413,7 +427,7 @@ \subsection{Advanced: Creating a New Polar Axis System} up the scaling so that a value of |360| on this axis corresponds to a complete circle. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.polar}}] \tikz \datavisualization [new polar axes={angle axis}{radius axis}, radius axis={unit length=1cm}, @@ -430,7 +444,7 @@ \subsection{Advanced: Creating a New Polar Axis System} In contrast to |degrees|, this option sets up things so that a value of |2*pi| on this axis corresponds to a complete circle. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.polar}}] \tikz \datavisualization [new polar axes={angle axis}{radius axis}, radius axis={unit length=1cm}, diff --git a/doc/generic/pgf/text-en/pgfmanual-en-dv-stylesheets.tex b/doc/generic/pgf/text-en/pgfmanual-en-dv-stylesheets.tex index 21dde5ab1..2c9358ade 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-dv-stylesheets.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-dv-stylesheets.tex @@ -24,10 +24,6 @@ \subsection{Overview} experiment using circles; and so on. Finally, at some place in the visualization -- either inside the data or in a legend next to it -- the meaning of the colors or symbols need to be explained. -% -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{datavisualization.formats.functions} -\end{codeexample} Just as you would like \tikzname\ to map the data points automatically onto the axes, you will also typically wish \tikzname\ to choose for instance the @@ -75,9 +71,7 @@ \subsection{Concepts: Style Sheets} For the following examples, let us first define a simple data set: % -% TODOsp: this is needed as `pre` for the following examples -% (thus, `setup code` doesn't work here) -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz \datavisualization data group {function classes} = { data [set=log, format=function] { var x : interval [0.2:2.5]; @@ -98,7 +92,27 @@ \subsection{Concepts: Style Sheets} }; \end{codeexample} -\begin{codeexample}[width=6cm] +\begin{codeexample}[ + width=6cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}] \tikz \datavisualization [ school book axes, all axes={unit length=7.5mm}, visualize as smooth line/.list={log, lin, squared, exp}, @@ -106,7 +120,27 @@ \subsection{Concepts: Style Sheets} data group {function classes}; \end{codeexample} -\begin{codeexample}[width=6cm] +\begin{codeexample}[ + width=6cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}] \tikz \datavisualization [ school book axes, all axes={unit length=7.5mm}, visualize as smooth line/.list={log, lin, squared, exp}, @@ -135,7 +169,27 @@ \subsection{Concepts: Legends} for visualizers directly inside the data visualization, which is even better than adding a legend, in general. % -\begin{codeexample}[width=7cm] +\begin{codeexample}[ + width=7cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}] \tikz \datavisualization [ school book axes, all axes={unit length=7.5mm}, x axis={label=$x$}, @@ -148,7 +202,27 @@ \subsection{Concepts: Legends} data group {function classes}; \end{codeexample} -\begin{codeexample}[width=6.3cm] +\begin{codeexample}[ + width=6.3cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}] \tikz \datavisualization [ school book axes, x axis={label=$x$}, @@ -182,7 +256,28 @@ \subsubsection{Picking a Style Sheet} Adds the \meta{style sheet} to the list of style sheets attached to the |set| attribute. % -\begin{codeexample}[width=6cm] +\begin{codeexample}[ + width=6cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}, +] \tikz \datavisualization [ school book axes, all axes={unit length=7.5mm}, visualize as smooth line/.list={log, lin, squared, exp}, @@ -287,7 +382,7 @@ \subsubsection{Creating a New Style Sheet} We would now write: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] \pgfkeys{ /pgf/data visualization/style sheets/traffic light/.cd, % All these styles have the above prefix. @@ -327,7 +422,17 @@ \subsubsection{Creating a New Style Sheet} 3/.style={red!80!black}, default style/.style={black} } -\begin{codeexample}[] +\begin{codeexample}[ + preamble={\usetikzlibrary{datavisualization}}, + pre={\pgfkeys{ + /pgf/data visualization/style sheets/traffic light/.cd, + % All these styles have the above prefix. + 1/.style={green!50!black}, + 2/.style={yellow!90!black}, + 3/.style={red!80!black}, + default style/.style={black} +}}, +] % Definition of traffic light keys as above \begin{tikzpicture} \datavisualization data group {lines} = { @@ -360,7 +465,25 @@ \subsubsection{Creating a New Style Sheet} However, you would need them for instance when you would like several different data sets to use the same styling: % -\begin{codeexample}[] +\begin{codeexample}[ + preamble={\usetikzlibrary{datavisualization}}, + pre={\pgfkeys{ + /pgf/data visualization/style sheets/traffic light/.cd, + % All these styles have the above prefix. + 1/.style={green!50!black}, + 2/.style={yellow!90!black}, + 3/.style={red!80!black}, + default style/.style={black} +} +\tikz \datavisualization data group {lines} = { + data point [x=0, y=0, set=normal] + data point [x=2, y=2, set=normal] + data point [x=0, y=1, set=heated] + data point [x=2, y=1, set=heated] + data point [x=0.5, y=1.5, set=critical] + data point [x=2.25, y=1.75, set=critical] +};}, +] % Definition of traffic light keys as above \tikz \datavisualization [ school book axes, @@ -395,7 +518,17 @@ \subsubsection{Creating a New Style Sheet} large number of styles in this case, but can use the |default style| key to ``calculate'' the correct dashing. -\begin{codeexample}[] +\begin{codeexample}[ + preamble={\usetikzlibrary{datavisualization}}, + pre={\tikz \datavisualization data group {lines} = { + data point [x=0, y=0, set=normal] + data point [x=2, y=2, set=normal] + data point [x=0, y=1, set=heated] + data point [x=2, y=1, set=heated] + data point [x=0.5, y=1.5, set=critical] + data point [x=2.25, y=1.75, set=critical] +};}, +] \pgfdvdeclarestylesheet{my dashings}{ default style/.style={dash pattern={on #1pt off 1pt}} } @@ -424,7 +557,17 @@ \subsubsection{Creating a New Color Style Sheet} color is simply that it makes many internals of the data visualization engine a bit simpler. % -\begin{codeexample}[] +\begin{codeexample}[ + preamble={\usetikzlibrary{datavisualization}}, + pre={\tikz \datavisualization data group {lines} = { + data point [x=0, y=0, set=normal] + data point [x=2, y=2, set=normal] + data point [x=0, y=1, set=heated] + data point [x=2, y=1, set=heated] + data point [x=0.5, y=1.5, set=critical] + data point [x=2.25, y=1.75, set=critical] +};}, +] \pgfdvdeclarestylesheet{my colors} { default style/.style={visualizer color=black}, @@ -458,7 +601,17 @@ \subsubsection{Creating a New Color Style Sheet} series is used (since counting starts at |0| for color series). Thus, in general, you need to start the \meta{initial color} ``one early''. % -\begin{codeexample}[] +\begin{codeexample}[ + preamble={\usetikzlibrary{datavisualization}}, + pre={\tikz \datavisualization data group {lines} = { + data point [x=0, y=0, set=normal] + data point [x=2, y=2, set=normal] + data point [x=0, y=1, set=heated] + data point [x=2, y=1, set=heated] + data point [x=0.5, y=1.5, set=critical] + data point [x=2.25, y=1.75, set=critical] +};}, +] \tikzdvdeclarestylesheetcolorseries{greens}{hsb}{0.3,1.3,0.8}{0,-.4,-.1} \tikz \datavisualization [ school book axes, @@ -539,7 +692,35 @@ \subsection{Reference: Style Sheets for Lines} are only two or three lines, and even then it is not particularly pleasing visually. % -\begin{codeexample}[width=10cm] +\begin{codeexample}[ + width=10cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + example visualization/.style={ + scientific axes=clean, + y axis={ticks={style={ + /pgf/number format/fixed, + /pgf/number format/fixed zerofill, + /pgf/number format/precision=2}}}, + x axis={ticks={tick suffix=${}^\circ$}}, + 1={label in legend={text=$\frac{1}{6}\sin 11x$}}, + 2={label in legend={text=$\frac{1}{7}\sin 12x$}}, + 3={label in legend={text=$\frac{1}{8}\sin 13x$}}, + 4={label in legend={text=$\frac{1}{9}\sin 14x$}}, + 5={label in legend={text=$\frac{1}{10}\sin 15x$}}, + 6={label in legend={text=$\frac{1}{11}\sin 16x$}}, + 7={label in legend={text=$\frac{1}{12}\sin 17x$}}, + 8={label in legend={text=$\frac{1}{13}\sin 18x$}} + } +}}, +] \tikz \datavisualization [ visualize as smooth line/.list= {1,2,3,4,5,6,7,8}, @@ -557,7 +738,35 @@ \subsection{Reference: Style Sheets for Lines} often the best choice when the visualization is to be printed in black and white. % -\begin{codeexample}[width=10cm] +\begin{codeexample}[ + width=10cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + example visualization/.style={ + scientific axes=clean, + y axis={ticks={style={ + /pgf/number format/fixed, + /pgf/number format/fixed zerofill, + /pgf/number format/precision=2}}}, + x axis={ticks={tick suffix=${}^\circ$}}, + 1={label in legend={text=$\frac{1}{6}\sin 11x$}}, + 2={label in legend={text=$\frac{1}{7}\sin 12x$}}, + 3={label in legend={text=$\frac{1}{8}\sin 13x$}}, + 4={label in legend={text=$\frac{1}{9}\sin 14x$}}, + 5={label in legend={text=$\frac{1}{10}\sin 15x$}}, + 6={label in legend={text=$\frac{1}{11}\sin 16x$}}, + 7={label in legend={text=$\frac{1}{12}\sin 17x$}}, + 8={label in legend={text=$\frac{1}{13}\sin 18x$}} + } +}}, +] \tikz \datavisualization [ visualize as smooth line/.list= {1,2,3,4,5,6,7,8}, @@ -581,7 +790,35 @@ \subsection{Reference: Style Sheets for Lines} visualizations when many different lines (ten or more) should be printed in black and white. % -\begin{codeexample}[width=10cm] +\begin{codeexample}[ + width=10cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + example visualization/.style={ + scientific axes=clean, + y axis={ticks={style={ + /pgf/number format/fixed, + /pgf/number format/fixed zerofill, + /pgf/number format/precision=2}}}, + x axis={ticks={tick suffix=${}^\circ$}}, + 1={label in legend={text=$\frac{1}{6}\sin 11x$}}, + 2={label in legend={text=$\frac{1}{7}\sin 12x$}}, + 3={label in legend={text=$\frac{1}{8}\sin 13x$}}, + 4={label in legend={text=$\frac{1}{9}\sin 14x$}}, + 5={label in legend={text=$\frac{1}{10}\sin 15x$}}, + 6={label in legend={text=$\frac{1}{11}\sin 16x$}}, + 7={label in legend={text=$\frac{1}{12}\sin 17x$}}, + 8={label in legend={text=$\frac{1}{13}\sin 18x$}} + } +}}, +] \tikz \datavisualization [ visualize as smooth line/.list= {1,2,3,4,5,6,7,8}, @@ -594,7 +831,35 @@ \subsection{Reference: Style Sheets for Lines} For comparison, here is the must-less-than-satisfactory result of combining the two independent style sheets: % -\begin{codeexample}[width=10cm] +\begin{codeexample}[ + width=10cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + example visualization/.style={ + scientific axes=clean, + y axis={ticks={style={ + /pgf/number format/fixed, + /pgf/number format/fixed zerofill, + /pgf/number format/precision=2}}}, + x axis={ticks={tick suffix=${}^\circ$}}, + 1={label in legend={text=$\frac{1}{6}\sin 11x$}}, + 2={label in legend={text=$\frac{1}{7}\sin 12x$}}, + 3={label in legend={text=$\frac{1}{8}\sin 13x$}}, + 4={label in legend={text=$\frac{1}{9}\sin 14x$}}, + 5={label in legend={text=$\frac{1}{10}\sin 15x$}}, + 6={label in legend={text=$\frac{1}{11}\sin 16x$}}, + 7={label in legend={text=$\frac{1}{12}\sin 17x$}}, + 8={label in legend={text=$\frac{1}{13}\sin 18x$}} + } +}}, +] \tikz \datavisualization [ visualize as smooth line/.list= {1,2,3,4,5,6,7,8}, @@ -622,7 +887,35 @@ \subsection{Reference: Style Sheets for Scatter Plots} This style supports only up to six different data sets and requires the |plotmarks| library. % -\begin{codeexample}[width=10cm] +\begin{codeexample}[ + width=10cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + example visualization/.style={ + scientific axes=clean, + y axis={ticks={style={ + /pgf/number format/fixed, + /pgf/number format/fixed zerofill, + /pgf/number format/precision=2}}}, + x axis={ticks={tick suffix=${}^\circ$}}, + 1={label in legend={text=$\frac{1}{6}\sin 11x$}}, + 2={label in legend={text=$\frac{1}{7}\sin 12x$}}, + 3={label in legend={text=$\frac{1}{8}\sin 13x$}}, + 4={label in legend={text=$\frac{1}{9}\sin 14x$}}, + 5={label in legend={text=$\frac{1}{10}\sin 15x$}}, + 6={label in legend={text=$\frac{1}{11}\sin 16x$}}, + 7={label in legend={text=$\frac{1}{12}\sin 17x$}}, + 8={label in legend={text=$\frac{1}{13}\sin 18x$}} + } +}}, +] \tikz \datavisualization [ visualize as scatter/.list= {1,2,3,4,5,6,7,8}, @@ -631,29 +924,57 @@ \subsection{Reference: Style Sheets for Scatter Plots} data group {sin functions}; \end{codeexample} % -\begin{codeexample}[width=10cm] -\tikz \datavisualization [ - visualize as smooth line/.list= - {1,2,3,4,5,6,7,8}, - example visualization, - style sheet=cross marks] -data group {sin functions}; -\end{codeexample} - % -\end{stylesheet} - - -\subsection{Reference: Color Style Sheets} - -Color style sheets are very useful for creating visually pleasing data -visualizations that contain multiple data sets. However, there are two things -to keep in mind: -% -\begin{itemize} - \item At some point, every data visualization is printed or photo copied in - black and white by someone. In this case, data sets can often no longer - be distinguished. - \item A few people are color blind. They will not be able to distinguish +\begin{codeexample}[ + width=10cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + example visualization/.style={ + scientific axes=clean, + y axis={ticks={style={ + /pgf/number format/fixed, + /pgf/number format/fixed zerofill, + /pgf/number format/precision=2}}}, + x axis={ticks={tick suffix=${}^\circ$}}, + 1={label in legend={text=$\frac{1}{6}\sin 11x$}}, + 2={label in legend={text=$\frac{1}{7}\sin 12x$}}, + 3={label in legend={text=$\frac{1}{8}\sin 13x$}}, + 4={label in legend={text=$\frac{1}{9}\sin 14x$}}, + 5={label in legend={text=$\frac{1}{10}\sin 15x$}}, + 6={label in legend={text=$\frac{1}{11}\sin 16x$}}, + 7={label in legend={text=$\frac{1}{12}\sin 17x$}}, + 8={label in legend={text=$\frac{1}{13}\sin 18x$}} + } +}}, +] +\tikz \datavisualization [ + visualize as smooth line/.list= + {1,2,3,4,5,6,7,8}, + example visualization, + style sheet=cross marks] +data group {sin functions}; +\end{codeexample} + % +\end{stylesheet} + + +\subsection{Reference: Color Style Sheets} + +Color style sheets are very useful for creating visually pleasing data +visualizations that contain multiple data sets. However, there are two things +to keep in mind: +% +\begin{itemize} + \item At some point, every data visualization is printed or photo copied in + black and white by someone. In this case, data sets can often no longer + be distinguished. + \item A few people are color blind. They will not be able to distinguish between red and green lines (and some people are not even able to distinguish colors at all). \end{itemize} @@ -669,7 +990,35 @@ \subsection{Reference: Color Style Sheets} sheet, the visualizations are easier to read when this style sheet is used. Up to six different data sets are supported. % -\begin{codeexample}[width=10cm] +\begin{codeexample}[ + width=10cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + example visualization/.style={ + scientific axes=clean, + y axis={ticks={style={ + /pgf/number format/fixed, + /pgf/number format/fixed zerofill, + /pgf/number format/precision=2}}}, + x axis={ticks={tick suffix=${}^\circ$}}, + 1={label in legend={text=$\frac{1}{6}\sin 11x$}}, + 2={label in legend={text=$\frac{1}{7}\sin 12x$}}, + 3={label in legend={text=$\frac{1}{8}\sin 13x$}}, + 4={label in legend={text=$\frac{1}{9}\sin 14x$}}, + 5={label in legend={text=$\frac{1}{10}\sin 15x$}}, + 6={label in legend={text=$\frac{1}{11}\sin 16x$}}, + 7={label in legend={text=$\frac{1}{12}\sin 17x$}}, + 8={label in legend={text=$\frac{1}{13}\sin 18x$}} + } +}}, +] \tikz \datavisualization [ visualize as smooth line/.list= {1,2,3,4,5,6,7,8}, @@ -678,7 +1027,35 @@ \subsection{Reference: Color Style Sheets} data group {sin functions}; \end{codeexample} % -\begin{codeexample}[width=10cm] +\begin{codeexample}[ + width=10cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + example visualization/.style={ + scientific axes=clean, + y axis={ticks={style={ + /pgf/number format/fixed, + /pgf/number format/fixed zerofill, + /pgf/number format/precision=2}}}, + x axis={ticks={tick suffix=${}^\circ$}}, + 1={label in legend={text=$\frac{1}{6}\sin 11x$}}, + 2={label in legend={text=$\frac{1}{7}\sin 12x$}}, + 3={label in legend={text=$\frac{1}{8}\sin 13x$}}, + 4={label in legend={text=$\frac{1}{9}\sin 14x$}}, + 5={label in legend={text=$\frac{1}{10}\sin 15x$}}, + 6={label in legend={text=$\frac{1}{11}\sin 16x$}}, + 7={label in legend={text=$\frac{1}{12}\sin 17x$}}, + 8={label in legend={text=$\frac{1}{13}\sin 18x$}} + } +}}, +] \tikz \datavisualization [ visualize as smooth line/.list= {1,2,3,4,5,6,7,8}, @@ -698,7 +1075,35 @@ \subsection{Reference: Color Style Sheets} \begin{stylesheet}{vary hue} This style uses a different hue for each data set. % -\begin{codeexample}[width=10cm] +\begin{codeexample}[ + width=10cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + example visualization/.style={ + scientific axes=clean, + y axis={ticks={style={ + /pgf/number format/fixed, + /pgf/number format/fixed zerofill, + /pgf/number format/precision=2}}}, + x axis={ticks={tick suffix=${}^\circ$}}, + 1={label in legend={text=$\frac{1}{6}\sin 11x$}}, + 2={label in legend={text=$\frac{1}{7}\sin 12x$}}, + 3={label in legend={text=$\frac{1}{8}\sin 13x$}}, + 4={label in legend={text=$\frac{1}{9}\sin 14x$}}, + 5={label in legend={text=$\frac{1}{10}\sin 15x$}}, + 6={label in legend={text=$\frac{1}{11}\sin 16x$}}, + 7={label in legend={text=$\frac{1}{12}\sin 17x$}}, + 8={label in legend={text=$\frac{1}{13}\sin 18x$}} + } +}}, +] \tikz \datavisualization [ visualize as smooth line/.list= {1,2,3,4,5,6,7,8}, @@ -712,7 +1117,35 @@ \subsection{Reference: Color Style Sheets} \begin{stylesheet}{shades of blue} As the name suggests, different shades of blue are used for different data sets. -\begin{codeexample}[width=10cm] +\begin{codeexample}[ + width=10cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + example visualization/.style={ + scientific axes=clean, + y axis={ticks={style={ + /pgf/number format/fixed, + /pgf/number format/fixed zerofill, + /pgf/number format/precision=2}}}, + x axis={ticks={tick suffix=${}^\circ$}}, + 1={label in legend={text=$\frac{1}{6}\sin 11x$}}, + 2={label in legend={text=$\frac{1}{7}\sin 12x$}}, + 3={label in legend={text=$\frac{1}{8}\sin 13x$}}, + 4={label in legend={text=$\frac{1}{9}\sin 14x$}}, + 5={label in legend={text=$\frac{1}{10}\sin 15x$}}, + 6={label in legend={text=$\frac{1}{11}\sin 16x$}}, + 7={label in legend={text=$\frac{1}{12}\sin 17x$}}, + 8={label in legend={text=$\frac{1}{13}\sin 18x$}} + } +}}, +] \tikz \datavisualization [ visualize as smooth line/.list= {1,2,3,4,5,6,7,8}, @@ -724,7 +1157,35 @@ \subsection{Reference: Color Style Sheets} \end{stylesheet} \begin{stylesheet}{shades of red} -\begin{codeexample}[width=10cm] +\begin{codeexample}[ + width=10cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + example visualization/.style={ + scientific axes=clean, + y axis={ticks={style={ + /pgf/number format/fixed, + /pgf/number format/fixed zerofill, + /pgf/number format/precision=2}}}, + x axis={ticks={tick suffix=${}^\circ$}}, + 1={label in legend={text=$\frac{1}{6}\sin 11x$}}, + 2={label in legend={text=$\frac{1}{7}\sin 12x$}}, + 3={label in legend={text=$\frac{1}{8}\sin 13x$}}, + 4={label in legend={text=$\frac{1}{9}\sin 14x$}}, + 5={label in legend={text=$\frac{1}{10}\sin 15x$}}, + 6={label in legend={text=$\frac{1}{11}\sin 16x$}}, + 7={label in legend={text=$\frac{1}{12}\sin 17x$}}, + 8={label in legend={text=$\frac{1}{13}\sin 18x$}} + } +}}, +] \tikz \datavisualization [ visualize as smooth line/.list= {1,2,3,4,5,6,7,8}, @@ -738,7 +1199,35 @@ \subsection{Reference: Color Style Sheets} For once, this style sheet can also be used when the visualization is printed in black and white. % -\begin{codeexample}[width=10cm] +\begin{codeexample}[ + width=10cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + example visualization/.style={ + scientific axes=clean, + y axis={ticks={style={ + /pgf/number format/fixed, + /pgf/number format/fixed zerofill, + /pgf/number format/precision=2}}}, + x axis={ticks={tick suffix=${}^\circ$}}, + 1={label in legend={text=$\frac{1}{6}\sin 11x$}}, + 2={label in legend={text=$\frac{1}{7}\sin 12x$}}, + 3={label in legend={text=$\frac{1}{8}\sin 13x$}}, + 4={label in legend={text=$\frac{1}{9}\sin 14x$}}, + 5={label in legend={text=$\frac{1}{10}\sin 15x$}}, + 6={label in legend={text=$\frac{1}{11}\sin 16x$}}, + 7={label in legend={text=$\frac{1}{12}\sin 17x$}}, + 8={label in legend={text=$\frac{1}{13}\sin 18x$}} + } +}}, +] \tikz \datavisualization [ visualize as smooth line/.list= {1,2,3,4,5,6,7,8}, @@ -828,7 +1317,28 @@ \subsubsection{Placing a Label Next to a Data Set} point where the \meta{attribute} is at least \meta{number} (if this never happens, the last data point is used). % -\begin{codeexample}[width=6.3cm] +\begin{codeexample}[ + width=6.3cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}, +] \tikz \datavisualization [ school book axes, x axis={label=$x$}, @@ -848,7 +1358,28 @@ \subsubsection{Placing a Label Next to a Data Set} This key chooses the \meta{number}th data point belonging to the visualizer's data set. % -\begin{codeexample}[width=6.3cm] +\begin{codeexample}[ + width=6.3cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}, +] \tikz \datavisualization [ school book axes, x axis={label=$x$}, @@ -867,7 +1398,28 @@ \subsubsection{Placing a Label Next to a Data Set} index is at least \meta{fraction} times the number of all data points in the data set. % -\begin{codeexample}[width=6.3cm] +\begin{codeexample}[ + width=6.3cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}, +] \tikz \datavisualization [ school book axes, x axis={label=$x$}, @@ -893,7 +1445,10 @@ \subsubsection{Placing a Label Next to a Data Set} will be placed at different positions along the lines with hopefully only little overlap. % -\begin{codeexample}[width=6.3cm] +\begin{codeexample}[ + width=6.3cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, +] \tikz \datavisualization [ scientific axes=clean, visualize as smooth line/.list={linear, squared, cubed}, @@ -936,7 +1491,28 @@ \subsubsection{Placing a Label Next to a Data Set} This style has a default definition, usually you should just append things to this style. % -\begin{codeexample}[width=6.3cm] +\begin{codeexample}[ + width=6.3cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}, +] \tikz \datavisualization [ school book axes, x axis={label=$x$}, @@ -970,7 +1546,10 @@ \subsubsection{Connecting a Label to a Data Set via a Pin} to it via a small line (this is like the difference between the |label| and |pin| options). % -\begin{codeexample}[width=6.3cm] +\begin{codeexample}[ + width=6.3cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, +] \tikz \datavisualization [ scientific axes=clean, visualize as smooth line/.list={linear, squared, cubed}, @@ -1015,16 +1594,37 @@ \subsubsection{Connecting a Label to a Data Set via a Pin} See the description of |pin angle|. \end{key} % -\begin{codeexample}[width=6.3cm] -\tikz \datavisualization [ - school book axes, - x axis={label=$x$}, - visualize as smooth line/.list={log, lin, squared, exp}, - every data set label/.append style={text colored}, - log= {pin in data={text'=$\log x$, when=y is -1}}, - lin= {pin in data={text=$x/2$, when=x is 2, - pin length=1ex}}, - squared={pin in data={text=$x^2$, when=x is 1.1, +\begin{codeexample}[ + width=6.3cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}, +] +\tikz \datavisualization [ + school book axes, + x axis={label=$x$}, + visualize as smooth line/.list={log, lin, squared, exp}, + every data set label/.append style={text colored}, + log= {pin in data={text'=$\log x$, when=y is -1}}, + lin= {pin in data={text=$x/2$, when=x is 2, + pin length=1ex}}, + squared={pin in data={text=$x^2$, when=x is 1.1, pin angle=230}}, exp= {label in data={text=$e^x$, when=x is -2}}, style sheet=vary hue] @@ -1096,7 +1696,28 @@ \subsubsection{Creating Legends and Legend Entries} Adds the \meta{options} to the list of options that will be executed when the legend's node is created. % -\begin{codeexample}[width=8cm] +\begin{codeexample}[ + width=8cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}, +] \tikz \datavisualization [ scientific axes, visualize as smooth line/.list= @@ -1121,7 +1742,28 @@ \subsubsection{Creating Legends and Legend Entries} the right of the data set visualization. \end{stylekey} % -\begin{codeexample}[width=6cm] +\begin{codeexample}[ + width=6cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}, +] \tikz \datavisualization [ scientific axes, x axis={label=$x$}, visualize as smooth line/.list={log, lin, squared, exp}, @@ -1145,7 +1787,28 @@ \subsubsection{Creating Legends and Legend Entries} key creates a new |main legend| and immediately passes the configuration \meta{options} to this legend. % -\begin{codeexample}[width=7cm] +\begin{codeexample}[ + width=7cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}, +] \tikz \datavisualization [ scientific axes, x axis={label=$x$}, visualize as smooth line/.list={log, lin, squared, exp}, @@ -1198,7 +1861,28 @@ \subsubsection{Creating Legends and Legend Entries} Use this key to setup the \meta{text} that is shown as the label of the data set. % -\begin{codeexample}[width=8cm] +\begin{codeexample}[ + width=8cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}, +] \tikz \datavisualization [ scientific axes, x axis={label=$x$}, visualize as smooth line/.list= @@ -1262,7 +1946,30 @@ \subsubsection{Rows and Columns of Legend Entries} once a column is full, the next column is begun to the right of the previous one. This is the default. % -\begin{codeexample}[width=6cm] +\begin{codeexample}[ + width=6cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + legend example/.style={ + scientific axes, all axes={length=1cm, ticks=none}, + 1={label in legend={text=1}}, + 2={label in legend={text=2}}, + 3={label in legend={text=3}}, + 4={label in legend={text=4}}, + 5={label in legend={text=5}}, + 6={label in legend={text=6}}, + 7={label in legend={text=7}}, + 8={label in legend={text=8}} + } +}}, +] \tikz \datavisualization [ visualize as smooth line/.list={1,2,3,4,5,6,7,8}, legend example, style sheet=vary hue, @@ -1291,7 +1998,30 @@ \subsubsection{Rows and Columns of Legend Entries} \end{key} \begin{key}{/tikz/data visualization/legend options/down then left} -\begin{codeexample}[width=6cm] +\begin{codeexample}[ + width=6cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + legend example/.style={ + scientific axes, all axes={length=1cm, ticks=none}, + 1={label in legend={text=1}}, + 2={label in legend={text=2}}, + 3={label in legend={text=3}}, + 4={label in legend={text=4}}, + 5={label in legend={text=5}}, + 6={label in legend={text=6}}, + 7={label in legend={text=7}}, + 8={label in legend={text=8}} + } +}}, +] \tikz \datavisualization [ visualize as smooth line/.list={1,2,3,4,5,6,7,8}, legend example, style sheet=vary hue, @@ -1301,7 +2031,30 @@ \subsubsection{Rows and Columns of Legend Entries} \end{key} \begin{key}{/tikz/data visualization/legend options/up then right} -\begin{codeexample}[width=6cm] +\begin{codeexample}[ + width=6cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + legend example/.style={ + scientific axes, all axes={length=1cm, ticks=none}, + 1={label in legend={text=1}}, + 2={label in legend={text=2}}, + 3={label in legend={text=3}}, + 4={label in legend={text=4}}, + 5={label in legend={text=5}}, + 6={label in legend={text=6}}, + 7={label in legend={text=7}}, + 8={label in legend={text=8}} + } +}}, +] \tikz \datavisualization [ visualize as smooth line/.list={1,2,3,4,5,6,7,8}, legend example, style sheet=vary hue, @@ -1311,7 +2064,30 @@ \subsubsection{Rows and Columns of Legend Entries} \end{key} \begin{key}{/tikz/data visualization/legend options/up then left} -\begin{codeexample}[width=6cm] +\begin{codeexample}[ + width=6cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + legend example/.style={ + scientific axes, all axes={length=1cm, ticks=none}, + 1={label in legend={text=1}}, + 2={label in legend={text=2}}, + 3={label in legend={text=3}}, + 4={label in legend={text=4}}, + 5={label in legend={text=5}}, + 6={label in legend={text=6}}, + 7={label in legend={text=7}}, + 8={label in legend={text=8}} + } +}}, +] \tikz \datavisualization [ visualize as smooth line/.list={1,2,3,4,5,6,7,8}, legend example, style sheet=vary hue, @@ -1321,7 +2097,30 @@ \subsubsection{Rows and Columns of Legend Entries} \end{key} \begin{key}{/tikz/data visualization/legend options/left then up} -\begin{codeexample}[width=6cm] +\begin{codeexample}[ + width=6cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + legend example/.style={ + scientific axes, all axes={length=1cm, ticks=none}, + 1={label in legend={text=1}}, + 2={label in legend={text=2}}, + 3={label in legend={text=3}}, + 4={label in legend={text=4}}, + 5={label in legend={text=5}}, + 6={label in legend={text=6}}, + 7={label in legend={text=7}}, + 8={label in legend={text=8}} + } +}}, +] \tikz \datavisualization [ visualize as smooth line/.list={1,2,3,4,5,6,7,8}, legend example, style sheet=vary hue, @@ -1331,7 +2130,30 @@ \subsubsection{Rows and Columns of Legend Entries} \end{key} \begin{key}{/tikz/data visualization/legend options/left then down} -\begin{codeexample}[width=6cm] +\begin{codeexample}[ + width=6cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + legend example/.style={ + scientific axes, all axes={length=1cm, ticks=none}, + 1={label in legend={text=1}}, + 2={label in legend={text=2}}, + 3={label in legend={text=3}}, + 4={label in legend={text=4}}, + 5={label in legend={text=5}}, + 6={label in legend={text=6}}, + 7={label in legend={text=7}}, + 8={label in legend={text=8}} + } +}}, +] \tikz \datavisualization [ visualize as smooth line/.list={1,2,3,4,5,6,7,8}, legend example, style sheet=vary hue, @@ -1341,7 +2163,30 @@ \subsubsection{Rows and Columns of Legend Entries} \end{key} \begin{key}{/tikz/data visualization/legend options/right then up} -\begin{codeexample}[width=6cm] +\begin{codeexample}[ + width=6cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + legend example/.style={ + scientific axes, all axes={length=1cm, ticks=none}, + 1={label in legend={text=1}}, + 2={label in legend={text=2}}, + 3={label in legend={text=3}}, + 4={label in legend={text=4}}, + 5={label in legend={text=5}}, + 6={label in legend={text=6}}, + 7={label in legend={text=7}}, + 8={label in legend={text=8}} + } +}}, +] \tikz \datavisualization [ visualize as smooth line/.list={1,2,3,4,5,6,7,8}, legend example, style sheet=vary hue, @@ -1351,7 +2196,30 @@ \subsubsection{Rows and Columns of Legend Entries} \end{key} \begin{key}{/tikz/data visualization/legend options/right then down} -\begin{codeexample}[width=6cm] +\begin{codeexample}[ + width=6cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + legend example/.style={ + scientific axes, all axes={length=1cm, ticks=none}, + 1={label in legend={text=1}}, + 2={label in legend={text=2}}, + 3={label in legend={text=3}}, + 4={label in legend={text=4}}, + 5={label in legend={text=5}}, + 6={label in legend={text=6}}, + 7={label in legend={text=7}}, + 8={label in legend={text=8}} + } +}}, +] \tikz \datavisualization [ visualize as smooth line/.list={1,2,3,4,5,6,7,8}, legend example, style sheet=vary hue, @@ -1371,7 +2239,30 @@ \subsubsection{Rows and Columns of Legend Entries} As the legend matrix is being filled, whenever the number of rows in the current column would exceed \meta{number}, a new column is started. % -\begin{codeexample}[width=7cm] +\begin{codeexample}[ + width=7cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + legend example/.style={ + scientific axes, all axes={length=1cm, ticks=none}, + 1={label in legend={text=1}}, + 2={label in legend={text=2}}, + 3={label in legend={text=3}}, + 4={label in legend={text=4}}, + 5={label in legend={text=5}}, + 6={label in legend={text=6}}, + 7={label in legend={text=7}}, + 8={label in legend={text=8}} + } +}}, +] \tikz \datavisualization [ visualize as smooth line/.list={1,2,3,4,5,6,7,8}, legend example, style sheet=vary hue, @@ -1379,7 +2270,30 @@ \subsubsection{Rows and Columns of Legend Entries} data group {sin functions}; \end{codeexample} % -\begin{codeexample}[width=7cm] +\begin{codeexample}[ + width=7cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + legend example/.style={ + scientific axes, all axes={length=1cm, ticks=none}, + 1={label in legend={text=1}}, + 2={label in legend={text=2}}, + 3={label in legend={text=3}}, + 4={label in legend={text=4}}, + 5={label in legend={text=5}}, + 6={label in legend={text=6}}, + 7={label in legend={text=7}}, + 8={label in legend={text=8}} + } +}}, +] \tikz \datavisualization [ visualize as smooth line/.list={1,2,3,4,5,6,7,8}, legend example, style sheet=vary hue, @@ -1387,7 +2301,30 @@ \subsubsection{Rows and Columns of Legend Entries} data group {sin functions}; \end{codeexample} % -\begin{codeexample}[width=7cm] +\begin{codeexample}[ + width=7cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + legend example/.style={ + scientific axes, all axes={length=1cm, ticks=none}, + 1={label in legend={text=1}}, + 2={label in legend={text=2}}, + 3={label in legend={text=3}}, + 4={label in legend={text=4}}, + 5={label in legend={text=5}}, + 6={label in legend={text=6}}, + 7={label in legend={text=7}}, + 8={label in legend={text=8}} + } +}}, +] \tikz \datavisualization [ visualize as smooth line/.list={1,2,3,4,5,6,7,8}, legend example, style sheet=vary hue, @@ -1403,7 +2340,30 @@ \subsubsection{Rows and Columns of Legend Entries} you use this key with a strategy that first goes left or right and then up or down. % -\begin{codeexample}[width=7cm] +\begin{codeexample}[ + width=7cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + legend example/.style={ + scientific axes, all axes={length=1cm, ticks=none}, + 1={label in legend={text=1}}, + 2={label in legend={text=2}}, + 3={label in legend={text=3}}, + 4={label in legend={text=4}}, + 5={label in legend={text=5}}, + 6={label in legend={text=6}}, + 7={label in legend={text=7}}, + 8={label in legend={text=8}} + } +}}, +] \tikz \datavisualization [ visualize as smooth line/.list={1,2,3,4,5,6,7,8}, legend example, style sheet=vary hue, @@ -1411,7 +2371,30 @@ \subsubsection{Rows and Columns of Legend Entries} data group {sin functions}; \end{codeexample} % -\begin{codeexample}[width=7cm] +\begin{codeexample}[ + width=7cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + legend example/.style={ + scientific axes, all axes={length=1cm, ticks=none}, + 1={label in legend={text=1}}, + 2={label in legend={text=2}}, + 3={label in legend={text=3}}, + 4={label in legend={text=4}}, + 5={label in legend={text=5}}, + 6={label in legend={text=6}}, + 7={label in legend={text=7}}, + 8={label in legend={text=8}} + } +}}, +] \tikz \datavisualization [ visualize as smooth line/.list={1,2,3,4,5,6,7,8}, legend example, style sheet=vary hue, @@ -1419,7 +2402,30 @@ \subsubsection{Rows and Columns of Legend Entries} data group {sin functions}; \end{codeexample} % -\begin{codeexample}[width=7cm] +\begin{codeexample}[ + width=7cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + legend example/.style={ + scientific axes, all axes={length=1cm, ticks=none}, + 1={label in legend={text=1}}, + 2={label in legend={text=2}}, + 3={label in legend={text=3}}, + 4={label in legend={text=4}}, + 5={label in legend={text=5}}, + 6={label in legend={text=6}}, + 7={label in legend={text=7}}, + 8={label in legend={text=8}} + } +}}, +] \tikz \datavisualization [ visualize as smooth line/.list={1,2,3,4,5,6,7,8}, legend example, style sheet=vary hue, @@ -1447,7 +2453,30 @@ \subsubsection{Rows and Columns of Legend Entries} |max rows| value of rows per column, more columns than the ideal number are created. % -\begin{codeexample}[width=7cm] +\begin{codeexample}[ + width=7cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + legend example/.style={ + scientific axes, all axes={length=1cm, ticks=none}, + 1={label in legend={text=1}}, + 2={label in legend={text=2}}, + 3={label in legend={text=3}}, + 4={label in legend={text=4}}, + 5={label in legend={text=5}}, + 6={label in legend={text=6}}, + 7={label in legend={text=7}}, + 8={label in legend={text=8}} + } +}}, +] \tikz \datavisualization [ visualize as smooth line/.list={1,2,3,4,5,6,7,8}, legend example, style sheet=vary hue, @@ -1455,7 +2484,30 @@ \subsubsection{Rows and Columns of Legend Entries} data group {sin functions}; \end{codeexample} % -\begin{codeexample}[width=7cm] +\begin{codeexample}[ + width=7cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + legend example/.style={ + scientific axes, all axes={length=1cm, ticks=none}, + 1={label in legend={text=1}}, + 2={label in legend={text=2}}, + 3={label in legend={text=3}}, + 4={label in legend={text=4}}, + 5={label in legend={text=5}}, + 6={label in legend={text=6}}, + 7={label in legend={text=7}}, + 8={label in legend={text=8}} + } +}}, +] \tikz \datavisualization [ visualize as smooth line/.list={1,2,3,4,5,6,7,8}, legend example, style sheet=vary hue, @@ -1463,7 +2515,30 @@ \subsubsection{Rows and Columns of Legend Entries} data group {sin functions}; \end{codeexample} % -\begin{codeexample}[width=7cm] +\begin{codeexample}[ + width=7cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + legend example/.style={ + scientific axes, all axes={length=1cm, ticks=none}, + 1={label in legend={text=1}}, + 2={label in legend={text=2}}, + 3={label in legend={text=3}}, + 4={label in legend={text=4}}, + 5={label in legend={text=5}}, + 6={label in legend={text=6}}, + 7={label in legend={text=7}}, + 8={label in legend={text=8}} + } +}}, +] \tikz \datavisualization [ visualize as smooth line/.list={1,2,3,4,5,6,7,8}, legend example, style sheet=vary hue, @@ -1480,7 +2555,30 @@ \subsubsection{Rows and Columns of Legend Entries} \begin{key}{/tikz/data visualization/legend options/ideal number of rows=\meta{number}} Works like |ideal number of columns|. % -\begin{codeexample}[width=7cm] +\begin{codeexample}[ + width=7cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + legend example/.style={ + scientific axes, all axes={length=1cm, ticks=none}, + 1={label in legend={text=1}}, + 2={label in legend={text=2}}, + 3={label in legend={text=3}}, + 4={label in legend={text=4}}, + 5={label in legend={text=5}}, + 6={label in legend={text=6}}, + 7={label in legend={text=7}}, + 8={label in legend={text=8}} + } +}}, +] \tikz \datavisualization [ visualize as smooth line/.list={1,2,3,4,5,6,7,8}, legend example, style sheet=vary hue, @@ -1488,7 +2586,30 @@ \subsubsection{Rows and Columns of Legend Entries} data group {sin functions}; \end{codeexample} % -\begin{codeexample}[width=7cm] +\begin{codeexample}[ + width=7cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + legend example/.style={ + scientific axes, all axes={length=1cm, ticks=none}, + 1={label in legend={text=1}}, + 2={label in legend={text=2}}, + 3={label in legend={text=3}}, + 4={label in legend={text=4}}, + 5={label in legend={text=5}}, + 6={label in legend={text=6}}, + 7={label in legend={text=7}}, + 8={label in legend={text=8}} + } +}}, +] \tikz \datavisualization [ visualize as smooth line/.list={1,2,3,4,5,6,7,8}, legend example, style sheet=vary hue, @@ -1496,7 +2617,30 @@ \subsubsection{Rows and Columns of Legend Entries} data group {sin functions}; \end{codeexample} % -\begin{codeexample}[width=7cm] +\begin{codeexample}[ + width=7cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {sin functions} = { + data [format=function] { + var set : {1,...,8}; + var x : interval [0:50]; + func y = sin(\value x * (\value{set}+10))/(\value{set}+5); + } +}; +\tikzdatavisualizationset { + legend example/.style={ + scientific axes, all axes={length=1cm, ticks=none}, + 1={label in legend={text=1}}, + 2={label in legend={text=2}}, + 3={label in legend={text=3}}, + 4={label in legend={text=4}}, + 5={label in legend={text=5}}, + 6={label in legend={text=6}}, + 7={label in legend={text=7}}, + 8={label in legend={text=8}} + } +}}, +] \tikz \datavisualization [ visualize as smooth line/.list={1,2,3,4,5,6,7,8}, legend example, style sheet=vary hue, @@ -1546,7 +2690,28 @@ \subsubsection{Legend Placement: The General Mechanism} As an example, let us put a legend to the right of the visualization, but so that the first entry starts at the top of the visualization: % -\begin{codeexample}[width=8cm] +\begin{codeexample}[ + width=8cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}, +] \tikz \datavisualization [ scientific axes, x axis={label=$x$}, visualize as smooth line/.list= @@ -1575,7 +2740,28 @@ \subsubsection{Legend Placement: Outside to the Data Visualization} \begin{key}{/tikz/data visualization/legend options/east outside} Placing the legend to the right of the data visualization is the default: % -\begin{codeexample}[width=8cm] +\begin{codeexample}[ + width=8cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}, +] \tikz \datavisualization [ scientific axes, visualize as smooth line/.list= @@ -1598,7 +2784,28 @@ \subsubsection{Legend Placement: Outside to the Data Visualization} A variant, where the legend is to the right, but aligned with the northern end of the data visualization: % -\begin{codeexample}[width=8cm] +\begin{codeexample}[ + width=8cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}, +] \tikz \datavisualization [ scientific axes, visualize as smooth line/.list= @@ -1615,7 +2822,28 @@ \subsubsection{Legend Placement: Outside to the Data Visualization} \end{key} \begin{key}{/tikz/data visualization/legend options/south east outside} -\begin{codeexample}[width=8cm] +\begin{codeexample}[ + width=8cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}, +] \tikz \datavisualization [ scientific axes, visualize as smooth line/.list= @@ -1633,7 +2861,28 @@ \subsubsection{Legend Placement: Outside to the Data Visualization} \begin{key}{/tikz/data visualization/legend options/west outside} The legend is placed left. Note that the text also swaps its position. % -\begin{codeexample}[width=8cm] +\begin{codeexample}[ + width=8cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}, +] \tikz \datavisualization [ scientific axes, visualize as smooth line/.list= @@ -1653,7 +2902,28 @@ \subsubsection{Legend Placement: Outside to the Data Visualization} \end{key} \begin{key}{/tikz/data visualization/legend options/north west outside} -\begin{codeexample}[width=8cm] +\begin{codeexample}[ + width=8cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}, +] \tikz \datavisualization [ scientific axes, visualize as smooth line/.list= @@ -1669,7 +2939,28 @@ \subsubsection{Legend Placement: Outside to the Data Visualization} \end{key} \begin{key}{/tikz/data visualization/legend options/south west outside} -\begin{codeexample}[width=8cm] +\begin{codeexample}[ + width=8cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}, +] \tikz \datavisualization [ scientific axes, visualize as smooth line/.list= @@ -1689,7 +2980,28 @@ \subsubsection{Legend Placement: Outside to the Data Visualization} The legend is placed above the data. Note that the legend entries now for a row rather than a column. % -\begin{codeexample}[width=8cm] +\begin{codeexample}[ + width=8cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}, +] \tikz \datavisualization [ scientific axes, visualize as smooth line/.list= @@ -1709,7 +3021,28 @@ \subsubsection{Legend Placement: Outside to the Data Visualization} \end{key} \begin{key}{/tikz/data visualization/legend options/south outside} -\begin{codeexample}[width=8cm] +\begin{codeexample}[ + width=8cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}, +] \tikz \datavisualization [ scientific axes, visualize as smooth line/.list= @@ -1740,7 +3073,28 @@ \subsubsection{Legend Placement: Inside to the Data Visualization} \begin{key}{/tikz/data visualization/legend options/south east inside} Puts the legend in the upper right corner of the data. % -\begin{codeexample}[width=8cm] +\begin{codeexample}[ + width=8cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}, +] \tikz \datavisualization [ scientific axes, visualize as smooth line/.list= @@ -1802,7 +3156,28 @@ \subsubsection{Legend Placement: Inside to the Data Visualization} is now a little smaller since there tends to be much less space inside the data visualization than next to it. % -\begin{codeexample}[width=8cm] +\begin{codeexample}[ + width=8cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}, +] \tikz \datavisualization [ scientific axes, visualize as smooth line/.list={log, lin}, @@ -1829,7 +3204,28 @@ \subsubsection{Legend Placement: Inside to the Data Visualization} key--value pairs that specify a data point. The legend will then be centered at this data point. % -\begin{codeexample}[width=6cm] +\begin{codeexample}[ + width=6cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}, +] \tikz \datavisualization [ scientific axes, visualize as smooth line/.list={log, lin}, @@ -1845,7 +3241,28 @@ \subsubsection{Legend Placement: Inside to the Data Visualization} \begin{key}{/tikz/data visualization/legend options/right of=\meta{data point}} Works like |at values|, but the anchor is set to |west|: % -\begin{codeexample}[width=6cm] +\begin{codeexample}[ + width=6cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}, +] \tikz \datavisualization [ scientific axes, visualize as smooth line/.list={log, lin}, @@ -1903,7 +3320,28 @@ \subsubsection{Legend Entries: General Styling} |/tikz/data visualization/legend entry options|. Thus, this key can use keys like |node style| to configure the styling of all text nodes: % -\begin{codeexample}[width=8cm] +\begin{codeexample}[ + width=8cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}, +] \tikz \datavisualization [ scientific axes, every label in legend/.style={node style= @@ -1926,7 +3364,28 @@ \subsubsection{Legend Entries: General Styling} This key can be used with a legend. It will simply add the \meta{options} to the |every label in legend| style for the given legend. % -\begin{codeexample}[width=8cm] +\begin{codeexample}[ + width=8cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}, +] \tikz \datavisualization [ scientific axes, visualize as smooth line/.list= @@ -1951,7 +3410,28 @@ \subsubsection{Legend Entries: Styling the Text Node} \begin{key}{/tikz/data visualization/legend entry options/node style=\meta{options}} This key adds \meta{options} to the styling of the text nodes of the label. % -\begin{codeexample}[width=8cm] +\begin{codeexample}[ + width=8cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}, +] \tikz \datavisualization [ scientific axes, visualize as smooth line/.list= @@ -1973,7 +3453,28 @@ \subsubsection{Legend Entries: Styling the Text Node} effect of this is that the label's text will have the same color as the data set to which it is attached. % -\begin{codeexample}[width=8cm] +\begin{codeexample}[ + width=8cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}, +] \tikz \datavisualization [ scientific axes, visualize as smooth line/.list= @@ -2003,7 +3504,28 @@ \subsubsection{Legend Entries: Text Placement} \begin{key}{/tikz/data visualization/legend entry options/text left} Placed the text node to the left of the data set style visualization. % -\begin{codeexample}[width=8cm] +\begin{codeexample}[ + width=8cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}, +] \tikz \datavisualization [ scientific axes, visualize as smooth line/.list= @@ -2024,7 +3546,28 @@ \subsubsection{Legend Entries: Text Placement} options only makes sense in conjunction with the |text colored| options, which is why this options is also selected implicitly. % -\begin{codeexample}[width=8cm] +\begin{codeexample}[ + width=8cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, + pre={\tikz \datavisualization data group {function classes} = { + data [set=log, format=function] { + var x : interval [0.2:2.5]; + func y = ln(\value x); + } + data [set=lin, format=function] { + var x : interval [-2:2.5]; + func y = 0.5*\value x; + } + data [set=squared, format=function] { + var x : interval [-1.5:1.5]; + func y = \value x*\value x; + } + data [set=exp, format=function] { + var x : interval [-2.5:1]; + func y = exp(\value x); + } +};}, +] \tikz \datavisualization [ scientific axes, visualize as smooth line/.list= @@ -2102,7 +3645,7 @@ \subsubsection{Advanced: Labels in Legends and Their Visualizers} picture. Typically, this will be a visual representation of the data set styling, but it could also be something different. % -\begin{codeexample}[width=6cm] +\begin{codeexample}[width=6cm,preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [ school book axes, visualize as line/.list={a,b}, style sheet=vary dashing, @@ -2186,7 +3729,7 @@ \subsubsection{Reference: Label in Legend Visualizers for Lines and Scatter Plot changing this style will change the appearance of lines in legends. The main other sensible option for this key is |straight label in legend line|. % -\begin{codeexample}[width=5cm] +\begin{codeexample}[width=5cm,preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [ school book axes, visualize as line/.list={a,b}, style sheet=vary dashing, @@ -2195,7 +3738,7 @@ \subsubsection{Reference: Label in Legend Visualizers for Lines and Scatter Plot data point [x=-1, y=1, set=b] data point [x=1, y=0.5, set=b]; \end{codeexample} % -\begin{codeexample}[width=5cm] +\begin{codeexample}[width=5cm,preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [ school book axes, visualize as line/.list={a,b}, legend entry options/default label in legend path/.style= @@ -2219,7 +3762,7 @@ \subsubsection{Reference: Label in Legend Visualizers for Lines and Scatter Plot default is to use |label in legend line one mark|. Another possible value is |label in legend line three marks|. % -\begin{codeexample}[width=5cm] +\begin{codeexample}[width=5cm,preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [ visualize as scatter/.list={a,b,c}, style sheet=cross marks, @@ -2257,7 +3800,7 @@ \subsubsection{Reference: Label in Legend Visualizers for Lines and Scatter Plot that is just a straight line, so it should start somewhere to the left of the origin at height $0$ and go to the origin: % -\begin{codeexample}[width=5cm] +\begin{codeexample}[width=5cm,preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [ school book axes, visualize as line/.list={a,b}, style sheet=vary dashing, @@ -2271,7 +3814,7 @@ \subsubsection{Reference: Label in Legend Visualizers for Lines and Scatter Plot Now let us make this a bit more fancy and useful by using shifted lines: % -\begin{codeexample}[width=5cm] +\begin{codeexample}[width=5cm,preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [ school book axes, visualize as line/.list={a,b}, legend={up then right}, style sheet=vary dashing, @@ -2285,7 +3828,7 @@ \subsubsection{Reference: Label in Legend Visualizers for Lines and Scatter Plot In the final example, we use a little ``hat'' to represent lines: % -\begin{codeexample}[width=5cm] +\begin{codeexample}[width=5cm,preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [ school book axes, visualize as line/.list={a,b}, legend={up then right}, style sheet=vary dashing, @@ -2312,7 +3855,7 @@ \subsubsection{Reference: Label in Legend Visualizers for Lines and Scatter Plot but usually it is not. In general, it is better to have marks for instance not at the ends of the line. % -\begin{codeexample}[width=5cm] +\begin{codeexample}[width=5cm,preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [ school book axes, visualize as line/.list={a,b}, legend={up then right}, @@ -2341,7 +3884,7 @@ \subsubsection{Reference: Label in Legend Visualizers for Lines and Scatter Plot \begin{key}{/tikz/data visualization/legend entry options/straight label in legend line} Just gives a straight line and two plot marks. % -\begin{codeexample}[width=5cm] +\begin{codeexample}[width=5cm,preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [visualize as line, line={style={mark=x}, label in legend={text=example, straight label in legend line}}]; @@ -2352,7 +3895,7 @@ \subsubsection{Reference: Label in Legend Visualizers for Lines and Scatter Plot distinguish -- even though there is no problem distinguishing them in a graph. % -\begin{codeexample}[width=5cm] +\begin{codeexample}[width=5cm,preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [visualize as line/.list={a,b,c}, legend entry options/default label in legend path/.style= straight label in legend line, @@ -2369,7 +3912,7 @@ \subsubsection{Reference: Label in Legend Visualizers for Lines and Scatter Plot plot marks are at the extremal points of the line. It works pretty well in almost all situations and is the default. % -\begin{codeexample}[width=5cm] +\begin{codeexample}[width=5cm,preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [ visualize as line=a, visualize as smooth line/.list={b,c}, @@ -2383,7 +3926,7 @@ \subsubsection{Reference: Label in Legend Visualizers for Lines and Scatter Plot optimal. This is the reason that the |cross marks| style uses different crosses: % -\begin{codeexample}[width=5cm] +\begin{codeexample}[width=5cm,preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [ visualize as line/.list={a,b}, visualize as smooth line=c, @@ -2400,7 +3943,10 @@ \subsubsection{Reference: Label in Legend Visualizers for Lines and Scatter Plot automatically selected for instance by the |polygon| or the |smooth cycle| styles. % -\begin{codeexample}[width=7cm] +\begin{codeexample}[ + width=7cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, +] \tikz \datavisualization [ scientific axes={clean}, all axes={length=3cm}, visualize as line/.list={a,b,c}, @@ -2429,7 +3975,10 @@ \subsubsection{Reference: Label in Legend Visualizers for Lines and Scatter Plot This style is especially tailored to for the |gap cycle| style and automatically selected by it: % -\begin{codeexample}[width=7cm] +\begin{codeexample}[ + width=7cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, +] \tikz \datavisualization [ scientific axes={clean}, all axes={length=3cm}, visualize as line/.list={a,b,c}, @@ -2460,7 +4009,7 @@ \subsubsection{Reference: Label in Legend Visualizers for Lines and Scatter Plot single mark (this is the default with a scatter plot or when the |no line| is selected. % -\begin{codeexample}[width=5cm] +\begin{codeexample}[width=5cm,preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [visualize as scatter/.list={a,b,c}, style sheet=cross marks, a={label in legend={text=example a}}, @@ -2473,7 +4022,7 @@ \subsubsection{Reference: Label in Legend Visualizers for Lines and Scatter Plot \begin{key}{/tikz/data visualization/legend entry options/label in legend three marks} An alternative to the previous style, where several marks are shown. % -\begin{codeexample}[width=5cm] +\begin{codeexample}[width=5cm,preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [visualize as scatter/.list={a,b,c}, style sheet=cross marks, a={label in legend={text=example a, label in legend three marks}}, diff --git a/doc/generic/pgf/text-en/pgfmanual-en-dv-visualizers.tex b/doc/generic/pgf/text-en/pgfmanual-en-dv-visualizers.tex index 5ae58720d..2c6fc8481 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-dv-visualizers.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-dv-visualizers.tex @@ -18,10 +18,6 @@ \subsection{Overview} in Section~\ref{section-dv-axes} to determine \emph{where} data points are visualized. It is the job of the visualizers to determine \emph{how} they are visualized. -% -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{datavisualization.formats.functions} -\end{codeexample} The most basic and common visualizer is the \emph{line visualizer}. It simply connects subsequent data points by straight lines to indicate either that the @@ -74,7 +70,7 @@ \subsubsection{Using a Single Visualizer} options starting with |visualize as ...| together with the |\datavisualization| command: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] % Define a data set: \tikz \datavisualization data group {example} = { data { @@ -133,7 +129,7 @@ \subsubsection{Using Multiple Visualizers} Since the |set| key has the path prefix |/data point|, it can be set like any other attribute of a data key: % -\begin{codeexample}[width=7cm] +\begin{codeexample}[width=7cm,preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [scientific axes=clean, visualize as line=sin, @@ -168,7 +164,7 @@ \subsubsection{Using Multiple Visualizers} \begin{key}{/pgf/data/set=\meta{name}} Shorthand for |/data point/set=|\meta{name}. % -\begin{codeexample}[width=7cm] +\begin{codeexample}[width=7cm,preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [scientific axes=clean, visualize as line=sin, @@ -200,7 +196,10 @@ \subsubsection{Using Multiple Visualizers} ``value'' passed to the key is parsed as a list of values. The key is then executed once for each of these values: % -\begin{codeexample}[width=7cm] +\begin{codeexample}[ + width=7cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, +] \tikz \datavisualization [scientific axes=clean, visualize as line/.list={sin, cos, tan}] @@ -240,7 +239,10 @@ \subsubsection{Styling a Visualizer} |label in legend| and |label in data|. The latter two options are discussed in Section~\ref{section-dv-labels-in}, the first option below. % -\begin{codeexample}[width=7cm] +\begin{codeexample}[ + width=7cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, +] \tikz \datavisualization [scientific axes=clean, visualize as smooth line/.list={sin, cos}, @@ -262,7 +264,10 @@ \subsubsection{Styling a Visualizer} The \meta{options} given to this key should be normal \tikzname\ options. They will be executed when the visualizer is used. % -\begin{codeexample}[width=7cm] +\begin{codeexample}[ + width=7cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, +] \tikz \datavisualization [scientific axes=clean, visualize as smooth line=sin, @@ -286,7 +291,10 @@ \subsubsection{Styling a Visualizer} (and easier) to use a style sheet, see Section~\ref{section-dv-style-sheets}. % -\begin{codeexample}[width=7cm] +\begin{codeexample}[ + width=7cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, +] \tikz \datavisualization [scientific axes={clean, end labels}, x axis={label=$x$}, y axis={grid={major also at=0}}, @@ -335,7 +343,10 @@ \subsubsection{Styling a Visualizer} This style is used with every visualizer. Note that it should contain normal \tikzname\ keys. % -\begin{codeexample}[width=7cm] +\begin{codeexample}[ + width=7cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, +] \tikz \datavisualization [scientific axes=clean, every visualizer/.style={dashed}, @@ -383,7 +394,10 @@ \subsubsection{Visualizing Data Points Using Lines} offered by \tikzname\ for configuring marks are available such as |mark repeat|: % -\begin{codeexample}[width=7cm] +\begin{codeexample}[ + width=7cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, +] \tikz \datavisualization [scientific axes=clean, visualize as line=my data, @@ -414,7 +428,10 @@ \subsubsection{Visualizing Data Points Using Lines} at the previous data point and a new line starts at the next data point. % -\begin{codeexample}[width=7cm] +\begin{codeexample}[ + width=7cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, +] \tikz \datavisualization [scientific axes=clean, x axis={grid={major at=(pi/2)}}, visualize as smooth line] @@ -439,7 +456,7 @@ \subsubsection{Visualizing Data Points Using Lines} \begin{key}{/tikz/data visualization/visualizer options/straight line} Causes the data points to be connected by straight lines. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz [scale=.55] \datavisualization [scientific axes=clean, all axes={ticks=few}, visualize as smooth line=my data, my data={straight line}] @@ -455,7 +472,7 @@ \subsubsection{Visualizing Data Points Using Lines} \begin{key}{/tikz/data visualization/visualizer options/straight cycle} Causes the data points to be connected by a polygon. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz [scale=.55] \datavisualization [scientific axes=clean, all axes={ticks=few}, visualize as smooth line=my data, my data={straight cycle}] @@ -476,7 +493,7 @@ \subsubsection{Visualizing Data Points Using Lines} Causes the data points to be connected by a line that is smoothed at the joins: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz [scale=.55] \datavisualization [scientific axes=clean, all axes={ticks=few}, visualize as smooth line=my data, my data={smooth line}] @@ -493,7 +510,7 @@ \subsubsection{Visualizing Data Points Using Lines} Causes the data points to be connected by a circular line that is smoothed at the joins: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz [scale=.55] \datavisualization [scientific axes=clean, all axes={ticks=few}, visualize as smooth line=my data, my data={smooth cycle}] @@ -511,7 +528,7 @@ \subsubsection{Visualizing Data Points Using Lines} quite touch'' the data points. This is implemented by using the |\pgfplothandlergaplineto|, see Section~\ref{section-plot-gapped}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz [scale=.55] \datavisualization [scientific axes=clean, all axes={ticks=few}, visualize as smooth line=my data, my data={gap line}] @@ -527,7 +544,7 @@ \subsubsection{Visualizing Data Points Using Lines} \begin{key}{/tikz/data visualization/visualizer options/gap cycle} Like |gapped line|, only with a cycle: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz [scale=.55] \datavisualization [scientific axes=clean, all axes={ticks=few}, visualize as smooth line=my data, my data={gap cycle}] @@ -544,7 +561,7 @@ \subsubsection{Visualizing Data Points Using Lines} Suppresses the line. This option only makes sense when the |mark| option is used. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz [scale=.55] \datavisualization [scientific axes=clean, all axes={ticks=few}, visualize as smooth line=my data, my data={no lines, style={mark=x}}] @@ -566,7 +583,10 @@ \subsubsection{Visualizing Data Points Using Marks} so that is will use |mark=x| (plus some size adjustments) to draw marks at the data points. % -\begin{codeexample}[width=7cm] +\begin{codeexample}[ + width=7cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, +] \tikz \datavisualization [scientific axes=clean, visualize as scatter] @@ -771,7 +791,7 @@ \subsection{Advanced: Creating New Visualizers} visualize as circle/.default=circle } -\begin{codeexample}[width=7cm] +\begin{codeexample}[width=7cm,preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [ scientific axes=clean, visualize as circle/.list={a, b, c}, diff --git a/doc/generic/pgf/text-en/pgfmanual-en-gd-overview.tex b/doc/generic/pgf/text-en/pgfmanual-en-gd-overview.tex index 4200be050..79dcdc1a6 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-gd-overview.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-gd-overview.tex @@ -36,11 +36,8 @@ \subsection{What Is Algorithmic Graph Drawing?} algorithm gets your description of the graph as an input and then decides where the nodes should go on the page. % -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{graphs} -\end{codeexample} -% -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} +\usegdlibrary{trees}}] \tikz \graph [binary tree layout, level distance=5mm] { 4 -- { 3 -- 0 -- 1[second], @@ -52,9 +49,8 @@ \subsection{What Is Algorithmic Graph Drawing?} }; \end{codeexample} -\begin{codeexample}[] -% \usetikzlibrary{graphs,graphdrawing,quotes} -% \usegdlibrary{force} +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing,quotes} +\usegdlibrary{force}}] \tikz \graph [spring layout, edge quotes mid, edges={nodes={font=\scriptsize, fill=white, sloped, inner sep=1pt}}] @@ -92,7 +88,8 @@ \subsection{Using the Graph Drawing System} should be drawn (``should be laid out'') using a so-called ``layered graph drawing algorithm'' (what these are will be explained later): % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows,graphs,graphdrawing} +\usegdlibrary{layered}}] \tikz [>=spaced stealth'] \graph [layered layout, components go right top aligned, nodes=draw, edges=rounded corners] { @@ -105,7 +102,8 @@ \subsection{Using the Graph Drawing System} Here is another example, where a different layout method is used that is more appropriate for trees: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} +\usegdlibrary{trees}}] \tikz [grow'=up, binary tree layout, nodes={circle,draw}] \node {1} child { node {2} @@ -126,7 +124,9 @@ \subsection{Using the Graph Drawing System} A final example, this time using a ``spring electrical layout'' (whatever that might be\dots): % -\begin{codeexample}[] +\begin{codeexample}[ + preamble={\usetikzlibrary{decorations.pathmorphing,graphs,graphdrawing} +\usegdlibrary{force}}] \tikz [spring electrical layout, node distance=1.3cm, every edge/.style={ decoration={coil, aspect=-.5, post length=1mm, diff --git a/doc/generic/pgf/text-en/pgfmanual-en-gd-usage-pgf.tex b/doc/generic/pgf/text-en/pgfmanual-en-gd-usage-pgf.tex index fc3830866..b3ade13c9 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-gd-usage-pgf.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-gd-usage-pgf.tex @@ -27,9 +27,6 @@ \section{Using Graph Drawing in PGF} \end{purepgflibrary} \ifluatex -\begin{codeexample}[setup code,hidden] - \usepgflibrary{graphdrawing} -\end{codeexample} \else This section of the manual can only be typeset using Lua\TeX. \expandafter\endinput @@ -75,7 +72,8 @@ \subsection{How Graph Drawing in PGF Works} Let us have a look at a simple example to see what happens when a graph is specified: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} +\usegdlibrary{trees}}] \tikz[tree layout] \graph {root [as=Hello] -> World[fill=blue!20]}; \end{codeexample} @@ -87,8 +85,8 @@ \subsection{How Graph Drawing in PGF Works} passed down to the graph drawing engine. This is implemented on the lowest layer, namely by directly intercepting nodes freshly created using |\pgfnode|. In our example, this happens in two places: For the |root| node and for the -|World| node. The |graph| library and \tikzname\ internally call the |\pgfnode| -macro for these two nodes (after a large number of internal syntax +|World| node. The |graphs| library and \tikzname\ internally call the +|\pgfnode| macro for these two nodes (after a large number of internal syntax translations, but the graph drawing system does not care about them). Note that the node boxes will have been fully created before they are passed @@ -536,7 +534,8 @@ \subsection{Layout Keys} |{tikzpicture}|, to |\scoped|, to |{scope}|, to |graph|, and to |{graph}|. For instance, the |tree layout| option can be used in the following ways: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} +\usegdlibrary{trees}}] \tikz [tree layout] \graph {1 -> {b,c}}; \tikz \graph [tree layout] {2 -> {b,c}}; \tikz \path graph [tree layout] {3 -> {b,c}}; @@ -558,7 +557,8 @@ \subsection{Layout Keys} particular, to typeset a tree given in the |child| syntax somewhere inside a |{tikzpicture}|, you must prefix it with the |\scoped| command: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} +\usegdlibrary{trees}}] \begin{tikzpicture} \scoped [tree layout] \node {root} @@ -569,7 +569,8 @@ \subsection{Layout Keys} % Naturally, the above could have been written more succinctly as % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} +\usegdlibrary{trees}}] \tikz [tree layout] \node {root} child { node {left child} } @@ -578,7 +579,8 @@ \subsection{Layout Keys} % Or even more succinctly: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} +\usegdlibrary{trees}}] \tikz \graph [tree layout] { root -- {left child, right child} }; \end{codeexample} % diff --git a/doc/generic/pgf/text-en/pgfmanual-en-gd-usage-tikz.tex b/doc/generic/pgf/text-en/pgfmanual-en-gd-usage-tikz.tex index 621ec0da7..7e29d1733 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-gd-usage-tikz.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-gd-usage-tikz.tex @@ -19,9 +19,6 @@ \section{Using Graph Drawing in \tikzname} \end{tikzlibrary} \ifluatex -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{graphdrawing} -\end{codeexample} \else This section of the manual can only be typeset using Lua\TeX. \expandafter\endinput @@ -92,7 +89,8 @@ \subsection{Choosing a Layout and a Library} you just add an option ending with |... layout| to the |graph| path operation and then let the graph drawing do its magic: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} +\usegdlibrary{layered}}] \tikz [rounded corners] \graph [layered layout, sibling distance=8mm, level distance=8mm] { @@ -173,7 +171,8 @@ \subsection{Graph Drawing Parameters} important for many algorithms and they are documented in the course of the present section. Here is an example of an option the ``always works'': % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} +\usegdlibrary{force}}] \tikz \graph [spring layout, vertical=1 to 2] { 1--2--3--1 }; \end{codeexample} @@ -222,7 +221,8 @@ \subsubsection{Sublayouts} Let us start with the ``plain'' syntax for opening sublayouts: You pass a key for creating layouts to a |scope|: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} +\usegdlibrary{force,trees}}] \tikz [spring layout] { \begin{scope}[tree layout] \node (a) {a}; @@ -261,7 +261,8 @@ \subsubsection{Sublayouts} of \meta{sublayout} will be parsed using the usual |graph| syntax, but will form a sublayout. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} +\usegdlibrary{force,trees}}] \tikz \graph [spring layout] { // [tree layout] { a -- {b, c} }; // [tree layout] { 1 -- 2 }; @@ -273,7 +274,8 @@ \subsubsection{Sublayouts} that the two sublayouts will be part of the main graph, but will not be indicated otherwise. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} +\usegdlibrary{circular,trees}}] \tikz \graph [simple necklace layout] { // [simple necklace layout] { a -> b -> c -> d -> e -> f -> a }; @@ -297,7 +299,8 @@ \subsubsection{Sublayouts} Compare the above to the following code: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} +\usegdlibrary{circular,trees}}] \tikz \graph [simple necklace layout] { // [tree layout] { % first ``giant node'' a -> {1, 2}; @@ -339,7 +342,11 @@ \subsubsection{Subgraph Nodes} The idea ist that a subgraph node is declared like a normal node specification, but is followed by a double slash and a subgraph: % -\begin{codeexample}[width=5cm] +\begin{codeexample}[ + width=5cm, + preamble={\usetikzlibrary{graphs,graphdrawing} +\usegdlibrary{circular,trees}}, +] \tikz \graph [simple necklace layout] { tree 1[draw, circle] // [tree layout] { a -> {1, 2}; } -> b @@ -358,7 +365,8 @@ \subsubsection{Subgraph Nodes} subgraph node will simply surround all nodes that were placed by the main layout wherever they were placed: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} +\usegdlibrary{trees}}] \tikz [subgraph text bottom=text centered, subgraph nodes={font=\itshape}] \graph [tree layout] { @@ -380,7 +388,8 @@ \subsubsection{Subgraph Nodes} \begin{key}{/tikz/subgraph nodes=\meta{style}} Sets the |every subgraph node| style to \meta{style}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} +\usegdlibrary{trees}}] \tikz [subgraph text bottom=text centered, subgraph nodes=red] \graph [tree layout] { @@ -401,7 +410,8 @@ \subsubsection{Subgraph Nodes} option is useful in situations when subgraph nodes generally should not have any text inside them. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} +\usegdlibrary{trees}}] \tikz [subgraph text none] \graph [tree layout] { a -> { b -> {c, d}, e -> {f, g -> h} }; @@ -420,7 +430,8 @@ \subsubsection{Subgraph Nodes} the subgraph node: Still inside the node, but above all nodes inside the subgraph node. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} +\usegdlibrary{trees}}] \tikz [subgraph text top=text ragged left] \graph [tree layout] { a -> { b -> {c, d}, e -> {f, g -> h} }; @@ -435,7 +446,11 @@ \subsubsection{Subgraph Nodes} You can pass any of the \meta{text alignment options} understood by \tikzname, such as |text centered|: % -\begin{codeexample}[width=5cm] +\begin{codeexample}[ + width=5cm, + preamble={\usetikzlibrary{graphs,graphdrawing} +\usegdlibrary{trees}}, +] \tikz [subgraph text top=text centered] \graph [tree layout] { a -> { b -> {c, d}, e -> {f, g -> h} }; @@ -447,7 +462,8 @@ \subsubsection{Subgraph Nodes} To place a label \emph{outside} the subgraph node, use a label, typically defined using the |quotes| library: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing,quotes} +\usegdlibrary{trees}}] \tikz \graph [tree layout] { a -> { b -> {c, d}, e -> {f, g -> h} }; diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-3d.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-3d.tex index ace4e1d9f..a8f91c730 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-3d.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-3d.tex @@ -14,10 +14,6 @@ \section{Three Dimensional Drawing Library} This package provides some styles and options for drawing three dimensional shapes. \end{tikzlibrary} -% -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{3d} -\end{codeexample} \subsection{Coordinate Systems} @@ -43,7 +39,7 @@ \subsection{Coordinate Systems} Factor by which the $z$-vector is multiplied. \end{key} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{3d}}] \begin{tikzpicture}[->] \draw (0,0,0) -- (xyz cylindrical cs:radius=1); \draw (0,0,0) -- (xyz cylindrical cs:radius=1,angle=90); @@ -75,7 +71,7 @@ \subsection{Coordinate Systems} Same as |longitude|. \end{key} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{3d}}] \begin{tikzpicture}[->] \draw (0,0,0) -- (xyz spherical cs:radius=1); \draw (0,0,0) -- (xyz spherical cs:radius=1,latitude=90); @@ -112,7 +108,7 @@ \subsubsection{Switching to an arbitrary plane} Note that you have to set the units \emph{before} calling |canvas is plane|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{3d}}] \begin{tikzpicture}[ ->, plane x={(0.707,-0.707)}, @@ -192,7 +188,7 @@ \subsubsection{Predefined planes} \subsection{Examples} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{3d}}] \begin{tikzpicture}[z={(10:10mm)},x={(-45:5mm)}] \def\wave{ \draw[fill,thick,fill opacity=.2] @@ -223,7 +219,7 @@ \subsection{Examples} \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{3d}}] \begin{tikzpicture} \begin{scope}[canvas is zy plane at x=0] \draw (0,0) circle (1cm); diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-angles.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-angles.tex index 0b96a8e06..a011ea8b5 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-angles.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-angles.tex @@ -14,10 +14,6 @@ \section{Angle Library} \begin{tikzlibrary}{angles} This library defines pic types for drawing angles. \end{tikzlibrary} -% -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{angles} -\end{codeexample} \begin{pictype}{angle}{\opt{|=|\meta{A}|--|\meta{B}|--|\meta{C}}} This pic adds a drawing of an angle to the current path. This ``drawing of @@ -29,7 +25,7 @@ \section{Angle Library} \begin{key}{/tikz/angle radius=\meta{dimension} (initially 5mm)} The length of the sides of the angle's wedge: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{angles}}] \tikz \draw (2,0) coordinate (A) -- (0,0) coordinate (B) -- (-1,-1) coordinate (C) pic [fill=black!50] {angle = A--B--C} @@ -51,7 +47,7 @@ \section{Angle Library} an option like |fill| or |shade| is passed to the pic. The following example shows the difference: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{angles}}] \tikz \draw [line width=2mm] (2,0) coordinate (A) -- (0,0) coordinate (B) -- (1,1) coordinate (C) @@ -65,19 +61,19 @@ \section{Angle Library} following factor: % \begin{key}{/tikz/angle eccentricity=\meta{factor} (initially 0.6)} -\begin{codeexample}[preamble={\usetikzlibrary{quotes}}] +\begin{codeexample}[preamble={\usetikzlibrary{angles,quotes}}] \tikz \draw (2,0) coordinate (A) -- (0,0) coordinate (B) -- (1,1) coordinate (C) pic ["$\alpha$", draw, ->] {angle}; \end{codeexample} % -\begin{codeexample}[preamble={\usetikzlibrary{quotes}}] +\begin{codeexample}[preamble={\usetikzlibrary{angles,quotes}}] \tikz \draw (2,0) coordinate (A) -- (0,0) coordinate (B) -- (1,1) coordinate (C) pic ["$\alpha$", draw, angle eccentricity=1] {angle}; \end{codeexample} % -\begin{codeexample}[preamble={\usetikzlibrary{quotes}}] +\begin{codeexample}[preamble={\usetikzlibrary{angles,quotes}}] \tikz { \draw (2,0) coordinate (A) -- (0,0) coordinate (B) -- (1,1) coordinate (C) @@ -93,7 +89,7 @@ \section{Angle Library} This pic adds a drawing of a right angle to the current path. It works in the same way as |angle| pic. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{angles}}] \tikz \draw (0,0,0) coordinate (O) (1,0,0) coordinate (A) -- (O) diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-automata.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-automata.tex index 3a18153d8..b8241558e 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-automata.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-automata.tex @@ -14,10 +14,6 @@ \section{Automata Drawing Library} This packages provides shapes and styles for drawing finite state automata and Turing machines. \end{tikzlibrary} -% -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{automata} -\end{codeexample} \subsection{Drawing Automata} @@ -47,7 +43,7 @@ \subsection{Drawing Automata} nondeterministic four state automaton that checks whether an input contains the sequence $0^*1$ or the sequence $1^*0$. % -\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] +\begin{codeexample}[preamble={\usetikzlibrary{automata,positioning}}] \begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto] \draw[help lines] (0,0) grid (3,2); @@ -86,7 +82,7 @@ \subsection{States With and Without Output} output, use the command |\nodepart{lower}| inside the node. This style also calls |every state|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{automata}}] \begin{tikzpicture} \draw[help lines] (0,0) grid (3,2); @@ -101,7 +97,8 @@ \subsection{States With and Without Output} \begin{stylekey}{/tikz/state (initially state without output)} You should redefine it to something else, if you wish to use states of a different nature. -\begin{codeexample}[] + % +\begin{codeexample}[preamble={\usetikzlibrary{automata}}] \begin{tikzpicture}[state/.style=state with output] \node[state] {$q_0$ \nodepart{lower} $11$}; \node[state] at (2,0) {$q_1$ \nodepart{lower} $00$}; @@ -115,7 +112,7 @@ \subsection{States With and Without Output} |state without output|. By default, it does nothing, but you can use it to make your state look more fancy: % -\begin{codeexample}[preamble={\usetikzlibrary{arrows,positioning}}] +\begin{codeexample}[preamble={\usetikzlibrary{arrows,automata,positioning}}] \begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,>=stealth', every state/.style={draw=blue!50,very thick,fill=blue!20}] @@ -170,7 +167,7 @@ \subsection{Initial and Accepting States} whatever. \end{stylekey} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{automata}}] \begin{tikzpicture}[every initial by arrow/.style={text=red,->>}] \node[state,initial,initial distance=2cm] {$q_0$}; \end{tikzpicture} @@ -240,7 +237,7 @@ \subsection{Initial and Accepting States} text. \end{stylekey} % -\begin{codeexample}[preamble={\usetikzlibrary{arrows,positioning}}] +\begin{codeexample}[preamble={\usetikzlibrary{arrows,automata,positioning}}] \begin{tikzpicture} [shorten >=1pt,node distance=2cm,on grid,>=stealth',initial text=, every state/.style={draw=blue!50,very thick,fill=blue!20}, @@ -286,7 +283,7 @@ \subsection{Examples} state: Initial states are red, accepting states are green, and normal states are orange. Then, we must find a path from a red state to a green state. % -\begin{codeexample}[preamble={\usetikzlibrary{arrows,positioning,shadows}}] +\begin{codeexample}[preamble={\usetikzlibrary{arrows,automata,positioning,shadows}}] \begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,>=stealth',thick, every state/.style={fill,draw=none,orange,text=white,circular drop shadow}, accepting/.style ={green!50!black,text=white}, @@ -308,7 +305,7 @@ \subsection{Examples} The next example is the current candidate for the five-state busiest beaver: % -\begin{codeexample}[preamble={\usetikzlibrary{arrows,positioning}}] +\begin{codeexample}[preamble={\usetikzlibrary{arrows,automata,positioning}}] \begin{tikzpicture}[->,>=stealth',shorten >=1pt,% auto,node distance=2cm,on grid,semithick, inner sep=2pt,bend angle=45] diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-backgrounds.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-backgrounds.tex index 9acb80d15..7755003fb 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-backgrounds.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-backgrounds.tex @@ -18,10 +18,6 @@ \section{Background Library} picture to get a rectangular box around your picture or |gridded| to put a grid behind your picture. \end{tikzlibrary} -% -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{backgrounds} -\end{codeexample} The first use of this library is to make the following key available: % @@ -34,7 +30,7 @@ \section{Background Library} be executed \emph{before} the actual background material starts and, thus, will have no effect on it. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{backgrounds}}] \begin{tikzpicture} % On main layer: \fill[blue] (0,0) circle (1cm); @@ -66,7 +62,7 @@ \section{Background Library} you have a global setup in |every picture|, you should consider putting that part of it that concerns the graphics state into this style. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{backgrounds}}] \tikzset{ every picture/.style={line width=1ex}, every on background layer/.style={every picture} @@ -88,7 +84,7 @@ \section{Background Library} option must be given to the |{tikzpicture}| environment or to the |\tikz| command. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{backgrounds}}] \begin{tikzpicture}[show background rectangle] \draw (0,0) ellipse (10mm and 5mm); \end{tikzpicture} @@ -134,7 +130,7 @@ \section{Background Library} causes a light blue background to be added to the picture. You can also use more fancy settings as shown in the following example: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{backgrounds}}] \begin{tikzpicture} [background rectangle/.style= {double,ultra thick,draw=red,top color=blue,rounded corners}, @@ -146,7 +142,7 @@ \section{Background Library} Naturally, no one in their right mind would use the above, but here is a nice background: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{backgrounds}}] \begin{tikzpicture} [background rectangle/.style= {draw=blue!50,fill=blue!20,rounded corners=1ex}, @@ -167,7 +163,7 @@ \section{Background Library} right corner of the grid is computed in the same way as for the background rectangle: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{backgrounds}}] \begin{tikzpicture}[show background grid] \draw (0,0) ellipse (10mm and 5mm); \end{tikzpicture} @@ -178,7 +174,7 @@ \section{Background Library} \begin{stylekey}{/tikz/background grid (initially draw,help lines)} This style dictates how the background grid path is drawn. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{backgrounds}}] \begin{tikzpicture} [background grid/.style={thick,draw=red,step=.5cm}, show background grid] @@ -190,7 +186,7 @@ \section{Background Library} This option can be combined with the |framed| option (use the |framed| option first): % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{backgrounds}}] \tikzset{background grid/.style={thick,draw=red,step=.5cm}, background rectangle/.style={rounded corners,fill=yellow}} \begin{tikzpicture}[framed,gridded] @@ -209,7 +205,7 @@ \section{Background Library} rectangle. Normally, the line coincides exactly with the top line of the background rectangle: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{backgrounds}}] \begin{tikzpicture}[ background rectangle/.style={fill=yellow}, framed,show background top] @@ -222,7 +218,7 @@ \section{Background Library} \begin{key}{/tikz/outer frame xsep=\meta{dimension} (initially 0pt)} The \meta{dimension} is added at the left and right side of the line. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{backgrounds}}] \begin{tikzpicture} [background rectangle/.style={fill=yellow}, framed, @@ -242,7 +238,7 @@ \section{Background Library} Sets both the $x$- and $y$-separation. \end{key} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{backgrounds}}] \begin{tikzpicture} [background rectangle={fill=blue!20}, outer frame sep=1ex,% @@ -258,7 +254,7 @@ \section{Background Library} style: % \begin{stylekey}{/tikz/background top (initially draw)} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{backgrounds}}] \tikzset{background rectangle/.style={fill=blue!20}, background top/.style={draw=blue!50,line width=1ex}} \begin{tikzpicture}[framed,show background top] diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-calendar.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-calendar.tex index 92232a6d3..2696fe196 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-calendar.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-calendar.tex @@ -19,10 +19,6 @@ \section{Calendar Library} The |\calendar| command is quite configurable, allowing you to produce all kinds of different calendars. \end{tikzlibrary} -% -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{calendar} -\end{codeexample} \subsection{Calendar Command} @@ -105,7 +101,7 @@ \subsection{Calendar Command} arrangement is a bit tricky, it is explained only later on. For the time being, let us use a predefined arrangement to produce our first calendar: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \tikz \calendar[dates=2000-01-01 to 2000-01-31,week list]; \end{codeexample} @@ -120,7 +116,7 @@ \subsection{Calendar Command} Specifies the horizontal shift between days. This is not the gap between days, but the shift between the anchors of their nodes. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \tikz \calendar[dates=2000-01-01 to 2000-01-31,week list,day xshift=3ex]; \end{codeexample} \end{key} @@ -129,7 +125,7 @@ \subsection{Calendar Command} Specifies the vertical shift between days. Again, this is the shift between the anchors of their nodes. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \tikz \calendar[dates=2000-01-01 to 2000-01-31,week list,day yshift=2ex]; \end{codeexample} \end{key} @@ -141,12 +137,12 @@ \subsection{Calendar Command} \begin{key}{/tikz/month yshift=\meta{dimension}} Specifies an additional vertical shift between different months. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \tikz \calendar[dates=2000-01-01 to 2000-02-last,week list, month yshift=0pt]; \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \tikz \calendar[dates=2000-01-01 to 2000-02-last,week list, month yshift=1cm]; \end{codeexample} @@ -173,7 +169,7 @@ \subsection{Calendar Command} the whole matrix. For example, the following calendar is placed in such a way the center of 2000-01-20 lies on the position $(2,2)$: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \begin{tikzpicture} \draw[help lines] (0,0) grid (3,2); \matrix [anchor=cal-2000-01-20.center] at (2,2) @@ -199,7 +195,7 @@ \subsection{Calendar Command} day. The default is to create a node with an appropriate name, but you can change this: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \tikz \calendar[dates=2000-01-01 to 2000-01-31,week list, day code={\fill[blue] (0,0) circle (2pt);}]; \end{codeexample} @@ -221,7 +217,7 @@ \subsection{Calendar Command} been named |mycal|, then the node containing the |1| for this date will be names |mycal-2006-01-01|. You can later reference this node. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \begin{tikzpicture} \calendar (mycal) [dates=2000-01-01 to 2000-01-31,week list]; @@ -235,7 +231,7 @@ \subsection{Calendar Command} macro simply yields the current day of month, but you can change it arbitrarily. Here is a silly example: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \tikz \calendar[dates=2000-01-01 to 2000-01-31,week list, day text=x]; \end{codeexample} @@ -259,7 +255,7 @@ \subsection{Calendar Command} Let us redefine the |day text| so that it yields the day with a leading zero: % -\begin{codeexample}[leave comments] +\begin{codeexample}[leave comments,preamble={\usetikzlibrary{calendar}}] \tikz \calendar[dates=2000-01-01 to 2000-01-31,week list, day text=\%d0]; \end{codeexample} @@ -270,7 +266,7 @@ \subsection{Calendar Command} |every day| style is useful for changing the way days look. For example, let us make all days red: % -\begin{codeexample}[leave comments] +\begin{codeexample}[leave comments,preamble={\usetikzlibrary{calendar}}] \tikz[every day/.style=red] \calendar[dates=2000-01-01 to 2000-01-31,week list]; \end{codeexample} @@ -284,7 +280,7 @@ \subsection{Calendar Command} per month or year and this is not done by default. Rather, special styles starting with |month label| place these labels and make them visible: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \tikz \calendar[dates=2000-01-01 to 2000-02-last,week list, month label above centered]; \end{codeexample} @@ -309,7 +305,7 @@ \subsection{Calendar Command} default, the month text is a long textual presentation of the current month being typeset. % -\begin{codeexample}[leave comments] +\begin{codeexample}[leave comments,preamble={\usetikzlibrary{calendar}}] \tikz \calendar[dates=2000-01-01 to 2000-01-31,week list, month label above centered, month text=\textcolor{red}{\%mt} \%y-]; @@ -389,7 +385,7 @@ \subsection{Calendar Command} Let us now have a look at some examples. First, we use a conditional to make all Sundays red. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \tikz \calendar [dates=2000-01-01 to 2000-01-31,week list] @@ -398,7 +394,7 @@ \subsection{Calendar Command} % Next, let us do something on a specific date: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \tikz \calendar [dates=2000-01-01 to 2000-01-31,week list] @@ -411,7 +407,7 @@ \subsection{Calendar Command} |base east| anchor, which shifts the label up and right. To overcome this problem we can change the anchor: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \tikz [every day/.style={anchor=mid}] \calendar [dates=2000-01-01 to 2000-01-31,week list] @@ -500,7 +496,7 @@ \subsubsection{Creating a Simple List of Days} each day. This shift must be \emph{outside} the day scope as we want day shifts to accumulate. Thus, we use the following code: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \tikz \calendar [dates=2000-01-01 to 2000-01-08, execute after day scope= @@ -527,7 +523,7 @@ \subsubsection{Adding a Month Label} safer to put the code inside the scope to ensure that settings to not inadvertently ``leak outside''. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \tikz \calendar [dates=2000-01-01 to 2000-01-08, @@ -559,7 +555,7 @@ \subsubsection{Creating a Week List Arrangement} beginning of the day scope to horizontally shift the day according to its day of week. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \tikz \calendar [dates=2000-01-01 to 2000-01-20, @@ -587,7 +583,7 @@ \subsubsection{Creating a Month List Arrangement} that the first day of the month lies on the correct day of week column. For this, we remember this day of week the first time we see it. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \newcount\mycount \tikz \calendar @@ -623,7 +619,7 @@ \subsection{Arrangements} The shift between days is given by |day yshift|. Between month an additional shift of |month yshift| is added. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \tikz \calendar [dates=2000-01-28 to 2000-02-03, day list downward,month yshift=1em]; @@ -634,7 +630,7 @@ \subsection{Arrangements} \begin{stylekey}{/tikz/day list upward} Works as above, only the list grows upward instead of downward. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \tikz \calendar [dates=2000-01-28 to 2000-02-03, day list upward,month yshift=1em]; @@ -647,7 +643,7 @@ \subsection{Arrangements} Instead of |day yshift| and |month yshift|, the values of |day xshift| and |month xshift| are used. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \tikz \calendar [dates=2000-01-28 to 2000-02-03, day list right,month xshift=1em]; @@ -679,12 +675,12 @@ \subsection{Arrangements} additional vertical space of |month yshift| is added. If this is set to |0pt| you get a continuous list of days. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \tikz \calendar [dates=2000-01-01 to 2000-02-last,week list]; \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \tikz \calendar [dates=2000-01-01 to 2000-02-last,week list, month yshift=0pt]; @@ -705,7 +701,7 @@ \subsection{Arrangements} does not start with a Monday, its days are shifted to the right such that the days lie on the correct columns. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \sffamily\scriptsize \tikz \calendar [dates=2000-01-01 to 2000-12-31, @@ -734,7 +730,7 @@ \subsection{Month Labels} position is chosen ``as if'' the month had started on a Monday -- which is usually exactly what you want.) % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \tikz \calendar [dates=2000-01-28 to 2000-02-03, day list downward,month yshift=1em, @@ -747,7 +743,7 @@ \subsection{Month Labels} This style works like the above style, only the label is rotated counterclockwise by 90 degrees. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \tikz \calendar [dates=2000-01-28 to 2000-02-03, day list downward,month yshift=1em, @@ -762,7 +758,7 @@ \subsection{Month Labels} the right of the first day, for a week list it is to the right of the first week, and for a month list it is to the right of the whole month. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \tikz \calendar [dates=2000-01-28 to 2000-02-03, day list downward,month yshift=1em, @@ -774,7 +770,7 @@ \subsection{Month Labels} \begin{stylekey}{/tikz/month label right vertical} Works as above, only the label is rotated clockwise by 90 degrees. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \tikz \calendar [dates=2000-01-28 to 2000-02-03, day list downward,month yshift=1em, @@ -789,14 +785,14 @@ \subsection{Month Labels} raised is fixed to |1.25em|; use the |yshift| option with the month node to modify this. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \tikz \calendar [dates=2000-01-28 to 2000-02-03, day list right,month xshift=1em, month label above left]; \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \tikz \calendar [dates=2000-01-20 to 2000-02-10, week list,month label above left]; @@ -808,13 +804,13 @@ \subsection{Month Labels} Works as above, only the label is centered above the row containing the first day. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \tikz \calendar [dates=2000-02-01 to 2000-02-last, day list right,month label above centered]; \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \tikz \calendar [dates=2000-01-20 to 2000-02-10, week list,month label above centered]; @@ -825,7 +821,7 @@ \subsection{Month Labels} \begin{stylekey}{/tikz/month label above right} Works as above, but flushed right % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \tikz \calendar [dates=2000-01-20 to 2000-02-10, week list,month label above right]; @@ -838,7 +834,7 @@ \subsection{Month Labels} row. This placement is not really useful with the |week list| arrangement, but rather with the |day list right| or |month list| arrangement. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \tikz \calendar [dates=2000-02-01 to 2000-02-last, day list right,month label below left]; @@ -849,7 +845,7 @@ \subsection{Month Labels} \begin{stylekey}{/tikz/month label below centered} Works like |month label above centered|, only below. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \tikz \calendar [dates=2000-02-01 to 2000-02-last, day list right,month label below centered]; @@ -867,7 +863,10 @@ \subsection{Examples} approach the big celebration. For this, we set the shape to |strike out| for these dates. % -\begin{codeexample}[leave comments,preamble={\usetikzlibrary{shapes.misc}}] +\begin{codeexample}[ + leave comments, + preamble={\usetikzlibrary{calendar,shapes.misc}}, +] \begin{tikzpicture} \calendar [ @@ -886,7 +885,10 @@ \subsection{Examples} really should be done by then. All days on which we can no longer work on the project are crossed out. % -\begin{codeexample}[leave comments,preamble={\usetikzlibrary{shapes.misc}}] +\begin{codeexample}[ + leave comments, + preamble={\usetikzlibrary{calendar,shapes.misc}}, +] \begin{tikzpicture} \calendar [ @@ -908,7 +910,7 @@ \subsection{Examples} The following example is a futuristic calendar that is all about circles: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calendar}}] \sffamily \colorlet{winter}{blue} @@ -956,7 +958,7 @@ \subsection{Examples} Next, let's us have a whole year in a tight column: % -\begin{codeexample}[leave comments] +\begin{codeexample}[leave comments,preamble={\usetikzlibrary{calendar}}] \begin{tikzpicture} \small\sffamily \colorlet{darkgreen}{green!50!black} diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-chains.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-chains.tex index 4b8bb595f..1dc247866 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-chains.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-chains.tex @@ -14,10 +14,6 @@ \section{Chains} \begin{tikzlibrary}{chains} This library defines options for creating chains. \end{tikzlibrary} -% -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{chains} -\end{codeexample} \subsection{Overview} @@ -78,7 +74,7 @@ \subsection{Starting and Continuing a Chain} Other than this, this key has no further effect. In particular, to place nodes on the chain, you must use the |on chain| option, described next. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{chains}}] \begin{tikzpicture}[start chain] % The chain is called just "chain" \node [on chain] {A}; @@ -87,7 +83,7 @@ \subsection{Starting and Continuing a Chain} \end{tikzpicture} \end{codeexample} -\begin{codeexample}[preamble={\usetikzlibrary{scopes}}] +\begin{codeexample}[preamble={\usetikzlibrary{chains,scopes}}] \begin{tikzpicture} % Same as above, using the scope shorthand { [start chain] @@ -98,7 +94,7 @@ \subsection{Starting and Continuing a Chain} \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{chains}}] \begin{tikzpicture}[start chain=1 going right, start chain=2 going below, node distance=5mm, @@ -127,7 +123,7 @@ \subsection{Starting and Continuing a Chain} first is to change the direction of a chain as it is being constructed. For this, just give this option somewhere inside the scope of the chain. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{chains}}] \begin{tikzpicture}[start chain=going right,node distance=5mm] \node [draw,on chain] {Hello}; \node [draw,on chain] {World}; @@ -140,7 +136,7 @@ \subsection{Starting and Continuing a Chain} The second application is to reactivate a chain after it ``has already been closed down''. % -\begin{codeexample}[preamble={\usetikzlibrary{scopes}}] +\begin{codeexample}[preamble={\usetikzlibrary{chains,scopes}}] \begin{tikzpicture}[node distance=5mm, every node/.style=draw] { [start chain=1] @@ -235,7 +231,7 @@ \subsection{Nodes on a Chain} to |\tikzchainprevious| and |\tikzchaincount| for doing your positioning calculations. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{chains}}] \begin{tikzpicture}[start chain=circle placed {at=(\tikzchaincount*30:1.5)}] \foreach \i in {1,...,10} \node [on chain] {\i}; @@ -256,7 +252,7 @@ \subsection{Nodes on a Chain} the right of the previous one, spaced by the current value of |node distance|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{chains}}] \begin{tikzpicture}[start chain,node distance=5mm] \node [draw,on chain] {}; \node [draw,on chain] {Hallo}; @@ -267,7 +263,7 @@ \subsection{Nodes on a Chain} The optional \meta{direction} allows us to temporarily change the direction in the middle of a chain: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{chains}}] \begin{tikzpicture}[start chain,node distance=5mm] \node [draw,on chain] {Hello}; \node [draw,on chain] {World}; @@ -279,7 +275,7 @@ \subsection{Nodes on a Chain} You can also use more complicated computations in the \meta{direction}: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{chains}}] \begin{tikzpicture}[start chain=going {at=(\tikzchainprevious),shift=(30:1)}] \draw [help lines] (0,0) grid (3,2); \node [draw,on chain] {1}; @@ -330,7 +326,7 @@ \subsection{Nodes on a Chain} In particular, it is possible to continue to path after a |\chainin| command, though that does not seem very useful. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{chains}}] \begin{tikzpicture}[node distance=5mm, every node/.style=draw,every join/.style=->] \draw [help lines] (0,0) grid (3,2); @@ -351,7 +347,7 @@ \subsection{Nodes on a Chain} connected using a chain % {\catcode`\|=12 -\begin{codeexample}[preamble={\usetikzlibrary{matrix,scopes,shapes.geometric}}] +\begin{codeexample}[preamble={\usetikzlibrary{chains,matrix,scopes,shapes.geometric}}] \begin{tikzpicture}[every node/.style=draw] \matrix [matrix of nodes,column sep=5mm,row sep=5mm] { @@ -395,7 +391,7 @@ \subsection{Joining Nodes on a Chain} order to connect it to several nodes. This is especially useful for joining in branches, see the next section. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{chains}}] \begin{tikzpicture}[start chain,node distance=5mm, every join/.style={->,red}] \node [draw,on chain,join] {}; @@ -442,7 +438,7 @@ \subsection{Branches} to the fork node. \end{itemize} % -\begin{codeexample}[preamble={\usetikzlibrary{scopes}}] +\begin{codeexample}[preamble={\usetikzlibrary{chains,scopes}}] \begin{tikzpicture}[every on chain/.style=join,every join/.style=->, node distance=2mm and 1cm] { [start chain=trunk] @@ -477,7 +473,7 @@ \subsection{Branches} chain}|/|\meta{branch name} is used as the chain name, rather than just \meta{branch name}. % -\begin{codeexample}[preamble={\usetikzlibrary{scopes}}] +\begin{codeexample}[preamble={\usetikzlibrary{chains,scopes}}] \begin{tikzpicture}[every on chain/.style=join,every join/.style=->, node distance=2mm and 1cm] { [start chain=trunk] diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-circuits.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-circuits.tex index e6fcc8afb..746d0e7cf 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-circuits.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-circuits.tex @@ -24,12 +24,6 @@ \subsection{Introduction} graphical representations of circuits. % \begin{codeexample}[setup code,hidden] - \usetikzlibrary{ - circuits.logic.US, - circuits.logic.IEC, - circuits.logic.CDH, - circuits.ee.IEC, - } \tikzset{ % from `shape` library shape example/.style= {color = black!30, @@ -44,7 +38,7 @@ \subsection{Introduction} \subsubsection{A First Example} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \begin{tikzpicture}[circuit ee IEC,x=3cm,y=2cm,semithick, every info/.style={font=\footnotesize}, small circuit symbols, @@ -221,7 +215,7 @@ \subsubsection{Symbol Graphics} |circuit logic IEC| instead will set up |and gate| to use another symbol graphic. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.logic.US}}] \begin{tikzpicture}[circuit logic US] \matrix[column sep=7mm] { @@ -241,7 +235,7 @@ \subsubsection{Symbol Graphics} \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.logic.IEC}}] \begin{tikzpicture}[circuit logic IEC] \matrix[column sep=7mm] { @@ -273,7 +267,7 @@ \subsubsection{Annotations} annotation to it. This is done by passing the annotation as a parameter to the symbol as in the following example: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \tikz [circuit ee IEC] \draw (0,0) to [diode={light emitting}] (3,0) to [resistor={adjustable}] (3,2); @@ -308,7 +302,7 @@ \subsubsection{Symbol Size} Note, that it is still possible to overwrite the size of any particular symbol. These settings apply only to the default sizes. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \begin{tikzpicture}[circuit ee IEC] \draw (0,1) to [resistor] (3.5,1); \draw[circuit symbol unit=14pt] @@ -344,7 +338,7 @@ \subsubsection{Symbol Size} value. Thus, this option can be used with a node command to set the size of the node as a multiple of the circuit symbol unit. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \begin{tikzpicture}[circuit ee IEC] \draw (0,1) to [resistor] (2,1) to[inductor] (4,1); @@ -391,7 +385,7 @@ \subsubsection{Declaring New Symbols} This key gets graphic options as parameter that will be set when a symbol |foo| should be shown: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits}}] \begin{tikzpicture} [circuit declare symbol=foo, set foo graphic={draw,shape=rectangle,minimum size=5mm}] @@ -476,14 +470,14 @@ \subsubsection{Declaring New Symbols} node. Another effect is that you can use this key multiple times on a path to add several node to a path, provided they do not overlap. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits}}] \begin{tikzpicture}[circuit] \draw (0,0) to [circuit handle symbol={draw,shape=rectangle,near start}, circuit handle symbol={draw,shape=circle,near end}] (3,2); \end{tikzpicture} \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits}}] \begin{tikzpicture}[transform shape,circuit] \draw (0,0) to [circuit handle symbol={draw,shape=rectangle,at start}, circuit handle symbol={draw,shape=circle,near end}] (3,2); @@ -506,7 +500,7 @@ \subsubsection{Pointing Symbols in the Right Direction} like this: \tikz[circuit ee IEC]\node[inductor]{};) is automatically rotated around: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \tikz [circuit ee IEC] \draw (3,0) to[inductor] (1,0) to[inductor] (0,2); \end{codeexample} @@ -521,7 +515,7 @@ \subsubsection{Pointing Symbols in the Right Direction} \begin{key}{/tikz/point up} This is the same as |rotate=90|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \tikz [circuit ee IEC] \node [diode,point up] {}; \end{codeexample} \end{key} @@ -529,7 +523,7 @@ \subsubsection{Pointing Symbols in the Right Direction} \begin{key}{/tikz/point down} This is the same as |rotate=-90|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \tikz [circuit ee IEC] \node [diode,point down] {}; \end{codeexample} \end{key} @@ -537,7 +531,7 @@ \subsubsection{Pointing Symbols in the Right Direction} \begin{key}{/tikz/point left} This is the same as |rotate=-180|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \tikz [circuit ee IEC] \node [diode,point left] {}; \end{codeexample} \end{key} @@ -545,7 +539,7 @@ \subsubsection{Pointing Symbols in the Right Direction} \begin{key}{/tikz/point right} This key has no effect. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \tikz [circuit ee IEC] \node [diode,point right] {}; \end{codeexample} \end{key} @@ -576,7 +570,7 @@ \subsubsection{Info Labels} The \meta{options} and \meta{angle} are passed directly to the |label| command. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \begin{tikzpicture}[circuit ee IEC,every info/.style=red] \node [resistor,info=$3\Omega$] {}; \end{tikzpicture} @@ -588,7 +582,7 @@ \subsubsection{Info Labels} Hint: To place some text \emph{on} the main node, use |center| as the \meta{angle}: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \begin{tikzpicture}[circuit ee IEC,every info/.style=red] \node [resistor,info=center:$3\Omega$] {}; \node [resistor,point up,info=center:$R_1$] at (2,0) {}; @@ -605,7 +599,7 @@ \subsubsection{Info Labels} you get a label below the node. In case the node has been rotated, the positions of the info nodes are rotated accordingly. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \begin{tikzpicture}[circuit ee IEC,every info/.style=red] \draw (0,0) to[resistor={info={$3\Omega$},info'={$R_1$}}] (3,0) to[resistor={info={$4\Omega$},info'={$R_2$}}] (3,2); @@ -618,7 +612,7 @@ \subsubsection{Info Labels} This key works like |info|, only the |transform shape| option is set when the label is drawn, causing it to follow the sloping of the main node. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \begin{tikzpicture}[circuit ee IEC,every info/.style=red] \draw (0,0) to[resistor={info sloped={$3\Omega$}}] (3,0) to[resistor={info sloped={$4\Omega$}}] (3,2); @@ -630,7 +624,7 @@ \subsubsection{Info Labels} \begin{key}{/tikz/info' sloped=} This is a combination of |info'| and |info sloped|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \begin{tikzpicture}[circuit ee IEC,every info/.style=red] \draw (0,0) to[resistor={info' sloped={$3\Omega$}}] (3,0) to[resistor={info' sloped={$4\Omega$}}] (3,2); @@ -660,7 +654,7 @@ \subsubsection{Info Labels} is used internally, by changing the |every info| style, you can change the appearance of all units infos. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \begin{tikzpicture}[circuit ee IEC,circuit declare unit={my ohm}{O}] \draw (0,0) to[resistor={my ohm' sloped=3}] (3,2); \end{tikzpicture} @@ -728,6 +722,7 @@ \subsubsection{Declaring and Using Annotations} {(0pt,8pt) arc (-270:80:3.5pt)} } \begin{codeexample}[ + preamble={\usetikzlibrary{circuits.ee.IEC}} pre={\tikzset{circuit declare annotation= {circular annotation} {8pt} @@ -742,7 +737,7 @@ \subsubsection{Declaring and Using Annotations} node an nothing else. This path is not drawn or filled, so we do not see anything. What we must do is to use an |edge| path operation: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \tikzset{circuit declare annotation={circular annotation}{9pt} {(0pt,8pt) edge[to path={arc(-270:80:3.5pt)}] ()} } @@ -761,7 +756,7 @@ \subsubsection{Declaring and Using Annotations} \tikzset{circuit declare annotation={circular annotation}{9pt} {(0pt,8pt) edge[to path={arc (-270:80:3.5pt)}] ()} } -\begin{codeexample}[ +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}} pre={\tikzset{circuit declare annotation= {circular annotation} {8pt} @@ -793,7 +788,7 @@ \subsubsection{Theming Symbols} For instance, in the following picture the symbols are ridiculously thick and resistors are red. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \begin{tikzpicture} [circuit ee IEC, every circuit symbol/.style={ultra thick}, @@ -812,7 +807,7 @@ \subsubsection{Theming Symbols} some area. For instance, the IEC version of a resistor is an open symbol. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \tikz [circuit ee IEC, circuit symbol open/.style={thick,draw,fill=yellow}] \draw (0,0) to [inductor] ++(right:3) to [resistor] ++(up:2); @@ -829,7 +824,7 @@ \subsubsection{Theming Symbols} This style is used with symbols that consist only of lines that do not surround anything. Examples are a capacitor. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \tikz [circuit ee IEC, circuit symbol lines/.style={thick,draw=red}] \draw (0,0) to [capacitor] ++(right:3) to [resistor] ++(up:2); @@ -846,7 +841,7 @@ \subsubsection{Theming Symbols} Compare % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \tikz [circuit ee IEC,circuit symbol lines/.style={draw,very thick}] \draw (0,0) to [capacitor={near start}, make contact={near end}] (3,0); @@ -854,7 +849,7 @@ \subsubsection{Theming Symbols} % to % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \tikz [circuit ee IEC,circuit symbol wires/.style={draw,very thick}] \draw (0,0) to [capacitor={near start}, make contact={near end}] (3,0); @@ -892,7 +887,7 @@ \subsubsection{Theming Symbols} IEC library. In this case you can set the graphic for the resistor to this variant (or back to the original) by saying |set resistor graphic| yourself: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \begin{tikzpicture}[circuit ee IEC] % Standard resistor \draw (0,2) to [resistor] (3,2); @@ -966,7 +961,7 @@ \subsubsection{Overview} appearance. These keys are called |and gate IEC graphic|, |or gate IEC graphic|, and so on. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.logic.IEC}}] \begin{tikzpicture}[circuit logic IEC, every circuit symbol/.style={ logic gate IEC symbol color=black, @@ -1005,7 +1000,7 @@ \subsubsection{Overview} Here is an example: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.logic.CDH}}] \begin{tikzpicture}[circuit logic CDH, tiny circuit symbols, every circuit symbol/.style={ @@ -1053,11 +1048,11 @@ \subsubsection{Overview} dictated by the which circuit environment is used. To further configure the appearance of the |and gate|, see Section~\ref{section-theming-symbols}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.logic.IEC}}] \tikz [circuit logic IEC] \node [and gate] {$A$}; \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.logic.US}}] \tikz [circuit logic US] { \node [and gate,point down] {$A$}; @@ -1083,7 +1078,7 @@ \subsubsection{Overview} supports one input the anchor is simply called |input| with no numerical index. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.logic.IEC}}] \begin{tikzpicture}[circuit logic IEC] \node[and gate,inputs={inini}] (A) {}; \foreach \a in {1,...,5} @@ -1161,7 +1156,7 @@ \subsubsection{Implementation: The Logic Gates Shape Library} supports one input the anchor is simply called |input| with no numerical index. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.logic.IEC}}] \begin{tikzpicture}[minimum height=0.75cm] \node[and gate IEC, draw, logic gate inputs={inverted, normal, inverted}] (A) {}; @@ -1178,7 +1173,7 @@ \subsubsection{Implementation: The Logic Gates Shape Library} \emph{without the commas}. So, for example, |ini| is equivalent to |inverted, normal, inverted|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.logic.US}}] \begin{tikzpicture}[minimum height=0.75cm] \node[or gate US, draw,logic gate inputs=inini] (A) {}; \foreach \a in {1,...,5} @@ -1204,7 +1199,7 @@ \subsubsection{Implementation: The Logic Gates Shape Library} This is also the radius of the circle used for the inverted output of the |nand|, |nor|, |xnor| and |not| gates. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.logic.CDH}}] \begin{tikzpicture}[minimum height=0.75cm] \tikzset{every node/.style={shape=nand gate CDH, draw, logic gate inputs=ii}} \node[logic gate inverted radius=2pt] {A}; @@ -1218,7 +1213,7 @@ \subsubsection{Implementation: The Logic Gates Shape Library} Set the distance between the \emph{centers} of the inputs to the logic gate. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.logic.IEC}}] \begin{tikzpicture}[minimum size=0.75cm] \draw [help lines] grid (3,2); \tikzset{every node/.style={shape=and gate IEC, draw, logic gate inputs=ini}} @@ -1263,7 +1258,7 @@ \subsubsection{Implementation: The US-Style Logic Gates Shape Library} by shape basis: whether the bounding box is used is determined by value of this key when the anchor is accessed. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.logic.US}}] \begin{tikzpicture}[minimum height=1.5cm] \node[xnor gate US, draw, gray!50,line width=2pt] (A) {}; \foreach \x/\y/\z in {false/blue/1pt, true/red/2pt} @@ -1302,7 +1297,7 @@ \subsubsection{Implementation: The US-Style Logic Gates Shape Library} this gate with two non-inverted inputs (using the normal compass point anchors) are shown below. Anchor |30| is an example of a border anchor. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.logic.US}}] \Huge \begin{tikzpicture} \node[name=s,shape=nand gate US,shape example, inner sep=0cm, @@ -1446,7 +1441,7 @@ \subsubsection{Implementation: The IEC-Style Logic Gates Shape Library} gate with two inverted inputs are shown below. Anchor |30| is an example of a border anchor. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.logic.IEC}}] \Huge \begin{tikzpicture} \node[name=s,shape=nand gate IEC ,shape example, inner xsep=1cm, inner ysep=1cm, @@ -1531,7 +1526,7 @@ \subsubsection{Overview} When used with a node, it will cause this node to ``look like'' a resistor (by default, in the IEC library, this is just a simple rectangle). % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \tikz [circuit ee IEC] \node [resistor] {}; \end{codeexample} @@ -1540,7 +1535,7 @@ \subsubsection{Overview} in |node [resistor] {foo}|). Instead, the labeling of resistors should be done using the |label|, |info| and |ohm| options. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \tikz [circuit ee IEC] \node [resistor,ohm=5] {}; \end{codeexample} @@ -1549,7 +1544,7 @@ \subsubsection{Overview} with a normal node, you can just as well given them to the |node| itself. Thus, the following has the same effect as the above example: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \tikz [circuit ee IEC] \node [resistor={ohm=5}] {}; \end{codeexample} @@ -1559,7 +1554,7 @@ \subsubsection{Overview} useful. They are just shorthands for appropriate rotations like |rotate=90|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \tikz [circuit ee IEC] { \node (R1) [resistor,point up,ohm=5] at (3,1) {}; \node (R2) [resistor,ohm=10k] at (0,0) {}; @@ -1589,7 +1584,7 @@ \subsubsection{Overview} resistor node on the path, you can use it to add labels to the node. Here is a simple example: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \tikz [circuit ee IEC] \draw (0,0) to [resistor=red] (3,0) to [resistor={ohm=2\mu}] (3,2); @@ -1622,21 +1617,21 @@ \subsubsection{Overview} you get $\mathrm{5k\Omega}$, |ohm=5p| yields $\mathrm{5p\Omega}$, and |ohm=5.6\cdot 10^{2}\mu| yields $\mathrm{5.6\cdot 10^{2}\mu\Omega}$. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \tikz [circuit ee IEC] \draw (0,0) to [resistor={ohm=5M}] (0,2); \end{codeexample} Instead of |ohm| you can also use |ohm'|, which places the label on the other side. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \tikz [circuit ee IEC] \draw (0,0) to [resistor={ohm'=5M}] (0,2); \end{codeexample} Finally, there are also keys |ohm sloped| and |ohm' sloped| for having the info label rotate together with the main node. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \tikz [circuit ee IEC] \draw (0,0) to [resistor={ohm sloped=5M}] (0,2) (2,0) to [resistor={ohm' sloped=6f}] (2,2); @@ -1655,7 +1650,7 @@ \subsubsection{Overview} node. It causes some drawings (in this case, two parallel lines) to be placed next to the node. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \tikz [circuit ee IEC] \draw (0,0) to [diode=light emitting] (2,0); \end{codeexample} @@ -1672,7 +1667,7 @@ \subsubsection{Overview} been changed to accommodate for the space taken up by the annotation. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \tikz [circuit ee IEC] { \draw (0,2) to [diode={light emitting,info=not good}] (2,2); @@ -1953,7 +1948,7 @@ \subsubsection{Implementation: The EE-Symbols Shape Library} The anchors of this shape are just the compass anchors, which lie on a rectangle whose width and height are the above-computed height and width. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \begin{tikzpicture} \pgfsetarrowoptions{direction ee}{6cm} \node[name=s,shape=direction ee,shape example,minimum height=0.7654*6cm] {}; @@ -1967,7 +1962,7 @@ \subsubsection{Implementation: The EE-Symbols Shape Library} \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \begin{tikzpicture}[direction ee arrow=angle 45] \node[name=s,shape=direction ee,shape example,minimum height=1.75cm] {}; \foreach \anchor/\placement in {north/above, south/below, @@ -2010,7 +2005,7 @@ \subsubsection{Implementation: The IEC-Style EE-Symbols Shape Library} % Here is an examples of how to use this shape: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \tikz \node [generic circle IEC, /pgf/generic circle IEC/before background={ \pgfpathmoveto{\pgfpointorigin} @@ -2030,7 +2025,7 @@ \subsubsection{Implementation: The IEC-Style EE-Symbols Shape Library} rectangle around the diode, see the below example. The diode's size is based on the current settings of |minimum width| and |minimum height|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \begin{tikzpicture} \node[name=s,shape=generic diode IEC,shape example,minimum size=6cm] {}; \foreach \anchor/\placement in @@ -2060,7 +2055,7 @@ \subsubsection{Implementation: The IEC-Style EE-Symbols Shape Library} The idea is that you use this key to draw different kinds of diode endings. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \tikz \node [minimum size=1cm,generic diode IEC, /pgf/generic diode IEC/before background={ \pgfpathmoveto{\pgfqpoint{-.5pt}{-1pt}} @@ -2081,7 +2076,7 @@ \subsubsection{Implementation: The IEC-Style EE-Symbols Shape Library} size is based on the current settings of |minimum width| and |minimum height|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \begin{tikzpicture} \node[name=s,shape=breakdown diode IEC,shape example,minimum width=6cm,minimum height=4cm] {}; \foreach \anchor/\placement in @@ -2110,7 +2105,7 @@ \subsubsection{Implementation: The IEC-Style EE-Symbols Shape Library} All of this means that, in general, the shape should be much wider than high. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \begin{tikzpicture} \node[name=s,shape=var resistor IEC,shape example,minimum width=7cm,minimum height=1cm] {}; \foreach \anchor/\placement in @@ -2136,7 +2131,7 @@ \subsubsection{Implementation: The IEC-Style EE-Symbols Shape Library} |minimum height|. The |center| of the shape is just above the |south| anchor, at a distance of the |outer ysep|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \begin{tikzpicture} \node[name=s,shape=inductor IEC,shape example,minimum width=7cm,minimum height=1cm] {}; \foreach \anchor/\placement in @@ -2158,7 +2153,7 @@ \subsubsection{Implementation: The IEC-Style EE-Symbols Shape Library} the background path, only the ``left and right lines'' that make up the rectangle are drawn. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \begin{tikzpicture} \node[name=s,shape=capacitor IEC,shape example, minimum width=2cm,minimum height=3cm,inner sep=0pt] {}; @@ -2178,7 +2173,7 @@ \subsubsection{Implementation: The IEC-Style EE-Symbols Shape Library} This shape is similar to a |capacitor IEC|, however, the right line is only half the height of the left line. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \tikz \node[shape=battery IEC,shape example,minimum size=2cm, inner sep=0pt] {}; \end{codeexample} @@ -2189,7 +2184,7 @@ \subsubsection{Implementation: The IEC-Style EE-Symbols Shape Library} This shape is similar to a |batter IEC|, only three lines of different heights are drawn. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \tikz \node[shape=ground IEC,shape example,minimum size=2cm, inner sep=0pt] {}; \end{codeexample} @@ -2201,7 +2196,7 @@ \subsubsection{Implementation: The IEC-Style EE-Symbols Shape Library} right corner. The size and anchors of this shape are computed in the same way as for an |inductor IEC|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \begin{tikzpicture} \node[name=s,shape=make contact IEC,shape example,minimum width=3cm,minimum height=1cm] {}; \foreach \anchor/\placement in @@ -2221,7 +2216,7 @@ \subsubsection{Implementation: The IEC-Style EE-Symbols Shape Library} the path at the lower left corner. The radius of this circle is one twelfth of the width of the node. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \tikz \node[shape=var make contact IEC,shape example, minimum height=1cm,minimum width=3cm,inner sep=0pt] {}; \end{codeexample} @@ -2232,7 +2227,7 @@ \subsubsection{Implementation: The IEC-Style EE-Symbols Shape Library} This shape depicts a contact that can be broken. It works like |make contact IEC|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{circuits.ee.IEC}}] \tikz \node[shape=break contact IEC,shape example, minimum height=1cm,minimum width=3cm,inner sep=0pt] {}; \end{codeexample} diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-decorations.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-decorations.tex index b754060b3..91ce2fd87 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-decorations.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-decorations.tex @@ -20,18 +20,6 @@ \subsection{Overview and Common Options} explains how decorations are used in \tikzname, and \ref{section-base-decorations}, which explains how new decorations can be defined. -% -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{ - decorations.footprints, - decorations.fractals, - decorations.markings, - decorations.pathmorphing, - decorations.pathreplacing, - decorations.shapes, - decorations.text, - } -\end{codeexample} The decorations are influenced by a number of parameters that can be set using the |decoration| option. These parameters are typically shared between @@ -143,7 +131,7 @@ \subsubsection{Decorations Producing Straight Line Paths} This decoration is actually always defined when the decoration module is loaded, but it is documented here for consistency. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations}}] \begin{tikzpicture}[decoration=lineto] \draw [help lines] grid (3,2); \draw [decorate,fill=yellow!80!black] @@ -167,7 +155,7 @@ \subsubsection{Decorations Producing Straight Line Paths} |zigzag| decorations. \end{itemize} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \begin{tikzpicture}[decoration={straight zigzag,meta-segment length=1.1cm}] \draw [help lines] grid (3,2); \draw [decorate,fill=yellow!80!black] @@ -189,7 +177,7 @@ \subsubsection{Decorations Producing Straight Line Paths} $[-d,d]$, where $d$ is the value of |amplitude|. \end{itemize} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \begin{tikzpicture} [decoration={random steps,segment length=2mm}] \draw [help lines] grid (3,2); @@ -210,7 +198,7 @@ \subsubsection{Decorations Producing Straight Line Paths} \item |segment length| determines the length each spike. \end{itemize} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \begin{tikzpicture}[decoration=saw] \draw [help lines] grid (3,2); \draw [decorate,fill=yellow!80!black] @@ -231,7 +219,7 @@ \subsubsection{Decorations Producing Straight Line Paths} cycle. \end{itemize} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \begin{tikzpicture}[decoration=zigzag] \draw [help lines] grid (3,2); \draw [decorate,fill=yellow!80!black] @@ -258,14 +246,14 @@ \subsubsection{Decorations Producing Curved Line Paths} Note that this decoration makes only little sense for curves. You should apply it only to straight lines. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \begin{tikzpicture}[decoration=bent] \draw [help lines] grid (3,2); \draw [decorate] (0,0) -- (3,1) -- (1.5,2) -- (0,1); \end{tikzpicture} \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \begin{tikzpicture}[decoration={bent,aspect=.3}] \draw [decorate,fill=yellow!80!black] (0,0) rectangle (3.5,2); \node[circle,draw] (A) at (.5,.5) {A}; @@ -286,7 +274,7 @@ \subsubsection{Decorations Producing Curved Line Paths} \item |segment length| determines the width of the half ellipse. \end{itemize} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \begin{tikzpicture}[decoration=bumps] \draw [help lines] grid (3,2); \draw [decorate,fill=yellow!80!black] @@ -315,7 +303,7 @@ \subsubsection{Decorations Producing Curved Line Paths} default, means ``look more from the front''. \end{itemize} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \begin{tikzpicture}[decoration=coil] \draw [help lines] grid (3,2); \draw [decorate,fill=yellow!80!black] @@ -323,7 +311,7 @@ \subsubsection{Decorations Producing Curved Line Paths} \end{tikzpicture} \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \begin{tikzpicture} [decoration={coil,aspect=0.3,segment length=3mm,amplitude=3mm}] \draw [help lines] grid (3,2); @@ -344,7 +332,7 @@ \subsubsection{Decorations Producing Curved Line Paths} This decoration is mostly useful in conjunction with meta-decorations. It is also actually defined in the decoration module and is always available. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \begin{tikzpicture}[decoration=curveto] \draw [help lines] grid (3,2); \draw [decorate,fill=yellow!80!black] @@ -364,7 +352,7 @@ \subsubsection{Decorations Producing Curved Line Paths} \item |segment length| determines the sine wave's wavelength. \end{itemize} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \begin{tikzpicture}[decoration=snake] \draw [help lines] grid (3,2); \draw [decorate,fill=yellow!80!black] @@ -400,7 +388,7 @@ \subsection{Path Replacing Decorations} the path. \end{itemize} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathreplacing}}] \begin{tikzpicture}[decoration=border] \draw [help lines] grid (3,2); \draw [postaction={decorate,draw,red}] @@ -422,7 +410,7 @@ \subsection{Path Replacing Decorations} ``middle part'' of the brace will be. \end{itemize} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathreplacing}}] \begin{tikzpicture}[decoration=brace] \draw [help lines] grid (3,2); \draw [decorate] (0,0) -- (3,1); @@ -442,7 +430,7 @@ \subsection{Path Replacing Decorations} Thus, the total opening angle is twice this angle. \end{itemize} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathreplacing}}] \begin{tikzpicture}[decoration={expanding waves,angle=5}] \draw [help lines] grid (3,2); \draw [decorate] (0,0) -- (3,1) arc (0:180:1.5 and 1); @@ -470,7 +458,7 @@ \subsection{Path Replacing Decorations} \item |amplitude| determines half the length of the ticks. \end{itemize} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathreplacing}}] \begin{tikzpicture}[decoration=ticks] \draw [help lines] grid (3,2); \draw [decorate] (0,0) -- (3,1) arc (0:180:1.5 and 1); @@ -491,7 +479,7 @@ \subsection{Path Replacing Decorations} \item |radius| determines the radius of each arc. \end{itemize} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathreplacing}}] \begin{tikzpicture}[decoration={waves,radius=4mm}] \draw [help lines] grid (3,2); \draw [decorate] (0,0) -- (3,1) arc (0:180:1.5 and 1); @@ -506,7 +494,7 @@ \subsection{Path Replacing Decorations} Typically, each segment will be replaced with another path, but this need not necessarily be the case. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathreplacing}}] \begin{tikzpicture}[>=stealth, every node/.style={midway, sloped, font=\tiny}, decoration={show path construction, moveto code={ @@ -578,7 +566,7 @@ \subsection{Path Replacing Decorations} \end{command} % {\tikzexternaldisable -\begin{codeexample}[preamble={\usetikzlibrary{shapes.misc}}] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathreplacing,shapes.misc}}] \tikzset{ show curve controls/.style={ decoration={ @@ -654,7 +642,7 @@ \subsection{Arbitrary Markings} Let us start with the above example in real code: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.markings}}] \begin{tikzpicture}[decoration={ markings,% switch on markings mark=% actually add a mark @@ -673,7 +661,7 @@ \subsection{Arbitrary Markings} We can also add the cross repeatedly: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.markings}}] \begin{tikzpicture}[decoration={ markings,% switch on markings mark=% actually add a mark @@ -733,7 +721,7 @@ \subsection{Arbitrary Markings} not allowed (and will result in chaos) to have a marking that lies earlier on the path to follow a marking that is later on the path. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.markings}}] \begin{tikzpicture}[decoration={ markings,% switch on markings mark=at position 1cm with \node[red]{1cm};, @@ -748,7 +736,7 @@ \subsection{Arbitrary Markings} Here is an example that shows how markings can be used to place text on plots: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.markings}}] \begin{tikzpicture}[domain=0:4,label/.style={postaction={ decorate, decoration={ @@ -801,7 +789,7 @@ \subsection{Arbitrary Markings} a path starting with the beginning of the path ($\meta{start pos} = 0$) and ending at the end ($\meta{end pos} = 1$). % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.markings}}] \begin{tikzpicture}[decoration={markings, mark=between positions 0 and 1 step 0.1 with { \draw (-2pt,-2pt) -- (2pt,2pt); @@ -815,7 +803,7 @@ \subsection{Arbitrary Markings} crosses. Note the use of the |transform shape| option to ensure that the nodes are actually rotated. % -\begin{codeexample}[preamble={\usetikzlibrary{shapes.arrows}}] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.markings,shapes.arrows}}] \begin{tikzpicture}[decoration={markings, mark=between positions 0 and 1 step 1cm with { \node [single arrow,fill=red, @@ -829,7 +817,7 @@ \subsection{Arbitrary Markings} even refer to them later on. % % FIXME: the automatic key highlighting fails here! -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.markings}}] \begin{tikzpicture}[decoration={markings, mark=between positions 0 and 1 step 1cm with { \node [draw, @@ -845,7 +833,7 @@ \subsection{Arbitrary Markings} In the following example we use the distance info to place ``length information'' on a path: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.markings}}] \begin{tikzpicture}[decoration={markings, % Main marks mark=between positions 0 and 1 step 40pt with @@ -892,7 +880,7 @@ \subsection{Arbitrary Markings} Here are two examples that show how this works: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.markings}}] \begin{tikzpicture}[decoration={markings, mark connection node=my node, mark=at position .5 with @@ -902,7 +890,7 @@ \subsection{Arbitrary Markings} \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.markings}}] \begin{tikzpicture}[decoration={markings, mark connection node=my node, mark=at position .25 with @@ -929,7 +917,7 @@ \subsubsection{Arrow Tip Markings} The \meta{options} can only be given when \tikzname\ is used. In this case, they are executed in a scope that contains the arrow tip. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.markings}}] \begin{tikzpicture}[decoration={ markings,% switch on markings mark=at position 1cm with {\node[red]{1cm};}, @@ -942,7 +930,8 @@ \subsubsection{Arrow Tip Markings} \end{codeexample} Here is a more useful example: -\begin{codeexample}[] + % +\begin{codeexample}[preamble={\usetikzlibrary{decorations.markings}}] \begin{tikzpicture}[decoration={ markings,% switch on markings mark=between positions 0 and .75 step 4mm with {\arrow{stealth}}, @@ -972,7 +961,7 @@ \subsubsection{Footprint Markings} The footprint decoration adds little footprints around the path. They start with the left foot. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.footprints}}] \begin{tikzpicture}[decoration={footprints,foot length=5pt,stride length=10pt}] \draw [help lines] grid (3,3); \fill [decorate] (0,0) -- (3,2) arc (0:180:1.5 and 1); @@ -986,7 +975,7 @@ \subsubsection{Footprint Markings} The length or size of the footprint itself. A larger value makes the footprint larger, but does not change the stride length. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.footprints}}] \begin{tikzpicture}[decoration={footprints,foot length=20pt}] \fill [decorate] (0,0) -- (3,0); \end{tikzpicture} @@ -997,7 +986,7 @@ \subsubsection{Footprint Markings} The length of strides. This is the distance between the beginnings of left footprints along the path. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.footprints}}] \begin{tikzpicture}[decoration={footprints,stride length=50pt}] \fill [decorate] (0,0) -- (3,0); \end{tikzpicture} @@ -1008,7 +997,7 @@ \subsubsection{Footprint Markings} The separation in the middle between the footprints. The footprints are moved away from the path by half this amount. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.footprints}}] \begin{tikzpicture}[decoration={footprints,foot sep=10pt}] \fill [decorate] (0,0) -- (3,0); \end{tikzpicture} @@ -1018,7 +1007,7 @@ \subsubsection{Footprint Markings} \begin{key}{/pgf/decoration/foot angle (initially 10)} Footprints are rotated by this much. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.footprints}}] \begin{tikzpicture}[decoration={footprints,foot angle=60}] \fill [decorate] (0,0) -- (3,0); \end{tikzpicture} @@ -1084,7 +1073,7 @@ \subsubsection{Shape Background Markings} \item |shape width| determines the width of each cross. \end{itemize} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.shapes}}] \begin{tikzpicture}[decoration=crosses] \draw [help lines] grid (3,2); \draw [decorate] (0,0) -- (3,1) arc (0:180:1.5 and 1); @@ -1105,7 +1094,7 @@ \subsubsection{Shape Background Markings} \item |shape width| determines the width of the triangle. \end{itemize} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.shapes}}] \begin{tikzpicture}[decoration=triangles] \draw [help lines] grid (3,2); \draw [decorate,fill=yellow!80!black] (0,0) -- (3,1) arc (0:180:1.5 and 1); @@ -1127,14 +1116,14 @@ \subsubsection{Shape Background Markings} size of the text box (like the arrow shapes).} If any of these restrictions pose a problem, use the |markings| library instead. % -\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.shapes,shapes.geometric}}] \begin{tikzpicture}[decoration={shape backgrounds,shape=star,shape size=5pt}] \draw [help lines] grid (3,2); \draw [decorate] (0,0) -- (3,1) arc (0:180:1.5 and 1); \end{tikzpicture} \end{codeexample} -\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.shapes,shapes.geometric}}] \tikzset{paint/.style={ draw=#1!50!black, fill=#1!50 }, decorate with/.style= {decorate,decoration={shape backgrounds,shape=#1,shape size=2mm}}} @@ -1156,7 +1145,7 @@ \subsubsection{Shape Background Markings} A shape background path is added at the start point of the path and, if the distance between the shapes is appropriate, at the end point of the path. % -\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.shapes,shapes.geometric}}] \begin{tikzpicture}[decoration={ shape backgrounds,shape=regular polygon,shape size=4mm}] \draw [help lines] grid (3,2); @@ -1177,7 +1166,7 @@ \subsubsection{Shape Background Markings} |inner sep| and |minimum size| will be ignored, but transformations can be applied to each segment as described below. % -\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.shapes,shapes.geometric}}] \tikzset{ paint/.style={draw=#1!50!black, fill=#1!50}, my star/.style={decorate,decoration={shape backgrounds,shape=star}, @@ -1204,7 +1193,7 @@ \subsubsection{Shape Background Markings} shapes or between the edges of the \emph{boundaries} of the shape borders. % -\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.shapes,shapes.symbols}}] \begin{tikzpicture}[ decoration={shape backgrounds,shape size=.5cm,shape=signal}, signal from=west, signal to=east, @@ -1230,7 +1219,7 @@ \subsubsection{Shape Background Markings} distance between shapes is determined. These keywords will only have a noticeable effect if the shapes sizes differ over time. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.shapes}}] \tikzset{ paint/.style={draw=#1!50!black, fill=#1!50}, spreading/.style={ @@ -1255,7 +1244,7 @@ \subsubsection{Shape Background Markings} Internally this sets the \TeX-if |\ifpgfshapedecorationsloped| accordingly. % -\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.shapes,shapes.geometric}}] \tikzset{ paint/.style={draw=#1!50!black, fill=#1!50} } @@ -1277,7 +1266,7 @@ \subsubsection{Shape Background Markings} shapes are scaled: \begin{key}{/pgf/decoration/shape scaled=\meta{boolean} (initially false)} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.shapes}}] \tikzset{ bigger/.style={decoration={shape start size=.125cm, shape end size=.5cm}}, smaller/.style={decoration={shape start size=.5cm, shape end size=.125cm}}, @@ -1313,7 +1302,7 @@ \subsubsection{Shape Background Markings} that a shape will take only if it is drawn exactly at the end of the path. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.shapes}}] \tikzset{ bigger/.style={decoration={shape start size=.25cm, shape end size=1cm}}, smaller/.style={decoration={shape start size=1cm, shape end size=.25cm}}, @@ -1358,7 +1347,7 @@ \subsection{Text Decorations} the decoration is done. This is why no line is shown in the following example. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text}}] \catcode`\|12 \begin{tikzpicture}[decoration={text along path, text={Some long text along a ridiculously long curve that}}] @@ -1409,7 +1398,7 @@ \subsection{Text Decorations} codes of delimiters -- see below). % {\catcode`\|12 -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text}}] \catcode`\|12 \begin{tikzpicture} \draw [help lines] grid (3,2); @@ -1424,7 +1413,7 @@ \subsection{Text Decorations} added to any existing formatting. % {\catcode`\|12 -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text}}] \begin{tikzpicture} \draw [help lines] grid (3,2); \path [decorate,decoration={text along path, @@ -1450,7 +1439,7 @@ \subsection{Text Decorations} the specified format commands are added to any existing ones, you should avoid using |+| as a delimiter. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text}}] \begin{tikzpicture} \draw [help lines] grid (3,2); \path [decorate, decoration={text along path,text format delimiters={[}{]}, @@ -1469,7 +1458,7 @@ \subsection{Text Decorations} This key reverses the path. This is especially useful for typesetting text along different sides of curves. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text}}] \begin{tikzpicture} \draw [help lines] grid (3,2); \draw [gray, ->] @@ -1492,7 +1481,7 @@ \subsection{Text Decorations} Aligns the text according to \meta{alignment}, which should be one of |left|, |right|, or |center|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text}}] \begin{tikzpicture} \draw [help lines] grid (3,2); \draw [red, dashed] @@ -1533,7 +1522,7 @@ \subsection{Text Decorations} (i.e., the automaton would have to shift \emph{backwards} between characters) this key will have no effect. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text}}] \begin{tikzpicture} \draw [help lines] grid (3,2); \draw [red, dashed] @@ -1550,7 +1539,7 @@ \subsection{Text Decorations} forward only for space characters (including |\space|, but \emph{excluding} |\ |). % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text}}] \begin{tikzpicture} \draw [help lines] grid (3,2); \draw [red, dashed] @@ -1568,7 +1557,7 @@ \subsection{Text Decorations} options (such as |text|, |scale| and |opacity|) can be used to create `text effects'. % -\begin{codeexample}[preamble={\usetikzlibrary{math}}] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text,math}}] \bfseries\large \begin{tikzpicture}[decoration={text effects along path, text={text effects along path!}, text align=center, @@ -1618,7 +1607,7 @@ \subsection{Text Decorations} separated by a \emph{word separator}. This, however, does not mean that you are limited to using only natural language as the decoration text. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text}}] \begin{tikzpicture}[decoration={text effects along path, text={000-001-010-011-100-101-110-111}, text effects/.cd, @@ -1632,7 +1621,7 @@ \subsection{Text Decorations} In addition, it is possible to replace characters with \tikzname\ code: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text}}] \begin{tikzpicture}[decoration={text effects along path, text={000-001-010-011-100-101-110-111}, text align=center, text effects/.cd, @@ -1676,7 +1665,7 @@ \subsection{Text Decorations} horizontally fit each node to the character it contains, reducing the spacing between characters). % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text}}] \begin{tikzpicture}[decoration={text effects along path, text={text effects along path!}}] @@ -1753,7 +1742,7 @@ \subsection{Text Decorations} \begin{key}{/pgf/decoration/text effects/character widths=\marg{effects}} Shorthand for the |every character width| style. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text}}] \begin{tikzpicture}[decoration={text effects along path, text={text effects along path!}, text align=center, text effects/.cd, @@ -1777,7 +1766,7 @@ \subsection{Text Decorations} \begin{key}{/pgf/decoration/text effects/character count=\meta{macro}} Store the number of the character being typeset in \meta{macro}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text}}] \begin{tikzpicture}[decoration={text effects along path, text={text effects along path!}, text effects/.cd, @@ -1795,7 +1784,7 @@ \subsection{Text Decorations} \meta{macro}. This key can be used with the |character count| key to produce some quite pleasing effects: % -\begin{codeexample}[preamble={\usetikzlibrary{math}}] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text,math}}] \begin{tikzpicture}[decoration={text effects along path, text={text effects along path!}, text effects/.cd, @@ -1814,7 +1803,7 @@ \subsection{Text Decorations} character in the word) in \meta{macro}. Numbering starts at |1| and the character acting as a word separator is numbered |0|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text}}] \begin{tikzpicture}[decoration={text effects along path, text={text effects along path!}, text effects/.cd, @@ -1837,7 +1826,7 @@ \subsection{Text Decorations} \meta{macro} takes the number of the previous word. If the decoration text starts with a word separator \meta{macro} will be |0|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text}}] \begin{tikzpicture}[decoration={text effects along path, text={text effects along path!}, text effects/.cd, @@ -1862,7 +1851,7 @@ \subsection{Text Decorations} This key enables \meta{effects} to be applied to every character in the decoration text that is specified in \meta{characters}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text}}] \begin{tikzpicture}[decoration={text effects along path, text={Falsches {\"U}ben von Xylophonmusik qu{\"a}lt jeden gr{\"o}{\ss}eren Zwerg}, text effects/.cd, @@ -1882,7 +1871,7 @@ \subsection{Text Decorations} path was actually a straight line starting from the given point. This `virtual' straight line is then decorated with the text. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text}}] \begin{tikzpicture}[decoration={text effects along path, text={text effects along path!}, text effects/.cd, @@ -1900,7 +1889,7 @@ \subsection{Text Decorations} line that is used as the decorated path is rotated by \meta{angle} around the starting point. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text}}] \begin{tikzpicture}[decoration={text effects along path, text={text effects along path!}, text effects/.cd, @@ -1917,7 +1906,7 @@ \subsection{Text Decorations} This key will make the decoration increase the space between characters so that the entire path is used by the decoration. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text}}] \begin{tikzpicture}[decoration={text effects along path, text={text effects along path!}, text effects/every character/.style={text along path}}] @@ -1936,7 +1925,7 @@ \subsection{Text Decorations} This key will make the decoration scale the text so that the entire path is used by the decoration. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text}}] \begin{tikzpicture}[decoration={text effects along path, text={text effects along path!}, text effects/every character/.style={text along path}}] @@ -1956,7 +1945,7 @@ \subsection{Text Decorations} useful if using `right-to-left` languages. Unfortunately, any leading `soft' spaces in the original text will be lost. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text}}] \begin{tikzpicture}[decoration={text effects along path, text={text effects along path!}, text effects/.cd, @@ -1976,7 +1965,7 @@ \subsection{Text Decorations} Alternatively, to get the numbering to follow the reversed text, it is possible to reverse the path and then invert the scale: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text}}] \begin{tikzpicture}[decoration={text effects along path, text={text effects along path!}, text effects/.cd, @@ -1996,7 +1985,7 @@ \subsection{Text Decorations} Group sequences of letters together so they are treated as a single `character'. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text}}] \begin{tikzpicture}[decoration={text effects along path, text={text effects along path!}, text effects/.cd, @@ -2016,7 +2005,7 @@ \subsection{Text Decorations} The order in which the |reverse text| and |group letters| keys are applied is important: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text}}] \begin{tikzpicture}[decoration={text effects along path, text={text effects along path!}, text effects/.cd, @@ -2043,7 +2032,7 @@ \subsection{Text Decorations} decoration starts. If any of these options are given the behaviour of the |repeat text| key is undefined, but typically it will be ignored. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text}}] \begin{tikzpicture}[decoration={text effects along path, text={text effects along path!\ }, text effects/.cd, @@ -2063,7 +2052,7 @@ \subsection{Text Decorations} which takes one argument. The argument will be a macro which when expanded will contain the current character. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text}}] \def\mycommand#1{#1$_\n$} \begin{tikzpicture}[decoration={text effects along path, text={text effects along path!}, @@ -2087,7 +2076,7 @@ \subsection{Text Decorations} with the |every character| or |every letter| styles) will also be applied to \meta{code}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text}}] \begin{tikzpicture}[decoration={text effects along path, text={text effects along path!}, text effects/.cd, @@ -2117,7 +2106,7 @@ \subsection{Fractal Decorations} repeatedly applying this replacement, different levels of the Koch curve fractal can be created. Its Hausdorff dimension is $\log 5/\log 3$. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.fractals}}] \begin{tikzpicture}[decoration=Koch curve type 1] \draw decorate{ (0,0) -- (3,0) }; \draw decorate{ decorate{ (0,-1.5) -- (3,-1.5) }}; @@ -2131,7 +2120,7 @@ \subsection{Fractal Decorations} This decoration replaces a straight line by a ``rectangular sine''. Its Hausdorff dimension is $3/2$. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.fractals}}] \begin{tikzpicture}[decoration=Koch curve type 2] \draw decorate{ (0,0) -- (3,0) }; \draw decorate{ decorate{ (0,-2) -- (3,-2) }}; @@ -2145,7 +2134,7 @@ \subsection{Fractal Decorations} This decoration replaces a straight line by a ``line with a spike''. The Hausdorff dimension of Koch's snowflake's is $\log 4/\log 3$. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.fractals}}] \begin{tikzpicture}[decoration=Koch snowflake] \draw decorate{ (0,0) -- (3,0) }; \draw decorate{ decorate{ (0,-1) -- (3,-1) }}; @@ -2160,7 +2149,7 @@ \subsection{Fractal Decorations} This decoration replaces a straight line by a ``line with a gap in the middle''. The Hausdorff dimension of the Cantor set is $\log 2/\log 3$. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.fractals}}] \begin{tikzpicture}[decoration=Cantor set,very thick] \draw decorate{ (0,0) -- (3,0) }; \draw decorate{ decorate{ (0,-.5) -- (3,-.5) }}; diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-edges.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-edges.tex index caacee343..08cb5934a 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-edges.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-edges.tex @@ -19,10 +19,6 @@ \section{To Path Library} This library is loaded automatically by \tikzname, so you do not need to load it yourself. \end{tikzlibrary} -% -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{topaths} -\end{codeexample} \subsection{Straight Lines} diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-er.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-er.tex index a0511cc59..28939c1a5 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-er.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-er.tex @@ -13,10 +13,6 @@ \section{Entity-Relationship Diagram Drawing Library} \begin{tikzlibrary}{er} This packages provides styles for drawing entity-relationship diagrams. \end{tikzlibrary} -% -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{er} -\end{codeexample} This library is intended to help you in creating E/R-diagrams. It defines only few new styles, but using the style |entity| instead of saying |rectangle,draw| @@ -38,7 +34,7 @@ \subsection{Entities} and a class in object-oriented programming). If this bothers you, feel free to define a style |entity type| instead. % -\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] +\begin{codeexample}[preamble={\usetikzlibrary{er,positioning}}] \begin{tikzpicture} \node[entity] (sheep) {Sheep}; \node[entity] (genome) [right=of sheep] {Genome}; @@ -51,7 +47,7 @@ \subsection{Entities} This style is evoked by the style |entity|. To change the appearance of entities, you can change this style. % -\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] +\begin{codeexample}[preamble={\usetikzlibrary{er,positioning}}] \begin{tikzpicture} [every entity/.style={draw=blue!50,fill=blue!20,thick}] \node[entity] (sheep) {Sheep}; @@ -71,7 +67,7 @@ \subsection{Relationships} This style works like |entity|, only it is to be used for relationships. Again, |relationship|s are actually relationship types. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{er}}] \begin{tikzpicture} \node[entity] (sheep) at (0,0) {Sheep}; \node[entity] (genome) at (2,0) {Genome}; @@ -86,7 +82,7 @@ \subsection{Relationships} \begin{stylekey}{/tikz/every relationship} Works like |every entity|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{er}}] \begin{tikzpicture} [every entity/.style={fill=blue!20,draw=blue,thick}, every relationship/.style={fill=orange!20,draw=orange,thick,aspect=1.5}] @@ -108,7 +104,7 @@ \subsection{Attributes} attribute to its entity, you can use, for example, the |child| command or the |pin| option. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{er}}] \begin{tikzpicture} \node[entity] (sheep) {Sheep} child {node[attribute] {name}} @@ -116,7 +112,7 @@ \subsection{Attributes} \end{tikzpicture} \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{er}}] \begin{tikzpicture}[every pin edge/.style=draw] \node[entity,pin={[attribute]60:name},pin={[attribute]120:color}] {Sheep}; \end{tikzpicture} @@ -134,7 +130,7 @@ \subsection{Attributes} This style is used with every attribute, and therefore also for every key attribute. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{er}}] \begin{tikzpicture} [text depth=1pt, every attribute/.style={fill=black!20,draw=black}, diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-fit.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-fit.tex index 3658929fe..d528a2a4e 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-fit.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-fit.tex @@ -15,10 +15,6 @@ \section{Fitting Library} The library defines (currently only two) options for fitting a node so that it contains a set of coordinates. \end{tikzlibrary} -% -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{fit} -\end{codeexample} When you load this library, the following options become available: @@ -42,7 +38,7 @@ \section{Fitting Library} fit these points again in a circular node. Note how the circle encompasses exactly the same bounding box. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{fit}}] \begin{tikzpicture}[inner sep=0pt,thick, dot/.style={fill=blue,circle,minimum size=3pt}] \draw[help lines] (0,0) grid (3,2); @@ -96,7 +92,7 @@ \section{Fitting Library} Suppose, for instance, that in the above example we want the word ``box'' to appear inside the box, but at its top. This can be achieved as follows: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{fit}}] \begin{tikzpicture}[inner sep=0pt,thick, dot/.style={fill=blue,circle,minimum size=3pt}] \draw[help lines] (0,0) grid (3,2); @@ -113,7 +109,7 @@ \section{Fitting Library} Here is a real-life example that uses fitting: % -\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] +\begin{codeexample}[preamble={\usetikzlibrary{fit,shapes.geometric}}] \begin{tikzpicture} [vertex/.style={minimum size=2pt,fill,draw,circle}, open/.style={fill=none}, @@ -148,7 +144,7 @@ \section{Fitting Library} This key fits \meta{coordinates or nodes} inside a node that is rotated by \meta{angle}. As a side effect, it also sets the |/tikz/rotate| key. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{fit}}] \begin{tikzpicture}[inner sep=0pt,thick, dot/.style={fill=blue,circle,minimum size=3pt}] \draw[help lines] (0,0) grid (3,2); diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-fixedpoint.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-fixedpoint.tex index c888fc66e..968db32b7 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-fixedpoint.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-fixedpoint.tex @@ -15,10 +15,6 @@ \section{Fixed Point Arithmetic Library} point arithmetic. In addition to loading this library you must ensure |fp| is loaded, otherwise errors will occur. \end{pgflibrary} -% -\begin{codeexample}[setup code,hidden] - \usepgflibrary{fixedpointarithmetic} -\end{codeexample} \subsection{Overview} @@ -90,7 +86,7 @@ \subsection{Using Fixed Point Arithmetic in PGF and \tikzname} |*| is used at the beginning of an expression the evaluation of the expression will evaluated and then multiplied by \meta{factor}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepgflibrary{fixedpointarithmetic}}] \begin{tikzpicture}[fixed point arithmetic={scale results=10^-6}] \draw [help lines] grid (3,2); \draw (0,0) -- (2,2); diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-folding.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-folding.tex index 55cc7db2b..7deff0a55 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-folding.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-folding.tex @@ -15,14 +15,13 @@ \section{Paper-Folding Diagrams Library} This library defines pic types for creating paper-folding diagrams. Many thanks to Nico van Cleemput for providing most of the code. \end{tikzlibrary} -% -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{folding} -\end{codeexample} Here is a big example that produces a diagram for a calendar: % -\begin{codeexample}[leave comments,preamble={\usetikzlibrary{calendar}}] +\begin{codeexample}[ + leave comments, + preamble={\usetikzlibrary{calendar,folding}}, +] \sffamily\scriptsize \tikz \pic [ transform shape, @@ -82,7 +81,7 @@ \section{Paper-Folding Diagrams Library} Here is a simple example: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{folding}}] \tikz \pic [ transform shape, folding line length=6mm, @@ -103,7 +102,7 @@ \section{Paper-Folding Diagrams Library} \begin{stylekey}{/tikz/every fold (initially help lines)} Executed for every line that should be folded. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{folding}}] \tikz \pic[ every cut/.style=red, every fold/.style=dotted, @@ -122,7 +121,7 @@ \section{Paper-Folding Diagrams Library} \begin{pictype}{tetrahedron truncated folding}{} A folding of a truncated tetrahedron. % -\begin{codeexample}[width=5cm] +\begin{codeexample}[width=5cm,preamble={\usetikzlibrary{folding}}] \tikz \pic [folding line length=6mm, numbered faces, transform shape] { tetrahedron truncated folding }; \end{codeexample} @@ -132,7 +131,7 @@ \section{Paper-Folding Diagrams Library} \begin{pictype}{cube folding}{} A folding of a cube. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{folding}}] \tikz \pic [folding line length=6mm, numbered faces, transform shape] { cube folding }; \end{codeexample} @@ -142,7 +141,7 @@ \section{Paper-Folding Diagrams Library} \begin{pictype}{cube truncated folding}{} A folding of a truncated cube. % -\begin{codeexample}[width=5cm] +\begin{codeexample}[width=5cm,preamble={\usetikzlibrary{folding}}] \tikz \pic [folding line length=6mm, numbered faces, transform shape] { cube truncated folding }; \end{codeexample} @@ -152,7 +151,7 @@ \section{Paper-Folding Diagrams Library} \begin{pictype}{octahedron folding}{} A folding of an octahedron. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{folding}}] \tikz \pic [folding line length=6mm, numbered faces, transform shape] { octahedron folding }; \end{codeexample} @@ -162,7 +161,7 @@ \section{Paper-Folding Diagrams Library} \begin{pictype}{octahedron folding}{} A folding of a truncated octahedron. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{folding}}] \tikz \pic [folding line length=6mm, numbered faces, transform shape] { octahedron truncated folding }; \end{codeexample} @@ -172,7 +171,7 @@ \section{Paper-Folding Diagrams Library} \begin{pictype}{dodecahedron folding}{} A folding of a dodecahedron. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{folding}}] \tikz \pic [folding line length=6mm, numbered faces, transform shape] { dodecahedron folding }; \end{codeexample} @@ -182,7 +181,7 @@ \section{Paper-Folding Diagrams Library} \begin{pictype}{dodecahedron' folding}{} This is an alternative folding of a dodecahedron. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{folding}}] \tikz \pic [folding line length=6mm, numbered faces, transform shape] { dodecahedron' folding }; \end{codeexample} @@ -192,7 +191,7 @@ \section{Paper-Folding Diagrams Library} \begin{pictype}{cuboctahedron folding}{} A folding of a cuboctahedron. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{folding}}] \tikz \pic [folding line length=6mm, numbered faces, transform shape] { cuboctahedron folding }; \end{codeexample} @@ -202,7 +201,7 @@ \section{Paper-Folding Diagrams Library} \begin{pictype}{cuboctahedron truncated folding}{} A folding of a truncated cuboctahedron. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{folding}}] \tikz \pic [folding line length=6mm, numbered faces, transform shape] { cuboctahedron truncated folding }; \end{codeexample} @@ -212,7 +211,7 @@ \section{Paper-Folding Diagrams Library} \begin{pictype}{icosahedron folding}{} A folding of an icosahedron. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{folding}}] \tikz \pic [folding line length=6mm, numbered faces, transform shape] { icosahedron folding }; \end{codeexample} @@ -222,7 +221,7 @@ \section{Paper-Folding Diagrams Library} \begin{pictype}{rhombicuboctahedron folding}{} A folding of an rhombicuboctahedron. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{folding}}] \tikz \pic [folding line length=6mm, numbered faces, transform shape] { rhombicuboctahedron folding }; \end{codeexample} @@ -232,7 +231,7 @@ \section{Paper-Folding Diagrams Library} \begin{pictype}{snub cube folding}{} A folding of a snub cube. % -\begin{codeexample}[width=5cm] +\begin{codeexample}[width=5cm,preamble={\usetikzlibrary{folding}}] \tikz \pic [folding line length=6mm, numbered faces, transform shape] { snub cube folding }; \end{codeexample} @@ -242,7 +241,7 @@ \section{Paper-Folding Diagrams Library} \begin{pictype}{icosidodecahedron folding}{} A folding of an icosidodecahedron. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{folding}}] \tikz \pic [folding line length=6mm, numbered faces, transform shape] { icosidodecahedron folding }; \end{codeexample} diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-fpu.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-fpu.tex index e5a7c2359..60b08330b 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-fpu.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-fpu.tex @@ -21,14 +21,10 @@ \section{Floating Point Unit Library} \begin{pgflibrary}{fpu} The floating point unit (fpu) allows the full data range of scientific computing for use in \pgfname. Its core is the \pgfname\ math routines for - mantissa operations, leading to a reasonable trade--of between speed and - accuracy. It does not require any third--party packages or external + mantissa operations, leading to a reasonable trade-of between speed and + accuracy. It does not require any third-party packages or external programs. \end{pgflibrary} -% -\begin{codeexample}[setup code,hidden] - \usepgflibrary{fpu} -\end{codeexample} \subsection{Overview} @@ -36,7 +32,7 @@ \subsection{Overview} The fpu provides a replacement set of math commands which can be installed in isolated placed to achieve large data ranges at reasonable accuracy. It provides at least% - \footnote{To be more precise, the FPU's exponent is currently a 32 bit + \footnote{To be more precise, the FPU's exponent is currently a 32-bit integer. That means it supports a significantly larger data range than an IEEE double precision number -- but if a future \TeX\ version may provide low-level access to doubles, this may change.}% @@ -60,7 +56,7 @@ \subsection{Usage} will be replaced with |\pgfmathfloatadd| and so on. Furthermore, any number will be parsed with |\pgfmathfloatparsenumber|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepgflibrary{fpu}}] \pgfkeys{/pgf/fpu} \pgfmathparse{1+1}\pgfmathresult \end{codeexample} @@ -77,7 +73,8 @@ \subsection{Usage} such methods as well. %-------------------------------------------------- -% \begin{codeexample}[] +% TODOsp: codeexamples: Why is this example commented? +% \begin{codeexample}[preamble={\usepgflibrary{fpu}}] % \begin{tikzpicture} % \fill[red,fpu,/pgf/fpu/scale results=1e-10] (*1.234e10,*1e10) -- (*2e10,*2e10); % \end{tikzpicture} @@ -101,7 +98,7 @@ \subsection{Usage} The predefined choice |float| uses the low-level format used by the FPU. This is useful for further processing inside of any library. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepgflibrary{fpu}}] \pgfkeys{/pgf/fpu,/pgf/fpu/output format=float} \pgfmathparse{exp(50)*42}\pgfmathresult \end{codeexample} @@ -110,7 +107,7 @@ \subsection{Usage} \meta{mantissa}|e|\meta{exponent}. It provides almost no computational overhead. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepgflibrary{fpu}}] \pgfkeys{/pgf/fpu,/pgf/fpu/output format=sci} \pgfmathparse{4.22e-8^-2}\pgfmathresult \end{codeexample} @@ -119,7 +116,7 @@ \subsection{Usage} highest compatibility with the \pgfname\ engine. It is activated automatically in case the FPU scales results. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepgflibrary{fpu}}] \pgfkeys{/pgf/fpu,/pgf/fpu/output format=fixed} \pgfmathparse{sqrt(1e-12)}\pgfmathresult \end{codeexample} @@ -361,7 +358,7 @@ \subsubsection{Creating and Converting Floats} \item[5] for $-\infty$. \end{description} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{fpu}}] \pgfmathfloatparsenumber{42} \pgfmathfloatifflags{\pgfmathresult}{0}{It's zero!}{It's not zero!} \pgfmathfloatifflags{\pgfmathresult}{1}{It's positive!}{It's not positive!} @@ -654,12 +651,12 @@ \subsubsection{Math Operations Commands} $\meta{x} \le 0$), |\pgfmathresult| will be \emph{empty}, no error message will be generated. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{fpu}}] \pgfmathlog{1.452e-7} \pgfmathresult \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{fpu}}] \pgfmathlog{6.426e+8} \pgfmathresult \end{codeexample} diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-lsystems.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-lsystems.tex index b752a3c1d..7d83ccb75 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-lsystems.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-lsystems.tex @@ -21,15 +21,14 @@ \subsection{Overview} string of symbols, the rewrite rules are applied several times and the when resulting string is processed the action associated with each symbol is executed. -% -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{lindenmayersystems} -\end{codeexample} In \pgfname, L-systems can be used to create simple 2-dimensional fractal patterns\ldots % -\begin{codeexample}[pre={\expandafter\let\csname pgf@lsystem@Koch curve\endcsname=\relax}] +\begin{codeexample}[ + preamble={\usetikzlibrary{lindenmayersystems}}, + pre={\expandafter\let\csname pgf@lsystem@Koch curve\endcsname=\relax}, +] \begin{tikzpicture} \pgfdeclarelindenmayersystem{Koch curve}{ \rule{F -> F-F++F-F} @@ -43,7 +42,7 @@ \subsection{Overview} % \noindent\ldots and ``plant like'' patterns\ldots % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{lindenmayersystems}}] \begin{tikzpicture} \draw [green!50!black, rotate=90] [l-system={rule set={F -> FF-[-F+F]+[+F-F]}, axiom=F, order=4, step=2pt, @@ -243,7 +242,10 @@ \subsubsection{Declaring L-systems} case |A| and |B|, do not have to have code associated with them. They simply control the growth of the system. % -\begin{codeexample}[pre={\nullfont\expandafter\let\csname pgf@lsystem@Hilbert curve\endcsname=\relax}] +\begin{codeexample}[ + preamble={\usetikzlibrary{lindenmayersystems}}, + pre={\nullfont\expandafter\let\csname pgf@lsystem@Hilbert curve\endcsname=\relax}, +] \pgfdeclarelindenmayersystem{Hilbert curve}{ \symbol{X}{\pgflsystemdrawforward} \symbol{+}{\pgflsystemturnright} % Explicitly define + and - symbols. @@ -272,7 +274,7 @@ \subsubsection{Using L-Systems in PGF} This origin will be where the L-system starts. In addition, the relevant keys should be set appropriately. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{lindenmayersystems}}] \begin{tikzpicture} \draw [help lines] grid (3,2); \pgfset{lindenmayer system/.cd, angle=60, step=2pt} @@ -356,7 +358,7 @@ \subsubsection{Using L-Systems in Ti\emph{k}Z} drawing (empty symbols can still be used to control the growth of the system). The rules in \meta{list} should be separated by commas. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{lindenmayersystems}}] \tikz[rotate=65]\draw [green!60!black] l-system [l-system={rule set={F -> F[+F]F[-F]}, axiom=F, order=4, angle=25,step=3pt}]; \end{codeexample} @@ -369,7 +371,7 @@ \subsubsection{Using L-Systems in Ti\emph{k}Z} inside a special (rectangle) node which can be positioned using \meta{anchor}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{lindenmayersystems}}] \begin{tikzpicture}[l-system={step=1.75pt, order=5, angle=60}] \pgfdeclarelindenmayersystem{Sierpinski triangle}{ \symbol{X}{\pgflsystemdrawforward} diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-math.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-math.tex index 2fe65a268..afd853200 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-math.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-math.tex @@ -15,10 +15,6 @@ \section{Math Library} This library defines a simple mathematical language to define simple functions and perform sequences of basic mathematical operations. \end{tikzlibrary} -% -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{math} -\end{codeexample} \subsection{Overview} @@ -54,7 +50,7 @@ \subsection{Overview} that \emph{every statement should end with a semi-colon}. This is likely to be the most common reason why the |\tikzmath| command fails. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{math}}] \tikzmath{ % Adapted from http://www.cs.northwestern.edu/academics/courses/110/html/fib_rec.html function fibonacci(\n) { @@ -86,7 +82,7 @@ \subsection{Overview} \begin{key}{/tikz/evaluate={\meta{statements}}} This key simply executes |\tikzmath{|\meta{statements}|}|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{math}}] \tikz[x=0.25cm,y=0.25cm, evaluate={ int \i, \j; @@ -100,7 +96,6 @@ \subsection{Overview} \foreach \i in {0,...,10} \foreach \j in {0,...,10} \fill [red!\a{\i,\j}!yellow] (\i,\j) rectangle ++(1, 1); - \end{codeexample} % \end{key} @@ -120,7 +115,7 @@ \subsection{Assignment} a macro, or a \TeX\ count or dimension register. In this case, use of the |math| library is straightforward: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{math}}] \newcount\mycount \newdimen\mydimen \tikzmath{ @@ -136,7 +131,7 @@ \subsection{Assignment} index, similar to indices in mathematical notation, for example, $x_1$, $x_2$, $x_3$: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{math}}] \tikzmath{ \x1 = 3+4; \x2 = 30+40; \x3 = 300+400; } @@ -146,7 +141,7 @@ \subsection{Assignment} The index does not have to be a number. By using braces |{}|, more sophisticated indices can be created: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{math}}] \tikzmath{ \c{air} = 340; \c{water} = 1435; \c{steel} = 6100; } @@ -171,7 +166,7 @@ \subsection{Assignment} Any spaces preceding \meta{expression} are removed, but any trailing spaces (before the semi-colon) are included. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{math}}] \tikzmath{ let \x = (5*4)+1; let \c1 = blue; @@ -200,7 +195,7 @@ \subsection{Integers, ``Real'' Numbers, and Coordinates} library you want it to do a particular assignment for a variable, it will also do the same assignment when the variable is indexed. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{math}}] \tikzmath{ integer \x; \x1 = 3+4; \x2 = 30+40; \x3 = 300+400; @@ -218,7 +213,7 @@ \subsection{Integers, ``Real'' Numbers, and Coordinates} \emph{not} \TeX\ registers. In addition the variables should \emph{not} be indexed. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{math}}] \tikzmath{ integer \x, \y, \z; \x = 4*5+6; @@ -253,7 +248,7 @@ \subsection{Integers, ``Real'' Numbers, and Coordinates} |(my node.east)| to be parsed and assigned to \meta{variable} in the form $x,y$, which can then be used in a |tikzpicture|: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{math}}] \tikzmath{ coordinate \c; \c = (45:10pt); @@ -265,7 +260,7 @@ \subsection{Integers, ``Real'' Numbers, and Coordinates} performed; the coordinate expression does not have to be surrounded by |($|\ldots|$)|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{math}}] \tikzmath{ coordinate \c, \d; \c = (-1,2)+(1,-1); @@ -281,7 +276,7 @@ \subsection{Integers, ``Real'' Numbers, and Coordinates} the name of \meta{variable} suffixed with |y| (i.e., |\cy|) and is assigned the $y$ coordinate of |\c|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{math}}] \tikzmath{ coordinate \c; \c1 = (30:20pt); @@ -311,7 +306,7 @@ \subsection{Repeating Things} comma, it \emph{must} be surrounded by braces, for example, |{mod(5, 2)}|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{math}}] \tikzmath{ int \x, \v; \v=1; @@ -334,7 +329,7 @@ \subsection{Repeating Things} |for| statement. This includes the values assigned to the \meta{variable}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{math}}] \tikzmath{ int \x, \y; \y = 0; @@ -366,7 +361,7 @@ \subsection{Branching Statements} \meta{if-zero-statements} are executed if the expression in \meta{condition} evaluates to zero. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{math}}] \begin{tikzpicture} \tikzmath{ int \x; @@ -409,7 +404,7 @@ \subsection{Declaring Functions} Although \meta{definition} can take any statements accepted by |\tikzmath|, it is not advisable try to define functions inside other functions. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{math}}] \tikzmath{ function product(\x,\y) { return \x*\y; @@ -442,7 +437,7 @@ \subsection{Executing Code Outside the Parser} in real programming languages). The \meta{code} is executed inside a \TeX\ group. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{math}}] \tikzmath{ int \x, \y, \z; \x = random(2, 5); @@ -462,7 +457,7 @@ \subsection{Executing Code Outside the Parser} notation can be used in functions so that |tikz| path commands can be safely executed inside a |tikzpicture|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{math}}] \begin{tikzpicture} \draw [help lines] grid (3,2); \tikzmath{ diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-matrices.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-matrices.tex index 70dbb4c79..d32d54547 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-matrices.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-matrices.tex @@ -14,10 +14,6 @@ \section{Matrix Library} This library package defines additional styles and options for creating matrices. \end{tikzlibrary} -% -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{matrix} -\end{codeexample} \subsection{Matrices of Nodes} @@ -35,7 +31,7 @@ \subsection{Matrices of Nodes} example, if the matrix has the name |my matrix|, then the node in the upper left cell will get the name |my matrix-1-1|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{matrix}}] \begin{tikzpicture} \matrix (magic) [matrix of nodes] { @@ -55,7 +51,7 @@ \subsection{Matrices of Nodes} \item You can modify, say, the |row 2 column 3| style to pass special options to this particular cell. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{matrix}}] \begin{tikzpicture}[row 2 column 3/.style=red] \matrix [matrix of nodes] { @@ -71,7 +67,7 @@ \subsection{Matrices of Nodes} and the next bar is passed on to the |node| command. % {\catcode`\|=12 -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{matrix}}] \begin{tikzpicture} \matrix [matrix of nodes] { @@ -90,7 +86,7 @@ \subsection{Matrices of Nodes} is an extra column skip. % {\catcode`\|=12 -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{matrix}}] \begin{tikzpicture} \matrix [matrix of nodes] { @@ -107,7 +103,7 @@ \subsection{Matrices of Nodes} This means that for this particular cell you can provide totally different contents. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{matrix}}] \begin{tikzpicture} \matrix [matrix of nodes] { @@ -126,7 +122,7 @@ \subsection{Matrices of Nodes} on in all nodes. % {\catcode`\|=12 -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{matrix}}] \begin{tikzpicture} \matrix [matrix of math nodes] { @@ -144,7 +140,7 @@ \subsection{Matrices of Nodes} Normally, empty cells are just, well, empty. The style can be used together with both a |matrix of nodes| and a |matrix of math nodes|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{matrix}}] \begin{tikzpicture} \matrix [matrix of math nodes,nodes={circle,draw}] { @@ -155,7 +151,7 @@ \subsection{Matrices of Nodes} \end{tikzpicture} \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{matrix}}] \begin{tikzpicture} \matrix [matrix of math nodes,nodes={circle,draw},nodes in empty cells] { @@ -210,7 +206,7 @@ \subsection{End-of-Lines and End-of-Row Characters in Matrices of Nodes} put the whole cell in curly braces. The following example illustrates the difference: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{matrix}}] \begin{tikzpicture} \matrix [matrix of nodes,nodes={text width=16mm,draw}] { @@ -219,7 +215,8 @@ \subsection{End-of-Lines and End-of-Row Characters in Matrices of Nodes} }; \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] +% +\begin{codeexample}[preamble={\usetikzlibrary{matrix}}] \begin{tikzpicture} \matrix [matrix of nodes,nodes={text width=16mm,draw}] { @@ -251,7 +248,7 @@ \subsection{Delimiters} |north|, |south| and so on. The \meta{delimiter} can be any delimiter that is acceptable to \TeX's |\left| command. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{matrix}}] \begin{tikzpicture} \matrix [matrix of math nodes,left delimiter=(,right delimiter=\}] { @@ -262,7 +259,7 @@ \subsection{Delimiters} \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{matrix}}] \begin{tikzpicture} \node [fill=red!20,left delimiter=(,right delimiter=\}] {$\displaystyle\int_0^1 x\,dx$}; @@ -277,7 +274,7 @@ \subsection{Delimiters} \begin{stylekey}{/tikz/every left delimiter (initially \normalfont empty)} This style is additionally executed for every left delimiter. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{matrix}}] \begin{tikzpicture} [every left delimiter/.style={red,xshift=1ex}, every right delimiter/.style={xshift=-1ex}] @@ -304,7 +301,7 @@ \subsection{Delimiters} This option allows you to add a delimiter above the node. It is implemented by rotating a left delimiter. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{matrix}}] \begin{tikzpicture} \matrix [matrix of math nodes,% left delimiter=\|,right delimiter=\rmoustache,% diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-mindmaps.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-mindmaps.tex index 559221882..8c2ff1a18 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-mindmaps.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-mindmaps.tex @@ -13,10 +13,6 @@ \section{Mindmap Drawing Library} \begin{tikzlibrary}{mindmap} This packages provides styles for drawing mindmap diagrams. \end{tikzlibrary} -% -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{mindmap} -\end{codeexample} \subsection{Overview} @@ -52,7 +48,7 @@ \subsection{The Mindmap Style} Use this style with all pictures or at least scopes that contain a mindmap. It installs a whole bunch of settings that are useful for drawing mindmaps. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{mindmap}}] \tikz[mindmap,concept color=red!50] \node [concept] {Root concept} child[grow=right] {node[concept] {Child concept}}; @@ -65,7 +61,7 @@ \subsection{The Mindmap Style} This style is included by the |mindmap| style. Change this style to add special settings to your mindmaps. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{mindmap}}] \tikz[large mindmap,concept color=red!50] \node [concept] {Root concept} child[grow=right] {node[concept] {Child concept}}; @@ -125,7 +121,7 @@ \subsubsection{Isolated Concepts} uniform color called |concept color|, see below. Additionally, the style |every concept| is called. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{mindmap}}] \tikz[mindmap,concept color=red!50] \node [concept] {Some concept}; \end{codeexample} @@ -156,7 +152,7 @@ \subsubsection{Isolated Concepts} order to indicate in the code that these concepts are additional, you can use this style. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{mindmap}}] \begin{tikzpicture}[mindmap,concept color=blue!80] \node [concept] {Root concept}; \node [extra concept] at (10,0) {extra concept}; @@ -179,7 +175,7 @@ \subsubsection{Concepts in Trees} This style is used for the roots of mindmap trees. By adding something to this, you can change how the root of a mindmap will be rendered. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{mindmap}}] \tikz [root concept/.append style={concept color=blue!80,minimum size=3.5cm}, mindmap] @@ -194,7 +190,7 @@ \subsubsection{Concepts in Trees} The |mindmap| style adds this style to the |level 1| style. This means that the first level children of a mindmap tree will use this style. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{mindmap}}] \tikz [root concept/.append style={concept color=blue!80}, level 1 concept/.append style={concept color=red!50}, @@ -229,7 +225,7 @@ \subsubsection{Concepts in Trees} Here is an example: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{mindmap}}] \tikz[mindmap,concept color=blue!80] \node [concept] {Root concept} child[concept color=red,grow=30] {node[concept] {Child concept}} @@ -239,7 +235,7 @@ \subsubsection{Concepts in Trees} In order to have a concept color which changes with the hierarchy level, a tiny bit of magic is needed: % FIXME: is this a bug in the software!? The root concept is black!? -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{mindmap}}] \tikz[mindmap,text=white, root concept/.style={concept color=blue}, level 1 concept/.append style= @@ -271,7 +267,7 @@ \subsubsection{Simple Connections} coordinates of the concepts have been determined. In this case you should place the connecting lines on a background layer as in the following example: -\begin{codeexample}[preamble={\usetikzlibrary{backgrounds}}] +\begin{codeexample}[preamble={\usetikzlibrary{backgrounds,mindmap}}] \begin{tikzpicture} [root concept/.append style={concept color=blue!20,minimum size=2cm}, level 1 concept/.append style={sibling angle=45}, @@ -325,7 +321,7 @@ \subsubsection{The Circle Connection Bar Decoration} Here is an example that should make this clearer: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{mindmap}}] \begin{tikzpicture} [decoration={start radius=1cm,end radius=.5cm,amplitude=2mm,angle=30}] \fill[blue!20] (0,0) circle (1cm); @@ -340,7 +336,7 @@ \subsubsection{The Circle Connection Bar Decoration} really useful for drawing. However, if you fill the decorated path only, and if you use the same color as for the circles, the result is better. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{mindmap}}] \begin{tikzpicture} [blue!50,decoration={start radius=1cm, end radius=.5cm,amplitude=2mm,angle=30}] @@ -361,7 +357,7 @@ \subsubsection{The Circle Connection Bar Decoration} one or two points (for very large distances you may need line width up to 4pt). % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{mindmap}}] \begin{tikzpicture} [blue!50,decoration={start radius=1cm, end radius=.5cm,amplitude=2mm,angle=30}] @@ -406,7 +402,7 @@ \subsubsection{The Circle Connection Bar To-Path} to-paths. \end{stylekey} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{mindmap}}] \begin{tikzpicture}[concept color=blue!50,blue!50,outer sep=0pt] \node (n1) at (0,0) [circle,minimum size=2cm,fill,draw,thick] {}; \node (n2) at (2.5,0) [circle,minimum size=1cm,fill,draw,thick] {}; @@ -432,7 +428,7 @@ \subsubsection{The Circle Connection Bar To-Path} difference is that instead of filling the path with a single color a shading is used. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{mindmap}}] \begin{tikzpicture}[outer sep=0pt] \node (n1) at (0,0) [circle,minimum size=2cm,fill,draw,thick,red] {}; \node (n2) at (30:2.5) [circle,minimum size=1cm,fill,draw,thick,blue] {}; @@ -463,7 +459,7 @@ \subsubsection{Tree Edges} Here is an example of a tree built in this way: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{mindmap}}] \begin{tikzpicture} \path[mindmap,concept color=black,text=white] node[concept] {Computer Science} @@ -502,7 +498,7 @@ \subsection{Adding Annotations} style |every annotation|, which allows you to change this style in a convenient fashion. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{mindmap}}] \begin{tikzpicture} [mindmap,concept color=blue!80, every annotation/.style={fill=red!20}] diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-perspective.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-perspective.tex index ff1745953..3d5c9b127 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-perspective.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-perspective.tex @@ -7,10 +7,6 @@ \section{Three Point Perspective Drawing Library} This library provides tools for perspective drawing with one, two, or three vanishing points. \end{tikzlibrary} -% -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{perspective} -\end{codeexample} \subsection{Coordinate Systems} @@ -82,7 +78,7 @@ \subsection{Setting the view} $+z$ will be pointing upward, and $+x$ will be pointing right. The default is as shown below. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{perspective}}] \begin{tikzpicture}[3d view] \draw[->] (-1,0,0) -- (1,0,0) node[pos=1.1]{x}; \draw[->] (0,-1,0) -- (0,1,0) node[pos=1.1]{y}; @@ -96,7 +92,8 @@ \subsection{Setting the view} |isometric view| style. It simply sets |3d view={-45}{35.26}|. The value for \meta{elevation} is determined with $\arctan(1/\sqrt{2})$. In isometric projection the angle between any pair of axes is 120$^\circ$, as shown below. -\begin{codeexample}[] + % +\begin{codeexample}[preamble={\usetikzlibrary{perspective}}] \begin{tikzpicture}[isometric view] \draw[->] (-1,0,0) -- (1,0,0) node[pos=1.1]{x}; \draw[->] (0,-1,0) -- (0,1,0) node[pos=1.1]{y}; @@ -112,7 +109,7 @@ \subsection{Defining the perspective} scaling. As a reference, the axes will be shown too, without perspective projection. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{perspective}}] \newcommand\simplecuboid[3]{% \fill[gray!80!white] (tpp cs:x=0,y=0,z=#3) -- (tpp cs:x=0,y=#2,z=#3) @@ -164,7 +161,7 @@ \subsection{Defining the perspective} the vanishing points. The default values have a stronger perspective towards $x$ and $y$ than towards $z$, as shown below. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{perspective}}] \begin{tikzpicture}[3d view,perspective] \simplecuboid{2}{2}{2} \simpleaxes{2}{2}{2} @@ -178,7 +175,7 @@ \subsection{Defining the perspective} The location of the vanishing point that determines the `strength' of the perspective in $x$-direction can be set with the |p| key. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{perspective}}] \begin{tikzpicture}[ 3d view, perspective={ @@ -199,7 +196,7 @@ \subsection{Defining the perspective} By changing the $y$ and $z$ components of |p|, one can achieve various effects. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{perspective}}] \begin{tikzpicture}[ 3d view, perspective={ @@ -209,7 +206,7 @@ \subsection{Defining the perspective} \end{tikzpicture} \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{perspective}}] \begin{tikzpicture}[ 3d view, perspective={ @@ -219,7 +216,7 @@ \subsection{Defining the perspective} \end{tikzpicture} \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{perspective}}] \begin{tikzpicture}[ 3d view, perspective={ @@ -235,7 +232,7 @@ \subsection{Defining the perspective} Similar to |p|, but can be turned off by setting its $y$ component to \texttt{0}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{perspective}}] \begin{tikzpicture}[ 3d view, perspective={ @@ -251,7 +248,7 @@ \subsection{Defining the perspective} Similar to |p|, but can be turned off by setting its $z$ component to \texttt{0}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{perspective}}] \begin{tikzpicture}[ 3d view, perspective={ @@ -289,7 +286,7 @@ \subsection{Examples} An |r| that lies `below' your drawing can mimic a macro effect. % \nopagebreak -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{perspective}}] \begin{tikzpicture}[ isometric view, perspective={ @@ -307,7 +304,7 @@ \subsection{Examples} never reach it. % \nopagebreak -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{perspective}}] \begin{tikzpicture}[ isometric view, perspective={ @@ -330,7 +327,7 @@ \subsection{Examples} then three would. % \nopagebreak -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{perspective}}] \begin{tikzpicture}[ scale=0.7, 3d view, @@ -358,7 +355,7 @@ \subsection{Examples} strong. This might lead to \texttt{Dimension too large} errors. % \nopagebreak -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{perspective}}] \begin{tikzpicture}[ 3d view, perspective={ @@ -395,7 +392,7 @@ \subsection{Examples} become increasingly more complex. % \nopagebreak -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{perspective}}] \begin{tikzpicture}[ cycle of vertices/.style 2 args={ insert path={ diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-petri.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-petri.tex index bb33af9fc..87397dba3 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-petri.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-petri.tex @@ -13,10 +13,6 @@ \section{Petri-Net Drawing Library} \begin{tikzlibrary}{petri} This packages provides shapes and styles for drawing Petri nets. \end{tikzlibrary} -% -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{petri,positioning} -\end{codeexample} \subsection{Places} @@ -30,7 +26,7 @@ \subsection{Places} its capacity. You should use the |tokens| options, explained in Section~\ref{section-tokens}, to add tokens inside the place. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{petri,positioning}}] \begin{tikzpicture} \node[place,label=above:$p_1$,tokens=2] (p1) {}; \node[place,label=below:$p_2\ge1$,right=of p1] (p2) {}; @@ -41,7 +37,7 @@ \subsection{Places} This style is evoked by the style |place|. To change the appearance of places, you can change this style. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{petri,positioning}}] \begin{tikzpicture} [every place/.style={draw=blue,fill=blue!20,thick,minimum size=9mm}] \node[place,tokens=7,label=above:$p_1$] (p1) {}; @@ -65,7 +61,7 @@ \subsection{Transitions} To connect a transition to places, you can use the |edge| command as in the following example: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{petri,positioning}}] \begin{tikzpicture} \node[place,tokens=2,label=above:$p_1$] (p1) {}; \node[place,label=above:$p_2\ge1$,right=of p1] (p2) {}; @@ -116,7 +112,7 @@ \subsection{Tokens} be typeset in a tiny font and in white on black (naturally, you can easily change this by setting the style |every token|). % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{petri,positioning}}] \begin{tikzpicture} \node[place,label=above:$p_1$] (p1) {}; \node[token] at (p1) {}; @@ -147,7 +143,7 @@ \subsection{Tokens} the children next to each other inside (or, rather, on top) of the place node. Additionally, the edge from the parent node is not drawn. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{petri}}] \begin{tikzpicture} \node[place,label=above:$p_1$] {} [children are tokens] @@ -170,7 +166,7 @@ \subsection{Tokens} place more than nice tokens on a place, you will have to write your own placement code. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{petri}}] \begin{tikzpicture} \node[place,label=above:$p_2$] {} [children are tokens] @@ -185,7 +181,7 @@ \subsection{Tokens} This specifies the distance between the centers of the tokens in the arrangements of the option |children are tokens|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{petri}}] \begin{tikzpicture} \node[place,label=above:$p_3$] {} [children are tokens,token distance=1.1ex] @@ -210,7 +206,7 @@ \subsection{Tokens} having the style |token|. Thus, the following two pieces of codes have the same effect: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{petri}}] \tikz \node[place] {} [children are tokens] @@ -225,7 +221,7 @@ \subsection{Tokens} option does not handle ten or more tokens correctly. If you need this many tokens, you will have to program your own code. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{petri}}] \begin{tikzpicture}[every place/.style={minimum size=9mm}] \foreach \x/\y/\tokennumber in {0/2/1,1/2/2,2/2/3, @@ -242,7 +238,7 @@ \subsection{Tokens} gets a list of colors as parameter. It will then add as many tokens to the place as there are colors in this list, each filled correspondingly. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{petri}}] \tikz \node[place,colored tokens={black,black,red,blue}] {}; \end{codeexample} % @@ -252,11 +248,11 @@ \subsection{Tokens} This option, which must again be passed to a place, gets a list of texts for tokens. For each text, a new token will be added to the place. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{petri}}] \tikz \node[place,structured tokens={$x$,$y$,$z$}] {}; \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{petri}}] \begin{tikzpicture}[every place/.style={minimum size=9mm}] \foreach \x/\y/\tokennumber in {0/2/1,1/2/2,2/2/3, @@ -273,7 +269,7 @@ \subsection{Tokens} \subsection{Examples} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{petri}}] \begin{tikzpicture}[yscale=-1.6,xscale=1.5,thick, every transition/.style={draw=red,fill=red!20,minimum size=3mm}, every place/.style={draw=blue,fill=blue!20,minimum size=6mm}] diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-rdf.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-rdf.tex index 241322c69..c5d276aa0 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-rdf.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-rdf.tex @@ -62,10 +62,6 @@ \subsection{Starting the RDF Engine} explicitly to include semantic information in the output. \end{key} \end{tikzlibrary} -% -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{rdf} -\end{codeexample} \begin{key}{/tikz/rdf engine=\meta{rdf keys}} This key only has an effect when |rdf engine on| is called, otherwise the @@ -570,7 +566,7 @@ \subsubsection{An Example Library for Drawing Finite Automata} The library could be used as follows: % -\begin{codeexample}[width=5cm,preamble={\usetikzlibrary{graphs}}] +\begin{codeexample}[width=5cm,preamble={\usetikzlibrary{graphs,rdf}}] \tikz [dfa] \graph [math nodes, grow right = 1.5cm] { q_0 [state, initial] -> [transition = a] @@ -899,7 +895,7 @@ \subsubsection{The Resulting RDF Graph} \emph{Using} this code is still ``as easy as before'', indeed, the code for creating the automaton is perfectly unchanged: % -\begin{codeexample}[width=5cm,preamble={\usetikzlibrary{graphs}}] +\begin{codeexample}[width=5cm,preamble={\usetikzlibrary{graphs,rdf}}] \tikzset { rdf engine on } \tikz [dfa] \graph [math nodes, grow right = 1.5cm] { diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-shadings.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-shadings.tex index a0daa0eb4..3f73bd926 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-shadings.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-shadings.tex @@ -15,10 +15,6 @@ \section{Shadings Library} The package defines a number of shadings in addition to the ball and axis shadings that are available by default. \end{pgflibrary} -% -\begin{codeexample}[setup code,hidden] - \usepgflibrary{shadings} -\end{codeexample} In the following, the shadings defined in the library are listed in alphabetical order. The colors of some of these shadings can be configured @@ -46,7 +42,7 @@ \section{Shadings Library} \item The rotation angle of the shading is set to 0. \end{enumerate} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepgflibrary{shadings}}] \tikz \draw[top color=red] (0,0) rectangle (2,1); \end{codeexample} \end{key} @@ -64,7 +60,7 @@ \section{Shadings Library} middle color, this option should be given \emph{last} if all of these options need to be given: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepgflibrary{shadings}}] \tikz \draw[top color=white,bottom color=black,middle color=red] (0,0) rectangle (2,1); \end{codeexample} @@ -93,7 +89,7 @@ \section{Shadings Library} black. Because of this, it also makes sense to say |ball color=white| or |ball color=black| % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepgflibrary{shadings}}] \begin{tikzpicture} \shade[ball color=white] (0,0) circle (2ex); \shade[ball color=red] (1,0) circle (2ex); @@ -111,7 +107,7 @@ \section{Shadings Library} also defines four options, called the same way, that can be used to set these colors and select the shading implicitly. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepgflibrary{shadings}}] \tikz \shade[upper left=red,upper right=green, lower left=blue,lower right=yellow] @@ -141,13 +137,13 @@ \section{Shadings Library} \label{shading-color-wheel}% This shading fills the path with a color wheel. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepgflibrary{shadings}}] \tikz \shade[shading=color wheel] (0,0) circle (1.5); \end{codeexample} % To produce a color ring, cut out a circle from the color wheel: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepgflibrary{shadings}}] \tikz \shade[shading=color wheel] [even odd rule] (0,0) circle (1.5) (0,0) circle (1); @@ -159,7 +155,7 @@ \section{Shadings Library} This shading looks like a color wheel, but the brightness drops to zero in the center. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepgflibrary{shadings}}] \tikz \shade[shading=color wheel black center] (0,0) circle (1.5); \end{codeexample} % @@ -169,7 +165,7 @@ \section{Shadings Library} This shading looks like a color wheel, but the saturation drops to zero in the center. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepgflibrary{shadings}}] \tikz \shade[shading=color wheel white center] (0,0) circle (1.5); \end{codeexample} % @@ -183,7 +179,7 @@ \section{Shadings Library} arbitrarily (give it a try, if you have a fast computer). % \pgfutil@ifluatex -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepgflibrary{shadings}}] \tikz \shade[shading=Mandelbrot set] (0,0) rectangle (2,2); \end{codeexample} \else @@ -209,7 +205,7 @@ \section{Shadings Library} When this option is used, the |shade| and |shading=radial| options are set. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepgflibrary{shadings}}] \tikz \draw[inner color=red] (0,0) rectangle (2,1); \end{codeexample} \end{key} @@ -218,7 +214,7 @@ \section{Shadings Library} This option sets the color used at the border and outside of a |radial| shading. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepgflibrary{shadings}}] \tikz \draw[outer color=red,inner color=white] (0,0) rectangle (2,1); \end{codeexample} diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-shadows.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-shadows.tex index 1ac248c19..989206465 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-shadows.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-shadows.tex @@ -15,10 +15,6 @@ \section{Shadows Library} This library defines styles that help adding a (partly) transparent shadow to a path or node. \end{tikzlibrary} -% -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{shadows} -\end{codeexample} \subsection{Overview} @@ -67,7 +63,7 @@ \subsection{The General Shadow Option} shadows are not taken into account when the picture's bounding box is computed. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shadows}}] \tikz [even odd rule] \draw [general shadow={fill=red}] (0,0) circle (.5) (0.5,0) circle (.5); \end{codeexample} @@ -75,7 +71,7 @@ \subsection{The General Shadow Option} \begin{key}{/tikz/shadow scale=\meta{factor} (initially 1)} Shadows are scaled by \meta{factor}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shadows}}] \tikz [even odd rule] \draw [general shadow={fill=red,shadow scale=1.25}] (0,0) circle (.5) (0.5,0) circle (.5); @@ -85,7 +81,7 @@ \subsection{The General Shadow Option} \begin{key}{/tikz/shadow xshift=\meta{dimension} (initially 0pt)} Shadows are shifted horizontally by \meta{dimension}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shadows}}] \tikz [even odd rule] \draw [general shadow={fill=red,shadow xshift=-5pt}] (0,0) circle (.5) (0.5,0) circle (.5); @@ -112,19 +108,19 @@ \subsubsection{Drop Shadows} opacity=.5, fill=black!50, every shadow \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shadows}}] \tikz [even odd rule] \filldraw [drop shadow,fill=white] (0,0) circle (.5) (0.5,0) circle (.5); \end{codeexample} -\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] +\begin{codeexample}[preamble={\usetikzlibrary{shadows,shapes.symbols}}] \begin{tikzpicture} \foreach \i in {1,...,4} \node[starburst,drop shadow,fill=white,draw] at (0,\i) {Burst \i}; \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shadows}}] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); \filldraw [drop shadow={opacity=1},fill=white] @@ -141,7 +137,7 @@ \subsubsection{Drop Shadows} This style is executed in addition to any \meta{shadow options} for each shadow. Use this style to reconfigure the way shadows are drawn. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shadows}}] \begin{tikzpicture}[every shadow/.style={opacity=.8,fill=blue!50!black}] \filldraw [drop shadow,fill=white] (0,0) circle (.5) (0.5,0) circle (.5); \end{tikzpicture} @@ -167,7 +163,7 @@ \subsubsection{Copy Shadows} color} are also set, where the \meta{fill color} and \meta{draw color} are the fill and draw colors used for the main path. % -\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] +\begin{codeexample}[preamble={\usetikzlibrary{shadows,shapes.symbols}}] \begin{tikzpicture} \node [copy shadow,fill=blue!20,draw=blue,thick] {Hello World!}; @@ -193,7 +189,7 @@ \subsubsection{Copy Shadows} This shadow works like a |copy shadow|, only the shadow is added twice, the second time with the double |xshift| and |yshift|. % -\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] +\begin{codeexample}[preamble={\usetikzlibrary{shadows,shapes.symbols}}] \begin{tikzpicture} \node [double copy shadow,fill=blue!20,draw=blue,thick] {Hello World!}; @@ -230,7 +226,7 @@ \subsection{Shadows for Special Paths and Nodes} every shadow, \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shadows}}] \begin{tikzpicture} \foreach \i in {1,...,8} \node[circle,circular drop shadow,draw=blue,fill=blue!20,thick] @@ -251,7 +247,7 @@ \subsection{Shadows for Special Paths and Nodes} every shadow, \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shadows}}] \begin{tikzpicture} \foreach \i in {1,...,8} \node[circle,circular glow,fill=red!20,draw=red,thick] @@ -259,7 +255,7 @@ \subsection{Shadows for Special Paths and Nodes} \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shadows}}] \begin{tikzpicture} \foreach \i in {1,...,8} \node[circle,circular glow={fill=white},fill=red!20,draw=red,thick] @@ -267,7 +263,7 @@ \subsection{Shadows for Special Paths and Nodes} \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shadows}}] \begin{tikzpicture} \foreach \i in {1,...,8} \node[circle,circular glow={fill=green},fill=black,text=green!50!black] @@ -278,7 +274,7 @@ \subsection{Shadows for Special Paths and Nodes} An especially interesting effect can be achieved by only using the glow and not filling the path: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shadows}}] \begin{tikzpicture} \foreach \i in {1,...,8} \node[circle,circular glow={fill=red!\i0}] diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-shapes.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-shapes.tex index 142cf8fb1..92558a826 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-shapes.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-shapes.tex @@ -19,19 +19,6 @@ \subsection{Overview} section, these shapes are described. Note that the library |shapes| is provided for compatibility only. Please include sublibraries like |shapes.geometric| or |shapes.misc| directly. -% -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{ - shapes.geometric, - shapes.misc, - shapes.symbols, - shapes.arrows, - shapes.callouts, - shapes.multipart, - shapes.gates.logic.US, - shapes.gates.logic.IEC, - } -\end{codeexample} The appearance of shapes is influenced by numerous parameters like |minimum height| or |inner xsep|. These general parameters are documented in @@ -65,7 +52,7 @@ \subsection{Predefined Shapes} figure shows the anchors this shape defines; the anchors |10| and |130| are example of border anchors. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \Huge \begin{tikzpicture} \node[name=s,shape=circle,shape example] {Circle\vrule width 1pt height 2cm}; @@ -90,7 +77,7 @@ \subsection{Predefined Shapes} anchors this shape defines; the anchors |10| and |130| are example of border anchors. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \Huge \begin{tikzpicture} \node[name=s,shape=rectangle,shape example] {Rectangle\vrule width 1pt height 2cm}; @@ -130,7 +117,7 @@ \subsection{Geometric Shapes} The following figure shows the anchors this shape defines; the anchors |10| and |130| are example of border anchors. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \Huge \begin{tikzpicture} \node[name=s,shape=diamond,shape example] {Diamond\vrule width 1pt height 2cm}; @@ -153,7 +140,7 @@ \subsection{Geometric Shapes} separation is given. The following figure shows the anchors this shape defines; the anchors |10| and |130| are example of border anchors. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \Huge \begin{tikzpicture} \node[name=s,shape=ellipse,shape example] {Ellipse\vrule width 1pt height 2cm}; @@ -182,7 +169,7 @@ \subsection{Geometric Shapes} the natural dimensions of the node contents (which includes any |inner sep|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \begin{tikzpicture}[every node/.style={trapezium, draw}] \node at (0,2) {A}; \node[trapezium left angle=75, trapezium right angle=45] @@ -212,7 +199,7 @@ \subsection{Geometric Shapes} Regardless of the rotation of the shape border, the width and height of the trapezium are as follows: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \begin{tikzpicture}[>=stealth, every node/.style={text=black}, shape border uses incircle, shape border rotate=60] \node [trapezium, fill=gray!25, minimum width=2cm] (t) {}; @@ -229,7 +216,7 @@ \subsection{Geometric Shapes} minimum size specification. This is initially |false|, ensuring that the shape ``looks the same but bigger'' when enlarged. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \tikzset{my node/.style={trapezium, fill=#1!20, draw=#1!75, text=black}} \begin{tikzpicture} \draw [help lines] grid (3,2); @@ -242,7 +229,7 @@ \subsection{Geometric Shapes} By setting \meta{boolean} to |true|, the trapezium can be stretched horizontally or vertically. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \tikzset{my node/.style={trapezium, fill=#1!20, draw=#1!75, text=black}} \begin{tikzpicture} \tikzset{trapezium stretches=true} @@ -259,7 +246,7 @@ \subsection{Geometric Shapes} \meta{boolean} is |true|, \pgfname{} enlarges only the body of the trapezium when applying minimum width. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \tikzset{my node/.style={trapezium, fill=#1!20, draw=#1!75, text=black}} \begin{tikzpicture} \draw [help lines] grid (3,2); @@ -275,7 +262,7 @@ \subsection{Geometric Shapes} The anchors for the trapezium are shown below. The anchor |160| is an example of a border anchor. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \Huge \begin{tikzpicture} \node[name=s, shape=trapezium, shape example, inner sep=1cm] @@ -304,7 +291,7 @@ \subsection{Geometric Shapes} |semicircle| shape are shown below. Anchor |30| is an example of a border anchor. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \Huge \begin{tikzpicture} \node[name=s,shape=semicircle,shape border rotate=0,shape example, inner sep=1cm] @@ -331,7 +318,7 @@ \subsection{Geometric Shapes} whose radius is calculated to tightly fit the node contents (including any |inner sep|). % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \begin{tikzpicture} \foreach \a in {3,...,7}{ \draw[red, dashed] (\a*2,0) circle(0.5cm); @@ -345,7 +332,7 @@ \subsection{Geometric Shapes} as the diameter of the circumcircle, that is, the circle that passes through all the corners of the polygon border. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \begin{tikzpicture} \foreach \a in {3,...,7}{ \draw[blue, dashed] (\a*2,0) circle(0.5cm); @@ -364,7 +351,7 @@ \subsection{Geometric Shapes} The anchors for a regular polygon shape are shown below. The anchor |75| is an example of a border anchor. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \Huge \begin{tikzpicture} \node[name=s, shape=regular polygon, shape example, inner sep=.5cm] @@ -395,7 +382,7 @@ \subsection{Geometric Shapes} specified minimum size, width or height, is interpreted as the diameter of the circumcircle. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \begin{tikzpicture} \draw [help lines] (0,0) grid (2,2); \draw [blue, dashed] (1,1) circle(1cm); @@ -429,7 +416,7 @@ \subsection{Geometric Shapes} The inner and outer points form the principle anchors for the star, as shown below (anchor |75| is an example of a border anchor). % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \Huge \begin{tikzpicture} \node[name=s, shape=star, star points=5, star point ratio=1.65, shape example, inner sep=1.5cm] @@ -456,7 +443,7 @@ \subsection{Geometric Shapes} regardless of the rotation of the shape border, the width and height are always considered as follows: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \begin{tikzpicture}[>=stealth, every node/.style={text=black}, shape border uses incircle, shape border rotate=-30] \node [isosceles triangle, fill=gray!25, minimum width=1.5cm] (t) {}; @@ -480,7 +467,7 @@ \subsection{Geometric Shapes} will increase the width (and vice versa), in order to keep the apex angle the same. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \begin{tikzpicture}[paint/.style={draw=#1!75, fill=#1!20}] \tikzset{every node/.style={isosceles triangle, draw, inner sep=0pt, anchor=left corner, shape border rotate=90}} @@ -495,7 +482,7 @@ \subsection{Geometric Shapes} However, by setting \meta{boolean} to |true|, minimum width and height can be applied independently. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \begin{tikzpicture}[paint/.style={draw=#1!75, fill=#1!20}] \tikzset{every node/.style={isosceles triangle, draw, inner sep=0pt, anchor=south, shape border rotate=90, isosceles triangle stretches}} @@ -514,7 +501,7 @@ \subsection{Geometric Shapes} is rotated to 90 degrees. Note also that the |center| anchor does not necessarily correspond to any kind of geometric center. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \Huge \begin{tikzpicture} \node[name=s, shape=isosceles triangle, shape example, inner xsep=1cm] @@ -558,7 +545,7 @@ \subsection{Geometric Shapes} angles will be the same. \end{key} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \begin{tikzpicture}[every node/.style={kite, draw}] \node[kite upper vertex angle=135, kite lower vertex angle=70] at (0,0) {A}; \node[kite vertex angles=90 and 45] at (1,0) {B}; @@ -569,7 +556,7 @@ \subsection{Geometric Shapes} The anchors for the |kite| are shown below. Anchor |110| is an example of a border anchor. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \Huge \begin{tikzpicture} \node[name=s, shape=kite, shape example, inner sep=1.5cm] @@ -601,7 +588,7 @@ \subsection{Geometric Shapes} the angle between the `tails' of the dart. To use these keys in \tikzname, simply remove the \declare{|/pgf/|} path. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \begin{tikzpicture} \node[dart, draw, gray, shape border uses incircle, shape border rotate=45] (d) {dart}; @@ -624,7 +611,7 @@ \subsection{Geometric Shapes} rotated 90 degrees anti-clockwise). Anchor |110| is an example of a border anchor. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \Huge \begin{tikzpicture} \node[name=s, shape=dart, shape border rotate=90, shape example, inner sep=1.25cm] @@ -651,7 +638,7 @@ \subsection{Geometric Shapes} rotation determines the direction in which the `apex' of the sector points (unless other transformations have been applied). % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \begin{tikzpicture}[ every node/.style={circular sector, shape border uses incircle, draw}, ] @@ -671,7 +658,7 @@ \subsection{Geometric Shapes} The anchors for the circular sector shape are shown below. Anchor |30| is an example of a border anchor. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \Huge \begin{tikzpicture} \node[name=s,shape=circular sector, style=shape example, inner sep=1cm] @@ -694,7 +681,7 @@ \subsection{Geometric Shapes} the rotation of the shape border as described in Section~\ref{section-rotating-shape-borders}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \begin{tikzpicture} \node[cylinder, draw, shape aspect=.5] {ABC}; \end{tikzpicture} @@ -704,7 +691,7 @@ \subsection{Geometric Shapes} distance between the curved ends, and the width is always the distance between the straight sides. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \begin{tikzpicture}[>=stealth] \node [cylinder, gray!50, rotate=30, draw, minimum height=2cm, minimum width=1cm] (c) {Cylinder}; @@ -719,7 +706,7 @@ \subsection{Geometric Shapes} the cylinder. By contrast, enlarging the shape to some minimum width will stretch the curved ends. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \begin{tikzpicture}[shape aspect=.5] \tikzset{every node/.style={cylinder, shape border rotate=90, draw}} \node [minimum height=1.5cm] {A}; @@ -735,7 +722,7 @@ \subsection{Geometric Shapes} cylinder end. This may be ignored if the shape is enlarged to some minimum width. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \begin{tikzpicture}[] \tikzset{every node/.style={cylinder, shape border rotate=90, draw}} \node [aspect=1.0] {A}; @@ -753,7 +740,7 @@ \subsection{Geometric Shapes} |\ifpgfcylinderusescustomfill| appropriately. \end{key} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \begin{tikzpicture}[aspect=0.5] \node [cylinder, cylinder uses custom fill, cylinder end fill=red!50, cylinder body fill=red!25] {Cylinder}; @@ -776,7 +763,7 @@ \subsection{Geometric Shapes} also the center of rotation. The |shape center| is the center of the shape which includes the 2-dimensional representation of the cylinder top. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \Huge \begin{tikzpicture} \node[name=s, shape=cylinder, shape example, aspect=.5, inner xsep=3cm, @@ -811,7 +798,7 @@ \subsection{Symbol Shapes} diagonal line part of the foreground path; thus, the diagonal line is on top of the text. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] \begin{tikzpicture} \node [correct forbidden sign,line width=1ex,draw=red,fill=white] {Smoking}; \end{tikzpicture} @@ -825,7 +812,7 @@ \subsection{Symbol Shapes} lower left to the upper right. The strange naming of these shapes is for historical reasons. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] \begin{tikzpicture} \node [forbidden sign,line width=1ex,draw=red,fill=white] {Smoking}; \end{tikzpicture} @@ -847,7 +834,7 @@ \subsection{Symbol Shapes} The length of the handle as a multiple of the circle radius. \end{key} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] \begin{tikzpicture} \node [magnifying glass,line width=1ex,draw] {huge}; \end{tikzpicture} @@ -861,7 +848,7 @@ \subsection{Symbol Shapes} speaking, using an ellipse which tightly fits the node contents -- including any |inner sep|). % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] \begin{tikzpicture} \node[cloud, draw, fill=gray!20, aspect=2] {ABC}; \node[cloud, draw, fill=gray!20] at (1.5,0) {D}; @@ -893,7 +880,7 @@ \subsection{Symbol Shapes} |\ifpgfcloudignoresaspect| is set appropriately. The initial value is |false|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] \begin{tikzpicture}[aspect=1, every node/.style={cloud, cloud puffs=11, draw}] \node [fill=gray!20] {rain}; \node [cloud ignores aspect, fill=white] at (1.5,0) {snow}; @@ -906,7 +893,7 @@ \subsection{Symbol Shapes} These requirements are considered \emph{after} any aspect specification is applied. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] \begin{tikzpicture} \draw [help lines] grid (3,2); \draw [blue, dashed] (1.5, 1) ellipse (1.5cm and 1cm); @@ -918,7 +905,7 @@ \subsection{Symbol Shapes} The anchors for the cloud shape are shown below for a cloud with eleven puffs. Anchor 70 is an example of a border anchor. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] \Huge \begin{tikzpicture} \node[name=s, shape=cloud, style=shape example, cloud puffs=11, aspect=1.5, @@ -943,7 +930,7 @@ \subsection{Symbol Shapes} rotation of the shape border as described in Section~\ref{section-rotating-shape-borders}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] \begin{tikzpicture} \node[starburst, fill=yellow, draw=red, line width=2pt] {\bf BANG!}; \end{tikzpicture} @@ -963,7 +950,7 @@ \subsection{Symbol Shapes} are randomly generated, so there is (unfortunately) no guarantee that any such requirements will be fully met. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] \begin{tikzpicture} \draw[help lines] grid(3,2); \node[starburst, draw, minimum width=3cm, minimum height=2cm] @@ -994,7 +981,7 @@ \subsection{Symbol Shapes} The basic anchors for a nine point |starburst| shape are shown below. Anchor |80| is an example of a border anchor. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] \Huge \begin{tikzpicture} \node[name=s, shape=starburst, starburst points=9, starburst point height=3.5cm, @@ -1024,7 +1011,7 @@ \subsection{Symbol Shapes} points from that direction. The resulting points extend the node contents (which include the |inner sep|). % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] \begin{tikzpicture} [every node/.style={signal, draw, text=white, signal to=nowhere}] \node[fill=green!65!black, signal to=east] at (0,1) {To East}; @@ -1067,7 +1054,7 @@ \subsection{Symbol Shapes} The anchors for the signal shape are shown below. Anchor |70| is an example of a border anchor. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] \Huge \begin{tikzpicture} \node[name=s, shape=signal, signal from=west, shape example, inner sep=2cm] @@ -1091,7 +1078,7 @@ \subsection{Symbol Shapes} This shape is a rectangle with optional, ``bendy'' top and bottom sides, which tightly fits the node contents (including the |inner sep|). % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] \begin{tikzpicture} \node[tape, draw]{ABCD}; \node[tape, draw, tape bend top=none] at (1.5, 0) {EFGH}; @@ -1109,7 +1096,7 @@ \subsection{Symbol Shapes} style |in and out| will mean the side will first bend inwards and then bend outwards. The opposite holds true for |out and in|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] \begin{tikzpicture}[-stealth] \node[tape, draw, gray, minimum width=2cm](t){Tape}; \draw [blue]([yshift=5pt] t.north west) -- ([yshift=5pt]t.north east) @@ -1125,7 +1112,7 @@ \subsection{Symbol Shapes} bend styles, but the author of this shape cannot think of a single use for such a combination. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] \begin{tikzpicture}[every node/.style={tape, draw}] \node [tape bend top=out and in, tape bend bottom=out and in] {Parallel}; \node at (2,0) [tape bend bottom=out and in] {Why?}; @@ -1140,7 +1127,7 @@ \subsection{Symbol Shapes} \begin{key}{/pgf/tape bend height=\meta{length} (initially 5pt)} Sets the total height for a side with a bend. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] \begin{tikzpicture}[>=stealth] \draw [help lines] grid(3,2); \node [tape, fill, minimum size=2cm, red!50, tape bend top=none, @@ -1155,7 +1142,7 @@ \subsection{Symbol Shapes} of a border anchor. Note that border anchors will snap to the center of convex curves (i.e.\ when bending in). % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] \Huge \begin{tikzpicture} \node[name=s, shape=tape, tape bend height=1cm, shape example, inner xsep=3cm] @@ -1179,7 +1166,7 @@ \subsection{Symbol Shapes} is sometimes used in flowcharts. It is essentially a circle with a little tail: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] \tikz\node [magnetic tape, draw] (A) {A}; \end{codeexample} @@ -1189,7 +1176,7 @@ \subsection{Symbol Shapes} This key sets how far the tail extends beyond the radius of the tape. Negative values will be ignored. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] \begin{tikzpicture}[every node/.style={magnetic tape, draw}] \node [magnetic tape tail extend=0cm] at (0,0) {A}; \node [magnetic tape tail extend=0.25cm] at (0,1) {B}; @@ -1202,7 +1189,7 @@ \subsection{Symbol Shapes} the radius of the shape. The \meta{proportion} should be between |0.0| and |1.0|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] \begin{tikzpicture}[every node/.style={magnetic tape, draw}] \node [magnetic tape tail=0.5, magnetic tape tail extend=0.5cm] {A}; \node [magnetic tape tail=0.25] at (0,1) {B}; @@ -1213,7 +1200,7 @@ \subsection{Symbol Shapes} The following figure shows the anchors this shape defines; the anchors 10 and 130 are example of border anchors. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] \Huge \begin{tikzpicture} \node[name=s,shape=magnetic tape,shape example,inner sep=0.75cm, @@ -1251,7 +1238,7 @@ \subsection{Arrow Shapes} rotation determines in which direction the arrow points (provided no other rotational transformations are applied). % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.arrows}}] \begin{tikzpicture}[every node/.style={single arrow, draw}, rotate border/.style={shape border uses incircle, shape border rotate=#1}] \node {right}; @@ -1264,7 +1251,7 @@ \subsection{Arrow Shapes} between the back ends of the arrow head, and the height is measured from the arrow tip to the end of the arrow tail. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.arrows}}] \begin{tikzpicture}[>=stealth, rotate border/.style={shape border uses incircle, shape border rotate=#1}] \node[rotate border=-30, fill=gray!25, minimum height=3cm, single arrow, @@ -1289,7 +1276,7 @@ \subsection{Arrow Shapes} of the arrow head. This may change if the shape is enlarged to some minimum width. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.arrows}}] \begin{tikzpicture} \node[single arrow, draw, single arrow head extend=.5cm, gray!50, rotate=60] (a) {Arrow}; @@ -1303,7 +1290,7 @@ \subsection{Arrow Shapes} This moves the point where the arrow head joins the shaft of the arrow \emph{towards} the arrow tip, by \meta{length}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.arrows}}] \begin{tikzpicture}[every node/.style={single arrow, draw=none, rotate=60}] \node [fill=red!50] {arrow 1}; \node [fill=blue!50, single arrow head indent=1ex] at (1.5,0) {arrow 2}; @@ -1314,7 +1301,7 @@ \subsection{Arrow Shapes} The anchors for this shape are shown below (anchor |20| is an example of a border anchor). % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.arrows}}] \Huge \begin{tikzpicture} \node[name=s,shape=single arrow, shape example, single arrow head extend=1.5cm] @@ -1339,7 +1326,7 @@ \subsection{Arrow Shapes} (including any |inner sep|), and supports the rotation of the shape border, as described in Section~\ref{section-rotating-shape-borders}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.arrows}}] \begin{tikzpicture}[every node/.style={double arrow, draw}] \node [double arrow, draw] {Left or Right}; \end{tikzpicture} @@ -1350,7 +1337,7 @@ \subsection{Arrow Shapes} of the arrow heads, and the height is \emph{always} the tip-to-tip distance. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.arrows}}] \begin{tikzpicture}[>=stealth, rotate border/.style={shape border uses incircle, shape border rotate=#1}] \node[rotate border=210, fill=gray!25, minimum height=3cm, double arrow, @@ -1381,7 +1368,7 @@ \subsection{Arrow Shapes} This moves the point where the arrow heads join the shaft of the arrow \emph{towards} the arrow tips, by \meta{length}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.arrows}}] \begin{tikzpicture}[every node/.style={double arrow, draw=none, rotate=-60}] \node [fill=red!50] {arrow 1}; \node [fill=blue!50, double arrow head indent=1ex] at (1.5,0) {arrow 2}; @@ -1392,7 +1379,7 @@ \subsection{Arrow Shapes} The anchors for this shape are shown below (anchor |20| is an example of a border anchor). % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.arrows}}] \Huge \begin{tikzpicture} \node[name=s,shape=double arrow, double arrow head extend=1.5cm, shape example, inner xsep=2cm] @@ -1416,7 +1403,7 @@ \subsection{Arrow Shapes} This shape is a rectangle with optional arrows which extend from the four sides. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.arrows}}] \begin{tikzpicture} \node[arrow box, draw] {A}; \node[arrow box, draw, arrow box arrows={north:.5cm, west:0.75cm}] @@ -1430,7 +1417,7 @@ \subsection{Arrow Shapes} length of each arrow independently, from either the border of the rectangle (the default) or the center of the rectangle. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.arrows}}] \begin{tikzpicture} \tikzset{box/.style={arrow box, fill=#1}} \draw [help lines] grid(3,2); @@ -1498,7 +1485,7 @@ \subsection{Arrow Shapes} considered unavailable. They are (unavoidably) defined, but default to the center of the appropriate side. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.arrows}}] \Huge \begin{tikzpicture} \node[shape=arrow box, shape example, inner xsep=1cm, inner ysep=1.5cm, arrow box shaft width=2cm, @@ -1539,7 +1526,7 @@ \subsection{Shapes with Multiple Text Parts} middle. The upper part is the main part (the |text| part), the lower part is the |lower| part. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.multipart}}] \begin{tikzpicture} \node [circle split,draw,double,fill=red!20] { @@ -1553,7 +1540,7 @@ \subsection{Shapes with Multiple Text Parts} The shape inherits all anchors from the |circle| shape and defines the |lower| anchor in addition. See also the following figure: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.multipart}}] \Huge \begin{tikzpicture} \node[name=s,shape=circle split,shape example] {text\nodepart{lower}lower}; @@ -1575,7 +1562,7 @@ \subsection{Shapes with Multiple Text Parts} This shape (due to Manuel Lacruz) is similar to the split circle, but the two text parts are arranged diagonally. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.multipart}}] \begin{tikzpicture} \node [circle solidus,draw,double,fill=red!20] { @@ -1586,7 +1573,7 @@ \subsection{Shapes with Multiple Text Parts} \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.multipart}}] \Huge \begin{tikzpicture} \node[name=s,shape=circle solidus,shape example,inner xsep=1cm] {text\nodepart{lower}lower}; @@ -1610,7 +1597,7 @@ \subsection{Shapes with Multiple Text Parts} part is the |lower| part. The anchors for this shape are shown below. Anchor |60| is a border anchor. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.multipart}}] \Huge \begin{tikzpicture} \node[name=s,shape=ellipse split,shape example] {text\nodepart{lower}lower}; @@ -1631,7 +1618,7 @@ \subsection{Shapes with Multiple Text Parts} This shape is a rectangle which can be split either horizontally or vertically into several parts. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.multipart}}] \begin{tikzpicture}[my shape/.style={ rectangle split, rectangle split parts=#1, draw, anchor=center}] \node [my shape=5] at (0,1) @@ -1681,7 +1668,7 @@ \subsection{Shapes with Multiple Text Parts} range |1| to |20|. If more than four parts are needed, the boxes should be allocated in advance as described above. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.multipart}}] \begin{tikzpicture}[every text node part/.style={align=center}] \node[rectangle split, rectangle split parts=3, draw, text width=2.75cm] {Student @@ -1706,7 +1693,7 @@ \subsection{Shapes with Multiple Text Parts} |rectangle split parts| key in that, if 3 parts (for example) are specified, but one is empty, only two will be shown. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.multipart}}] \begin{tikzpicture}[every node/.style={draw, anchor=text, rectangle split, rectangle split parts=3}] \node {text \nodepart{second} \nodepart{third}third}; @@ -1743,7 +1730,7 @@ \subsection{Shapes with Multiple Text Parts} part and \emph{does not} affect the alignment of the contents of the boxes. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.multipart}}] \def\x{one \nodepart{two} 2 \nodepart{three} three \nodepart{four} 4} \begin{tikzpicture}[ every node/.style={rectangle split, rectangle split parts=4, @@ -1762,7 +1749,7 @@ \subsection{Shapes with Multiple Text Parts} in relation to each other, whereas the other values align the boxes in relation to the part of the shape they occupy. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.multipart}}] \def\x{\Large w\nodepart{two}x\nodepart{three}\Huge y\nodepart{four}\tiny z} \begin{tikzpicture}[ every node/.style={rectangle split, rectangle split parts=4, @@ -1799,7 +1786,7 @@ \subsection{Shapes with Multiple Text Parts} color from the last entry in the list. This key will automatically set |/pgf/rectangle split use custom fill|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.multipart}}] \begin{tikzpicture} \tikzset{every node/.style={rectangle split, draw, minimum width=.5cm}} \node[rectangle split part fill={red!50, green!50, blue!50, yellow!50}] {}; @@ -1816,7 +1803,7 @@ \subsection{Shapes with Multiple Text Parts} considered unavailable. They are (unavoidably) defined, but default to other anchor positions. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.multipart}}] \Huge \begin{tikzpicture} \node[name=s,shape=rectangle split, rectangle split parts=4, shape example, @@ -1857,7 +1844,7 @@ \subsection{Callout Shapes} automatically. However, the pointer is ignored when calculating the minimum size of the shape, and also when positioning anchors. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.callouts}}] \begin{tikzpicture}[remember picture] \node[ellipse callout, draw] (hallo) {Hallo!}; \end{tikzpicture} @@ -1873,7 +1860,7 @@ \subsection{Callout Shapes} coordinate absolutely (and can even point to named coordinates in different pictures). % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.callouts}}] \begin{tikzpicture}[remember picture, note/.style={rectangle callout, fill=#1}] \draw [help lines] grid(3,2); \node [note=red!50, callout relative pointer={(0,1)}] at (3,1) {Relative}; @@ -1915,7 +1902,7 @@ \subsection{Callout Shapes} Moves the callout pointer towards the center of the callout's main shape by \meta{distance}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.callouts}}] \begin{tikzpicture} \tikzset{callout/.style={ellipse callout, callout pointer arc=30, callout absolute pointer={#1}}} @@ -1943,7 +1930,7 @@ \subsection{Callout Shapes} not to be used to used to position the shape as it is calculated whilst the shape is being drawn. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.callouts}}] \Huge \begin{tikzpicture} \node[name=s,shape=rectangle callout, callout relative pointer={(1.25cm,-1cm)}, @@ -1980,7 +1967,7 @@ \subsection{Callout Shapes} the |pointer| anchor can only be used to position the shape when the relative anchor is specified. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.callouts}}] \Huge \begin{tikzpicture} \node[name=s,shape=ellipse callout, callout relative pointer={(1.25cm,-1cm)}, @@ -2007,7 +1994,7 @@ \subsection{Callout Shapes} ellipses. This callout requires the symbol shape library (for the cloud shape). If this library is not loaded an error will result. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.callouts}}] \begin{tikzpicture} \node[cloud callout, cloud puffs=15, aspect=2.5, cloud puff arc=120, shading=ball,text=white] {\bf Imagine...}; @@ -2051,7 +2038,7 @@ \subsection{Callout Shapes} anchor is specified. Note that the center of the last segment is drawn at the |pointer| anchor. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.callouts}}] \Huge \begin{tikzpicture} \node[name=s, shape=cloud callout, style=shape example, cloud puffs=11, aspect=1.5, @@ -2086,7 +2073,7 @@ \subsection{Miscellaneous Shapes} diagonal lines between the corners of the node's bounding box. Here is an example: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.misc}}] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); \node [cross out,draw=red] at (1.5,1) {cross out}; @@ -2095,14 +2082,14 @@ \subsection{Miscellaneous Shapes} A useful application is inside text as in the following example: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.misc}}] Cross \tikz[baseline] \node [cross out,draw,anchor=text] {me}; out! \end{codeexample} This shape inherits all anchors from the |rectangle| shape, see also the following figure: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.misc}}] \Huge \begin{tikzpicture} \node[name=s,shape=cross out,shape example] {cross out\vrule width 1pt height 2cm}; @@ -2124,7 +2111,7 @@ \subsection{Miscellaneous Shapes} This shape is identical to the |cross out| shape, only its foreground path consists of a single line from the lower left to the upper right. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.misc}}] Strike \tikz[baseline] \node [strike out,draw,anchor=text] {me}; out! \end{codeexample} @@ -2134,7 +2121,7 @@ \subsection{Miscellaneous Shapes} \begin{shape}{rounded rectangle} This shape is a rectangle which can have optionally rounded sides. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.misc}}] \begin{tikzpicture} \node[rounded rectangle, draw, fill=red!20]{Hallo}; \end{tikzpicture} @@ -2147,7 +2134,7 @@ \subsection{Miscellaneous Shapes} Sets the length of the arcs for the rounded ends. Recommended values for \meta{angle} are between |90| and |180|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.misc}}] \begin{tikzpicture} \matrix[row sep=5pt, every node/.style={draw, rounded rectangle}]{ \node[rounded rectangle arc length=180] {180}; \\ @@ -2161,7 +2148,7 @@ \subsection{Miscellaneous Shapes} Sets the style of the rounding for the left side. The permitted values for \meta{arc type} are |concave|, |convex|, or |none|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.misc}}] \begin{tikzpicture} \matrix[row sep=5pt, every node/.style={draw, rounded rectangle}]{ \node[rounded rectangle west arc=concave] {Concave}; \\ @@ -2187,7 +2174,7 @@ \subsection{Miscellaneous Shapes} border angle). Note that if only one side is rounded, the |center| anchor will not be the precise center of the shape. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.misc}}] \Huge \begin{tikzpicture} \node[name=s,shape=rounded rectangle, shape example, inner xsep=1.5cm, inner ysep=1cm] @@ -2209,7 +2196,7 @@ \subsection{Miscellaneous Shapes} \begin{shape}{chamfered rectangle} This shape is a rectangle with optionally chamfered corners. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.misc}}] \begin{tikzpicture} \node[chamfered rectangle, white, fill=red, double=red, draw, very thick] {\bf STOP!}; @@ -2222,7 +2209,7 @@ \subsection{Miscellaneous Shapes} \begin{key}{/pgf/chamfered rectangle angle=\meta{angle} (initially 45)} Sets the angle \emph{from the vertical} for the chamfer. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.misc}}] \begin{tikzpicture} \tikzset{every node/.style={chamfered rectangle, draw}} \node[chamfered rectangle angle=30] {abc}; @@ -2238,7 +2225,7 @@ \subsection{Miscellaneous Shapes} \meta{length} is ignored and the chamfered edges are drawn so that they meet in the middle. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.misc}}] \begin{tikzpicture} \tikzset{every node/.style={chamfered rectangle, draw}} \node[chamfered rectangle xsep=2pt] {def}; @@ -2267,7 +2254,7 @@ \subsection{Miscellaneous Shapes} chamfered. Two additional values |chamfer all| and |chamfer none|, are also permitted. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.misc}}] \begin{tikzpicture} \tikzset{every node/.style={chamfered rectangle, draw}} \node[chamfered rectangle corners=north west] {ghi}; @@ -2279,7 +2266,7 @@ \subsection{Miscellaneous Shapes} The anchors for this shape are shown below (anchor |60| is an example of a border angle. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.misc}}] \Huge \begin{tikzpicture} \node[name=s,shape=chamfered rectangle, chamfered rectangle sep=1cm, diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-spy.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-spy.tex index 2b195d666..9bc7a69a9 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-spy.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-spy.tex @@ -16,10 +16,6 @@ \section{Spy Library: Magnifying Parts of Pictures} picture is repeated in another area in a magnified way (as if you were looking through a spyglass, hence the name). \end{tikzlibrary} -% -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{decorations.fractals,spy} -\end{codeexample} \subsection{Magnifying a Part of a Picture} @@ -28,7 +24,7 @@ \subsection{Magnifying a Part of a Picture} pictures in which some important parts are repeated somewhere, but magnified as if you were looking through a spyglass: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.fractals,spy}}] \begin{tikzpicture} [spy using outlines={circle, magnification=4, size=2cm, connect spies}] @@ -45,7 +41,7 @@ \subsection{Magnifying a Part of a Picture} \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.fractals,spy}}] \begin{tikzpicture}[spy using overlays={size=12mm}] \draw [decoration=Koch snowflake] decorate { decorate{ decorate{ decorate{ (0,0) -- (2,0) }}}}; @@ -150,7 +146,7 @@ \subsection{Spy Scopes} scope, whereas |\spy| commands outside the inner |spy scope| but inside the outer |spy scope| allow you to ``spy on the spy''. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.fractals,spy}}] \begin{tikzpicture} [spy using outlines={rectangle, red, magnification=5, size=1.5cm, connect spies}] @@ -244,7 +240,7 @@ \subsection{The Spy Command} to-be-magnified area. You can change this by providing the |at| option yourself: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.fractals,spy}}] \begin{tikzpicture} [spy using outlines={circle, magnification=3, size=1cm}] @@ -287,7 +283,7 @@ \subsection{The Spy Command} node is (also) always named |tikzspyinnode|. Following the spy scope, you can use this node like any other node: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.fractals,spy}}] \begin{tikzpicture} \begin{scope} [spy using outlines={circle, magnification=3, size=2cm, connect spies}] @@ -328,7 +324,7 @@ \subsection{The Spy Command} resulting in a node whose size and shape exactly corresponds to the area in the picture that is shown in the spy-on node. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.fractals,spy}}] \begin{tikzpicture} [spy using outlines={lens={scale=3,rotate=20}, size=2cm, connect spies}] @@ -368,7 +364,7 @@ \subsection{Predefined Spy Styles} filled, using a thick line; and the spy-on node is drawn, but not filled, using a very thin line. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.fractals,spy}}] \begin{tikzpicture} [spy using outlines={circle, magnification=3, size=1cm, connect spies}] @@ -385,7 +381,7 @@ \subsection{Predefined Spy Styles} This key creates a |spy scope| in which both the spy-in and spy-on nodes are filled, but with the fill opacity set to 20\%. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.fractals,spy}}] \begin{tikzpicture} [spy using overlays={circle, magnification=3, size=1cm, connect spies}] @@ -403,7 +399,7 @@ \subsection{Predefined Spy Styles} \begin{key}{/tikz/connect spies} Causes the spy-in and the spy-on nodes to be connected by a thin line. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.fractals,spy}}] \begin{tikzpicture} [spy using overlays={circle, magnification=3, size=1cm}] @@ -424,7 +420,7 @@ \subsection{Examples} However, you might also wish to use the |circle| shape for the spy-on node and the |magnifying glass| shape for the spy-in node: % -\begin{codeexample}[preamble={\usetikzlibrary{shadows,shapes.symbols}}] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.fractals,shadows,shapes.symbols,spy}}] \tikzset{spy using mag glass/.style={ spy scope={ every spy on node/.style={ @@ -446,7 +442,7 @@ \subsection{Examples} With the magnifying glass, you can also put it ``on top'' of the picture itself: % -\begin{codeexample}[preamble={\usetikzlibrary{shadows,shapes.symbols}}] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.fractals,shadows,shapes.symbols,spy}}] \begin{tikzpicture} [spy scope={magnification=4, size=1cm}, every spy in node/.style={ diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-svg-path.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-svg-path.tex index 5460d6ad2..862525617 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-svg-path.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-svg-path.tex @@ -15,10 +15,6 @@ \section{SVG-Path Library} This library defines a command that allows you to specify a path using the \textsc{svg}-syntax. \end{pgflibrary} -% -\begin{codeexample}[setup code,hidden] - \usepgflibrary{svg.path} -\end{codeexample} \begin{command}{\pgfpathsvg\marg{path}} This command extends the current path by a \meta{path} given in the @@ -45,7 +41,7 @@ \section{SVG-Path Library} path commands. \end{itemize} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepgflibrary{svg.path}}] \begin{pgfpicture} \pgfpathsvg{M 0 0 l 20 0 0 20 -20 0 q 10 0 10 10 t 10 10 10 10 h -50 z} diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-through.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-through.tex index f0fbf10dd..1d9e278f4 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-through.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-through.tex @@ -14,10 +14,6 @@ \section{Through Library} \begin{tikzlibrary}{through} This library defines keys for creating shapes that go through given points. \end{tikzlibrary} -% -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{through} -\end{codeexample} \begin{key}{/tikz/circle through=\meta{coordinate}} When this key is given as an option to a node, the following happens: @@ -30,7 +26,7 @@ \section{Through Library} \meta{coordinate}. \end{enumerate} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{through}}] \begin{tikzpicture} \draw[help lines] (0,0) grid (3,2); \node (a) at (2,1.5) {$a$}; diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-trees.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-trees.tex index c22af0eb8..c29dc7c55 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-trees.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-trees.tex @@ -14,10 +14,6 @@ \section{Tree Library} \begin{tikzlibrary}{trees} This packages defines styles to be used when drawing trees. \end{tikzlibrary} -% -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{trees} -\end{codeexample} \subsection{Growth Functions} @@ -45,7 +41,7 @@ \subsection{Growth Functions} Here are some arrangements based on this growth function. We start with a simple ``above'' arrangement: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{trees}}] \begin{tikzpicture}[grow via three points={% one child at (0,1) and two children at (-.5,1) and (.5,1)}] \node at (0,0) {one} child; @@ -58,7 +54,7 @@ \subsection{Growth Functions} The next arrangement places children above, but ``grows only to the right''. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{trees}}] \begin{tikzpicture}[grow via three points={% one child at (0,1) and two children at (0,1) and (1,1)}] \node at (0,0) {one} child; @@ -70,7 +66,7 @@ \subsection{Growth Functions} In the final arrangement, the children are placed along a line going down and right. -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{trees}}] \begin{tikzpicture}[grow via three points={% one child at (-1,-.5) and two children at (-1,-.5) and (0,-.75)}] \node at (0,0) {one} child; @@ -98,7 +94,7 @@ \subsection{Growth Functions} Note that this function will rotate the coordinate system of the children to ensure that the grandchildren will grow in the right direction. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{trees}}] \begin{tikzpicture} [grow cyclic, level 1/.style={level distance=8mm,sibling angle=60}, @@ -124,7 +120,7 @@ \subsection{Growth Functions} Note that this function will not rotate the coordinate system. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{trees}}] \begin{tikzpicture} \node {root} [clockwise from=30,sibling angle=30] @@ -153,7 +149,7 @@ \subsection{Edges From Parent} distance) and then on to the child using only horizontal and vertical lines. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{trees}}] \begin{tikzpicture} \node {root} [edge from parent fork down] @@ -171,7 +167,7 @@ \subsection{Edges From Parent} This style behaves similarly, only it will first draw its edge to the right. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{trees}}] \begin{tikzpicture} \node {root} [edge from parent fork right,grow=right] diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-turtle.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-turtle.tex index 50bb8e5c1..5a002fb3b 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-turtle.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-turtle.tex @@ -11,21 +11,17 @@ \section{Turtle Graphics Library} \label{section-library-tutrle} -\begin{pgflibrary}{turtle} +\begin{tikzlibrary}{turtle} This little library defines some keys to create simple turtle graphics in the tradition of the Logo programming language. These commands are mostly for fun, but they can also be used for more ``serious'' business. % -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{turtle} -\end{codeexample} - % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{turtle}}] \tikz[turtle/distance=2mm] \draw [turtle={home,forward,right,forward,left,forward,left,forward}]; \end{codeexample} % -\end{pgflibrary} +\end{tikzlibrary} Even though the |turtle| keys looks like an option, it uses the |insert path| option internally to produce a path. @@ -44,7 +40,7 @@ \section{Turtle Graphics Library} This key executes the \meta{keys} with the current key path set to |/tikz/turtle|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{turtle}}] \tikz[turtle/distance=2mm] \draw [turtle={home,fd,rt,fd,lt,fd,lt,fd}]; \end{codeexample} @@ -73,7 +69,7 @@ \section{Turtle Graphics Library} This style can set up the |to path| used by turtles. By setting this style you can change the to-path: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{turtle}}] \tikz \draw [turtle={how/.style={bend left},home,forward,right,forward}]; \end{codeexample} \end{stylekey} @@ -111,7 +107,7 @@ \section{Turtle Graphics Library} Turtle graphics are especially nice in conjunction with the |\foreach| statement: -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{turtle}}] \tikz \filldraw [thick,blue,fill=blue!20] [turtle=home] \foreach \i in {1,...,5} diff --git a/doc/generic/pgf/text-en/pgfmanual-en-library-views.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-views.tex index fed3797aa..0a14a1016 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-views.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-views.tex @@ -16,10 +16,6 @@ \section{Views Library} of a part of a picture so that this part ``fits'' into a ``viewbox''. Mostly, views are useful in conjunction with animations. \end{tikzlibrary} -% -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{views} -\end{codeexample} A \emph{view} is essentially a ``window'' through which you see a graphic. To establish a view, you specify a rectangle -- which is the window -- and another @@ -54,7 +50,7 @@ \section{Views Library} inside the window rectangle. \end{enumerate} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{views}}] \tikz { \draw [red, very thick] (0,0) rectangle (20mm,20mm); \begin{scope}[meet = {(0.5,0.5) (2.5,1.5) at (0,0) (2,2)}] @@ -63,7 +59,7 @@ \section{Views Library} \end{scope} } \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{views}}] \tikz { \draw [red, very thick] (0,0) rectangle (20mm,20mm); \begin{scope}[slice = {(0.5,0.5) (2.5,1.5) at (0,0) (2,2)}] @@ -77,7 +73,7 @@ \section{Views Library} the |meet| command as the target object and then animate its |:view| attribute: % -\begin{codeexample}[preamble={\usetikzlibrary{animations}}] +\begin{codeexample}[preamble={\usetikzlibrary{animations,views}}] \tikz [animate = { my scope:view = { begin on = { click, of next = here }, @@ -96,7 +92,7 @@ \section{Views Library} You can, of course, also specify the animation using the |animate myself:| key when you specify the animation inside the scope: % -\begin{codeexample}[preamble={\usetikzlibrary{animations}}] +\begin{codeexample}[preamble={\usetikzlibrary{animations,views}}] \tikz [animate = { my scope:view = { }}] { diff --git a/doc/generic/pgf/text-en/pgfmanual-en-module-parser.tex b/doc/generic/pgf/text-en/pgfmanual-en-module-parser.tex index b304eac0c..8a85b57c7 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-module-parser.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-module-parser.tex @@ -16,10 +16,6 @@ \section{Parser Module}% This module defines some commands for creating a simple letter-by-letter parser. \end{pgfmodule} -% -\begin{codeexample}[setup code,hidden] - \usepgfmodule{parser} -\end{codeexample} This module provides commands for defining a parser that scans some given text letter-by-letter. For each letter, some code is executed and, possibly a @@ -49,7 +45,7 @@ \section{Parser Module}% In the following example, the parser counts the number of |a|'s in the \text{text}, ignoring any |b|'s. The \meta{text} ends with the first~|c|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepgfmodule{parser}}] \newcount\mycount \pgfparserdef{myparser}{initial}{the letter a}% {\advance\mycount by 1\relax}% @@ -230,7 +226,10 @@ \section{Parser Module}% listed in subsection~\ref{sec:parser:keys}. \end{command}% -\subsection{Keys of the Parser Module}\label{sec:parser:keys}% + +\subsection{Keys of the Parser Module} +\label{sec:parser:keys} + \begin{key}{/pgfparser/silent=\meta{boolean} (initially false)}% If |true| then no error will be thrown when a letter is parsed for which no action is specified, silently ignoring it. This holds true for every parser. @@ -251,13 +250,19 @@ \subsection{Keys of the Parser Module}\label{sec:parser:keys}% defined parser. \end{key}% -\subsection{Examples}% + +\subsection{Examples} + The following example counts the different letters appearing in a more or less -random string of letters. Every letter is counted only once, this is achieved by -defining a new action for every encountered unknown letter that does nothing. We -can define such rule without knowing which letter is used, because +random string of letters. Every letter is counted only once, this is achieved +by defining a new action for every encountered unknown letter that does +nothing. We can define such rule without knowing which letter is used, because |\pgfparsertoken| has the same meaning as that letter. -\begin{codeexample}[] +% +\begin{codeexample}[ + preamble={\usepgfmodule{parser}}, + pre={\newcount\mycount}, +] \mycount=0 % using the shortcut syntax of just placing ; after the state \pgfparserdef{different letters}{all};{\pgfparserswitch{final}}% @@ -273,7 +278,8 @@ \subsection{Examples}% Next we want to try something that uses some of the different argument types available. -\begin{codeexample}[] +% +\begin{codeexample}[preamble={\usepgfmodule{parser}}] % using the same syntax as \pgfparserdef \pgfparserdef{arguments}{initial}{the letter a}[d()] {\pgfparserifmark{#1}{\textcolor{red}{\textit{use}}}{\textbf{#1}} }% diff --git a/doc/generic/pgf/text-en/pgfmanual-en-pgfsys-animations.tex b/doc/generic/pgf/text-en/pgfmanual-en-pgfsys-animations.tex index 387653d3a..ad5a886db 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-pgfsys-animations.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-pgfsys-animations.tex @@ -161,7 +161,9 @@ \subsection{Animations and Snapshots} % Now the example, where the circle will disappear, when clicked: % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvalscalar{1} @@ -215,7 +217,7 @@ \subsection{Animations and Snapshots} numerically stable. \end{enumerate} % -\begin{codeexample}[width=5cm] +\begin{codeexample}[width=5cm,preamble={\usetikzlibrary{animations}}] \foreach \t in {0.5,1,1.5,2} { \pgfsysanimsnapshot{\t} \tikz { @@ -259,7 +261,10 @@ \subsection{Commands for Animating an Attribute: Color, Opacity, Visibility, Sta Specify values with |\pgfsysanimvalscalar|. % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvalscalar{1} @@ -276,7 +281,10 @@ \subsection{Commands for Animating an Attribute: Color, Opacity, Visibility, Sta Specify values with |\pgfsysanimvalscalar|. % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvalscalar{1} @@ -293,7 +301,10 @@ \subsection{Commands for Animating an Attribute: Color, Opacity, Visibility, Sta Specify values with |\pgfsysanimvalscalar|. % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvalscalar{1} @@ -311,7 +322,10 @@ \subsection{Commands for Animating an Attribute: Color, Opacity, Visibility, Sta Specify values with |\pgfsysanimvaltext|. However, only two values are allowed: |visible| and |hidden|. % -\begin{codeexample}[animation list={-1,0,1,2,3}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={-1,0,1,2,3}, +] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvaltext{hidden} @@ -328,7 +342,10 @@ \subsection{Commands for Animating an Attribute: Color, Opacity, Visibility, Sta Specify values with |\pgfsysanimvalcolorrgb| and friends. % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvalcolorrgb{0}{0}{0} @@ -345,7 +362,10 @@ \subsection{Commands for Animating an Attribute: Color, Opacity, Visibility, Sta Specify values with |\pgfsysanimvalcolorrgb| and friends. % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvalcolorrgb{0}{0}{0} @@ -371,7 +391,11 @@ \subsection{Commands for Animating an Attribute: Paths and Their Rendering} Specify values with |\pgfsysanimvalpath|. % -\begin{codeexample}[animation list={0.5,1,1.5,2},animation bb={(0.9,-0.1)rectangle(2.1,1.1)}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, + animation bb={(0.9,-0.1)rectangle(2.1,1.1)}, +] \animationexample{my path}{path}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvalpath{\pgfsys@moveto{1cm}{0cm}% @@ -466,7 +490,11 @@ \subsection{Commands for Animating an Attribute: Paths and Their Rendering} animations may use different arrow tips / markers. This allows you to animate (change) which arrow tip is used on a path over time. % -\begin{codeexample}[animation list={0.5,1,1.5,2},animation bb={(0.7,-0.3)rectangle(2.3,1.3)}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, + animation bb={(0.7,-0.3)rectangle(2.3,1.3)}, +] % Declare a marker: \pgfsys@marker@declare\mymarker{% \pgfscope% @@ -505,7 +533,10 @@ \subsection{Commands for Animating an Attribute: Paths and Their Rendering} Specify values with |\pgfsysanimvaldimension|. % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvaldimension{1pt} @@ -522,7 +553,10 @@ \subsection{Commands for Animating an Attribute: Paths and Their Rendering} Specify values with |\pgfsysanimvaldash|. % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvaldash{1pt,10pt}{0pt} @@ -532,7 +566,10 @@ \subsection{Commands for Animating an Attribute: Paths and Their Rendering} } \end{codeexample} % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvaldash{1cm,1pt}{0pt} @@ -542,7 +579,10 @@ \subsection{Commands for Animating an Attribute: Paths and Their Rendering} } \end{codeexample} % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvaldash{3pt,1pt}{0pt} @@ -614,7 +654,7 @@ \subsection{Commands for Animating an Attribute: Transformations and Views} in two seconds and rotates the blue ball over 90$^\circ$ around the origin. The ball is placed at $(1,0)$. % -\begin{codeexample}[code only] +\begin{codeexample}[code only,setup code] \def\animationcanvasexample#1#2{% \animationexample{ball}{}{% \pgfsysanimkeycanvastransform{#1}{#2}% @@ -634,6 +674,8 @@ \subsection{Commands for Animating an Attribute: Transformations and Views} \fill [ball color=blue,name=ball] (1,0) circle [radius=3mm]; } } \end{codeexample} % +% TODOsp: codeexamples: this definition is needed for the next 4 `codeexample`s +% but because of the hash sign it can't simply be added `pre` \def\animationcanvasexample#1#2{% \animationexample{ball}{}{% \pgfsysanimkeycanvastransform{#1}{#2}% @@ -652,26 +694,42 @@ \subsection{Commands for Animating an Attribute: Transformations and Views} \pgfsysanimate{rotate} \fill [ball color=blue,name=ball] (1,0) circle [radius=3mm]; } } -\begin{codeexample}[width=9.9cm,animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + width=9.9cm, + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \animationcanvasexample {} {} \end{codeexample} % -\begin{codeexample}[width=9.9cm,animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + width=9.9cm, + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \animationcanvasexample {\pgfsys@transformshift{10mm}{0mm}} {\pgfsys@transformshift{-10mm}{0mm}} \end{codeexample} % -\begin{codeexample}[width=9.9cm,animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + width=9.9cm, + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \animationcanvasexample {\pgfsys@transformcm{0.5}{0.5}{-0.5}{0.5} {0pt}{0pt}} {} \end{codeexample} % -\begin{codeexample}[width=9.9cm,animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + width=9.9cm, + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \animationcanvasexample {\pgfsys@transformcm{0.5}{0.5}{-0.5}{0.5} {0pt}{0pt}} @@ -687,7 +745,10 @@ \subsection{Commands for Animating an Attribute: Transformations and Views} Specify values with |\pgfsysanimvaltranslate|. % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvaltranslate{0cm}{0cm}% @@ -705,7 +766,10 @@ \subsection{Commands for Animating an Attribute: Transformations and Views} Specify values with |\pgfsysanimvalscale|. % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvalscale{1}{1}% @@ -722,7 +786,10 @@ \subsection{Commands for Animating an Attribute: Transformations and Views} Specify values with |\pgfsysanimvalscalar|. % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, + ] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvalscalar{0}% @@ -740,7 +807,10 @@ \subsection{Commands for Animating an Attribute: Transformations and Views} Specify values with |\pgfsysanimvalscalar|. % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvalscalar{0}% @@ -784,7 +854,10 @@ \subsection{Commands for Animating an Attribute: Transformations and Views} simply be executed and must call |\pgfsys@lineto| and similar path-construction commands, but should not call other commands. % -\begin{codeexample}[animation list={0.5,1,1.5,2},render instead={ +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, + render instead={ \animationexample{node}{}{ \pgfsysanimkeymovealong{ \pgfsyssoftpath@movetotoken{0pt}{0pt} @@ -831,7 +904,10 @@ \subsection{Commands for Animating an Attribute: Transformations and Views} so that it points along the path as time progresses. This option is only applicable to motion animations. % -\begin{codeexample}[animation list={0.5,1,1.5,2},render instead={ +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, + render instead={ \animationexample{node}{}{ \pgfsysanimkeyrotatealong \pgfsysanimkeymovealong{ @@ -873,8 +949,12 @@ \subsection{Commands for Animating an Attribute: Transformations and Views} Specify values with |\pgfsysanimvalviewbox|. % -\begin{codeexample}[animation list={0.5,1,1.5,2},width=5cm,animation - bb={(0.9,-2.1) rectangle (3.1,2.1)}] +\begin{codeexample}[ + width=5cm, + preamble={\usetikzlibrary{animations,views}}, + animation list={0.5,1,1.5,2}, + animation bb={(0.9,-2.1) rectangle (3.1,2.1)}, +] \animationexample{my view}{view}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvalviewbox{-10mm}{-20mm}{10mm}{20mm}% @@ -1124,7 +1204,11 @@ \subsection{Commands for Specifying Timing: Repeats} Specifies that the animation should repeat the specified \meta{number of times}, which may be a fractional number. % -\begin{codeexample}[animation list={1,2,3,4,5,6,7,8},width=6cm] +\begin{codeexample}[ + width=6cm, + preamble={\usetikzlibrary{animations}}, + animation list={1,2,3,4,5,6,7,8}, +] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvaltranslate{0cm}{0cm} @@ -1141,7 +1225,11 @@ \subsection{Commands for Specifying Timing: Repeats} \begin{command}{\pgfsys@animation@repeat@indefinite} Specifies that the animation should repeat indefinitely. % -\begin{codeexample}[animation list={1,2,3,4,5,6,7,8},width=6cm] +\begin{codeexample}[ + width=6cm, + preamble={\usetikzlibrary{animations}}, + animation list={1,2,3,4,5,6,7,8}, +] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvaltranslate{0cm}{0cm} @@ -1159,7 +1247,11 @@ \subsection{Commands for Specifying Timing: Repeats} Specifies that the animation should repeat until \meta{seconds} have elapsed. % -\begin{codeexample}[animation list={1,2,3,4,5,6,7,8},width=6cm] +\begin{codeexample}[ + width=6cm, + preamble={\usetikzlibrary{animations}}, + animation list={1,2,3,4,5,6,7,8}, +] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvaltranslate{0cm}{0cm} @@ -1201,8 +1293,11 @@ \subsection{Commands for Specifying Timing: Beginning and Ending} after the graphic is shown. For instance, in the next example the animation will start automatically after 5\,s \emph{or} when then button is pressed. % -\begin{codeexample}[animation list={1,2,3,4,5,6,7,8},width=6cm,render - instead={ +\begin{codeexample}[ + width=6cm, + preamble={\usetikzlibrary{animations}}, + animation list={1,2,3,4,5,6,7,8}, +render instead={ \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvaltranslate{0cm}{0cm} @@ -1261,7 +1356,10 @@ \subsection{Commands for Specifying Timing: Beginning and Ending} onto the object, moved over the object, or moved off the object. \end{itemize} % -\begin{codeexample}[width=2cm] +\begin{codeexample}[ + width=2cm, + preamble={\usetikzlibrary{animations}}, +] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvaltranslate{0cm}{0cm} @@ -1271,7 +1369,10 @@ \subsection{Commands for Specifying Timing: Beginning and Ending} \pgfsysanimate{translate} } \end{codeexample} % -\begin{codeexample}[width=2cm] +\begin{codeexample}[ + width=2cm, + preamble={\usetikzlibrary{animations}}, +] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvaltranslate{0cm}{0cm} @@ -1281,7 +1382,10 @@ \subsection{Commands for Specifying Timing: Beginning and Ending} \pgfsysanimate{translate} } \end{codeexample} % -\begin{codeexample}[width=2cm] +\begin{codeexample}[ + width=2cm, + preamble={\usetikzlibrary{animations}}, +] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvaltranslate{0cm}{0cm} @@ -1291,7 +1395,10 @@ \subsection{Commands for Specifying Timing: Beginning and Ending} \pgfsysanimate{translate} } \end{codeexample} % -\begin{codeexample}[width=2cm] +\begin{codeexample}[ + width=2cm, + preamble={\usetikzlibrary{animations}}, +] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvaltranslate{0cm}{0cm} @@ -1301,7 +1408,10 @@ \subsection{Commands for Specifying Timing: Beginning and Ending} \pgfsysanimate{translate} } \end{codeexample} % -\begin{codeexample}[width=2cm] +\begin{codeexample}[ + width=2cm, + preamble={\usetikzlibrary{animations}}, +] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvaltranslate{0cm}{0cm} @@ -1319,7 +1429,11 @@ \subsection{Commands for Specifying Timing: Beginning and Ending} The animation begins (or end) with a certain offset when another animation has reached a certain repeat count. % -\begin{codeexample}[animation list={1,2,3,4,5,6,7,8},width=6cm] +\begin{codeexample}[ + width=6cm, + preamble={\usetikzlibrary{animations}}, + animation list={1,2,3,4,5,6,7,8}, +] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvaltranslate{0cm}{0cm} @@ -1352,7 +1466,10 @@ \subsection{Commands for Specifying Timing: Beginning and Ending} event may not be supported by some browsers for security reasons (prevent key loggers). % -\begin{codeexample}[width=2cm] +\begin{codeexample}[ + width=2cm, + preamble={\usetikzlibrary{animations}}, +] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvaltranslate{0cm}{0cm} @@ -1374,7 +1491,10 @@ \subsection{Commands for Specifying Timing: Restart Behaviour} Defines that the animation can be restarted at any time. This is the default. % -\begin{codeexample}[width=2cm] +\begin{codeexample}[ + width=2cm, + preamble={\usetikzlibrary{animations}}, +] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvaltranslate{0cm}{0cm} @@ -1391,7 +1511,10 @@ \subsection{Commands for Specifying Timing: Restart Behaviour} \begin{command}{\pgfsys@animation@restart@never} Defines that the animation cannot be restarted once it has run. % -\begin{codeexample}[width=2cm] +\begin{codeexample}[ + width=2cm, + preamble={\usetikzlibrary{animations}}, +] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvaltranslate{0cm}{0cm} @@ -1408,7 +1531,10 @@ \subsection{Commands for Specifying Timing: Restart Behaviour} \begin{command}{\pgfsys@animation@restart@whennotactive} Defines that the animation cannot be restarted while it is running. % -\begin{codeexample}[width=2cm] +\begin{codeexample}[ + width=2cm, + preamble={\usetikzlibrary{animations}}, +] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvaltranslate{0cm}{0cm} @@ -1429,7 +1555,11 @@ \subsection{Commands for Specifying Timing: Restart Behaviour} at the end of the animation the last value of the attributes stays in effect. % -\begin{codeexample}[animation list={1,2,3,4,5,6,7,8},width=6cm] +\begin{codeexample}[ + width=6cm, + preamble={\usetikzlibrary{animations}}, + animation list={1,2,3,4,5,6,7,8}, +] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvaltranslate{0cm}{0cm} @@ -1446,7 +1576,11 @@ \subsection{Commands for Specifying Timing: Restart Behaviour} \begin{command}{\pgfsys@animation@removeatend{}} The opposite of |\pgfsysanimkeyfreezeatend|. This is the default. % -\begin{codeexample}[animation list={1,2,3,4,5,6,7,8},width=6cm] +\begin{codeexample}[ + width=6cm, + preamble={\usetikzlibrary{animations}}, + animation list={1,2,3,4,5,6,7,8}, +] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvaltranslate{0cm}{0cm} @@ -1473,7 +1607,11 @@ \subsection{Commands for Specifying Accumulation} Specifies that each repeat of an animation works as if the last values attained during previous repeats are added to the current value. % -\begin{codeexample}[animation list={1,2,3,4,5,6,7,8},width=6cm] +\begin{codeexample}[ + width=6cm, + preamble={\usetikzlibrary{animations}}, + animation list={1,2,3,4,5,6,7,8}, +] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvaltranslate{0cm}{0cm} @@ -1492,7 +1630,11 @@ \subsection{Commands for Specifying Accumulation} Specifies that each repeat resets the to-be-animated value. This is the default. % -\begin{codeexample}[animation list={1,2,3,4,5,6,7,8},width=6cm] +\begin{codeexample}[ + width=6cm, + preamble={\usetikzlibrary{animations}}, + animation list={1,2,3,4,5,6,7,8}, +] \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvaltranslate{0cm}{0cm} diff --git a/doc/generic/pgf/text-en/pgfmanual-en-tikz-animations.tex b/doc/generic/pgf/text-en/pgfmanual-en-tikz-animations.tex index bbd0369af..8b0d4462f 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-tikz-animations.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-tikz-animations.tex @@ -14,10 +14,6 @@ \section{Animations} \begin{tikzlibrary}{animations} This library must be loaded in order to use animations with \tikzname. \end{tikzlibrary} -% -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{animations} -\end{codeexample} \subsection{Introduction} @@ -28,7 +24,12 @@ \subsection{Introduction} \tikzname\ allows you to specify such animations using special keys and notations. % -\begin{codeexample}[width=8cm,animation list={0.7,1.4,2.1,2.8},animation scale=.25] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + width=8cm, + animation list={0.7,1.4,2.1,2.8}, + animation scale=.25, +] \begin{tikzpicture}[ animate/orbit/.style 2 args = { myself:shift = { @@ -70,7 +71,7 @@ \subsection{Introduction} As a simple example, let us move a circle within thirty seconds by three centimeters to the left: % -\begin{codeexample}[width=2cm] +\begin{codeexample}[width=2cm,preamble={\usetikzlibrary{animations}}] \tikz \draw :xshift = {0s = "0cm", 30s = "-3cm", repeats} (0,0) circle (5mm); \end{codeexample} @@ -154,7 +155,7 @@ \subsubsection{Concepts: (Graphic) Objects} \item Graphic scopes, which are created by numerous command, including the |{scope}| environment, the |\scopes| command, but also |\tikz| itself creates a graphic scope and so does each node and even each path. - \item View boxes, which can only be created using the |view| library. + \item View boxes, which can only be created using the |views| library. \item Paths, which you create using the |\path| command or commands like |\draw| that call |\path| internally. However, the (usually background) path of a node can also be animated. Note that ``animating the path'' @@ -262,12 +263,18 @@ \subsubsection{The Animate Key} you will use it with a |{scope}| environment, inside the options of a node, or directly with the |\tikz| command: % -\begin{codeexample}[animation list = {0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list = {0.5,1,1.5,2}, +] \tikz \node [fill, text = white, animate = { myself:fill = {0s = "red", 2s = "blue", begin on = click }}] {Click me}; \end{codeexample} % -\begin{codeexample}[animation list = {0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list = {0.5,1,1.5,2}, +] \tikz [animate = {a node:fill = {0s = "red", 2s = "blue", begin on = click}}] \node (a node) [fill, text = white] {Click me}; @@ -281,7 +288,7 @@ \subsubsection{The Animate Key} styles for this key path and use them. For instance, we can define a |shake| animation like this: % -\begin{codeexample}[width=4cm] +\begin{codeexample}[width=4cm,preamble={\usetikzlibrary{animations}}] \tikzset{ animate/shake/.style = {myself:xshift = { begin on=click, 0s = "0mm", 50ms = "#1", 150ms = "-#1", 250ms = "#1", 300ms = "0mm" }}} @@ -337,7 +344,10 @@ \subsubsection{Timeline Entries} like |begin on|, are also added to the timeline of the object--attribute pair. % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz [animate = { object = node, attribute = fill, time = 0s, value = red, entry, object = node, attribute = fill, time = 2s, value = blue, entry, @@ -349,7 +359,10 @@ \subsubsection{Timeline Entries} object and the attribute in each line, they retain their values unless they are overwritten. Thus, we could also have written: % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz [animate = { object = node, attribute = fill, time = 0s, value = red, entry, time = 2s, value = blue, entry, @@ -368,7 +381,10 @@ \subsubsection{Timeline Entries} attributes (that is, between timelines), but the times for any given timeline must be given in non-decreasing order: % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz [animate = { object = node, attribute = fill, time = 0s, value = red, entry, object = node2, attribute = draw, entry, @@ -408,7 +424,10 @@ \subsubsection{Specifying Objects} |name path| key is not the same as |name|; it is an older key from the intersections package and not related.) % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz [animate = { object = b, :fill = {0s = "red", 2s = "blue", begin on = click }}] { \node (a) [fill, text = white, minimum width=1.5cm] at (0,1cm) {a}; @@ -416,7 +435,10 @@ \subsubsection{Specifying Objects} \node (c) [fill, text = white, minimum width=1.5cm] at (0,0mm) {c}; } \end{codeexample} % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz [animate = { object = b, :fill = {0s = "red", 2s = "blue", begin on = click }, object = c, :fill = {0s = "green", 2s = "blue", @@ -456,7 +478,10 @@ \subsubsection{Specifying Attributes} exact list of possible attributes is documented in Section~\ref{section-anim-attrs}. % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz [animate = {attribute = fill, n: = { 0s = "red", 2s = "blue", begin on = click } }] \node (n) [fill, text = white] {The node}; @@ -483,7 +508,10 @@ \subsubsection{Specifying IDs} object, the attribute, and the value of this key. We can now specify two separate timelines: % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz [animate = { id = 1, n:shift = { 0s = "{(0,0)}", 2s = "{(0,5mm)}", begin on = click }, id = 2, n:shift = { 0s = "{(0,0)}", 2s = "{(5mm,0)}", begin on = click } @@ -561,7 +589,10 @@ \subsubsection{Specifying Times} is interpreted as an offset to the time in the previous use of the time key: % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz \node :fill = { begin on = click, 0s = "white", 500ms later = "red", @@ -604,7 +635,10 @@ \subsubsection{Specifying Times} certain part to a longer animation. Consider for instance the definition of a |hilight| key: % -\begin{codeexample}[animation list={1.05,1.1,1.15,1.2,2.05,2.1,2.15,2.2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={1.05,1.1,1.15,1.2,2.05,2.1,2.15,2.2}, +] \tikz [animate/highlight/.style = { scope = { fork = #1, :fill = { 0s = "black", 0.1s = "white", 0.2s = "black"} } @@ -750,7 +784,10 @@ \subsubsection{Scopes} Executed the \meta{options} inside a \TeX\ scope. In particular, all settings made inside the scope have no effect after the end of the |scope|. % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz \node [animate = { myself: = { begin on = click, scope = { attribute = fill, repeats = 3, 0s = "red", 2s = "red!50" }, scope = { attribute = draw, 0s = "red", 2s = "red!50" } @@ -956,7 +993,10 @@ \subsubsection{The Colon Syntax II: Animating Myself} Let us have a look at some examples. First, we use the syntax to set the fill opacity of a node: % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz \node :fill opacity = { 0s="1", 2s="0", begin on=click } [fill = blue!20, draw = blue, ultra thick, circle] {Here!}; @@ -964,7 +1004,10 @@ \subsubsection{The Colon Syntax II: Animating Myself} % Next, we additionally rotate the node: % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz \node :fill opacity = { 0s="1", 2s="0", begin on=click } :rotate = { 0s="0", 2s="90", begin on=click } @@ -975,7 +1018,10 @@ \subsubsection{The Colon Syntax II: Animating Myself} this case. We could have exchanged the order of the options and the uses of the colon syntax: % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz \node :fill opacity = { 0s="1", 2s="0", begin on=click } [fill = blue!20, draw = blue, ultra thick, circle] @@ -984,7 +1030,10 @@ \subsubsection{The Colon Syntax II: Animating Myself} We can also use the special syntax with the |\tikz| command itself: % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz :fill opacity = { 0s="1", 2s="0", begin on=click } :rotate = { 0s="0", 2s="90", begin on=click } [ultra thick] @@ -1258,7 +1307,10 @@ \subsubsection{Animating Color, Opacity, and Visibility} color overrules the color of the scope. \begin{tikzanimateattribute}{fill, draw} -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz :fill = {0s = "red", 2s = "blue", begin on = click} [text = white, fill = orange ] { \node [fill] at (0mm,0) {A}; @@ -1272,7 +1324,10 @@ \subsubsection{Animating Color, Opacity, and Visibility} The |text| attribute only applies to nodes and you need to directly animate the |text| attribute of each node individually. % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz [my anim/.style={ animate = { myself:text = {0s = "red", 2s = "blue", begin on = click}}}, text = white, fill = orange ] { @@ -1284,7 +1339,10 @@ \subsubsection{Animating Color, Opacity, and Visibility} Unlike the |fill| and |draw| colors, you cannot animate the |text| color for scopes: % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz [animate = {myself:text = {0s = "red", 2s = "blue", begin on = click}}, text = white, fill = orange ] { @@ -1307,7 +1365,10 @@ \subsubsection{Animating Color, Opacity, and Visibility} for drawing using the attributes |fill opacity| and |draw opacity|, which are exactly the same as the usual \tikzname\ keys of the same names. % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz \node :fill opacity = { 0s="1", 2s="0", begin on=click } [fill = blue!20, draw = blue, ultra thick, circle] {Click me!}; \end{codeexample} @@ -1318,7 +1379,10 @@ \subsubsection{Animating Color, Opacity, and Visibility} which it is applied as a transparency group. In essence, ``this attribute does what you want'' at least in most situations. % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz \node :opacity = { 0s="1", 2s="0", begin on=click } [fill = blue!20, draw = blue, ultra thick, circle] {Click me!}; \end{codeexample} @@ -1331,7 +1395,10 @@ \subsubsection{Animating Color, Opacity, and Visibility} rendered. The (only) two possible values for this attribute are |false| and |true|. % -\begin{codeexample}[animation list={1,2,3,4}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={1,2,3,4}, +] \tikz :visible = {begin on=click, 0s="false", 2s="false"} \node (node) [fill = blue!20, draw = blue, very thick, circle] {Click me!}; \end{codeexample} @@ -1344,7 +1411,11 @@ \subsubsection{Animating Color, Opacity, and Visibility} object ``enters'' the stage and ``leaves'' once more when it is no longer ``on stage''. % -\begin{codeexample}[animation list={-1,0,1,2,3},animation bb={(1.3,-0.7) rectangle (2.7,0.7)}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={-1,0,1,2,3}, + animation bb={(1.3,-0.7) rectangle (2.7,0.7)}, +] \tikz [animate = {example:stage = { begin on = {click, of next=node}, 0s="true", 2s="true" }}] { @@ -1365,7 +1436,10 @@ \subsubsection{Animating Paths and their Rendering} that they animate and the syntax for setting is also the same: \begin{tikzanimateattribute}{line width} -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz \node :line width = { 0s="1pt", 2s="5mm", begin on=click} [fill = blue!20, draw = blue, ultra thick, circle] {Click me!}; \end{codeexample} @@ -1382,13 +1456,19 @@ \subsubsection{Animating Paths and their Rendering} identical. The interpolation of the values is done for each position of the sequences individually, and also on the phase. % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz \node :dash = { 0s="on 10pt off 1pt phase 0pt", 2s="on 1pt off 10pt phase 0pt", begin on=click} [fill = blue!20, draw = blue, ultra thick, circle] {Click me!}; \end{codeexample} % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz \node :dash = { 0s="on 1cm off 1pt phase 0pt", 2s="on 1cm off 1pt phase 1cm", begin on=click} [fill = blue!20, draw = blue, ultra thick, circle] {Click me!}; @@ -1399,7 +1479,10 @@ \subsubsection{Animating Paths and their Rendering} also set, namely to the current dash pattern that is in force when the animation is created. % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz \node :dash phase = { 0s="0pt", 2s="1cm", begin on=click} [fill = blue!20, draw = blue, ultra thick, circle, dashed] {Click me!}; \end{codeexample} @@ -1412,7 +1495,10 @@ \subsubsection{Animating Paths and their Rendering} \begin{tikzanimateattribute}{path} When you animate a path, the values are, of course, paths themselves: % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz \node :path = { 0s = "{(0,-1) .. controls (0,0) and (0,0) .. (0,1) -- (1,1)}", 2s = "{(0,-1) .. controls (-1,0) and (-1,0) .. (-1,1) -- (.5,-1)}", @@ -1436,7 +1522,10 @@ \subsubsection{Animating Paths and their Rendering} example shows, where we used the fact that a circle consists of four Bézier curves): % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz \node :path = { 0s = "{(0,0) circle [radius=1cm]}", 2s = "{(0,0) @@ -1509,7 +1598,11 @@ \subsubsection{Animating Paths and their Rendering} Here is an example: % -\begin{codeexample}[animation list={0.5,1,1.5,2},animation bb={(-0.1,-0.1) rectangle (1.1,1.1)}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, + animation bb={(-0.1,-0.1) rectangle (1.1,1.1)}, +] \tikz [very thick] { \node (node) at (-2,0) [fill = blue!20, draw = blue, very thick, circle] {Click me!}; @@ -1544,7 +1637,10 @@ \subsubsection{Animating Transformations: Relative Transformations} in \tikzname: \begin{tikzanimateattribute}{scale, xscale, yscale} -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz \node :scale = { 0s="1", 2s="0.2", begin on=click} [fill = blue!20, draw = blue, ultra thick, circle] {Click me!}; \end{codeexample} @@ -1553,7 +1649,10 @@ \subsubsection{Animating Transformations: Relative Transformations} \begin{tikzanimateattribute}{rotate} The |rotate| key adds an animation of the rotation: % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz \node :rotate = { 0s="45", 2s="90", begin on=click} [fill = blue!20, draw = blue, ultra thick, circle] {Click me!}; \end{codeexample} @@ -1566,12 +1665,18 @@ \subsubsection{Animating Transformations: Relative Transformations} The keys add an animation of the skew (given in degrees) or slant (given as in the |xslant| and |yslant| key): % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz \node :xskew = { 0s="0", 2s="45", begin on=click} [fill = blue!20, draw = blue, ultra thick, circle] {Click me!}; \end{codeexample} % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz \node :xslant = { 0s="-1", 2s="1", begin on=click} [fill = blue!20, draw = blue, ultra thick, circle] {Click me!}; \end{codeexample} @@ -1579,13 +1684,19 @@ \subsubsection{Animating Transformations: Relative Transformations} \end{tikzanimateattribute} \begin{tikzanimateattribute}{xshift, yshift} -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz \node :shift = { 0s="{(0,0)}", 2s="{(5mm,-5mm)}", begin on=click} [fill = blue!20, draw = blue, ultra thick, circle] {Click me!}; \end{codeexample} -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz \node :xshift = { 0s="0pt", 2s="5mm", begin on=click} [fill = blue!20, draw = blue, ultra thick, circle] {Click me!}; \end{codeexample} @@ -1597,7 +1708,10 @@ \subsubsection{Animating Transformations: Relative Transformations} specify a sequence of coordinates in the same way as you would use the |shift| key in \tikzname: % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz \node :shift = { 0s = "{(0,0)}", 2s = "{(5mm,-5mm)}", begin on = click } [fill = blue!20, draw = blue, ultra thick, circle] {Click me!}; @@ -1617,7 +1731,10 @@ \subsubsection{Animating Transformations: Relative Transformations} fractions of the distance along the path. A value of |"0"| refers to the beginning of the path and |"1"| refers to the end: % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz { \draw [help lines] (-0.2,-0.2) grid (2.2,1.2); \draw (1,.5) circle [radius=1mm]; @@ -1635,7 +1752,10 @@ \subsubsection{Animating Transformations: Relative Transformations} use |sloped|, the object will be continuously rotated so that it always points along the path. % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz { \draw [help lines] (-0.2,-0.2) grid (2.2,1.2); \draw (1,.5) circle [radius=1mm]; @@ -1659,7 +1779,10 @@ \subsubsection{Animating Transformations: Relative Transformations} which defaults to the local coordinate system of the to-be-animated object. Consider the following example: % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz { \draw [help lines] (-0.2,-0.2) grid (2.2,2.2); \node :rotate = { 0s="0", 2s="45", begin on=click} @@ -1678,7 +1801,10 @@ \subsubsection{Animating Transformations: Relative Transformations} Let us, by comparison, do a rotation of a scope surrounding the node where the origin is not (yet) shifted: % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz { \draw [help lines] (-0.2,-0.2) grid (2.2,2.2); \scoped :rotate = { 0s="0", 2s="45", begin on={click, of next=n} } @@ -1699,7 +1825,10 @@ \subsubsection{Animating Transformations: Relative Transformations} |(1,1)| relative to the picture's origin and the |origin| key shifts it one centimeter to the right. % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz { \draw [help lines] (-0.2,-0.2) grid (2.2,2.2); \node :rotate = { 0s="0", 2s="45", begin on=click, @@ -1728,7 +1857,10 @@ \subsubsection{Animating Transformations: Relative Transformations} transformation matrix), which can by numerically instable when you use ill-conditioned transformations. % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz { \draw [help lines] (-0.2,-0.2) grid (2.2,2.2); \node :xshift = { 0s="0cm", 2s="5mm", begin on=click, @@ -1737,7 +1869,10 @@ \subsubsection{Animating Transformations: Relative Transformations} } \end{codeexample} % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz { \draw [help lines] (-0.2,-0.2) grid (2.2,2.2); \node :xshift = { 0s="0cm", 2s="5mm", begin on=click, @@ -1786,7 +1921,10 @@ \subsubsection{Animating Transformations: Positioning} \begin{tikzanimateattribute}{position} Compare the two animations, one with |:position|, one with |:shift|. % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz { \draw [help lines] (-0.2,-0.2) grid (2.2,1.2); \draw (1,.5) circle [radius=1mm] (1.5,0) circle [radius=1mm]; @@ -1797,7 +1935,10 @@ \subsubsection{Animating Transformations: Positioning} % Compare this to a shift: % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz { \draw [help lines] (-0.2,-0.2) grid (2.2,1.2); \draw (1,.5) circle [radius=1mm] (1.5,0) circle [radius=1mm]; @@ -1810,7 +1951,10 @@ \subsubsection{Animating Transformations: Positioning} |:shift|, which is especially useful for specifying that a node ``travels'' between positions of the canvas: % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz { \draw [help lines] (-0.2,-0.2) grid (2.2,1.2); \draw (1,1) circle [radius=1mm] (1.5,0) circle [radius=1mm]; @@ -1847,7 +1991,7 @@ \subsubsection{Animating Transformations: Views} to-be-viewed rectangle). % \begin{codeexample}[ - preamble={\usetikzlibrary{views}}, + preamble={\usetikzlibrary{animations,views}}, animation list={0.5,1,1.5,2}, animation bb={(1.1,-0.9) rectangle (2.9,0.9)}, ] @@ -1887,7 +2031,10 @@ \subsubsection{Before and After the Timeline: Value Filling} A ``base'' value is a value that is used for the attribute whenever the timeline is \emph{not} active: % -\begin{codeexample}[animation list = {0.5,1,1.5,2,2.5}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list = {0.5,1,1.5,2,2.5}, +] \tikz \node [fill = green, text = white] :fill = { 1s = "red", 2s = "blue", base = "orange", begin on = click } {Click me}; @@ -1903,7 +2050,10 @@ \subsubsection{Before and After the Timeline: Value Filling} set the base. However, you can also use the |base| key in other ways; most noticeably, you can use it \emph{after} some value: % -\begin{codeexample}[animation list = {0.5,1,1.5,2,2.5}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list = {0.5,1,1.5,2,2.5}, +] \tikz \node [fill = green, text = white] :fill = { 1s = {"red" = base}, 2s = "blue", begin on = click } {Click me}; @@ -1913,7 +2063,10 @@ \subsubsection{Before and After the Timeline: Value Filling} the quotes of a value. This is particularly useful for setting up a base value that is also used in a timeline: % -\begin{codeexample}[animation list = {0.5,1,1.5,2,2.5}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list = {0.5,1,1.5,2,2.5}, +] \tikz \node [fill = green, text = white] :fill = { 1s = "red" base, 2s = "blue", begin on = click } {Click me}; @@ -1926,12 +2079,18 @@ \subsubsection{Before and After the Timeline: Value Filling} with the last value. You can also think of this as having the animation ``freeze'' at the end. % -\begin{codeexample}[animation list = {0.5,1,1.5,2,2.5}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list = {0.5,1,1.5,2,2.5}, +] \tikz \node :fill = { 1s="red", 2s="blue", forever, begin on=click} [fill = green!50!black, text = white] {Click me}; \end{codeexample} % -\begin{codeexample}[animation list = {0.5,1,1.5,2,2.5}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list = {0.5,1,1.5,2,2.5}, +] \tikz \node [fill = green!50!black, text = white] :fill = { 1s = "red", 2s = "blue", begin on = click } {Click me}; @@ -1976,7 +2135,7 @@ \subsubsection{Beginning and Ending Timelines} will run, relative to the moment when the graphic is displayed from 3\,s to 4\,s. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{animations}}] \tikz \node [fill = green!50!black, text = white] :rotate = { 1s = "0", 5s = "90", begin = 2s, end = 4s } {Click me}; @@ -2013,7 +2172,7 @@ \subsubsection{Beginning and Ending Timelines} referenced object is the node with the label |2| since it is the most recently referenced node with \meta{id} |X|. % -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{animations}}] \tikz [very thick] { \node (X) at (1,1.2) [fill = blue!20, draw = blue, circle] {1}; \node (X) at (1,0.4) [fill = orange!20, draw = orange, circle] {2}; @@ -2029,7 +2188,7 @@ \subsubsection{Beginning and Ending Timelines} the next) object with the given \meta{id}, not to a previous one. This, in the next example, the referenced node is the one with label |3|. % -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{animations}}] \tikz [very thick] { \node (X) at (1,1.2) [fill = blue!20, draw = blue, circle] {1}; \node (X) at (1,0.4) [fill = blue!20, draw = blue, circle] {2}; @@ -2058,7 +2217,7 @@ \subsubsection{Beginning and Ending Timelines} when the user clicks on the triggering object with a mouse (or something equivalent). % -\begin{codeexample}[width=2cm] +\begin{codeexample}[width=2cm,preamble={\usetikzlibrary{animations}}] \tikz \node :rotate = { 0s="0", 2s="90", begin on = {click}} [fill = blue!20, draw = blue, circle, ultra thick] {Here!}; \end{codeexample} @@ -2068,7 +2227,7 @@ \subsubsection{Beginning and Ending Timelines} Shorthand for |event=mousedown|. The event gets triggered when the user presses a mouse button down on the object. % -\begin{codeexample}[width=2cm] +\begin{codeexample}[width=2cm,preamble={\usetikzlibrary{animations}}] \tikz \node :rotate = { 0s="0", 2s="90", begin on = {mouse down}} [fill = blue!20, draw = blue, circle, ultra thick] {Here!}; \end{codeexample} @@ -2078,7 +2237,7 @@ \subsubsection{Beginning and Ending Timelines} Shorthand for |event=mouseup| and gets triggered, of course, when a pressed button is released on the object. % -\begin{codeexample}[width=2cm] +\begin{codeexample}[width=2cm,preamble={\usetikzlibrary{animations}}] \tikz \node :rotate = { 0s="0", 2s="90", begin on = {mouse up} } [fill = blue!20, draw = blue, circle, ultra thick] {Here!}; \end{codeexample} @@ -2088,7 +2247,7 @@ \subsubsection{Beginning and Ending Timelines} Shorthand for |event=mouseover|. The event gets triggered the moment the mouse cursor moves over the object. % -\begin{codeexample}[width=2cm] +\begin{codeexample}[width=2cm,preamble={\usetikzlibrary{animations}}] \tikz \node :rotate = { 0s="0", 2s="90", begin on = {mouse over} } [fill = blue!20, draw = blue, circle, ultra thick] {Here!}; \end{codeexample} @@ -2099,7 +2258,7 @@ \subsubsection{Beginning and Ending Timelines} times, namely each time the mouse moves while being ``over'' the object. % -\begin{codeexample}[width=2cm] +\begin{codeexample}[width=2cm,preamble={\usetikzlibrary{animations}}] \tikz \node :rotate = { 0s="0", 2s="90", begin on = {mouse move} } [fill = blue!20, draw = blue, circle, ultra thick] {Here!}; \end{codeexample} @@ -2109,7 +2268,7 @@ \subsubsection{Beginning and Ending Timelines} Shorthand for |event=mouseout|. The opposite of |mouse over|: triggered when the mouse leaves the object. % -\begin{codeexample}[width=2cm] +\begin{codeexample}[width=2cm,preamble={\usetikzlibrary{animations}}] \tikz \node :rotate = { 0s="0", 2s="90", begin on = {mouse out} } [fill = blue!20, draw = blue, circle, ultra thick] {Here!}; \end{codeexample} @@ -2121,7 +2280,7 @@ \subsubsection{Beginning and Ending Timelines} |of whom|. This means that the current animation will begin when some other animation begins. % -\begin{codeexample}[width=2cm] +\begin{codeexample}[width=2cm,preamble={\usetikzlibrary{animations}}] \tikz \node [animate = { myself:rotate = { 0s="0", 2s="90", begin on = {begin, of next=anim}}, myself:xshift = { 0s="0mm", 2s="5mm", begin on = {click}, name=anim} @@ -2136,7 +2295,7 @@ \subsubsection{Beginning and Ending Timelines} This means that the current animation will \emph{begin} when some other animation \emph{ends}. % -\begin{codeexample}[width=2cm] +\begin{codeexample}[width=2cm,preamble={\usetikzlibrary{animations}}] \tikz \node [animate = { myself:rotate = { 0s="0", 2s="90", begin on = {end, of next=anim}}, myself:xshift = { 0s="0mm", 2s="5mm", begin on = {click}, name=anim } @@ -2164,11 +2323,14 @@ \subsubsection{Beginning and Ending Timelines} \meta{number} times. % \begin{codeexample}[ - animation list={ - 0.333/\frac{1}{3},0.666/\frac{2}{3},1, - 1.333/1\frac{1}{3},1.666/1\frac{2}{3},2, - 2.333/2\frac{1}{3},2.666/2\frac{2}{3},3, - 3.333/2\frac{1}{3},3.666/2\frac{2}{3},4}] + preamble={\usetikzlibrary{animations}}, + animation list={ + 0.333/\frac{1}{3},0.666/\frac{2}{3},1, + 1.333/1\frac{1}{3},1.666/1\frac{2}{3},2, + 2.333/2\frac{1}{3},2.666/2\frac{2}{3},3, + 3.333/2\frac{1}{3},3.666/2\frac{2}{3},4% + }, +] \tikz \node [animate = { myself: = { :rotate = { 0s="0", 2s="90", begin on = {repeat = 2, of next = anim }, @@ -2208,7 +2370,7 @@ \subsubsection{Beginning and Ending Timelines} \item |false| means that once the animation has started once, it will never be restarted. % -\begin{codeexample}[width=2cm] +\begin{codeexample}[width=2cm,preamble={\usetikzlibrary{animations}}] \tikz \node :rotate = { 0s="0", 2s="90", restart = false, begin on = {click}} [fill = blue!20, draw = blue, circle, ultra thick] {Here!}; @@ -2218,7 +2380,7 @@ \subsubsection{Beginning and Ending Timelines} \item |when not active| means that the animation will restart when the event is triggered, but \emph{not} while the animation is running. % -\begin{codeexample}[width=2cm] +\begin{codeexample}[width=2cm,preamble={\usetikzlibrary{animations}}] \tikz \node :rotate = { 0s="0", 2s="90", restart = when not active, begin on = {click}} [fill = blue!20, draw = blue, circle, ultra thick] {Here!}; @@ -2245,7 +2407,10 @@ \subsubsection{Repeating Timelines and Accumulation} \begin{itemize} \item Empty, in which case the timeline repeats forever. % -\begin{codeexample}[animation list={1,2,3,4,5}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={1,2,3,4,5}, +] \tikz \node :rotate = { 0s = "0", 2s = "90", repeats, begin on = click } [fill = blue!20, draw = blue, ultra thick, circle] {Click me!}; @@ -2254,7 +2419,10 @@ \subsubsection{Repeating Timelines and Accumulation} \item A \meta{number} (like |2| or |3.25|), in which case the timeline repeats \meta{number} times. % -\begin{codeexample}[animation list={1,2,3,4,5}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={1,2,3,4,5}, +] \tikz \node :rotate = { 0s = "0", 2s = "90", repeats = 1.75, begin on = click } [fill = blue!20, draw = blue, ultra thick, circle] {Click me!}; @@ -2264,7 +2432,10 @@ \subsubsection{Repeating Timelines and Accumulation} which case the timeline repeats however often necessary so that it stops exactly after \meta{time}. % -\begin{codeexample}[animation list={1,2,3,4,5}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={1,2,3,4,5}, +] \tikz \node :rotate = { 0s = "0", 2s = "90", repeats = for 3.5s, begin on = click } [fill = blue!20, draw = blue, ultra thick, circle] {Click me!}; @@ -2286,13 +2457,19 @@ \subsubsection{Repeating Timelines and Accumulation} jump back, and so on for five times. In contrast, when the repeats are accumulating, the scope will move by 5\,cm over 5\,s in total. % -\begin{codeexample}[animation list={1,2,3,4,5}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={1,2,3,4,5}, +] \tikz \node :rotate = { 0s = "0", 2s = "90", begin on = click, repeats = accumulating } [fill = blue!20, draw = blue, ultra thick, circle] {Click me!}; \end{codeexample} % -\begin{codeexample}[animation list={1,2,3,4,5}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={1,2,3,4,5}, +] \tikz \node :rotate = { 0s = "0", 2s = "90", begin on = click, repeats = for 4s accumulating } [fill = blue!20, draw = blue, ultra thick, circle] {Click me!}; @@ -2362,7 +2539,10 @@ \subsubsection{Smoothing and Jumping Timelines} start position, then a smooth arrival at the end position, and, finally both. % -\begin{codeexample}[animation list={0.333/\frac{1}{3},0.666/\frac{2}{3},1,1.333/1\frac{1}{3},1.666/1\frac{2}{3}}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.333/\frac{1}{3},0.666/\frac{2}{3},1,1.333/1\frac{1}{3},1.666/1\frac{2}{3}}, +] \tikz { \foreach \i in {0,0.1,...,1} \draw (-0.9,.9-\i) -- ++(1.8,0); \node :yshift = { begin on = click, @@ -2373,7 +2553,10 @@ \subsubsection{Smoothing and Jumping Timelines} } \end{codeexample} -\begin{codeexample}[animation list={0.333/\frac{1}{3},0.666/\frac{2}{3},1,1.333/1\frac{1}{3},1.666/1\frac{2}{3}}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.333/\frac{1}{3},0.666/\frac{2}{3},1,1.333/1\frac{1}{3},1.666/1\frac{2}{3}}, +] \tikz { \foreach \i in {0,0.1,...,1} \draw (-0.9,.9-\i) -- ++(1.8,0); \node :yshift = { begin on = click, @@ -2384,7 +2567,10 @@ \subsubsection{Smoothing and Jumping Timelines} } \end{codeexample} -\begin{codeexample}[animation list={0.333/\frac{1}{3},0.666/\frac{2}{3},1,1.333/1\frac{1}{3},1.666/1\frac{2}{3}}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.333/\frac{1}{3},0.666/\frac{2}{3},1,1.333/1\frac{1}{3},1.666/1\frac{2}{3}}, +] \tikz { \foreach \i in {0,0.1,...,1} \draw (-0.9,.9-\i) -- ++(1.8,0); \node :yshift = { begin on = click, @@ -2417,7 +2603,10 @@ \subsubsection{Smoothing and Jumping Timelines} key with an animation having only two times is particularly easy, since we only need to set |ease| once: % -\begin{codeexample}[animation list={0.333/\frac{1}{3},0.666/\frac{2}{3},1,1.333/1\frac{1}{3},1.666/1\frac{2}{3}}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.333/\frac{1}{3},0.666/\frac{2}{3},1,1.333/1\frac{1}{3},1.666/1\frac{2}{3}}, +] \tikz { \foreach \i in {0,0.1,...,1} \draw (-0.9,.9-\i) -- ++(1.8,0); \node :yshift = { begin on = click, ease, 0s = "0cm", 2s = "-10mm" } @@ -2436,7 +2625,10 @@ \subsubsection{Smoothing and Jumping Timelines} value. This is similar to an exit control where the curve is ``infinitely flat''. % -\begin{codeexample}[animation list={0.5,1,1.5,2,2.5}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2,2.5}, +] \tikz { \foreach \i in {0,0.1,...,1} \draw (-0.9,.9-\i) -- ++(1.8,0); \node :yshift = { begin on = click, @@ -2454,7 +2646,10 @@ \subsubsection{Smoothing and Jumping Timelines} value right at the beginning of the time interval. It is similar to an entry control specifying a ``flat'' curve. % -\begin{codeexample}[animation list={0.5,1,1.5,2,2.5}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2,2.5}, +] \tikz { \foreach \i in {0,0.1,...,1} \draw (-0.9,.9-\i) -- ++(1.8,0); \node :yshift = { begin on = click, @@ -2489,7 +2684,7 @@ \subsection{Snapshots} each other into the printed document. This approach has been used with the examples of animations in this manual. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{animations}}] \foreach \t in {0.5, 1, 1.5, 2} \tikz [make snapshot of = \t] \fill :fill = {0s="black", 2s="red"} (0,0) circle [radius = 5mm]; @@ -2506,7 +2701,7 @@ \subsection{Snapshots} computation match the computations done by viewer applications as best as possible). % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{animations}}] \tikz [make snapshot of = 1s] { \fill :fill = { 0s = "black", 2s = "white" } (0,0) rectangle ++(1,1); \fill :fill = { 1s = "black", 3s = "white" } (2,0) rectangle ++(1,1); @@ -2530,7 +2725,7 @@ \subsection{Snapshots} Computationally, for the timeline the \meta{start time} is subtracted from the snapshot's \meta{time} when the value needs to be determined: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{animations}}] \tikz [make snapshot of = 1s] { \fill :fill = { 0s = "black", 2s = "white", begin snapshot = 1s } (0,0) rectangle ++(1,1); @@ -2573,7 +2768,7 @@ \subsection{Snapshots} the timeline, while this key would not apply the animation at all (it has already ended at time $t + \epsilon$). % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{animations}}] \tikz [make snapshot of = 2s] \fill :fill = { 0s = "green", 2s = "red" } (0,0) rectangle ++(1,1); \tikz [make snapshot after = 2s] diff --git a/doc/generic/pgf/text-en/pgfmanual-en-tikz-arrows.tex b/doc/generic/pgf/text-en/pgfmanual-en-tikz-arrows.tex index 7fd66231c..9cd8d3809 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-tikz-arrows.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-tikz-arrows.tex @@ -20,11 +20,7 @@ \subsection{Overview} syntax. The following example is a perhaps slightly ``excessive'' demonstration of what you can do (you need to load the |arrows.meta| library for it to work): % -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{arrows.meta} -\end{codeexample} -% -\begin{codeexample}[preamble={\usetikzlibrary{bending,positioning}}] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta,bending,positioning}}] \tikz { \node [circle,draw] (A) {A}; \node [circle,draw] (B) [right=of A] {B}; @@ -97,7 +93,7 @@ \subsection{Where and When Arrow Tips Are Placed} text |arrows=|.} What happens is that every (otherwise unknown) option that contains a |-| is interpreted as an arrow specification. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \begin{tikzpicture} \draw[->] (0,0) -- (1,0); \draw[>-Stealth] (0,0.3) -- (1,0.3); @@ -119,7 +115,7 @@ \subsection{Where and When Arrow Tips Are Placed} Section~\ref{section-arrow-config} below by adding options in square brackets following the arrow tip kind: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \begin{tikzpicture} \draw[-{Stealth[red]}] (0,0) -- (1,0); \end{tikzpicture} @@ -196,8 +192,6 @@ \subsection{Where and When Arrow Tips Are Placed} suppresses arrow tips on degenerate paths. \end{enumerate} -% --- -% TODOsp: codeexamples: These examples don't need the `arrows.meta` library \begin{codeexample}[] % No path, no arrow tips: \tikz [<->] \draw; @@ -230,7 +224,6 @@ \subsection{Where and When Arrow Tips Are Placed} % Two subpaths, but one is closed: No tips, even though last subpath is open \tikz [<->] \draw (0,0) circle[radius=2pt] (2,0) -- (3,0); \end{codeexample} -% --- % \end{key} @@ -303,19 +296,19 @@ \subsubsection{Size} distance from the ``very tip'' of the arrow to its ``back end'' along the line: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz{ \draw [-{Stealth[length=5mm]}] (0,0) -- (2,0); \draw [|<->|] (1.5,.4) -- node[above=1mm] {5mm} (2,.4); } \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz{ \draw [-{Latex[length=5mm]}] (0,0) -- (2,0); \draw [|<->|] (1.5,.4) -- node[above=1mm] {5mm} (2,.4); } \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz{ \draw [-{Classical TikZ Rightarrow[length=5mm]}] (0,0) -- (2,0); \draw [|<->|] (1.5,.6) -- node[above=1mm] {5mm} (2,.6); @@ -362,15 +355,15 @@ \subsubsection{Size} resulting length is 3pt. Finally, for the middle case, the ``middle'' between 5pt and 1pt is 3pt, so the length is 9pt. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz \draw [line width=1pt, double distance=3pt, arrows = {-Latex[length=0pt 3 0]}] (0,0) -- (1,0); \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz \draw [line width=1pt, double distance=3pt, arrows = {-Latex[length=0pt 3 .5]}] (0,0) -- (1,0); \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz \draw [line width=1pt, double distance=3pt, arrows = {-Latex[length=0pt 3 1]} ] (0,0) -- (1,0); \end{codeexample} @@ -392,7 +385,7 @@ \subsubsection{Size} ``pixel''. Thus, the thickness of the stroked line and also the miter ends should be taken into account: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz{ \draw [line width=1mm, -{Stealth[length=10mm, open]}] (0,0) -- (2,0); @@ -407,7 +400,7 @@ \subsubsection{Size} This creates some ``visual consistency'' if the two modes are mixed or if you later one change the mode. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz{ \draw [line width=1mm, -{Stealth[length=10mm, open, round]}] (0,0) -- (2,0); @@ -431,10 +424,10 @@ \subsubsection{Size} the two optional factor numbers following the \meta{dimension} is the same as for the |length| key. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz \draw [arrows = {-Latex[width=10pt, length=10pt]}] (0,0) -- (1,0); \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz \draw [arrows = {-Latex[width=0pt 10, length=10pt]}] (0,0) -- (1,0); \end{codeexample} \end{key} @@ -464,10 +457,10 @@ \subsubsection{Size} the resulting width will be $19\mathrm{pt} = 5\mathrm{pt} + 2\cdot 7\mathrm{pt}$. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz \draw [arrows = {-Latex[width'=0pt .5, length=10pt]}] (0,0) -- (1,0); \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz \draw [arrows = {-Latex[width'=0pt .5, length=15pt]}] (0,0) -- (1,0); \end{codeexample} % @@ -488,10 +481,10 @@ \subsubsection{Size} line width, where the line width is computed based on the \meta{outer factor} as described for the |length| key. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz \draw [arrows = {-Stealth[length=10pt, inset=5pt]}] (0,0) -- (1,0); \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz \draw [arrows = {-Stealth[length=10pt, inset=2pt]}] (0,0) -- (1,0); \end{codeexample} @@ -517,10 +510,10 @@ \subsubsection{Size} optional factors are given, they add a certain multiple of the line width to the \meta{dimension} before the sine and cosines are computed. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz \draw [arrows = {-Stealth[inset=0pt, angle=90:10pt]}] (0,0) -- (1,0); \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz \draw [arrows = {-Stealth[inset=0pt, angle=30:10pt]}] (0,0) -- (1,0); \end{codeexample} % @@ -531,11 +524,11 @@ \subsubsection{Size} the arrow length. This results in an arrow tip with an opening angle of \meta{angle} at its tip and with the specified |length| unchanged. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz \draw [arrows = {-Stealth[inset=0pt, length=10pt, angle'=90]}] (0,0) -- (1,0); \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz \draw [arrows = {-Stealth[inset=0pt, length=10pt, angle'=30]}] (0,0) -- (1,0); \end{codeexample} @@ -558,7 +551,7 @@ \subsubsection{Scaling} size parameters defined by special-purpose arrow tip kinds). Everything is simply scaled by the given \meta{factor}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz { \draw [arrows = {-Stealth[]}] (0,1) -- (1,1); \draw [arrows = {-Stealth[scale=1.5]}] (0,0.5) -- (1,0.5); @@ -579,7 +572,7 @@ \subsubsection{Scaling} ``along the axis of the arrow'', that is, to the length and to the inset, but not to the width. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz { \draw [arrows = {-Stealth[]}] (0,1) -- (1,1); \draw [arrows = {-Stealth[scale length=1.5]}] (0,0.5) -- (1,0.5); @@ -592,7 +585,7 @@ \subsubsection{Scaling} \begin{key}{/pgf/arrows keys/scale width=\meta{factor} (initially 1)} Like |scale length|, but for dimensions related to the width. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz { \draw [arrows = {-Stealth[]}] (0,1) -- (1,1); \draw [arrows = {-Stealth[scale width=1.5]}] (0,0.5) -- (1,0.5); @@ -614,7 +607,7 @@ \subsubsection{Arc Angles} setting the length and width''. In contrast, the |arc| key is used to set the degrees of arcs that are part of an arrow tip: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz [ultra thick] { \draw [arrows = {-Hooks[]}] (0,1) -- (1,1); \draw [arrows = {-Hooks[arc=90]}] (0,0.5) -- (1,0.5); @@ -633,7 +626,7 @@ \subsubsection{Slanting} Slanting is used to create an ``italics'' effect for arrow tips: All arrow tips get ``slanted'' a little bit relative to the axis of the arrow: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz { \draw [arrows = {->[]}] (0,1) -- (1,1); \draw [arrows = {->[slant=.5]}] (0,0.5) -- (1,0.5); @@ -649,7 +642,7 @@ \subsubsection{Slanting} Here is another example where slanting is used to match italic text: % -\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta,graphs}}] \tikz [>={[slant=.3] To[] To[]}] \graph [math nodes] { A -> B <-> C }; \end{codeexample} @@ -673,10 +666,10 @@ \subsubsection{Reversing, Halving, Swapping} If you apply this key twice, the effect cancels, which is useful for the definition of shorthands (which will be discussed later). % -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz [ultra thick] \draw [arrows = {-Stealth[reversed]}] (0,0) -- (1,0); \end{codeexample} -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz [ultra thick] \draw [arrows = {-Stealth[reversed, reversed]}] (0,0) -- (1,0); \end{codeexample} \end{key} @@ -684,10 +677,10 @@ \subsubsection{Reversing, Halving, Swapping} \begin{key}{/pgf/arrow keys/harpoon} The key requests that only the ``left half'' of the arrow tip should drawn: % -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz [ultra thick] \draw [arrows = {-Stealth[harpoon]}] (0,0) -- (1,0); \end{codeexample} -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz [ultra thick] \draw [arrows = {->[harpoon]}] (0,0) -- (1,0); \end{codeexample} % @@ -703,10 +696,10 @@ \subsubsection{Reversing, Halving, Swapping} only for asymmetric arrow tips like the harpoons created using the |harpoon| option. % -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz [ultra thick] \draw [arrows = {-Stealth[harpoon]}] (0,0) -- (1,0); \end{codeexample} -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz [ultra thick] \draw [arrows = {-Stealth[harpoon,swap]}] (0,0) -- (1,0); \end{codeexample} % @@ -721,10 +714,10 @@ \subsubsection{Reversing, Halving, Swapping} \begin{key}{/pgf/arrow keys/right} A shorthand for |harpoon, swap|. % -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz [ultra thick] \draw [arrows = {-Stealth[left]}] (0,0) -- (1,0); \end{codeexample} -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz [ultra thick] \draw [arrows = {-Stealth[right]}] (0,0) -- (1,0); \end{codeexample} % @@ -751,10 +744,10 @@ \subsubsection{Coloring} this default draw color of the path. Since this is the default behaviour, you usually do not need to specify anything: % -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz [ultra thick] \draw [red, arrows = {-Stealth}] (0,0) -- (1,0); \end{codeexample} -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz [ultra thick] \draw [blue, arrows = {-Stealth}] (0,0) -- (1,0); \end{codeexample} @@ -762,10 +755,10 @@ \subsubsection{Coloring} arrow tip should get this color \emph{instead} of the color of the main path: % -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz [ultra thick] \draw [red, arrows = {-Stealth[color=blue]}] (0,0) -- (1,0); \end{codeexample} -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz [ultra thick] \draw [red, arrows = {-Stealth[color=black]}] (0,0) -- (1,0); \end{codeexample} @@ -775,7 +768,7 @@ \subsubsection{Coloring} key is the name of a color and, if so, execute |color=|\meta{arrow key}. So, the first of the above examples can be rewritten as follows: % -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz [ultra thick] \draw [red, arrows = {-Stealth[blue]}] (0,0) -- (1,0); \end{codeexample} @@ -789,7 +782,7 @@ \subsubsection{Coloring} fill the arrow tips, even if a different color is specified for filling the path: % -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz [ultra thick] \draw [draw=red, fill=red!50, arrows = {-Stealth[length=10pt]}] (0,0) -- (1,1) -- (2,0); \end{codeexample} @@ -808,7 +801,7 @@ \subsubsection{Coloring} This color can be different from the color used to draw (stroke) the arrow tip: % -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz { \draw [help lines] (0,-.5) grid [step=1mm] (1,.5); \draw [thick, red, arrows = {-Stealth[fill=white,length=15pt]}] (0,0) -- (1,0); @@ -818,7 +811,7 @@ \subsubsection{Coloring} You can also specify the special ``color'' |none|. In this case, the arrow tip is not filled at all (not even with white): % -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz { \draw [help lines] (0,-.5) grid [step=1mm] (1,.5); \draw [thick, red, arrows = {-Stealth[fill=none,length=15pt]}] (0,0) -- (1,0); @@ -838,7 +831,7 @@ \subsubsection{Coloring} come first since it will reset the filling to the color specified for drawing. % -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz { \draw [help lines] (0,-.5) grid [step=1mm] (1,.5); \draw [thick, red, arrows = {-Stealth[color=blue, fill=white, length=15pt]}] @@ -851,7 +844,7 @@ \subsubsection{Coloring} path. (This special color is always available and always set to the current filling color of the graphic state.): % -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz [ultra thick] \draw [draw=red, fill=red!50, arrows = {-Stealth[length=15pt, fill=pgffillcolor]}] (0,0) -- (1,1) -- (2,0); @@ -886,22 +879,22 @@ \subsubsection{Line Styling} it will have an effect on where the exact ``tip'' of the arrow is since this will always be exactly at the end of the arrow: % -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz [line width=2mm] \draw [arrows = {-Computer Modern Rightarrow[line cap=butt]}] (0,0) -- (1,0); \end{codeexample} -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz [line width=2mm] \draw [arrows = {-Computer Modern Rightarrow[line cap=round]}] (0,0) -- (1,0); \end{codeexample} -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz [line width=2mm] \draw [arrows = {-Bracket[reversed,line cap=butt]}] (0,0) -- (1,0); \end{codeexample} -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz [line width=2mm] \draw [arrows = {-Bracket[reversed,line cap=round]}] (0,0) -- (1,0); @@ -914,22 +907,22 @@ \subsubsection{Line Styling} the key only has an effect on paths that have ``corners'' in them. The same rules as for |line cap| apply: the size is not affects, but the tip end is: % - \begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz [line width=2mm] \draw [arrows = {-Computer Modern Rightarrow[line join=miter]}] (0,0) -- (1,0); \end{codeexample} -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz [line width=2mm] \draw [arrows = {-Computer Modern Rightarrow[line join=round]}] (0,0) -- (1,0); \end{codeexample} -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz [line width=2mm] \draw [arrows = {-Bracket[reversed,line join=miter]}] (0,0) -- (1,0); \end{codeexample} -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz [line width=2mm] \draw [arrows = {-Bracket[reversed,line join=round]}] (0,0) -- (1,0); @@ -943,11 +936,11 @@ \subsubsection{Line Styling} A shorthand for |line cap=round, line join=round|, resulting in ``rounded'' arrow heads. % - \begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz [line width=2mm] \draw [arrows = {-Computer Modern Rightarrow[round]}] (0,0) -- (1,0); \end{codeexample} -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz [line width=2mm] \draw [arrows = {-Bracket[reversed,round]}] (0,0) -- (1,0); \end{codeexample} @@ -957,11 +950,12 @@ \subsubsection{Line Styling} \begin{key}{/pgf/arrow keys/sharp} A shorthand for |line cap=butt, line join=miter|, resulting in ``sharp'' or ``pointed'' arrow heads. - \begin{codeexample}[width=3cm] + % +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz [line width=2mm] \draw [arrows = {-Computer Modern Rightarrow[sharp]}] (0,0) -- (1,0); \end{codeexample} -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz [line width=2mm] \draw [arrows = {-Bracket[reversed,sharp]}] (0,0) -- (1,0); \end{codeexample} @@ -980,10 +974,10 @@ \subsubsection{Line Styling} The meaning of the factors is as usual the same as for |length| or |width|. % -\begin{codeexample}[width=2cm] +\begin{codeexample}[width=2cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz \draw [arrows = {-Latex[line width=0.1pt, fill=white, length=10pt]}] (0,0) -- (1,0); \end{codeexample} -\begin{codeexample}[width=2cm] +\begin{codeexample}[width=2cm,preamble={\usetikzlibrary{arrows.meta}}] \tikz \draw [arrows = {-Latex[line width=1pt, fill=white, length=10pt]}] (0,0) -- (1,0); \end{codeexample} % @@ -1026,7 +1020,7 @@ \subsubsection{Bending and Flexing} \pattern [pattern=bricks] (1,-.5) rectangle (2,.5); \draw [line width=1pt] (1cm+.5pt,-.5) -- ++(0,1); } \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \begin{tikzpicture} \wall \draw [red,line width=1mm,-{Stealth[length=1cm,open,blue]}] @@ -1097,7 +1091,7 @@ \subsubsection{Bending and Flexing} same amount to ensure that the line still has the same tangent at the end. This will result in the following: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \begin{tikzpicture} \wall \draw [red!25,line width=1mm] (-1,0) -- (1,0); @@ -1141,10 +1135,6 @@ \subsubsection{Bending and Flexing} all paths, unless |quick| is explicitly selected for the arrow tip. \end{tikzlibrary} -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{bending} -\end{codeexample} -% \begin{key}{/pgf/arrow keys/flex=\opt{\meta{factor}} (default 1)} When the |bending| library is loaded, this key is applied to all arrow tips by default. It has the following effect: @@ -1168,7 +1158,7 @@ \subsubsection{Bending and Flexing} original line ended. Then, the arrow is rotated so the \emph{the visual end lies on the line}: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta,bending}}] \begin{tikzpicture} \wall \draw [red!25,line width=1mm] (-1,0) -- (1,0); @@ -1198,7 +1188,7 @@ \subsubsection{Bending and Flexing} |flex=.5| will rotate the arrow's visual end ``halfway away from the tangent towards the actual position on the line''. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta,bending}}] \begin{tikzpicture} \wall \draw [red!25,line width=1mm] (-1,0) -- (1,0); @@ -1206,7 +1196,7 @@ \subsubsection{Bending and Flexing} (-1,-.5) .. controls (0,-.5) and (0,0) .. (1,0); \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta,bending}}] \begin{tikzpicture} \wall \draw [red!25,line width=1mm] (-1,0) -- (1,0); @@ -1219,7 +1209,7 @@ \subsubsection{Bending and Flexing} arrow tip. Open arrow tips do not go well with a flex value other than~|1|. Here is a more realistic use of the |flex=0| key: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta,bending}}] \begin{tikzpicture} \wall \draw [red!25,line width=1mm] (-1,0) -- (1,0); @@ -1231,7 +1221,7 @@ \subsubsection{Bending and Flexing} If there are several arrow tips on a path, the |flex| option positions them independently, so that each of them lies optimally on the path: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{bending}}] \begin{tikzpicture} \wall \draw [red!25,line width=1mm] (-1,0) -- (1,0); @@ -1250,7 +1240,7 @@ \subsubsection{Bending and Flexing} distance of |6.25mm| from the tip lie on the path, we have the point at a distance of |1cm| from the tip lie on the path: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta,bending}}] \begin{tikzpicture} \wall \draw [red!25,line width=1mm] (-1,0) -- (1,0); @@ -1266,7 +1256,7 @@ \subsubsection{Bending and Flexing} but rather with tips like the standard |>| in the context of a strongly curved line: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta,bending}}] \begin{tikzpicture} \wall \draw [red!25,line width=1mm] (-1,0) -- (1,0); @@ -1284,7 +1274,7 @@ \subsubsection{Bending and Flexing} that it should be rotated. This is exactly what the |flex'| option does since it allows us to align the ``back end'' of the tip with the red line: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta,bending}}] \begin{tikzpicture} \wall \draw [red!25,line width=1mm] (-1,0) -- (1,0); @@ -1309,7 +1299,7 @@ \subsubsection{Bending and Flexing} tips. On the other hand, for most arrow tips their bend version are visually quite pleasing and create a sophisticated look: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta,bending}}] \begin{tikzpicture} \wall \draw [red!25,line width=1mm] (-1,0) -- (1,0); @@ -1317,7 +1307,7 @@ \subsubsection{Bending and Flexing} (-1,-.5) .. controls (0,-.5) and (0,0) .. (1,0); \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{bending}}] \begin{tikzpicture} \wall \draw [red!25,line width=1mm] (-1,0) -- (1,0); @@ -1325,7 +1315,7 @@ \subsubsection{Bending and Flexing} (-1,-.5) .. controls (0,-.5) and (0,0) .. (1,0); \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta,bending}}] \begin{tikzpicture} \wall \draw [red!25,line width=1mm] (-1,0) -- (1,0); @@ -1493,7 +1483,7 @@ \subsubsection{Specifying Paddings} Let us now have a look at some examples. First, we use two arrow tips with different separations between them: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz { \draw [-{>[sep=1pt]>[sep= 2pt]>}] (0,1.0) -- (1,1.0); \draw [-{>[sep=1pt]>[sep=-2pt]>}] (0,0.5) -- (1,0.5); @@ -1507,7 +1497,7 @@ \subsubsection{Specifying Paddings} but will rather leave the specified amount of space. This is usually quite desirable. % -\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta,positioning}}] \tikz { \node [draw] (A) {A}; \node [draw] (B) [right=of A] {B}; @@ -1568,7 +1558,7 @@ \subsubsection{Specifying the Line End} Note that |.| is parsed as any other shorthand. In particular, if you wish to add a dot after a normal arrow tip kind name, you need to add brackets: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz [very thick] \draw [-{Stealth[] . Stealth[] Stealth[]}] (0,0) -- (2,0); \end{codeexample} % @@ -1601,11 +1591,11 @@ \subsubsection{Defining Shorthands} keys inside the \meta{end specification} are translated automatically. \todosp{remaining instance of bug \#473} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz [foo /.tip = {Stealth[sep]. >>}] \draw [-foo] (0,0) -- (2,0); \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz [foo /.tip = {Stealth[sep] Latex[sep]}, bar /.tip = {Stealth[length=10pt,open]}] \draw [-{foo[red] . bar}] (0,0) -- (2,0); @@ -1651,7 +1641,7 @@ \subsubsection{Defining Shorthands} \begin{codeexample}[] \tikz \draw [>->] (0,0) -- (1,0); \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz \draw [Stealth-Stealth] (0,0) -- (1,0); \end{codeexample} % @@ -1669,10 +1659,10 @@ \subsubsection{Defining Shorthands} start specifications}|-|\meta{name in end specifications}. Thus, to set the |>| key correctly, you actually need to write % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz [<-> /.tip = Stealth] \draw [<->>] (0,0) -- (1,0); \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz [<-> /.tip = Latex] \draw [>-<] (0,0) -- (1,0); \end{codeexample} @@ -1698,7 +1688,7 @@ \subsubsection{Defining Shorthands} \begin{key}{/tikz/>=\meta{end arrow specification}} This is a short way of saying |<->/.tip=|\meta{end arrow specification}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \begin{tikzpicture}[scale=2,ultra thick] \begin{scope}[>=Latex] \draw[>->] (0pt,3ex) -- (1cm,3ex); @@ -1853,7 +1843,7 @@ \subsection{Reference: Arrow Tips} difference is that the background will ``shine through'' an open arrow, while a filled arrow always obscures the background: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz { \shade [left color=white, right color=red!50] (0,0) rectangle (4,1); @@ -2156,7 +2146,7 @@ \subsubsection{Mathematical Barbed Arrow Tips} like \TeX's \texttt{\string\implies} arrow ($\implies$). A typical use of this arrow tip is % -\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta,graphs}}] \tikz \graph [clockwise=3, math nodes, edges = {double equal sign distance, -Implies}] { "\alpha", "\beta", "\gamma"; @@ -2400,7 +2390,7 @@ \subsubsection{Caps} happens to differ from the normal cap. In the following example, the line cap is ``round'', but, nevertheless, the right end is a ``butt'' cap: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz \draw [line width=1ex, line cap=round, -Butt Cap] (0,0) -- (1,0); \end{codeexample} % @@ -2417,7 +2407,7 @@ \subsubsection{Caps} {length=5mm,inset=-1cm}% {-15mm} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz \draw [line width=1ex, -{Round Cap []. Fast Round[] Fast Round[]}] (0,0) -- (1,0); @@ -2426,7 +2416,7 @@ \subsubsection{Caps} Note that in conjunction with the |bend| option, this works even quite well for curves: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta,bending}}] \tikz [f/.tip = Fast Round] % shorthand \draw [line width=1ex, -{[bend] Round Cap[] . f f f}] (0,0) to [bend left] (1,0); @@ -2449,7 +2439,7 @@ \subsubsection{Caps} {length=5mm,inset=-1cm}% {-15mm} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \tikz \draw [line width=1ex, -{Triangle Cap []. Fast Triangle[] Fast Triangle[]}] (0,0) -- (1,0); @@ -2457,7 +2447,7 @@ \subsubsection{Caps} % Again, this tip works well for curves: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta,bending}}] \tikz [f/.tip = Fast Triangle] % shorthand \draw [line width=1ex, -{[bend] Triangle Cap[] . f f f}] (0,0) to [bend left] (1,0); diff --git a/doc/generic/pgf/text-en/pgfmanual-en-tikz-decorations.tex b/doc/generic/pgf/text-en/pgfmanual-en-tikz-decorations.tex index 2f9f1c5ed..541e3466f 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-tikz-decorations.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-tikz-decorations.tex @@ -16,19 +16,11 @@ \subsection{Overview} Decorations are a general concept to make (sub)paths ``more interesting''. Before we have a look at the details, let us have a look at some examples: % -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{ - decorations.footprints, - decorations.fractals, - decorations.markings, - decorations.pathmorphing, - decorations.pathreplacing, - decorations.shapes, - decorations.text, - } -\end{codeexample} -% -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{ + decorations.pathmorphing, + decorations.pathreplacing, + decorations.shapes, +}}] \begin{tikzpicture}[thick] \draw (0,3) -- (3,3); \draw[decorate,decoration=zigzag] (0,2.5) -- (3,2.5); @@ -40,7 +32,7 @@ \subsection{Overview} \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \begin{tikzpicture} \node [fill=red!20,draw,decorate,decoration={bumps,mirror}, minimum height=1cm] @@ -48,7 +40,7 @@ \subsection{Overview} \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \begin{tikzpicture} \filldraw[fill=blue!20] (0,3) decorate [decoration=saw] { -- (3,3) } @@ -57,7 +49,7 @@ \subsection{Overview} \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \begin{tikzpicture} \node [fill=yellow!50,draw,thick, minimum height=2cm, minimum width=3cm, decorate, decoration={random steps,segment length=3pt,amplitude=1pt}] @@ -77,12 +69,12 @@ \subsection{Overview} consists of a line, an arc, and a line. In the second picture, this path has been used as the basis of a decoration. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \tikz \fill [fill=blue!20,draw=blue,thick] (0,0) -- (2,1) arc (90:-90:.5) -- cycle; \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \tikz \fill [decorate,decoration={zigzag}] [fill=blue!20,draw=blue,thick] (0,0) -- (2,1) arc (90:-90:.5) -- cycle; \end{codeexample} @@ -90,7 +82,7 @@ \subsection{Overview} It is also possible to decorate only a subpath (the exact syntax will be explained later in this section). % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \tikz \fill [decoration={zigzag}] [fill=blue!20,draw=blue,thick] (0,0) -- (2,1) decorate { arc (90:-90:.5) } -- cycle; @@ -118,7 +110,7 @@ \subsection{Overview} path has no effect since the path consist only of (numerous) unconnected straight line subpaths: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.shapes}}] \tikz \fill [decorate,decoration={crosses}] [fill=blue!20,draw=blue,thick] (0,0) -- (2,1) arc (90:-90:.5) -- cycle; \end{codeexample} @@ -134,7 +126,7 @@ \subsection{Overview} such decorations the path usage command for the main path have no influence on how the decoration looks like. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text}}] \tikz \fill [decorate,decoration={text along path, text=This is a text along a path. Note how the path is lost.}] [fill=blue!20,draw=blue,thick] (0,0) -- (2,1) arc (90:-90:.5) -- cycle; @@ -156,13 +148,16 @@ \subsection{Overview} (0,0) rectangle (3,2); \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \tikz \fill [fill=blue!20,draw=blue,thick] decorate[decoration={zigzag,segment length=10mm,amplitude=2.5mm}] { (0,0) rectangle (3,2) }; \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{ + decorations.pathmorphing, + decorations.shapes, +}}] \tikz \fill [fill=blue!20,draw=blue,thick] decorate[decoration={crosses,segment length=2mm}] { decorate[decoration={zigzag,segment length=10mm,amplitude=2.5mm}] { @@ -199,7 +194,7 @@ \subsection{Decorating a Subpath Using the Decorate Path Command} current decoration. Depending on the decoration, this may or may not extend the current path. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \begin{tikzpicture} \draw [help lines] grid (3,2); \draw decorate [decoration={name=zigzag}] @@ -217,7 +212,10 @@ \subsection{Decorating a Subpath Using the Decorate Path Command} You can use nodes normally inside the \meta{subpath}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{ + decorations.pathmorphing, + decorations.shapes, +}}] \begin{tikzpicture} \draw [help lines] grid (3,2); \draw decorate [decoration={name=zigzag}] @@ -242,7 +240,10 @@ \subsection{Decorating a Subpath Using the Decorate Path Command} |decorate| path command. Naturally, any local options of the |decorate| path command override these ``global'' options. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{ + decorations.pathmorphing, + decorations.shapes, +}}] \begin{tikzpicture}[decoration=zigzag] \draw decorate {(0,0) -- (3,2)}; \draw [red] decorate [decoration=crosses] {(0,2) -- (3,0)}; @@ -266,7 +267,7 @@ \subsection{Decorating a Subpath Using the Decorate Path Command} If you set \meta{name} to |none|, no decorations are added. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \begin{tikzpicture} \draw [help lines] grid (3,2); \draw decorate [decoration={name=zigzag}] @@ -278,7 +279,7 @@ \subsection{Decorating a Subpath Using the Decorate Path Command} |name=| part. Thus, the above example can be rewritten more succinctly: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \begin{tikzpicture} \draw [help lines] grid (3,2); \draw decorate [decoration=zigzag] @@ -301,7 +302,7 @@ \subsection{Decorating a Subpath Using the Decorate Path Command} path. In such cases, the construction of the main path is resumed after the |decorate| path command ends. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text}}] \begin{tikzpicture}[decoration={text along path,text= around and around and around and around we go}] @@ -318,7 +319,7 @@ \subsection{Decorating a Subpath Using the Decorate Path Command} Repeatedly applying this transformation to a triangle yields a fractal that looks a bit like a snowflake, hence the name. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.fractals}}] \begin{tikzpicture}[decoration=Koch snowflake,draw=blue,fill=blue!20,thick] \filldraw (0,0) -- ++(60:1) -- ++(-60:1) -- cycle ; \filldraw decorate{ (0,-1) -- ++(60:1) -- ++(-60:1) -- cycle }; @@ -353,7 +354,11 @@ \subsection{Decorating a Complete Path} in contrast to the |decorate| path command you cannot apply this option twice (this would just set it to |true|, once more). % -\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] +\begin{codeexample}[preamble={\usetikzlibrary{ + decorations.pathmorphing, + decorations.text, + shapes.geometric, +}}] \begin{tikzpicture}[decoration=zigzag] \draw [help lines] (0,0) grid (3,5); @@ -372,7 +377,11 @@ \subsection{Decorating a Complete Path} Incidentally, this is another application of the |decorate| option that you cannot achieve with the decorate path command. % -\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] +\begin{codeexample}[preamble={\usetikzlibrary{ + decorations.pathmorphing, + decorations.text, + shapes.geometric, +}}] \begin{tikzpicture}[decoration=zigzag] \node at (1.5,1) [inner sep=6mm,fill=red!20,ellipse, postaction={decorate,decoration= @@ -384,7 +393,7 @@ \subsection{Decorating a Complete Path} after the main path has been drawn. % % \catcode`\|12 % !? -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text}}] \begin{tikzpicture} \draw [help lines] grid (3,2); \fill [draw=red,fill=red!20, @@ -415,7 +424,7 @@ \subsubsection{Positioning Decorations Relative to the To-Be-Decorate Path} A negative \meta{dimension} will offset the decoration ``to the right'' of the to-be-decorated path. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.shapes}}] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); @@ -434,7 +443,7 @@ \subsubsection{Positioning Decorations Relative to the To-Be-Decorate Path} to-be-decorated path. This is done after and in addition to any transformations set using the |transform| and/or |raise| options. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathreplacing}}] \begin{tikzpicture} \node (a) {A}; \node (b) at (2,1) {B}; @@ -457,7 +466,7 @@ \subsubsection{Positioning Decorations Relative to the To-Be-Decorate Path} In the following example the |shift only| transformation is used to make sure that the crosses are \emph{not} sloped along the path. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.shapes}}] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); @@ -487,17 +496,20 @@ \subsubsection{Starting and Ending Decorations Early or Late} also need to set the |pre length| option. % % TODO: Nesting tikzpictures is NOT supported -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \tikz [decoration={zigzag,pre=lineto,pre length=1cm}] \draw [decorate] (0,0) -- (2,1) arc (90:0:1); \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \tikz [decoration={zigzag,pre=moveto,pre length=1cm}] \draw [decorate] (0,0) -- (2,1) arc (90:0:1); \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{ + decorations.pathmorphing, + decorations.shapes, +}}] \tikz [decoration={zigzag,pre=crosses,pre length=1cm}] \draw [decorate] (0,0) -- (2,1) arc (90:0:1); \end{codeexample} @@ -506,12 +518,12 @@ \subsubsection{Starting and Ending Decorations Early or Late} that the default |pre| decoration will not follow curves (for efficiency reasons). Change the |pre| key to |curveto| if you have a curved path. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \tikz [decoration={zigzag,pre length=3cm}] \draw [decorate] (0,0) -- (2,1) arc (90:0:1); \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \tikz [decoration={zigzag,pre=curveto,pre length=3cm}] \draw [decorate] (0,0) -- (2,1) arc (90:0:1); \end{codeexample} @@ -535,7 +547,7 @@ \subsubsection{Starting and Ending Decorations Early or Late} Here is a typical example that shows how these keys can be used: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \begin{tikzpicture} [decoration=snake, line around/.style={decoration={pre length=#1,post length=#1}}] diff --git a/doc/generic/pgf/text-en/pgfmanual-en-tikz-graphs.tex b/doc/generic/pgf/text-en/pgfmanual-en-tikz-graphs.tex index 13aa21dde..e49e2c190 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-tikz-graphs.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-tikz-graphs.tex @@ -21,20 +21,16 @@ \subsection{Overview} \begin{tikzlibrary}{graphs} The package must be loaded to use the |graph| path command. \end{tikzlibrary} -% -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{graphs} -\end{codeexample} In this section, by \emph{graph} we refer to a set of nodes together with some edges (sometimes also called arcs, in case they are directed) such as the following: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph { a -> {b, c} -> d }; \end{codeexample} -\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphs.standard}}] \tikz \graph { subgraph I_nm [V={a, b, c}, W={1,...,4}]; @@ -44,7 +40,7 @@ \subsection{Overview} }; \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [nodes={draw, circle}, clockwise, radius=.5cm, empty nodes, n=5] { subgraph I_n [name=inner] --[complete bipartite] @@ -52,7 +48,10 @@ \subsection{Overview} }; \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[ + preamble={\usetikzlibrary{graphs}}, + pre={\definecolor{graphicbackground}{rgb}{0.96,0.96,0.8}}, +] \tikz \graph [nodes={draw, circle}, clockwise, radius=.75cm, empty nodes, n=8] { subgraph C_n [name=inner] <->[shorten <=1pt, shorten >=1pt] @@ -60,7 +59,7 @@ \subsection{Overview} }; \end{codeexample} -\begin{codeexample}[width=6.6cm] +\begin{codeexample}[width=6.6cm,preamble={\usetikzlibrary{graphs}}] \tikz [>={To[sep]}, rotate=90, xscale=-1, mark/.style={fill=black!50}, mark/.default=] \graph [trie, simple, @@ -156,7 +155,7 @@ \subsubsection{Concept: Node Chains} The basic way of specifying a graph is to write down a \emph{node chain} as in the following example: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz [every node/.style = draw] \graph { foo -> bar -> blub }; \end{codeexample} @@ -169,7 +168,7 @@ \subsubsection{Concept: Node Chains} Inside a graph there can be more than one chain: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph { a -> b -> c; d -> e -> f; @@ -186,7 +185,7 @@ \subsubsection{Concept: Node Chains} identical by default. This is not always desirable and can be changed by using the |as| key or by providing another text after a slash: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph { x1/$x_1$ -> x2 [as=$x_2$, red] -> x34/{$x_3,x_4$}; x1 -> [bend left] x34; @@ -197,7 +196,7 @@ \subsubsection{Concept: Node Chains} dashes, you must surround the node name by quotes. This allows you to use quite arbitrary text as a ``node name'': % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph { "$x_1$" -> "$x_2$"[red] -> "$x_3,x_4$"; "$x_1$" ->[bend left] "$x_3,x_4$"; @@ -214,7 +213,7 @@ \subsubsection{Concept: Chain Groups} to another group. In this case, the ``exit points'' of the first node or group get connected to the ``entry points'' of the second node or group: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph { a -> { b -> c, @@ -225,7 +224,7 @@ \subsubsection{Concept: Chain Groups} Chain groups make it easy to create tree structures: % -\begin{codeexample}[width=10cm] +\begin{codeexample}[width=10cm,preamble={\usetikzlibrary{graphs}}] \tikz \graph [grow down, branch right=2.5cm] { @@ -273,7 +272,7 @@ \subsubsection{Concept: Edge Labels and Styles} groups, one or more edges will typically be created. These edges can be styles easily by providing options in square brackets directly after these connectors: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph { a ->[red] b --[thick] {c, d}; }; @@ -282,7 +281,7 @@ \subsubsection{Concept: Edge Labels and Styles} Using the quotes syntax, see Section~\ref{section-label-quotes}, you can even add labels to the edges easily by putting the labels in quotes: % -\begin{codeexample}[preamble={\usetikzlibrary{quotes}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,quotes}}] \tikz \graph { a ->[red, "foo"] b --[thick, "bar"] {c, d}; }; @@ -299,7 +298,7 @@ \subsubsection{Concept: Edge Labels and Styles} ``leading to'' to nodes. This is achieved by preceding the options with a greater-than sign: % -\begin{codeexample}[preamble={\usetikzlibrary{quotes}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,quotes}}] \tikz \graph { a -> b -- {c [> "foo"], d [> "bar"']}; }; @@ -308,7 +307,7 @@ \subsubsection{Concept: Edge Labels and Styles} Symmetrically, preceding the options by |<| causes the options and labels to apply to the ``outgoing'' edges of the node: % -\begin{codeexample}[preamble={\usetikzlibrary{quotes}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,quotes}}] \tikz \graph { a [< red] -> b -- {c [> blue], d [> "bar"']}; }; @@ -317,7 +316,7 @@ \subsubsection{Concept: Edge Labels and Styles} This syntax allows you to easily create trees with special edge labels as in the following example of a treap: % -\begin{codeexample}[preamble={\usetikzlibrary{quotes}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,quotes}}] \tikz \graph [edge quotes={fill=white,inner sep=1pt}, grow down, branch right, nodes={circle,draw}] { @@ -344,7 +343,7 @@ \subsubsection{Concept: Node Sets} command. For this, simply surround a node name by parentheses. This will cause a reference to be created to an already existing node: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz { \node (a) at (0,0) {A}; \node (b) at (1,0) {B}; @@ -359,7 +358,7 @@ \subsubsection{Concept: Node Sets} Then, inside a |graph| command, you can collectively refer to these nodes by surrounding the node set name in parentheses: % -\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,shapes.geometric}}] \tikz [new set=my nodes] { \node [set=my nodes, circle, draw] at (1,1) {A}; \node [set=my nodes, rectangle, draw] at (1.5,0) {B}; @@ -379,11 +378,11 @@ \subsubsection{Concept: Graph Macros} a graph macro has been defined, you can use the name of the graph to make a copy of the graph part of the graph currently being specified: % -\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphs.standard}}] \tikz \graph { subgraph K_n [n=6, clockwise] }; \end{codeexample} -\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphs.standard}}] \tikz \graph { subgraph C_n [n=5, clockwise] -> mid }; \end{codeexample} @@ -410,7 +409,7 @@ \subsubsection{Concept: Graph Expressions and Color Classes} all red and all green nodes. More advanced connectors, like the |butterfly| connector, allow you to add edges between color classes in a fancy manner. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz [x=8mm, y=6mm, circle] \graph [nodes={fill=blue!70}, empty nodes, n=8] { subgraph I_n [name=A] --[butterfly={level=4}] @@ -484,7 +483,7 @@ \subsubsection{The Graph Command} This option causes the \meta{options} to be applied to each newly created node inside the \meta{group specification}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [nodes=red] { a -> b -> c }; \end{codeexample} % @@ -495,7 +494,7 @@ \subsubsection{The Graph Command} This option causes the \meta{options} to be applied to each newly created edge inside the \meta{group specification}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [edges={red,thick}] { a -> b -> c }; \end{codeexample} % @@ -510,13 +509,13 @@ \subsubsection{The Graph Command} This key specifies that the \meta{node specification} should be added to each newly created edge as an implicitly placed node. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [edge node={node [red, near end] {X}}] { a -> b -> c }; \end{codeexample} % Again, multiple uses of this key accumulate. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [edge node={node [near end] {X}}, edge node={node [near start] {Y}}] { a -> b -> c }; \end{codeexample} @@ -527,7 +526,7 @@ \subsubsection{The Graph Command} The net effect is that the |text| is placed next to the newly created edges. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [edge label=x] { a -> b -> {c,d} }; \end{codeexample} \end{key} @@ -535,7 +534,7 @@ \subsubsection{The Graph Command} \begin{key}{/tikz/graphs/edge label'=\meta{text}} This key is an abbreviation for |edge node=node[auto,swap]{|\meta{text}|}|. % -\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphs.standard}}] \tikz \graph [edge label=out, edge label'=in] { subgraph C_n [clockwise, n=5] }; \end{codeexample} @@ -562,7 +561,7 @@ \subsubsection{Syntax of Group Specifications} In the following example, the group specification consists of three chain specifications, namely of |a -> b|, then |c| alone, and finally |d -> e -> f|: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph { a -> b, c; @@ -578,7 +577,7 @@ \subsubsection{Syntax of Group Specifications} often wish to use a comma also inside the options of a single node like in the following example: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph { a [red, draw] -> b [blue, draw], c [brown, draw, circle] @@ -597,7 +596,7 @@ \subsubsection{Syntax of Group Specifications} they are given at the beginning of this group. However, for groups nested inside other groups, it does make a difference: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph { a -> { [nodes=red] % the option is local to these nodes: b, c @@ -614,7 +613,7 @@ \subsubsection{Syntax of Group Specifications} executed and for each iteration the content of the statement's body is treated and parsed as a new chain specification. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [math nodes, branch down=5mm] { a -> { \foreach \i in {1,2,3} { @@ -648,7 +647,7 @@ \subsubsection{Syntax of Group Specifications} allows you to say, for instance, |parse/.expand once| to insert the text stored in some macro into the group. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \def\mychain{ a -> b -> c; } \tikz \graph { [parse/.expand once=\mychain] d -> e }; \end{codeexample} @@ -656,7 +655,7 @@ \subsubsection{Syntax of Group Specifications} In the following, more fancy example we use a loop to create a chain of dynamic length. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \def\mychain#1{ \def\mytext{1} \foreach \i in {2,...,#1} { @@ -769,13 +768,13 @@ \subsubsection{Syntax of Chain Specifications} no special anchor is used (which is the default). The \meta{anchor} is stored in the macro |\tikzgraphleftanchor| with a leading dot. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph { {a,b,c} -> [complete bipartite] {e,f,g} }; \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [left anchor=east, right anchor=west] { {a,b,c} -- [complete bipartite] {e,f,g} }; @@ -830,7 +829,7 @@ \subsubsection{Syntax of Chain Specifications} Here is an example that shows the default rendering of the different edge specifications: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [branch down=5mm] { a -> b; c -- d; @@ -892,7 +891,7 @@ \subsubsection{Syntax of Node Specifications} say that the already existing node is \emph{referenced}; otherwise we say that the node is \emph{fresh}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph { a -> b; % both are fresh c -> a; % only c is fresh, a is referenced @@ -919,7 +918,7 @@ \subsubsection{Syntax of Node Specifications} name is chosen is follows: An apostrophe (|'|) is appended repeatedly until a node name is found that has not yet been used: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [branch down=5mm] { { [fresh nodes] a -> { @@ -943,7 +942,7 @@ \subsubsection{Syntax of Node Specifications} \begin{key}{/tikz/graphs/number nodes sep=\meta{text} (initially \normalfont space)} \end{key} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [branch down=5mm] { { [number nodes] a -> { @@ -988,7 +987,7 @@ \subsubsection{Syntax of Node Specifications} node name}. Repeated calls of this key accumulate, leading to ever-longer ``name paths'': % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \begin{tikzpicture} \graph { { [name=first] 1, 2, 3} -- @@ -1013,7 +1012,7 @@ \subsubsection{Syntax of Node Specifications} the \meta{node name}. The default is |\space|, resulting in a space. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \begin{tikzpicture} \graph [name separator=] { % no separator { [name=first] 1, 2, 3} -- @@ -1023,7 +1022,7 @@ \subsubsection{Syntax of Node Specifications} \end{tikzpicture} \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \begin{tikzpicture} \graph [name separator=-] { { [name=first] 1, 2, 3} -- @@ -1055,7 +1054,7 @@ \subsubsection{Syntax of Node Specifications} provide a text for the node that differs arbitrarily from the name of the node. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph { a [as=$x$] -- b [as=$y_5$] -> c [red, as={a--b}] }; \end{codeexample} % @@ -1102,7 +1101,7 @@ \subsubsection{Syntax of Node Specifications} useful to change this: For instance, you might wish that the text of all graph nodes is, say, surrounded by parentheses: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [typeset=(\tikzgraphnodetext)] { a -> b -> c }; \end{codeexample} @@ -1110,7 +1109,7 @@ \subsubsection{Syntax of Node Specifications} A more advanced macro might take apart the node text and render it differently: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \def\mytypesetter{\expandafter\myparser\tikzgraphnodetext\relax} \def\myparser#1 #2 #3\relax{% $#1_{#2,\dots,#3}$ @@ -1125,7 +1124,7 @@ \subsubsection{Syntax of Node Specifications} Just sets |typeset| to nothing, which causes all nodes to have an empty text (unless, of course, the |as| option is used): % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [empty nodes, nodes={circle, draw}] { a -> {b, c} }; \end{codeexample} \end{key} @@ -1134,7 +1133,7 @@ \subsubsection{Syntax of Node Specifications} Sets |typeset| to |$\tikzgraphnodetext$|, which causes all nodes names to be typeset in math mode: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [math nodes, nodes={circle, draw}] { a_1 -> {b^2, c_3^n} }; \end{codeexample} \end{key} @@ -1153,7 +1152,7 @@ \subsubsection{Syntax of Node Specifications} a node is surrounded by quotation marks, you can use all sorts of special symbols as part of the text that are normally forbidden: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \begin{tikzpicture} \graph [grow right=2cm] { "Hi, World!" -> "It's \emph{important}!"[red,rotate=-45]; @@ -1255,7 +1254,7 @@ \subsubsection{Syntax of Node Specifications} created a group specification containing a list of references to all the nodes that are part of the node set. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \begin{tikzpicture}[new set=red, new set=green, shorten >=2pt] \foreach \i in {1,2,3} { \node [draw, red!80, set=red] (r\i) at (\i,1) {$r_\i$}; @@ -1280,7 +1279,7 @@ \subsubsection{Syntax of Node Specifications} showing how you can create nodes outside a |graph| command and then connect them inside as if they had been declared inside: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \begin{tikzpicture}[new set=import nodes] \begin{scope}[nodes={set=import nodes}] % make all nodes part of this set \node [red] (a) at (0,1) {$a$}; @@ -1302,7 +1301,7 @@ \subsubsection{Syntax of Node Specifications} specifications are part of chain specifications, which in turn are part of group specifications, this is a recursive definition. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph { a -> {b,c,d} -> {e -> {f,g}, h} }; \end{codeexample} @@ -1338,7 +1337,7 @@ \subsubsection{Specifying Tries} % In total, this is exactly the behaviour you would expect of a trie: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [trie] { a -> { a, @@ -1354,7 +1353,7 @@ \subsubsection{Specifying Tries} libraries, which need Lua\TeX. % \ifluatex -\begin{codeexample}[preamble={\usetikzlibrary{graphdrawing}\usegdlibrary{layered}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing}\usegdlibrary{layered}}] \tikz \graph [trie, simple, layered layout] { a -> b -> a, a -> b -> c, @@ -1365,7 +1364,7 @@ \subsubsection{Specifying Tries} In the following example, we setup the |typeset| key so that it shows the complete names of the nodes: % -\begin{codeexample}[preamble={\usetikzlibrary{graphdrawing}\usegdlibrary{layered}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing}\usegdlibrary{layered}}] \tikz \graph [trie, simple, layered layout, typeset=\tikzgraphnodefullname] { a -> b -> a, @@ -1378,7 +1377,7 @@ \subsubsection{Specifying Tries} You can also use the |trie| key locally and later reference nodes using their full name: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph { { [trie, simple] a -> { @@ -1460,11 +1459,11 @@ \subsection{Quick Graphs} Here is a typical way this syntax might be used: % -\begin{codeexample}[preamble={\usetikzlibrary{quotes}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,quotes}}] \tikz \graph [quick] { "a" --["foo"] "b"[x=1] }; \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [quick] { "a"/"$a$" -- "b"[x=1] --[red] "c"[x=2]; { [nodes=blue] "a" -- "d"[y=1]; }; @@ -1505,7 +1504,7 @@ \subsection{Simple Versus Multi-Graphs} part is a multi-graph), then when you specify an edge between two nodes several times, several such edges get created: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [multi] { % "multi" is not really necessary here a ->[bend left, red] b; a ->[bend right, blue] b; @@ -1527,7 +1526,7 @@ \subsection{Simple Versus Multi-Graphs} In contrast a multi-graph, in a simple graph, at most one edge gets created for every pair of vertices: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [simple]{ a ->[bend left, red] b; a ->[bend right, blue] b; @@ -1543,7 +1542,7 @@ \subsection{Simple Versus Multi-Graphs} create a complicated graph and then later redirect and otherwise modify edges easily: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [simple, grow right=2cm] { {a,b,c,d} ->[complete bipartite] {e,f,g,h}; @@ -1558,7 +1557,7 @@ \subsection{Simple Versus Multi-Graphs} superfluous. In a simple graph, however, it counts as an edge kind and you can thus use it to remove an edge that been added previously: % -\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphs.standard}}] \tikz \graph [simple] { subgraph K_n [n=8, clockwise]; % Get rid of the following edges: @@ -1611,7 +1610,7 @@ \subsubsection{Options For All Edges Between Two Groups} library and you write some text in quotes inside the |options|, this text will be added as a label to each edge: % -\begin{codeexample}[preamble={\usetikzlibrary{quotes}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,quotes}}] \tikz \graph [edge quotes=near start] { { a, b } -> [red, "x", complete bipartite] { c, d }; @@ -1622,7 +1621,7 @@ \subsubsection{Options For All Edges Between Two Groups} appearance of edge labels created using the quotes syntax by adding options after the closing quotes: % -\begin{codeexample}[preamble={\usetikzlibrary{quotes}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,quotes}}] \tikz \graph { a ->["x"] b ->["y"'] c ->["z" red] d; }; @@ -1634,7 +1633,7 @@ \subsubsection{Options For All Edges Between Two Groups} \begin{key}{/tikz/graphs/edge quotes=\opt{\meta{options}}} A shorthand for setting the style |every edge quotes| to \meta{options}. % -\begin{codeexample}[preamble={\usetikzlibrary{quotes}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,quotes}}] \tikz \graph [edge quotes={blue,auto}] { a ->["x"] b ->["y"'] c ->["b" red] d; }; @@ -1645,7 +1644,7 @@ \subsubsection{Options For All Edges Between Two Groups} \begin{key}{/tikz/graphs/edge quotes center} A shorthand for |edge quotes| to |anchor=center|. % -\begin{codeexample}[preamble={\usetikzlibrary{quotes}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,quotes}}] \tikz \graph [edge quotes center] { a ->["x"] b ->["y"] c ->["z" red] d; }; @@ -1656,7 +1655,7 @@ \subsubsection{Options For All Edges Between Two Groups} \begin{key}{/tikz/graphs/edge quotes mid} A shorthand for |edge quotes| to |anchor=mid|. % -\begin{codeexample}[preamble={\usetikzlibrary{quotes}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,quotes}}] \tikz \graph [edge quotes mid] { a ->["x"] b ->["y"] c ->["z" red] d; }; @@ -1669,7 +1668,7 @@ \subsubsection{Changing Options For Certain Edges} Consider the following tree-like graph: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph { a -> {b,c} }; \end{codeexample} @@ -1681,7 +1680,7 @@ \subsubsection{Changing Options For Certain Edges} There are several ways to solve this problem. First, we can simply split up the specification and specify the two edges separately: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph { a -> [red] b; a -> [blue] c; @@ -1700,7 +1699,7 @@ \subsubsection{Changing Options For Certain Edges} to first specify a graph and then, later on, replace edges by other edges and, thereby, provide new options: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [simple] { a -> {b,c}; a -> [red] b; @@ -1716,7 +1715,7 @@ \subsubsection{Changing Options For Certain Edges} the path or paths with some other edge options in force. In the following example, we use this to highlight a whole subtree of a larger tree: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [simple] { % The larger tree, no special options in force a -> { @@ -1753,7 +1752,7 @@ \subsubsection{Options For Incoming and Outgoing Edges} that is created by a connector like |->| in which the node is a \emph{target}. Consider the following example: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph { { a, b } -> { c [target edge style=red], d } -> @@ -1767,7 +1766,7 @@ \subsubsection{Options For Incoming and Outgoing Edges} When an edge already has options set directly, the \meta{options} are executed after these direct options, thus, they ``overrule'' them: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph { { a, b } -> [blue, thick] { c [target edge style=red], d } -> @@ -1779,7 +1778,7 @@ \subsubsection{Options For Incoming and Outgoing Edges} for edges created later on that lead to the node will have these options set: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph { { a, b } -> { c [target edge style=red], d } -> @@ -1798,7 +1797,7 @@ \subsubsection{Options For Incoming and Outgoing Edges} also edge labels (see below) for this node. \end{key} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph { { a, b } -> { c [target edge style=red], d }, @@ -1813,7 +1812,7 @@ \subsubsection{Options For Incoming and Outgoing Edges} will not be added as options to any newly created edges with the current node as their target, but rather it will be added as a node specification. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph { { a, b } -> { c [target edge node=node{X}], d } -> @@ -1830,7 +1829,7 @@ \subsubsection{Options For Incoming and Outgoing Edges} Works exactly like |target edge style|, only now the \meta{options} are only added when the node is a source of a newly created edge: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph { { a, b } -> { c [source edge style=red], d } -> @@ -1849,7 +1848,7 @@ \subsubsection{Options For Incoming and Outgoing Edges} |target node style|. \end{enumerate} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph { a [source edge style=red] ->[green] b [target edge style=blue] % blue wins @@ -1907,7 +1906,7 @@ \subsubsection{Special Syntax for Options For Incoming and Outgoing Edges} These mechanisms make it especially easy to create trees in which the edges are labeled in some special way: % -\begin{codeexample}[preamble={\usetikzlibrary{quotes}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,quotes}}] \tikz \graph [edge quotes={fill=white,inner sep=1pt}, grow down, branch right] { @@ -1929,7 +1928,7 @@ \subsubsection{Placing Node Texts on Incoming Edges} get any text, but rather the edge leading to the node should be labeled as in the following example: % -\begin{codeexample}[preamble={\usetikzlibrary{quotes}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,quotes}}] \tikz \graph [empty nodes] { root -> { @@ -1964,7 +1963,7 @@ \subsubsection{Placing Node Texts on Incoming Edges} % Here is an example that show how this command is used. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [put node text on incoming edges, math nodes, nodes={circle,draw}] { a -> b -> {c, d} }; @@ -2020,7 +2019,7 @@ \subsubsection{Color Classes} encompassing scopes, unless it is explicitly changed (see below) or unset (again, see below). % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [color class=red] { [cycle=red] % causes all "logically" red nodes to be connected in % a cycle @@ -2031,7 +2030,7 @@ \subsubsection{Color Classes} }; \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [color class=red, color class=green, math nodes, clockwise, n=5] { [complete bipartite={red}{green}] @@ -2046,7 +2045,7 @@ \subsubsection{Color Classes} the color \meta{color class name}. You can also use |!|\meta{color class name} as an alias for this key. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [color class=red, color class=green, math nodes, clockwise, n=5] { [complete bipartite={red}{green}] @@ -2062,7 +2061,7 @@ \subsubsection{Color Classes} color} instead. They loose having color \meta{color class name}, but other colors are not affected. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [color class=red, color class=green, math nodes, clockwise, n=5] { [complete bipartite={red}{green}] @@ -2087,12 +2086,13 @@ \subsubsection{Color Classes} saying |not source| or |not target| with a node, you can influence how it is connected: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph { a -> { b, c, d } -> e }; - \end{codeexample} - \begin{codeexample}[] +\end{codeexample} + % +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph { a -> { b[not source], c, d[not target] } -> e }; - \end{codeexample} +\end{codeexample} % \item Color classes |source'| and |target'|. These are temporary colors that are also explained in Section~\ref{section-library-graphs-join}. @@ -2155,7 +2155,7 @@ \subsubsection{Graph Operators on Groups of Nodes} \begin{key}{/tikz/graphs/--} Sets the |default edge kind| to |--|. % -\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphs.standard}}] \tikz \graph { subgraph K_n [--, n=5, clockwise, radius=6mm] }; \end{codeexample} \end{key} @@ -2163,7 +2163,7 @@ \subsubsection{Graph Operators on Groups of Nodes} \begin{key}{/tikz/graphs/->} Sets the |default edge kind| to |->|. % -\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphs.standard}}] \tikz \graph { subgraph K_n [->, n=5, clockwise, radius=6mm] }; \end{codeexample} \end{key} @@ -2171,7 +2171,7 @@ \subsubsection{Graph Operators on Groups of Nodes} \begin{key}{/tikz/graphs/<-} Sets the |default edge kind| to |<-|. % -\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphs.standard}}] \tikz \graph { subgraph K_n [<-, n=5, clockwise, radius=6mm] }; \end{codeexample} \end{key} @@ -2179,7 +2179,7 @@ \subsubsection{Graph Operators on Groups of Nodes} \begin{key}{/tikz/graphs/<->} Sets the |default edge kind| to |<->|. % -\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphs.standard}}] \tikz \graph { subgraph K_n [<->, n=5, clockwise, radius=6mm] }; \end{codeexample} \end{key} @@ -2204,7 +2204,7 @@ \subsubsection{Graph Operators on Groups of Nodes} In the following example we use an operator to connect every node colored |all| inside the subgroup to he node |root|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \def\myconnect#1{\tikzset{graphs/new ->={root}{#1}{}{}}} \begin{tikzpicture} @@ -2237,7 +2237,7 @@ \subsubsection{Graph Operators on Groups of Nodes} As an example, let us create an operator then adds a zig-zag path between two color classes: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \newcount\leftshorecount \newcount\rightshorecount \newcount\mycount \newcount\myothercount \def\zigzag{ @@ -2341,7 +2341,7 @@ \subsubsection{Graph Operators for Joining Groups} Finally, in the whole graph only |a|, |b|, and |c| are sources while only |d| and |f| are targets. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \def\hilightsource#1{\fill [green, opacity=.25] (#1) circle [radius=2mm]; } \def\hilighttarget#1{\fill [red, opacity=.25] (#1) circle [radius=2mm]; } \tikz \graph @@ -2390,7 +2390,7 @@ \subsubsection{Graph Operators for Joining Groups} \meta{edge specification} whose \meta{options} do not contain the |operator| key. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [default edge operator=matching] { {a, b} ->[matching and star] {c, d, e} --[complete bipartite] @@ -2419,7 +2419,7 @@ \subsubsection{Graph Operators for Joining Groups} with a group specification. In this case, however, the color classes must be named explicitly: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \begin{tikzpicture} \graph [color class=red, color class=green, math nodes] { [complete bipartite={red}{green}] @@ -2466,7 +2466,7 @@ \subsection{Graph Macros} with some \meta{options}, they are executed prior to inserting the \meta{specification}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [branch down=4mm, declare={claw}{1 -- {2,3,4}}] { a; claw; @@ -2476,7 +2476,7 @@ \subsection{Graph Macros} % In the next example, we use a key to configure a subgraph: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [ n/.code=\def\n{#1}, branch down=4mm, declare={star}{root -- { \foreach \i in {1,...,\n} {\i} }}] { star [n=5]; }; @@ -2486,7 +2486,7 @@ \subsection{Graph Macros} As a last example, let us define a somewhat more complicated graph macro. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \newcount\mycount \tikzgraphsset{ levels/.store in=\tikzgraphlevel, @@ -2519,7 +2519,7 @@ \subsection{Graph Macros} will typically have to use the |name| option so that different copies of the subgraph are created: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [branch down=4mm, declare={claw}{1 -- {2,3,4}}] { claw [name=left], claw [name=right] @@ -2567,7 +2567,7 @@ \subsubsection{Manual Placement} this strategy if you position nodes ``by hand''. For this, you can use the |at| key, the |shift| keys: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [no placement] { a[at={(0:0)}] -> b[at={(1,0)}] -> c[yshift=1cm]; @@ -2582,7 +2582,7 @@ \subsubsection{Manual Placement} written |at={(|\meta{x dimension}|,|\meta{y dimension}|)}|, where \meta{y dimension} is a value set using the |y| key: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [no placement] { a[x=0,y=0] -> b[x=1,y=0] -> c[x=0,y=1]; @@ -2592,7 +2592,7 @@ \subsubsection{Manual Placement} Note that you can specify an |x| or a |y| key for a whole scope and then vary only the other key: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [no placement] { a -> @@ -2630,7 +2630,7 @@ \subsubsection{Placement on a Grid} each node as computed by the |graphs| library. Just ignore the arcane code that is used to print these numbers. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [nodes={align=center, inner sep=1pt}, grow right=7mm, typeset={\tikzgraphnodetext\\[-4pt] @@ -2661,7 +2661,7 @@ \subsubsection{Placement on a Grid} Under the regime of the |Cartesian placement| strategy, each node is shifted by the current logical width times this \meta{coordinate}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [chain shift=(45:1)] { a -> b -> c; d -> e; @@ -2674,7 +2674,7 @@ \subsubsection{Placement on a Grid} Like for |chain shift|, each node is shifted by the current logical depth times this \meta{coordinate}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [chain shift=(45:7mm), group shift=(-45:7mm)] { a -> b -> c; d -> e; @@ -2689,7 +2689,7 @@ \subsubsection{Placement on a Grid} upward''. The distance by which the center of each new element is removed from the center of the previous one is \meta{distance}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [grow up=7mm] { a -> b -> c}; \end{codeexample} % @@ -2698,7 +2698,7 @@ \subsubsection{Placement on a Grid} \begin{key}{/tikz/graphs/grow down=\meta{distance} (default 1)} Like |grow up|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [grow down=7mm] { a -> b -> c}; \end{codeexample} % @@ -2707,7 +2707,7 @@ \subsubsection{Placement on a Grid} \begin{key}{/tikz/graphs/grow left=\meta{distance} (default 1)} Like |grow up|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [grow left=7mm] { a -> b -> c}; \end{codeexample} % @@ -2716,7 +2716,7 @@ \subsubsection{Placement on a Grid} \begin{key}{/tikz/graphs/grow right=\meta{distance} (default 1)} Like |grow up|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [grow right=7mm] { a -> b -> c}; \end{codeexample} % @@ -2727,7 +2727,7 @@ \subsubsection{Placement on a Grid} which the center of each new element is removed from the center of the previous one is \meta{distance}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [branch up=7mm] { a -> b -> {c, d, e} }; \end{codeexample} % @@ -2738,7 +2738,7 @@ \subsubsection{Placement on a Grid} \begin{key}{/tikz/graphs/branch down=\meta{distance} (default 1)} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [branch down=7mm] { a -> b -> {c, d, e}}; \end{codeexample} % @@ -2746,7 +2746,7 @@ \subsubsection{Placement on a Grid} \begin{key}{/tikz/graphs/branch left=\meta{distance} (default 1)} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [branch left=7mm, grow down=7mm] { a -> b -> {c, d, e}}; \end{codeexample} % @@ -2754,7 +2754,7 @@ \subsubsection{Placement on a Grid} \begin{key}{/tikz/graphs/branch right=\meta{distance} (default 1)} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [branch right=7mm, grow down=7mm] { a -> b -> {c, d, e}}; \end{codeexample} % @@ -2771,17 +2771,17 @@ \subsubsection{Placement on a Grid} automatically as $\sqrt{\texttt{\string|V\string|}}$. $N$ is the number of rows needed to lay out the graph in a grid with $M$ columns. % -\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphs.standard}}] % An example with 6 nodes, 3 columns and therefor 2 rows \tikz \graph [grid placement] { subgraph I_n[n=6, wrap after=3] }; \end{codeexample} % -\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphs.standard}}] % An example with 9 nodes with columns and rows computed automatically \tikz \graph [grid placement] { subgraph Grid_n [n=9] }; \end{codeexample} % -\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphs.standard}}] % Directions can be changed \tikz \graph [grid placement, branch up, grow left] { subgraph Grid_n [n=9] }; \end{codeexample} @@ -2789,7 +2789,7 @@ \subsubsection{Placement on a Grid} In case a user-defined graph instead of a pre-defined |subgraph| is to be laid out using |grid placement|, |n| has to be specified explicitly: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [grid placement] { [n=6, wrap after=3] a -- b -- c -- d -- e -- f @@ -2814,7 +2814,7 @@ \subsubsection{Placement Taking Node Sizes Into Account} along a chain are placed in such a way that the left end of a new node is \meta{distance} from the right end of the previous node: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [grow right sep, left anchor=east, right anchor=west] { start -- { long text -- {short, very long text} -- more text, @@ -2833,14 +2833,15 @@ \subsubsection{Placement Taking Node Sizes Into Account} \begin{key}{/tikz/graphs/grow left sep=\meta{distance} (default 1em)} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [grow left sep] { long -- longer -- longest }; \end{codeexample} % \end{key} \begin{key}{/tikz/graphs/grow up sep=\meta{distance} (default 1em)} -\begin{codeexample}[] +% +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [grow up sep] { a / $a=x$ -- b / {$b=\displaystyle \int_0^1 x dx$} -- @@ -2858,7 +2859,7 @@ \subsubsection{Placement Taking Node Sizes Into Account} This key works like |grow right sep|, only it affects groups rather than chains. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [grow down, branch right sep] { start -- { an even longer text -- {short, very long text} -- more text, @@ -2874,7 +2875,7 @@ \subsubsection{Placement Taking Node Sizes Into Account} \begin{key}{/tikz/graphs/branch left sep=\meta{distance} (default 1em)} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [grow down sep, branch left sep] { start -- { an even longer text -- {short, very long text} -- more text, @@ -2888,7 +2889,7 @@ \subsubsection{Placement Taking Node Sizes Into Account} \begin{key}{/tikz/graphs/branch up sep=\meta{distance} (default 1em)} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [branch up sep] { a, b, c[draw, circle, inner sep=7mm] }; \end{codeexample} % @@ -2915,7 +2916,7 @@ \subsubsection{Placement On a Circle} chain is shifted by |(|\meta{logical width}\meta{angle}|:|\meta{logical width}\meta{angle}|)|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [circular placement] { a -> b -> c; d -> e; @@ -2929,7 +2930,7 @@ \subsubsection{Placement On a Circle} Like for |group shift|, each node on a chain is shifted by |(|\meta{logical depth}\meta{angle}|:|\meta{logical depth}\meta{angle}|)|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [circular placement, group polar shift=(30:0)] { a -> b -> c; d -> e; @@ -2937,7 +2938,7 @@ \subsubsection{Placement On a Circle} }; \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [circular placement, chain polar shift=(30:0), group polar shift=(0:1cm)] { @@ -2953,11 +2954,11 @@ \subsubsection{Placement On a Circle} when the polar shift of a node has been calculated. Essentially, this key allows you to set the \meta{radius} of the innermost circle. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [circular placement, radius=5mm] { a, b, c, d }; \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [circular placement, radius=1cm] { a, b, c, d }; \end{codeexample} \end{key} @@ -2966,11 +2967,11 @@ \subsubsection{Placement On a Circle} This is an initial value that is added to the total computed angle when the polar shift of a node has been calculated. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [circular placement] { a, b, c, d }; \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [circular placement, phase=0] { a, b, c, d }; \end{codeexample} \end{key} @@ -2984,11 +2985,11 @@ \subsubsection{Placement On a Circle} which is exactly what you want when you use predefined graph macros like |subgraph K_n|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [clockwise=4] { a, b, c, d }; \end{codeexample} % -\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphs.standard}}] \tikz \graph [clockwise] { subgraph K_n [n=5] }; \end{codeexample} % @@ -3011,7 +3012,7 @@ \subsubsection{Levels and Level Styles} This key stores a number that is increased for each element on a chain, but gets reset at the end of a group: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [ branch down=5mm, typeset= \tikzgraphnodetext:\pgfkeysvalueof{/tikz/graphs/placement/level}] { @@ -3044,7 +3045,7 @@ \subsubsection{Levels and Level Styles} This key also gets executed for each newly created node with \meta{level} set to the current level of the node. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [ branch down=5mm, level 1/.style={nodes=red}, @@ -3063,7 +3064,7 @@ \subsubsection{Levels and Level Styles} }; \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [ branch down=5mm, level 1/.style={grow right=2cm}, @@ -3101,7 +3102,7 @@ \subsubsection{Defining New Online Placement Strategies} current chain. However, you only have access to this value inside the code passed to the macro |compute position|, explained later on. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [ grow right sep, typeset=\tikzgraphnodetext:\mynum, placement/compute position/.append code= @@ -3147,7 +3148,7 @@ \subsubsection{Defining New Online Placement Strategies} just setup things so that the computed width and depth of each node is displayed at the bottom of each node. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [nodes={align=center, inner sep=1pt}, grow right=7mm, typeset={\tikzgraphnodetext\\[-4pt] @@ -3171,7 +3172,7 @@ \subsubsection{Defining New Online Placement Strategies} option, which internally sets the |logical node width| key so that it returns the width of its parameter in points. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [grow right sep, branch down sep, nodes={align=left, inner sep=1pt}, typeset={\tikzgraphnodetext\\[-4pt] \tiny Width: \mywidth\\[-6pt] \tiny Depth: \mydepth}, @@ -3199,7 +3200,7 @@ \subsubsection{Defining New Online Placement Strategies} This key stores a number that tells us the sequence number of the chain in the current group. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [ grow right sep, branch down=5mm, typeset=\tikzgraphnodetext:\mynum, placement/compute position/.append code= @@ -3251,7 +3252,7 @@ \subsubsection{Defining New Online Placement Strategies} (Naturally, the same effect could be achieved much more easily using the |level| key.) % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \newcount\mycount \def\lightendeepernodes{ \pgfmathsetcount{\mycount}{ @@ -3326,7 +3327,7 @@ \subsubsection{Graph Macros} |V={1,...,|\meta{number}|}, name shore V/.style={name=V}|. \end{key} % -\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphs.standard}}] \tikz \graph [branch right, nodes={draw, circle}] { subgraph I_n [V={a,b,c}] }; \end{codeexample} @@ -3335,7 +3336,7 @@ \subsubsection{Graph Macros} used to introduce nodes into a graph that are then connected as in the following example: % -\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphs.standard}}] \tikz \graph [clockwise, clique] { subgraph I_n [n=4] }; \end{codeexample} % @@ -3346,7 +3347,7 @@ \subsubsection{Graph Macros} $m$ unconnected vertices. The first set consists of the vertices set by the key |V|, the other set consists of the vertices set by the key |W|. % -\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphs.standard}}] \tikz \graph { subgraph I_nm [V={1,2,3}, W={a,b,c}] }; \end{codeexample} % @@ -3376,7 +3377,7 @@ \subsubsection{Graph Macros} The main purpose of this subgraph is to setup the nodes in a bipartite graph: % -\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphs.standard}}] \tikz \graph { subgraph I_nm [n=3, m=4]; @@ -3391,7 +3392,7 @@ \subsubsection{Graph Macros} \begin{graph}{subgraph K\_n} This graph is the complete clique on the vertices from the |V| key. % -\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphs.standard}}] \tikz \graph [clockwise] { subgraph K_n [n=7] }; \end{codeexample} % @@ -3401,12 +3402,12 @@ \subsubsection{Graph Macros} This graph is the complete bipartite graph with the two shores |V| and |W| as in |subgraph I_nm|. % -\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphs.standard}}] \tikz \graph [branch right, grow down] { subgraph K_nm [V={6,...,9}, W={b,...,e}] }; \end{codeexample} % -\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphs.standard}}] \tikz \graph [simple, branch right, grow down] { subgraph K_nm [V={1,2,3}, W={a,b,c,d}, ->]; @@ -3419,7 +3420,7 @@ \subsubsection{Graph Macros} \begin{graph}{subgraph P\_n} This graph is the path on the vertices in |V|. % -\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphs.standard}}] \tikz \graph [branch right] { subgraph P_n [n=3] }; \end{codeexample} % @@ -3428,7 +3429,7 @@ \subsubsection{Graph Macros} \begin{graph}{subgraph C\_n} This graph is the cycle on the vertices in |V|. % -\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphs.standard}}] \tikz \graph [clockwise] { subgraph C_n [n=7, ->] }; \end{codeexample} % @@ -3444,12 +3445,12 @@ \subsubsection{Graph Macros} created between the nodes of a |Grid_n| |subgraph| using different values for |wrap after|. % -\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphs.standard}}] \tikz \graph [grid placement] { subgraph Grid_n [n=3,wrap after=1] }; \tikz \graph [grid placement] { subgraph Grid_n [n=3,wrap after=3] }; \end{codeexample} % -\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphs.standard}}] \tikz \graph [grid placement] { subgraph Grid_n [n=4,wrap after=2] }; \tikz \graph [grid placement] { subgraph Grid_n [n=4] }; \end{codeexample} @@ -3469,7 +3470,7 @@ \subsubsection{Graph Macros} % The names of the two shores |V| and |W| can be changed as described in % the documentation of the keys |/tikz/graphs/name shore V| and % |/tikz/graphs/name shore W|. -% \begin{codeexample}[] +% \begin{codeexample}[preamble={\usetikzlibrary{graphs}}] %\tikz \graph [grid placement] { subgraph Grid_nm [V={1,2,3}, W={4, 5, 6}] }; % \end{codeexample} %\end{graph} @@ -3486,7 +3487,7 @@ \subsubsection{Group Operators} a color that all nodes get by default, when you do not specify anything, all nodes will be connected. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [clockwise, n=5] { a, b, @@ -3497,7 +3498,7 @@ \subsubsection{Group Operators} }; \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [color class=red, clockwise, n=5] { [clique=red, ->] a, b[red], c[red], d, e[red] @@ -3512,7 +3513,7 @@ \subsubsection{Group Operators} an edge of kind |-!-| is added for each pair of vertices. This means that edge only get removed if you specify the |simple| option. % -\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphs.standard}}] \tikz \graph [simple] { subgraph K_n [<->, n=7, clockwise]; % create lots of edges @@ -3526,7 +3527,7 @@ \subsubsection{Group Operators} Connects the nodes colored \meta{color} is a cyclic fashion. The ordering is the ordering in which they appear in the whole graph specification. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [clockwise, n=6, phase=60] { { [cycle, ->] a, b, c }, { [cycle, <-] d, e, f } @@ -3540,7 +3541,7 @@ \subsubsection{Group Operators} all other edges between the nodes of the cycle, provided we are constructing a |simple| graph. % -\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphs.standard}}] \tikz \graph [simple] { subgraph K_n [n=7, clockwise]; % create lots of edges @@ -3554,7 +3555,7 @@ \subsubsection{Group Operators} Works like |cycle|, only there is no edge from the last to the first vertex. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [clockwise, n=6] { { [path, ->] a, b, c }, { [path, <-] d, e, f } @@ -3567,7 +3568,7 @@ \subsubsection{Group Operators} Works like |induced cycle|, only there is no edge from the last to the first vertex. % -\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphs.standard}}] \tikz \graph [simple] { subgraph K_n [n=7, clockwise]; % create lots of edges @@ -3588,14 +3589,14 @@ \subsubsection{Joining Operators} Adds all possible edges from every node having color \meta{from color} to every node having color \meta{to color}: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph { {a, b} ->[complete bipartite] {c, d, e} --[complete bipartite] {g, h, i, j} --[complete bipartite] k }; \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [color class=red, color class=green, clockwise, n=6] { [complete bipartite={red}{green}, ->] a [red], b[red], c[red], d[green], e[green], f[green] @@ -3609,7 +3610,7 @@ \subsubsection{Joining Operators} edges between the vertices in either shore are removed (more precisely, they get replaced by |-!-| edges). % -\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphs.standard}}] \tikz \graph [simple] { subgraph K_n [n=5, clockwise]; % Lots of edges @@ -3628,7 +3629,7 @@ \subsubsection{Joining Operators} what graph theoreticians call a \emph{perfect matching}, otherwise only a maximum, but not perfect matching results. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph { {a, b, c} ->[matching] {d, e, f} --[matching] @@ -3647,7 +3648,7 @@ \subsubsection{Joining Operators} This simple rule allows for some powerful effects (since this connector is the one initially set, there is no need to add it here): % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph { a -> {b, c} -> {d, e} -- f}; \end{codeexample} % @@ -3667,7 +3668,7 @@ \subsubsection{Joining Operators} each node gets connected to the corresponding node in the other set with the same index (as in a |matching|): % -\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphs.standard}}] \tikz \graph [left anchor=east, right anchor=west, branch down=4mm, grow right=15mm] { subgraph I_n [n=12, name=A] --[butterfly={level=3}] diff --git a/doc/generic/pgf/text-en/pgfmanual-en-tikz-matrices.tex b/doc/generic/pgf/text-en/pgfmanual-en-tikz-matrices.tex index fadf2d09e..f9b7a32d9 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-tikz-matrices.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-tikz-matrices.tex @@ -633,7 +633,10 @@ \subsection{Examples} \end{tikzpicture} \end{codeexample} -\begin{codeexample}[preamble={\usetikzlibrary{matrix}}] +\begin{codeexample}[ + preamble={\usetikzlibrary{matrix}}, + pre={\definecolor{graphicbackground}{rgb}{0.96,0.96,0.8}}, +] \begin{tikzpicture}[>=stealth,->,shorten >=2pt,looseness=.5,auto] \matrix [matrix of math nodes, column sep={2cm,between origins}, diff --git a/doc/generic/pgf/text-en/pgfmanual-en-tikz-pics.tex b/doc/generic/pgf/text-en/pgfmanual-en-tikz-pics.tex index c5c6964d0..674bde2d6 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-tikz-pics.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-tikz-pics.tex @@ -555,7 +555,7 @@ \subsubsection{The Quotes Syntax} As example of a pic type that takes these values into account is the |angle| pic type: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{angles,quotes}}] \tikz \draw (3,0) coordinate (A) -- (0,1) coordinate (B) -- (1,2) coordinate (C) diff --git a/doc/generic/pgf/text-en/pgfmanual-en-tutorial-chains.tex b/doc/generic/pgf/text-en/pgfmanual-en-tutorial-chains.tex index b1a56bbc9..bc4335359 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-tutorial-chains.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-tutorial-chains.tex @@ -589,6 +589,7 @@ \subsubsection{Connecting Already Positioned Nodes} \& \& \& \& \& \& \& \& \& \& \& \node (minus)[terminal] {-};\\ } \end{codeexample} +% \begin{codeexample}[ preamble={\usetikzlibrary{graphs,shapes.misc}}, pre={\tikzset{ampersand replacement=\&,point/.style={coordinate}}}, diff --git a/doc/generic/pgf/text-en/pgfmanual-en-tutorial-nodes.tex b/doc/generic/pgf/text-en/pgfmanual-en-tutorial-nodes.tex index ce5914d78..af0613266 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-tutorial-nodes.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-tutorial-nodes.tex @@ -454,11 +454,7 @@ \subsection{Placing Nodes Using Relative Placement} different ways of achieving this, but the nicest one in Hagen's case is the |below| option: % -\begin{codeexample}[setup code,hidden] - \usetikzlibrary{positioning} -\end{codeexample} -% -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \begin{tikzpicture} \node[place] (waiting) {}; \node[place] (critical) [below=of waiting] {}; @@ -490,7 +486,7 @@ \subsection{Adding Labels Next to Nodes} \item Hagen can just add a new node above the |north| anchor of the |semaphore| node. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \begin{tikzpicture} \node[place] (waiting) {}; \node[place] (critical) [below=of waiting] {}; @@ -514,7 +510,7 @@ \subsection{Adding Labels Next to Nodes} 3$''. Instead of |above| we could also use things like |below left| before the colon or a number like |60|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \begin{tikzpicture} \node[place] (waiting) {}; \node[place] (critical) [below=of waiting] {}; @@ -528,7 +524,6 @@ \subsection{Adding Labels Next to Nodes} It is also possible to give multiple |label| options, this causes multiple labels to be drawn. % -% TODOsp: codeexamples: nothing needed here \begin{codeexample}[] \tikz \node [circle,draw,label=60:$60^\circ$,label=below:$-90^\circ$] {my circle}; @@ -544,7 +539,7 @@ \subsection{Adding Labels Next to Nodes} |label={[red]above:$s\le3$}|. Since this looks a bit ugly, Hagen decides to redefine the |every label| style. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \begin{tikzpicture}[every label/.style={red}] \node[place] (waiting) {}; \node[place] (critical) [below=of waiting] {}; @@ -569,7 +564,7 @@ \subsection{Connecting Nodes} a coordinate that contains the node's name followed by a dot, followed by the anchor's name: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \begin{tikzpicture} \node[place] (waiting) {}; \node[place] (critical) [below=of waiting] {}; @@ -583,7 +578,7 @@ \subsection{Connecting Nodes} Next, let us tackle the curve from |waiting| to |enter critical|. This can be specified using curves and controls: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \begin{tikzpicture} \node[place] (waiting) {}; \node[place] (critical) [below=of waiting] {}; @@ -603,7 +598,7 @@ \subsection{Connecting Nodes} So, let us start improving the code for the edges. First, Hagen can leave out the anchors: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \begin{tikzpicture} \node[place] (waiting) {}; \node[place] (critical) [below=of waiting] {}; @@ -632,7 +627,7 @@ \subsection{Connecting Nodes} take angles at which a curve should leave or reach the start or target coordinates. Without these options, a straight line is drawn: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \begin{tikzpicture} \node[place] (waiting) {}; \node[place] (critical) [below=of waiting] {}; @@ -648,7 +643,7 @@ \subsection{Connecting Nodes} Hagen's problem: The |bend right| option. This option also takes an angle, but this angle only specifies the angle by which the curve is bent to the right: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \begin{tikzpicture} \node[place] (waiting) {}; \node[place] (critical) [below=of waiting] {}; @@ -670,7 +665,7 @@ \subsection{Connecting Nodes} color and so on and, still, all the edges can be given on the same path. This allows Hagen to write the following: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \begin{tikzpicture} \node[place] (waiting) {}; \node[place] (critical) [below=of waiting] {}; @@ -689,7 +684,7 @@ \subsection{Connecting Nodes} The finishing touch is to introduce two styles |pre| and |post| and to use the |bend angle=45| option to set the bend angle once and for all: % -\begin{codeexample}[preamble={\usetikzlibrary{arrows}}] +\begin{codeexample}[preamble={\usetikzlibrary{arrows,positioning}}] % Styles place and transition as before \begin{tikzpicture} [bend angle=45, @@ -744,7 +739,7 @@ \subsection{Adding Labels Next to Lines} numerous edges automatic placement can be a blessing. % \begin{codeexample}[ - preamble={\usetikzlibrary{arrows}}, + preamble={\usetikzlibrary{arrows,positioning}}, pre={\tikzset{ pre/.style={<-,shorten <=1pt,>=stealth',semithick}, post/.style={->,shorten >=1pt,>=stealth',semithick}, @@ -920,7 +915,7 @@ \subsection{The Complete Code} every transition/.style={thick,draw=black!75,fill=black!20}, every label/.style={red}, every picture/.style={on grid,node distance=1.3cm,>=stealth',bend angle=45,auto}, -} +}% \begin{tikzpicture}}, post={\end{tikzpicture}}, ] @@ -956,7 +951,8 @@ \subsection{The Complete Code} every transition/.style={thick,draw=black!75,fill=black!20}, red place/.style= {place,draw=red!75,fill=red!20}, every label/.style={red}, - every picture/.style={on grid,node distance=1.3cm,>=stealth',bend angle=45,auto}}, + every picture/.style={on grid,node distance=1.3cm,>=stealth',bend angle=45,auto}, +}% \begin{tikzpicture}}, post={\end{tikzpicture}}, ] @@ -1008,3 +1004,17 @@ \subsection{The Complete Code} {replacement of the \textcolor{red}{capacity} by \textcolor{red}{two places}}; \end{tikzpicture} \end{codeexample} + +% ----------------------------------------------------------------------------- +% TODOsp: codeexamples: This is needed because -- unlike I thought -- +% `setup code is remembered also outside this file. Thus the changed +% style of `place` and `transition` are "remembered" in +% +\begin{codeexample}[setup code,hidden] +% from +\tikzset{ + place/.style={circle,draw,inner sep=0pt,minimum size=5ex,every place}, + transition/.style={rectangle,draw,inner sep=0pt,minimum size=4mm,every transition}, +} +\end{codeexample} +% -----------------------------------------------------------------------------