diff --git a/.travis.yml b/.travis.yml index ab54326fc..0f44d1a89 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,9 +31,8 @@ matrix: script: - cd doc/generic/pgf/version-for-luatex/en - make latex="lualatex --interaction=nonstopmode" - after_success: + after_script: - cp pgfmanual.pdf ../../ - - cp pgfmanual.pdf $TRAVIS_BUILD_DIR/../ - cd ../../../../../ - bash ci/update_tlcontrib.sh before_deploy: @@ -45,7 +44,7 @@ matrix: - cd doc/generic/pgf/version-for-dvisvgm/en - touch pgfmanual.toc - make latex="lualatex --output-format=dvi --interaction=nonstopmode" - after_success: + after_script: - bash ../../../../../ci/update_website.sh - env: version=dvipdfm @@ -78,13 +77,28 @@ matrix: - cd doc/generic/pgf/version-for-xetex/en - make latex="xelatex --no-pdf --interaction=nonstopmode" + - if: repo = pgf-tikz/pgf AND type != pull_request + env: update=sourceforge + before_install: + - openssl aes-256-cbc -K $encrypted_fd6ed174e9a3_key -iv $encrypted_fd6ed174e9a3_iv + -in ci/deploy_key.enc -out ci/deploy_key -d + install: + - git clone --mirror https://github.com/pgf-tikz/pgf.git pgf-git-mirror + - cd pgf-git-mirror + before_script: + - eval "$(ssh-agent -s)" + - chmod 600 ../ci/deploy_key + - echo -e "Host git.code.sf.net\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config + - ssh-add ../ci/deploy_key + script: + - git remote add sf ssh://hmenke@git.code.sf.net/p/pgf/git + - git push --mirror --force sf + deploy: provider: releases api_key: $GH_TOKEN file_glob: true - file: - - $TRAVIS_BUILD_DIR/../pgf_*.zip - - $TRAVIS_BUILD_DIR/../pgfmanual.pdf + file: $TRAVIS_BUILD_DIR/../pgf_*.zip skip_cleanup: true overwrite: true on: diff --git a/README.md b/README.md index 639e2763c..7aac7156b 100644 --- a/README.md +++ b/README.md @@ -8,14 +8,12 @@ backend drivers, including `pdftex` and `dvips`. It comes with a user-friendly syntax layer called Ti*k*Z. See the directory `doc/generic/pgf` for more information. See the file -`doc/generic/pgf/pgfmanual.pdf` (also available from -https://pgf-tikz.github.io/pgf/pgfmanual.pdf) for a manual. This +`doc/generic/pgf/pgfmanual.pdf` for a manual. This documentation also explains the installation. See the file `doc/generic/pgf/license/LICENSE` for license details. -Please go to the official repository at https://github.com/pgf-tikz/pgf or the -official mailing list at https://tug.org/mailman/listinfo/pgf-tikz to submit -bug reports, request new features, etc. +Please go to https://github.com/pgf-tikz/pgf +to submit bug reports, request new features, etc. ## Installation diff --git a/ci/deploy_key.enc b/ci/deploy_key.enc new file mode 100644 index 000000000..ba3c45bfe Binary files /dev/null and b/ci/deploy_key.enc differ diff --git a/ci/update_tlcontrib.sh b/ci/update_tlcontrib.sh index 9bc390db9..c281d3ae3 100644 --- a/ci/update_tlcontrib.sh +++ b/ci/update_tlcontrib.sh @@ -37,16 +37,6 @@ if ! git diff --quiet HEAD -- && [ "$1" != "-f" ]; then exit 1 fi -CURRENT_BRANCH="$(git rev-parse --abbrev-ref HEAD)" -function cleanup { - echo "Cleaning up changes" - git reset --hard "${CURRENT_BRANCH}" - git checkout "${CURRENT_BRANCH}" -} -trap cleanup EXIT - -# Switch to a new branch -git checkout -f -B tlcontrib # Prepare sources for tlpkg mkdir -p texmf-dist/web2c @@ -56,7 +46,7 @@ done touch texmf-dist/doc/generic/pgf/pgfmanual.pdf # In case you forgot to move it git add texmf-dist/doc/generic/pgf/pgfmanual.pdf git add texmf-dist/tex/generic/pgf/pgf.revision.tex # This file HAS to exist! -git commit --no-gpg-sign --quiet --amend --no-edit +git commit --no-gpg-sign --quiet -m "Move files" # Prepare tlpkg mkdir -p /tmp/tlpkg/tlpsrc @@ -82,12 +72,8 @@ mkdir -p tlcontrib/tlnet/ perl /tmp/tlpkg/bin/tl-update-tlpdb -from-git -master "${PWD}" perl /tmp/tlpkg/bin/tl-update-containers -master "${PWD}" -location "${PWD}/tlcontrib/tlnet" -all -recreate -no-sign -# Copy pgfmanual.pdf to tlcontrib -cp texmf-dist/doc/generic/pgf/pgfmanual.pdf tlcontrib/ - -# Clear trap and cleanup -trap - EXIT -cleanup +# Reset git to previous state +git reset --hard HEAD~1 # Deploy the tree cd tlcontrib/ diff --git a/doc/generic/pgf/ChangeLog b/doc/generic/pgf/ChangeLog index 82ad382b1..19a3aa2a7 100644 --- a/doc/generic/pgf/ChangeLog +++ b/doc/generic/pgf/ChangeLog @@ -1,243 +1,3 @@ -2019-07-12 Henri Menke - - - Release 3.1.4 - -2019-07-12 Henri Menke - - - after_script runs after deploy - -2019-07-11 Henri Menke - - - Add pgfmanual to release files - -2019-07-11 johannesborgstrom - - - Add URL of the pdf manual to the README.md file - -2019-07-11 Henri Menke - - - Goodbye SourceForge - -2019-07-11 Henri Menke - - - Clear trap before deploy - -2019-07-11 Henri Menke - - - Switch to a new branch for tlcontrib - -2019-07-10 Henri Menke - - - Stretchable dash patterns #629 - -2019-07-09 Henri Menke - - - Try protected@edef in pgfmathparse - -2019-07-05 Henri Menke - - - Hardening patterns.meta a little - -2019-07-04 Henri Menke - - - \pgfmathrandominteger didn't handle expressions as input - -2019-07-04 Henri Menke - - - extract.lua: all extracted files are tex - -2019-07-04 Henri Menke - - - extract.lua: recurse into subdirectories, ignore remember picture - -2019-07-03 Henri Menke - - - Describe \pgfdeclarepattern and \tikzdeclarepattern - -2019-07-03 Henri Menke - - - Add patterns.meta to the manual - -2019-06-27 Henri Menke - - - /pgf/foreach/count is unscoped #702 - -2019-04-22 Henri Menke - - - On the way to more configurable patterns - -2019-06-27 Henri Menke - - - Add mailing list to the README - -2019-06-26 Henri Menke - - - Missed stripping pt on dimensions #701 - -2019-06-26 Henri Menke - - - Bend angle need not be integer #700 - -2019-06-26 Henri Menke - - - No dedicated options for libraries (for now) - -2019-06-26 Henri Menke - - - Add option to hide code - -2019-06-26 Henri Menke - - - Stripping comments was too greedy - -2019-06-26 Henri Menke - - - Small fix to the grammar - -2019-06-25 Henri Menke - - - Typos in luamath - -2019-06-24 Henri Menke - - - Functionality to print libraries in code listings - -2019-06-23 Stefan Pinnow - - - - fixed some typos - -2019-06-22 Stefan Pinnow - - - - fixed regression (accidentally duplicated part of code) - -2019-06-21 Henri Menke - - - \pgf@nodecallback might be called twice #693 - -2019-06-21 Henri Menke - - - Default implementation of \pgfsys@hboxsynced doesn't work for dvips #690 - -2019-06-21 Henri Menke - - - Fix position tracking for XeTeX #353 - -2019-06-06 Henri Menke - - - Wrong order in definition of \translate #689 - -2019-06-05 Henri Menke - - - FILES is generated - -2019-06-05 Henri Menke - - - Change priority of Travis jobs - -2019-06-05 Henri Menke - - - Load imakeidx before hyperref - -2019-06-05 Henri Menke - - - Remove user config from deploy script - -2019-06-03 Henri Menke - - - Revert "Missing spaces in error messages #679" - -2019-05-31 cfeuersaenger - - - Restored lost functionality in intersections / fillbetween feature - -2019-05-30 Christian Feuersaenger - - - Revert 00f4e8d4154dcb3133ed4a106b6254b8faf874e2 - -2019-05-30 Christian Feuersaenger - - - Fixed regression: the merge cc191ed4ae5bd11df9ce42595102caa4e1f141b4 accidentally deleted a feature - -2019-05-24 Henri Menke - - - Use imakeidx for automatic index creation - -2019-05-23 Henri Menke - - - Looks like I got tex4ht working - -2019-05-23 Henri Menke - - - Use T1 for DVI output for now, see also https://github.com/mgieseki/dvisvgm/issues/2 - -2019-05-23 Henri Menke - - - luaotfload was missing this whole time - -2019-05-23 Henri Menke - - - Merge remote-tracking branch 'loopspace/master' - -2019-05-23 Henri Menke - - - Disable T1 encoding for LuaTeX - -2019-05-21 Andrew Stacey - - - Extended the higher-level save of the last moveto so that it also works with nodes. - -2019-05-21 Andrew Stacey - - - Added dimensions for saving the last moveto coordinates so that -- cycle works with nodes. The existing method uses the coordinates stored from the last soft path move to, but this has an extra transformation applied to it meaning that when it gets used in node placement the transformation is applied twice. - -2019-05-20 Henri Menke - - - Missing spaces in error messages #679 - -2019-05-17 Henri Menke - - - Move tlcontrib to tlnet folder to make room for possible future MikTeX contrib - -2019-05-17 Henri Menke - - - Typo in alternate angles #676 - -2019-05-15 Henri Menke - - - Missing xcolor definitions for Plain and ConTeXt #675 - -2019-05-13 Henri Menke - - - Typo - -2019-05-13 Henri Menke - - - Some more fixes for the tex4ht manual - -2019-05-13 Henri Menke - - - Merge remote-tracking branch 'Mo-Gul/master' - -2019-05-13 Henri Menke - - - Revert all but the useful changes of 98829b450a96a6790570aba11949cd9834e49e2c - -2019-05-13 Henri Menke - - - Some more cleanup before deploy - -2019-05-10 Henri Menke - - - Fix .lastretry #672 - -2019-05-13 Henri Menke - - - Deploy TDS and CTAN zip - -2019-05-13 Henri Menke - - - Get git tag in Makefile - 2019-05-09 Henri Menke - Release 3.1.3 diff --git a/doc/generic/pgf/README b/doc/generic/pgf/README index 73e99b884..d0af9b9ad 100644 --- a/doc/generic/pgf/README +++ b/doc/generic/pgf/README @@ -5,6 +5,8 @@ doc/generic/pgf/pgfmanual.pdf for a manual. This documentation also explains the installation. See the file doc/generic/pgf/license/LICENSE for license details. -Please go to the official repository at https://github.com/pgf-tikz/pgf -or the official mailing list at https://tug.org/mailman/listinfo/pgf-tikz +Please go to https://github.com/pgf-tikz/pgf to submit bug reports, request new features, etc. + + + diff --git a/doc/generic/pgf/extract.lua b/doc/generic/pgf/extract.lua index 89141b6da..ee883f1ac 100644 --- a/doc/generic/pgf/extract.lua +++ b/doc/generic/pgf/extract.lua @@ -1,22 +1,3 @@ --- TODO: this has to go -local preamble = [[ -\usetikzlibrary{3d,arrows,arrows.spaced,arrows.meta,bending,babel,calc, - fit,patterns,plotmarks,shapes.geometric,shapes.misc,shapes.symbols, - shapes.arrows,shapes.callouts,shapes.multipart,shapes.gates.logic.US, - shapes.gates.logic.IEC,circuits.logic.US,circuits.logic.IEC, - circuits.logic.CDH,circuits.ee.IEC,datavisualization, - datavisualization.polar,datavisualization.formats.functions,er,automata, - backgrounds,chains,topaths,trees,petri,mindmap,matrix,calendar,folding, - fadings,shadings,spy,through,turtle,positioning,scopes, - decorations.fractals,decorations.shapes,decorations.text, - decorations.pathmorphing,decorations.pathreplacing,decorations.footprints, - decorations.markings,shadows,lindenmayersystems,intersections, - fixedpointarithmetic,fpu,svg.path,external,graphs,graphs.standard,quotes, - math,angles,views,animations,rdf,perspective} -\usetikzlibrary{graphdrawing} -\usegdlibrary{trees,circular,layered,examples,force,phylogenetics,routing} -]] - local lfs = require("lfs") local lpeg = require("lpeg") local C, Cf, Cg, Ct, P, S, V = lpeg.C, lpeg.Cf, lpeg.Cg, lpeg.Ct, lpeg.P, lpeg.S, lpeg.V @@ -149,17 +130,16 @@ local function walk(sourcedir, targetdir) goto continue end - -- Skip those that say "code only" - if not options["code only"] then + -- Skip those that say "code only" or "setup code" + if not options["code only"] and not options["setup code"] then local newname = name .. "-" .. n .. ".tex" local examplefile = io.open(targetdir .. newname, "w") - examplefile:write"\\documentclass{article}\n" + examplefile:write"\\documentclass{standalone}\n" examplefile:write"\\usepackage{fp,pgf,tikz,xcolor}\n" - examplefile:write(preamble) -- TODO: this has to go examplefile:write(options["preamble"] and options["preamble"] .. "\n" or "") examplefile:write"\\begin{document}\n" - examplefile:write"\\makeatletter\n" -- TODO: this has to go + examplefile:write(setup_code) local pre = options["pre"] or "" pre = pre:gsub("##", "#") diff --git a/doc/generic/pgf/text-en/pgfmanual-en-base-actions.tex b/doc/generic/pgf/text-en/pgfmanual-en-base-actions.tex index fa2f26158..c9ae72ba3 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-base-actions.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-base-actions.tex @@ -348,7 +348,7 @@ \subsection{Arrow Tips on a Path} To ``clear'' the start arrow, say |\pgfsetarrowsstart{}|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepgflibrary{arrows.meta}}] \begin{pgfpicture} \pgfsetarrowsstart{Latex[length=10pt]} \pgfpathmoveto{\pgfpointorigin} @@ -368,7 +368,7 @@ \subsection{Arrow Tips on a Path} \begin{command}{\pgfsetarrowsend\marg{end arrow tip specification}} Sets the arrow tip kind used at the end of a path. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepgflibrary{arrows.meta}}] \begin{pgfpicture} \pgfsetarrowsstart{Latex[length=10pt]} \pgfsetarrowsend{Computer Modern Rightarrow} @@ -385,7 +385,7 @@ \subsection{Arrow Tips on a Path} specification}|-|\meta{end arrow tip specification}. In this case, both the start and the end arrow specification are set: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepgflibrary{arrows.meta}}] \begin{pgfpicture} \pgfsetarrows{Latex[length=10pt]->>} \pgfpathmoveto{\pgfpointorigin} @@ -409,7 +409,7 @@ \subsection{Arrow Tips on a Path} This command is useful if you wish arrows or lines to ``stop shortly before'' a given point. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepgflibrary{arrows.meta}}] \begin{pgfpicture} \pgfpathcircle{\pgfpointorigin}{5mm} \pgfusepath{stroke} diff --git a/doc/generic/pgf/text-en/pgfmanual-en-base-animations.tex b/doc/generic/pgf/text-en/pgfmanual-en-base-animations.tex index 32bfa2438..4bfca8b78 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-base-animations.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-base-animations.tex @@ -32,7 +32,10 @@ \subsection{Overview} you to specify such animations using a set of commands and keys that are documented in the following. % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz { \pgfanimateattribute{opacity}{ whom = node, begin on = {click}, entry = {0s}{1}, entry = {2s}{0} } @@ -47,16 +50,16 @@ \subsection{Overview} in some specific way when the object is displayed. It is the job of the document viewer application to actually compute and display the animation. Interestingly, this means that animations neither increase the size of the -ouput files noticably nor does it put a special burden on \TeX. The hard and +output files noticeably nor does it put a special burden on \TeX. The hard and complicated calculations are done by the viewer application, not by \TeX\ and \pgfname. Only few viewer applications and formats are currently ``up to the job'' of -displaying animations. In particular, the popular \textsc{pdf} format does +displaying animations. In particular, the popular \textsc{pdf} format does \emph{not} allow one to specify animations in this way (one can partly ``fake'' animations at the high price of including a great number of precomputed pictures and using JavaScript in special viewers, but this is really not the -same thing as what \pgfname\ does). Indeed, currently only the \textsc{svg} +same thing as what \pgfname\ does). Indeed, currently only the \textsc{svg} format allows one to specify animations in a sensible way. Thus, \pgfname's animations will only be displayed when \textsc{svg} is used as output format. @@ -65,7 +68,11 @@ \subsection{Overview} you to create ``snapshots'' of animations. As an example, the following code shows how the same drawing is shown at different ``time snapshots'': % -\begin{codeexample}[width=3.9cm] +\begin{codeexample}[ + width=3.9cm, + preamble={\usetikzlibrary{animations} +\def\pgfname{\textsc{pgf}} +}] \tikz [make snapshot of=0.5s] \scoped :rotate = { 0s = "0", 2s = "90" } \node [draw=blue, very thick] {\pgfname}; \tikz [make snapshot of=1s] \scoped :rotate = { 0s = "0", 2s = "90" } @@ -95,7 +102,10 @@ \subsubsection{The Main Command} keys are used, ``outside'' the specified timeline the animation has no effect: % -\begin{codeexample}[animation list={0.5,1,1.5,2,2.5}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={0.5,1,1.5,2,2.5}, +] \tikz { \pgfanimateattribute{opacity}{ whom = node, begin on = {click}, entry = {0s}{1}, entry = {2s}{0} } @@ -226,7 +236,10 @@ \subsubsection{The Main Command} Assigns a name to the animation by which it can be referenced using the |of| and |of next| keys in another animation. % -\begin{codeexample}[animation list={.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6}, +] \tikz [very thick] { \pgfanimateattribute{rotate}{ whom = node, begin on = {end, of next = my move animation, delay = 1s}, @@ -257,7 +270,10 @@ \subsubsection{Specifying the Timeline} \meta{attribute} should have over time. At the \meta{time} specified, the \meta{attribute} will have the value specified as \meta{value}: % -\begin{codeexample}[animation list={.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={.5,1,1.5,2}, +] \tikz { \pgfanimateattribute{rotate}{ whom = node, begin on = {click}, @@ -318,7 +334,10 @@ \subsubsection{Specifying the Timeline} \begin{key}{/pgf/animations/exit control=\marg{time fraction}\marg{value fraction}} Same as |/tikz/animate/options/exit control|. % -\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={\usepgfmodule{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); \pgfanimateattribute{translate}{ @@ -346,7 +365,10 @@ \subsubsection{Specifying the Timeline} \begin{key}{/pgf/animations/stay} Same as |/tikz/animate/options/stay|. % -\begin{codeexample}[animation list={0.5,1,1.5,2,2.5}] +\begin{codeexample}[ + preamble={\usepgfmodule{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); \pgfanimateattribute{translate}{ @@ -365,7 +387,10 @@ \subsubsection{Specifying the Timeline} \begin{key}{/pgf/animations/jump} Same as |/tikz/animate/options/jump|. % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz { \foreach \i in {0,0.1,...,1} \draw (-0.9,.9-\i) -- ++(1.8,0); \pgfanimateattribute{translate}{ @@ -392,7 +417,10 @@ \subsubsection{Specifying the Timeline} the timeline is not active. This makes it easy to specify the value of an attribute when the animation is ``not running''. % -\begin{codeexample}[animation list={-1,0,1,2,3}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={-1,0,1,2,3}, +] \tikz { \pgfanimateattribute{rotate}{ whom = node, begin on = {click}, @@ -464,7 +492,7 @@ \subsubsection{``Anti-Animations'': Snapshots} is used in a \TeX\ scope, no animation is created and no support by the driver is needed (so, it works with \textsc{pdf}). % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{animations}}] \tikz [make snapshot of=1s, animate = { myself: = { :rotate = { 0s = "0", 2s = "90" }, @@ -539,14 +567,14 @@ \subsubsection{``Anti-Animations'': Snapshots} |\pgfsnapshot| will select the last value of the timeline while |\pgfsnapshotafter| will not apply the animation any more: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepgfmodule{animations}}] \foreach \t in {0,1,2,3,4} { \pgfsnapshot{\t} \tikz :rotate = { 0s = "0", 2s = "90", 2s = "180", 4s = "270" } \node [draw=blue, very thick] {f}; } \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepgfmodule{animations}}] \foreach \t in {0,1,2,3,4} { \pgfsnapshotafter{\t} \tikz :rotate = { 0s = "0", 2s = "90", 2s = "180", 4s = "270" } @@ -565,7 +593,10 @@ \subsection{Animating Color, Opacity, Visibility, and Staging} (stroking) color, respectively. To animate both the fill and draw color, you need to create two animations, one for each. % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz { \pgfanimateattribute{fill}{ whom = node.background, begin on = {click}, @@ -577,7 +608,10 @@ \subsection{Animating Color, Opacity, Visibility, and Staging} \end{animateattribute} \begin{animateattribute}{draw} -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz { \pgfanimateattribute{draw}{ whom = node.background, begin on = {click}, @@ -592,7 +626,11 @@ \subsection{Animating Color, Opacity, Visibility, and Staging} scope has its color set explicitly, this color overrules the color of the scope: % -\begin{codeexample}[animation list={0.5,1,1.5,2},animation bb={(1.5,-0.75) rectangle (3,0.75)}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={0.5,1,1.5,2}, + animation bb={(1.5,-0.75) rectangle (3,0.75)}, +] \tikz { \pgfanimateattribute{fill}{ whom = example, begin on = {click, of next=node}, @@ -622,7 +660,11 @@ \subsection{Animating Color, Opacity, Visibility, and Staging} choose \meta{name}|.text| as the target (or, if the node has more parts, use the name of the part as the identifier type instead of |text|). % -\begin{codeexample}[animation list={0.5,1,1.5,2},animation bb={(1.1,-0.9) rectangle (2.9,0.9)}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={0.5,1,1.5,2}, + animation bb={(1.1,-0.9) rectangle (2.9,0.9)}, +] \tikz { \pgfanimateattribute{fill}{ whom = example, begin on = {click, of next=node}, @@ -631,7 +673,11 @@ \subsection{Animating Color, Opacity, Visibility, and Staging} \node at (2,0) (example) [fill = blue!20, circle] {No effect}; } \end{codeexample} -\begin{codeexample}[animation list={0.5,1,1.5,2},animation bb={(1.1,-0.9) rectangle (2.9,0.9)}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={0.5,1,1.5,2}, + animation bb={(1.1,-0.9) rectangle (2.9,0.9)}, +] \tikz { \pgfanimateattribute{fill}{ whom = example.background, begin on = {click, of next=node}, @@ -640,7 +686,11 @@ \subsection{Animating Color, Opacity, Visibility, and Staging} \node at (2,0) (example) [fill = blue!20, circle] {Effect}; } \end{codeexample} -\begin{codeexample}[animation list={0.5,1,1.5,2},animation bb={(1.1,-0.9) rectangle (2.9,0.9)}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={0.5,1,1.5,2}, + animation bb={(1.1,-0.9) rectangle (2.9,0.9)}, +] \tikz { \pgfanimateattribute{fill}{ whom = example.text, begin on = {click, of next=node}, @@ -654,7 +704,10 @@ \subsection{Animating Color, Opacity, Visibility, and Staging} (opaque). \begin{animateattribute}{fill opacity} -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz { \pgfanimateattribute{fill opacity}{ whom = node, begin on = {click}, entry = {0s}{1}, entry = {2s}{0} } @@ -664,7 +717,10 @@ \subsection{Animating Color, Opacity, Visibility, and Staging} \end{animateattribute} \begin{animateattribute}{draw opacity} -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz { \pgfanimateattribute{draw opacity}{ whom = node, begin on = {click}, entry = {0s}{1}, entry = {2s}{0} } @@ -680,7 +736,10 @@ \subsection{Animating Color, Opacity, Visibility, and Staging} 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={\usepgfmodule{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz { \pgfanimateattribute{opacity}{ whom = node, begin on = {click}, entry = {0s}{1}, entry = {2s}{0} } @@ -696,7 +755,10 @@ \subsection{Animating Color, Opacity, Visibility, and Staging} rendered. The (only) two possible values for this attribute are |false| and |true|. % -\begin{codeexample}[animation list={1,2,3,4}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={1,2,3,4}, +] \tikz { \pgfanimateattribute{visible}{ whom = node, begin on = {click}, entry = {0s}{false}, entry = {2s}{false} } @@ -714,7 +776,11 @@ \subsection{Animating Color, Opacity, Visibility, and Staging} you explicitly set the ``stage attribute'' to |true| the 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={\usepgfmodule{animations}}, + animation list={-1,0,1,2,3}, + animation bb={(1.3,-0.7) rectangle (2.7,0.7)}, +] \tikz { \pgfanimateattribute{stage}{ whom = example, begin on = {click, of next=node}, @@ -732,7 +798,10 @@ \subsection{Animating Paths and their Rendering} You can animate the appearance of a path in the following ways: \begin{animateattribute}{line width} -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz [very thick] { \pgfanimateattribute{line width}{ whom = node, begin on = {click}, entry = {0s}{1pt}, entry = {2s}{5mm} } @@ -744,7 +813,10 @@ \subsection{Animating Paths and their Rendering} \end{animateattribute} \begin{animateattribute}{dash} -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz { \pgfanimateattribute{dash}{ whom = node, begin on = {click}, entry = {0s}{{{10pt}{1pt}}{0pt}}, @@ -753,7 +825,10 @@ \subsection{Animating Paths and their Rendering} } \end{codeexample} % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz { \pgfanimateattribute{dash}{ whom = node, begin on = {click}, entry = {0s}{{{1cm}{1pt}}{0pt}}, @@ -778,7 +853,10 @@ \subsection{Animating Paths and their Rendering} \begin{animateattribute}{path} You can animate the path itself: % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz { \pgfanimateattribute{path}{ whom = node.background.path, begin on = {click, of next=node}, @@ -838,7 +916,11 @@ \subsection{Animating Paths and their Rendering} path values are specified (since the shortening is done immediately when a path value is parsed). % -\begin{codeexample}[animation list={0,1,2,3,4},animation bb={(0.9,-0.1)rectangle(2.1,1.1)}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={0,1,2,3,4}, + animation bb={(0.9,-0.1)rectangle(2.1,1.1)}, +] \tikz { \pgfanimateattribute{path}{ whom = p.path, begin on = {click, of next=node}, arrows = ->, @@ -862,7 +944,11 @@ \subsection{Animating Paths and their Rendering} there is no active animation, \emph{will} use the arrow tips. As a result, you can use this to animate a path with an arrow tip: % -\begin{codeexample}[animation list={0,1,2,3,4},animation bb={(0.9,-0.1)rectangle(2.1,1.1)}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={0,1,2,3,4}, + animation bb={(0.9,-0.1)rectangle(2.1,1.1)}, +] \tikz { \pgfanimateattribute{path}{ whom = p.path, begin on = {click, of next=node}, arrows = ->, @@ -887,7 +973,11 @@ \subsection{Animating Paths and their Rendering} tip). Just like the |arrows| key, this key must be given before the path entries are specified. % -\begin{codeexample}[animation list={0,1,2,3,4},animation bb={(0.9,-0.1)rectangle(2.1,1.1)}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={0,1,2,3,4}, + animation bb={(0.9,-0.1)rectangle(2.1,1.1)}, +] \tikz { \pgfanimateattribute{path}{ whom = p.path, begin on = {click, of next=node}, arrows = ->, @@ -937,7 +1027,10 @@ \subsection{Animating Transformations and Views} \begin{animateattribute}{scale} The |scale| attribute adds an animation of the scaling: % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz [very thick] { \pgfanimateattribute{scale}{ whom = node, begin on = {click}, @@ -954,7 +1047,10 @@ \subsection{Animating Transformations and Views} \begin{animateattribute}{rotate} The |rotate| key adds an animation of the rotation: % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz [very thick] { \pgfanimateattribute{rotate}{ whom = node, begin on = {click}, @@ -970,7 +1066,10 @@ \subsection{Animating Transformations and Views} The |xskew| and |yskew| keys (and also |skew x| and |skew y|, which are aliases) add an animation of the skew (given in degrees, not as a slant): % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz [very thick] { \pgfanimateattribute{xskew}{ whom = node, begin on = {click}, entry = {0s}{0}, entry = {2s}{45} } @@ -996,7 +1095,10 @@ \subsection{Animating Transformations and Views} \begin{animateattribute}{translate} The |translate| key adds an animation of the translation (shift): % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz [very thick] { \pgfanimateattribute{translate}{ whom = node, begin on = {click}, @@ -1033,7 +1135,10 @@ \subsection{Animating Transformations and Views} origin of the transformation directly. Internally, however, all this key does is to create the above-mentioned scopes with the necessary shifts. % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz [very thick] { \pgfanimateattribute{rotate}{ whom = node, begin on = {click}, @@ -1048,7 +1153,10 @@ \subsection{Animating Transformations and Views} A second way of changing the canvas transformation matrix is to use the |motion| attribute: % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz [very thick] { \pgfanimateattribute{motion}{ whom = node, begin on = {click}, @@ -1070,7 +1178,10 @@ \subsection{Animating Transformations and Views} reference the start point of the path, a value of |1| references the end of the path and |0.5| referenced the point halfway along the path. % -\begin{codeexample}[animation list={0.25,0.5,0.75,1,1.25,1.5,1.75,2,2.25,2.5}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={0.25,0.5,0.75,1,1.25,1.5,1.75,2,2.25,2.5}, +] \tikz [very thick] { \pgfanimateattribute{motion}{ whom = node, begin on = {click}, @@ -1085,7 +1196,10 @@ \subsection{Animating Transformations and Views} When set to |true|, the |along| key additionally adds a rotation that varies in such a way that a tangent to the path always points right. % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={0.5,1,1.5,2}, +] \tikz [very thick] { \pgfanimateattribute{motion}{ whom = node, begin on = {click}, @@ -1113,11 +1227,16 @@ \subsection{Animating Transformations and Views} In order to use a view, you first need to create a view, which is done using a |{pgfviewboxscope}|, see Section~\ref{section-base-view}, which is - used by the |view| library internally. You can then animate the view using + used by the |views| library internally. You can then animate the view using the |view| attribute. The values passed to the |entry| key must be two \pgfname-points, each surrounded by parentheses. % -\begin{codeexample}[animation list={0.5,1,1.5,2},animation bb={(1.1,-0.9) rectangle (2.9,0.9)}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations} +\usetikzlibrary{views}}, + animation list={0.5,1,1.5,2}, + animation bb={(1.1,-0.9) rectangle (2.9,0.9)}, +] \tikz [very thick] { \pgfanimateattribute{view}{ whom = me.view, begin on = {click, of next=node}, freeze at end, @@ -1133,7 +1252,11 @@ \subsection{Animating Transformations and Views} } \end{codeexample} -\begin{codeexample}[width=2cm] +\begin{codeexample}[ + width=2cm, + preamble={\usepgfmodule{animations} +\usetikzlibrary{views}}, +] \tikz [very thick] { \pgfanimateattribute{view}{ whom = me.view, begin on = {click, of next=n1}, freeze at end, @@ -1189,7 +1312,7 @@ \subsection{Commands for Specifying Timing: Beginnings and Endings} will run, relative to the moment when the graphic is displayed from 3\,s to 4\,s. % -\begin{codeexample}[width=3cm] +\begin{codeexample}[preamble={\usepgfmodule{animations}},width=3cm] \tikz [very thick] { \pgfanimateattribute{rotate}{ whom = node, begin = 2s, end = 4s, @@ -1211,7 +1334,10 @@ \subsection{Commands for Specifying Timing: Beginnings and Endings} ``stays put''. When set to |false|, which is the initial value, once an animation ends, its effect will be removed ``as if it never happened''. % -\begin{codeexample}[animation list={0,1,2,3,4}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={0,1,2,3,4}, +] \tikz [very thick] { \pgfanimateattribute{rotate}{ whom = node, begin on = {click}, freeze at end = false, @@ -1219,7 +1345,10 @@ \subsection{Commands for Specifying Timing: Beginnings and Endings} \node (node) [fill = blue!20, draw = blue, circle] {Here!}; } \end{codeexample} % -\begin{codeexample}[animation list={0,1,2,3,4}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={0,1,2,3,4}, +] \tikz [very thick] { \pgfanimateattribute{rotate}{ whom = node, begin on = {click}, freeze at end, @@ -1271,7 +1400,10 @@ \subsection{Commands for Specifying Timing: Repeats} \begin{itemize} \item Empty, in which case the timeline repeats forever. % -\begin{codeexample}[animation list={1,2,3,4,5}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={1,2,3,4,5}, +] \tikz [very thick] { \pgfanimateattribute{rotate}{ whom = node, begin on = {click}, repeats, @@ -1282,7 +1414,10 @@ \subsection{Commands for Specifying Timing: Repeats} \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={\usepgfmodule{animations}}, + animation list={1,2,3,4,5}, +] \tikz [very thick] { \pgfanimateattribute{rotate}{ whom = node, begin on = {click}, repeats = 1.75, @@ -1294,7 +1429,10 @@ \subsection{Commands for Specifying Timing: Repeats} 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={\usepgfmodule{animations}}, + animation list={1,2,3,4,5}, +] \tikz [very thick] { \pgfanimateattribute{rotate}{ whom = node, begin on = {click}, repeats = for 3.5s, @@ -1319,7 +1457,10 @@ \subsection{Commands for Specifying Timing: Repeats} 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={\usepgfmodule{animations}}, + animation list={1,2,3,4,5}, +] \tikz [very thick] { \pgfanimateattribute{rotate}{ whom = node, begin on = {click}, repeats = accumulating, @@ -1327,7 +1468,10 @@ \subsection{Commands for Specifying Timing: Repeats} \node (node) [fill = blue!20, draw = blue, circle] {Click me!}; } \end{codeexample} % -\begin{codeexample}[animation list={1,2,3,4,5}] +\begin{codeexample}[ + preamble={\usepgfmodule{animations}}, + animation list={1,2,3,4,5}, +] \tikz [very thick] { \pgfanimateattribute{rotate}{ whom = node, begin on = {click}, repeats = 2 accumulating, diff --git a/doc/generic/pgf/text-en/pgfmanual-en-base-arrows.tex b/doc/generic/pgf/text-en/pgfmanual-en-base-arrows.tex index b26efb1b8..382db09e5 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-base-arrows.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-base-arrows.tex @@ -567,10 +567,66 @@ \subsection{Declaring an Arrow Tip Kind} }, defaults = { length = 4cm } } -\begin{codeexample}[] +\begin{codeexample}[ + preamble={\usetikzlibrary{arrows.meta}}, + pre={\pgfdeclarearrow{ + name = foo, + parameters = { \the\pgfarrowlength }, + setup code = { + % The different end values: + \pgfarrowssettipend{.25\pgfarrowlength} + \pgfarrowssetlineend{-.25\pgfarrowlength} + \pgfarrowssetvisualbackend{-.5\pgfarrowlength} + \pgfarrowssetbackend{-.75\pgfarrowlength} + % The hull + \pgfarrowshullpoint{.25\pgfarrowlength}{0pt} + \pgfarrowshullpoint{-.75\pgfarrowlength}{.5\pgfarrowlength} + \pgfarrowshullpoint{-.75\pgfarrowlength}{-.5\pgfarrowlength} + % Saves: Only the length: + \pgfarrowssavethe\pgfarrowlength + }, + drawing code = { + \pgfpathmoveto{\pgfqpoint{.25\pgfarrowlength}{0pt}} + \pgfpathlineto{\pgfqpoint{-.75\pgfarrowlength}{.5\pgfarrowlength}} + \pgfpathlineto{\pgfqpoint{-.5\pgfarrowlength}{0pt}} + \pgfpathlineto{\pgfqpoint{-.75\pgfarrowlength}{-.5\pgfarrowlength}} + \pgfpathclose + \pgfusepathqfill + }, + defaults = { length = 4cm } +}}, +] \tikz \draw [-foo] (0,0) -- (8,0); \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[ + preamble={\usetikzlibrary{arrows.meta,bending}}, + pre={\pgfdeclarearrow{ + name = foo, + parameters = { \the\pgfarrowlength }, + setup code = { + % The different end values: + \pgfarrowssettipend{.25\pgfarrowlength} + \pgfarrowssetlineend{-.25\pgfarrowlength} + \pgfarrowssetvisualbackend{-.5\pgfarrowlength} + \pgfarrowssetbackend{-.75\pgfarrowlength} + % The hull + \pgfarrowshullpoint{.25\pgfarrowlength}{0pt} + \pgfarrowshullpoint{-.75\pgfarrowlength}{.5\pgfarrowlength} + \pgfarrowshullpoint{-.75\pgfarrowlength}{-.5\pgfarrowlength} + % Saves: Only the length: + \pgfarrowssavethe\pgfarrowlength + }, + drawing code = { + \pgfpathmoveto{\pgfqpoint{.25\pgfarrowlength}{0pt}} + \pgfpathlineto{\pgfqpoint{-.75\pgfarrowlength}{.5\pgfarrowlength}} + \pgfpathlineto{\pgfqpoint{-.5\pgfarrowlength}{0pt}} + \pgfpathlineto{\pgfqpoint{-.75\pgfarrowlength}{-.5\pgfarrowlength}} + \pgfpathclose + \pgfusepathqfill + }, + defaults = { length = 4cm } +}}, +] \tikz \draw [-{foo[length=2cm,bend]}] (0,0) to [bend left] (3,0); \end{codeexample} @@ -846,10 +902,13 @@ \subsubsection{Defining New Arrow Keys} |\pgfarrowstheparameters|. Here is an example, where |\showvalueofmacro| is used in this example to show the value stored in a macro: % +\begin{codeexample}[setup code,hidden] \makeatletter \def\showvalueofmacro#1{% \texttt{\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\pgfutil@gobble\expandafter\expandafter\expandafter\string\expandafter\csname#1\endcsname} - } + }% +\end{codeexample} +% \begin{codeexample}[] \pgfarrowsthreeparameters{2pt 1} \showvalueofmacro\pgfarrowstheparameters diff --git a/doc/generic/pgf/text-en/pgfmanual-en-base-decorations.tex b/doc/generic/pgf/text-en/pgfmanual-en-base-decorations.tex index 81be7f5fc..604780df1 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-base-decorations.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-base-decorations.tex @@ -31,7 +31,7 @@ \subsection{Overview} \ldots but could also be as complex as typesetting text along a path: % {\catcode`\|12 -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations,decorations.text}}] \tikz \path decorate [decoration={text along path, text={Some text along a path}}] { (0,2) .. controls (2,2) and (1,0) .. (3,0) }; @@ -255,7 +255,7 @@ \subsection{Declaring Decorations} decoration will produce an output path, that is, it extends the preexisting path. Here is an example: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations}}] \pgfdeclaredecoration{example}{initial} { \state{initial}[width=10pt] @@ -285,7 +285,7 @@ \subsection{Declaring Decorations} parts of the rest of the output path for the following invocation. Here is an example: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations,shapes.geometric}}] \pgfdeclaredecoration{stars}{initial}{ \state{initial}[width=15pt] { @@ -306,7 +306,6 @@ \subsection{Declaring Decorations} .. controls (0,-5) and (3,-5) .. (3,-3); \end{codeexample} % - \item After the \meta{code} has been executed (possibly more than once, if the |repeat state| option is used), the state switches to whatever state has been specified inside the \meta{options} @@ -474,7 +473,7 @@ \subsection{Declaring Decorations} The following example shows how these options can be used: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations}}] \pgfdeclaredecoration{complicated example decoration}{initial} { \state{initial}[width=5pt,next state=up] @@ -604,7 +603,7 @@ \subsection{Using Decorations} \meta{before code} is executed. After the decoration automaton has finished, \meta{after code} is executed. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations,decorations.pathmorphing}}] \begin{tikzpicture}[decoration={segment length=5pt}] \draw [help lines] grid (3,2); \begin{pgfdecoration}{{curveto}{1cm},{zigzag}{2cm},{curveto}{1cm}} @@ -622,7 +621,7 @@ \subsection{Using Decorations} path. Thus, it is possible to specify lengths like |\pgfdecoratedpathlength/3|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations,decorations.pathmorphing}}] \begin{tikzpicture}[decoration={segment length=5pt}] \draw [help lines] grid (3,2); \begin{pgfdecoration}{ @@ -653,7 +652,7 @@ \subsection{Using Decorations} This means that if decorations do not use their own path, it is possible to do something with them and continue from the correct place. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations,decorations.pathmorphing}}] \begin{tikzpicture} \draw [help lines] grid (3,2); \begin{pgfdecoration}{ @@ -764,7 +763,7 @@ \subsection{Using Decorations} Note when applying multiple decorations, this will be reset between decorations, so it needs to be specified for each segment. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations,decorations.pathmorphing}}] \begin{tikzpicture} \draw [help lines] grid (3,2); \begin{pgfdecoration}{ @@ -906,7 +905,7 @@ \subsubsection{Declaring Meta-Decorations} Here is a complete example of a meta-decoration: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations,decorations.pathmorphing}}] \pgfdeclaremetadecoration{arrows}{initial}{ \state{initial}[width=0pt, next state=arrow] { diff --git a/doc/generic/pgf/text-en/pgfmanual-en-base-images.tex b/doc/generic/pgf/text-en/pgfmanual-en-base-images.tex index e8531820c..b7b536852 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-base-images.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-base-images.tex @@ -159,7 +159,7 @@ \subsection{Using an Image} The following example demonstrates the effect of using |\pgfuseimage| inside a colormixin environment. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepackage{xxcolor}}] \pgfdeclareimage[interpolate=true,width=1cm,height=1cm] {image1.!25!white}{brave-gnu-world-logo.25} \pgfdeclareimage[interpolate=true,width=1cm] @@ -194,7 +194,7 @@ \subsection{Using an Image} You can ``save'' the image for later usage by invoking |\pgfaliasimage| on |pgflastimage|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepackage{xxcolor}}] \begin{colormixin}{25!white} \begin{pgfpicture} \pgftext[at=\pgfpoint{1cm}{5cm},left,base] diff --git a/doc/generic/pgf/text-en/pgfmanual-en-base-nodes.tex b/doc/generic/pgf/text-en/pgfmanual-en-base-nodes.tex index 4e0ba4f53..24302f893 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-base-nodes.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-base-nodes.tex @@ -212,7 +212,7 @@ \subsubsection{Creating Multi-Part Nodes} Finally, when the node is drawn, the boxes are placed at the anchor positions |text| and |lower|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes}}] \setbox\pgfnodeparttextbox=\hbox{$q_1$} \setbox\pgfnodepartlowerbox=\hbox{01} \begin{pgfpicture} @@ -552,7 +552,7 @@ \subsubsection{Referencing Anchors of Nodes in the Same Picture} |\pgfpointanchor| without any transformations in force. Here is an example: % \makeatletter -\begin{codeexample}[] +\begin{codeexample}[pre={\makeatletter}] \begin{pgfpicture} \pgftransformrotate{30} \pgfnode{rectangle}{center}{Hello World!}{x}{\pgfusepath{stroke}} @@ -726,7 +726,7 @@ \subsection{Special Nodes} area. Note that excessive use of this option (keeping track of dozens of bounding boxes at the same time) will slow things down. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{scopes}}] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); { [local bounding box=outer box] @@ -1240,7 +1240,10 @@ \subsubsection{Command for Declaring New Shapes} on inheritance: % \makeatletter -\begin{codeexample}[] +\begin{codeexample}[ + preamble={\usetikzlibrary{shapes.geometric}}, + pre={\makeatletter}, +] \pgfdeclareshape{document}{ \inheritsavedanchors[from=rectangle] % this is nearly a rectangle \inheritanchorborder[from=rectangle] diff --git a/doc/generic/pgf/text-en/pgfmanual-en-base-patterns.tex b/doc/generic/pgf/text-en/pgfmanual-en-base-patterns.tex index a8f85fb4c..de7700e54 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-base-patterns.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-base-patterns.tex @@ -93,7 +93,7 @@ \subsection{Declaring a Pattern} The \meta{code} should be \pgfname\ code than can be protocolled. It should not contain any color code. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{patterns}}] \pgfdeclarepatternformonly{stars} {\pgfpointorigin}{\pgfpoint{1cm}{1cm}} {\pgfpoint{1cm}{1cm}} @@ -141,7 +141,7 @@ \subsection{Declaring a Pattern} values of the macro |\size|, the key |/tikz/radius|, and the \TeX{} dimension |\thickness|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{patterns}}] \pgfdeclarepatternformonly[/tikz/radius,\thickness,\size]{rings} {\pgfpoint{-0.5*\size}{-0.5*\size}} {\pgfpoint{0.5*\size}{0.5*\size}} @@ -181,7 +181,7 @@ \subsection{Declaring a Pattern} color commands, not the |\color| command, since this fill is not protocolled. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{patterns}}] \pgfdeclarepatterninherentlycolored{green stars} {\pgfpointorigin}{\pgfpoint{1cm}{1cm}} {\pgfpoint{1cm}{1cm}} @@ -214,7 +214,35 @@ \subsection{Setting a Pattern} the \meta{color} parameter is ignored. For form-only patterns, the \meta{color} parameter specifies the color to be used for the pattern. % -\begin{codeexample}[] +\begin{codeexample}[ + preamble={\usetikzlibrary{patterns} +\pgfdeclarepatternformonly{stars} +{\pgfpointorigin}{\pgfpoint{1cm}{1cm}} +{\pgfpoint{1cm}{1cm}} +{ + \pgftransformshift{\pgfpoint{.5cm}{.5cm}} + \pgfpathmoveto{\pgfpointpolar{0}{4mm}} + \pgfpathlineto{\pgfpointpolar{144}{4mm}} + \pgfpathlineto{\pgfpointpolar{288}{4mm}} + \pgfpathlineto{\pgfpointpolar{72}{4mm}} + \pgfpathlineto{\pgfpointpolar{216}{4mm}} + \pgfpathclose% + \pgfusepath{fill} +} +\pgfdeclarepatterninherentlycolored{green stars} +{\pgfpointorigin}{\pgfpoint{1cm}{1cm}} +{\pgfpoint{1cm}{1cm}} +{ + \pgfsetfillcolor{green!50!black} + \pgftransformshift{\pgfpoint{.5cm}{.5cm}} + \pgfpathmoveto{\pgfpointpolar{0}{4mm}} + \pgfpathlineto{\pgfpointpolar{144}{4mm}} + \pgfpathlineto{\pgfpointpolar{288}{4mm}} + \pgfpathlineto{\pgfpointpolar{72}{4mm}} + \pgfpathlineto{\pgfpointpolar{216}{4mm}} + \pgfpathclose% + \pgfusepath{stroke,fill} +}}] \begin{tikzpicture} \pgfsetfillpattern{stars}{red} \filldraw (0,0) rectangle (1.5,2); diff --git a/doc/generic/pgf/text-en/pgfmanual-en-base-points.tex b/doc/generic/pgf/text-en/pgfmanual-en-base-points.tex index 56f49d7e5..d743c57b0 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-base-points.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-base-points.tex @@ -534,7 +534,7 @@ \subsubsection{Points on the Intersection of Two Paths} solutions as ``a bit special'', in that the points returned will be ``absolute'' and unaffected by any further transformations. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{intersections}}] \begin{pgfpicture} \pgfintersectionofpaths { 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..87694af64 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-base-quick.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-base-quick.tex @@ -103,6 +103,7 @@ \subsection{Quick Path Construction Commands} orders of magnitude faster than |\pgfcircle{\pgfpointorigin}{|\meta{radius}|}|. % \begin{codeexample}[] +\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 2cd4553df..67525cd30 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-base-transformations.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-base-transformations.tex @@ -806,6 +806,7 @@ \subsubsection{Introduction} \subsubsection{Installing Nonlinear Transformation} +\begin{codeexample}[setup code,hidden] \makeatletter \def\polartransformation{ % \pgf@x will contain the radius @@ -817,6 +818,7 @@ \subsubsection{Installing Nonlinear Transformation} \pgf@y=\pgfmathresulty\pgf@y% } \makeatother +\end{codeexample} \begin{command}{\pgftransformnonlinear\marg{transformation code}} This command adds the \meta{transformation code} to the list of non-linear @@ -856,7 +858,7 @@ \subsubsection{Installing Nonlinear Transformation} transformation. In particular, a normal grid now becomes the typical ``polar grid''. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepgfmodule{nonlineartransformations}}] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); % Start nonlinear transformation @@ -908,7 +910,7 @@ \subsubsection{Applying Nonlinear Transformations to Paths} Note that this mapping is actually not quite satisfactory for long lines that are strongly curved: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepgfmodule{nonlineartransformations}}] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); { @@ -940,7 +942,7 @@ \subsubsection{Applying Nonlinear Transformations to Paths} (for them, splitting may occur again, if the curve is still too long). % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepgfmodule{nonlineartransformations}}] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); \draw[red] (0:20mm) arc [start angle=0, end angle=90, radius=2cm]; @@ -968,7 +970,7 @@ \subsubsection{Applying Nonlinear Transformations to Text} origin of the text it will look ``correct''. As an example, let us add some text at the grid point of the above example: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepgfmodule{nonlineartransformations}}] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); \pgftransformnonlinear{\polartransformation}% see above @@ -1005,7 +1007,7 @@ \subsubsection{Approximating Nonlinear Transformations Using Linear Transformati look almost the same as if you had not called it. \end{enumerate} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepgfmodule{nonlineartransformations}}] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); \pgftransformnonlinear{\polartransformation}% see above @@ -1035,7 +1037,7 @@ \subsubsection{Approximating Nonlinear Transformations Using Linear Transformati rotation, skewing, or scaling that is involved. This is useful for drawing text at the right position, but without ``mutilating'' the text. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepgfmodule{nonlineartransformations}}] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); \pgftransformnonlinear{\polartransformation}% see above @@ -1117,7 +1119,10 @@ \subsubsection{Nonlinear Transformation Libraries} |\pgftransformnonlinear| for details. % \makeatletter -\begin{codeexample}[] +\begin{codeexample}[ + preamble={\usepgfmodule{nonlineartransformations} +\usetikzlibrary{curvilinear}}, + pre=\makeatletter] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); { @@ -1134,7 +1139,10 @@ \subsubsection{Nonlinear Transformation Libraries} \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[ + preamble={\usepgfmodule{nonlineartransformations} +\usetikzlibrary{curvilinear}}, + pre=\makeatletter] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); { @@ -1171,7 +1179,10 @@ \subsubsection{Nonlinear Transformation Libraries} lines. % \makeatletter -\begin{codeexample}[] +\begin{codeexample}[ + preamble={\usepgfmodule{nonlineartransformations} +\usetikzlibrary{curvilinear}}, + pre=\makeatletter] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); { @@ -1190,7 +1201,10 @@ \subsubsection{Nonlinear Transformation Libraries} \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] +\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-base-transparency.tex b/doc/generic/pgf/text-en/pgfmanual-en-base-transparency.tex index 22156f98d..867a79d97 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-base-transparency.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-base-transparency.tex @@ -218,7 +218,9 @@ \subsection{Specifying a Fading} \end{tikzpicture} \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\pgfdeclarefading{fading2} +{\tikz \shade[left color=pgftransparent!0, + right color=pgftransparent!100] (0,0) rectangle (2,2);}}] \begin{tikzpicture} \fill [black!20] (0,0) rectangle (2,2); \fill [black!30] (0,0) arc (180:0:1); @@ -284,7 +286,11 @@ \subsection{Specifying a Fading} current path will be stroked, this much needs to be added around the path's bounding box to actually contain the path. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\pgfdeclarehorizontalshading{shading}{100bp} +{ color(0pt)=(transparent!0); color(25bp)=(transparent!0); + color(75bp)=(transparent!100); color(100bp)=(transparent!100)} +% +\pgfdeclarefading{fading}{\pgfuseshading{shading}}}] \begin{tikzpicture} \pgfsetlinewidth{2mm} \pgfpathmoveto{\pgfpointorigin} @@ -351,7 +357,7 @@ \subsection{Transparency Groups} % TODO: Nesting tikzpictures is NOT supported {\tikzexternaldisable -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] \begin{tikzpicture} \draw [help lines] (0,0) grid (2,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 a0e46cbaf..c8394d463 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-dv-axes.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-dv-axes.tex @@ -179,7 +179,7 @@ \subsubsection{The Axis Attribute} Here is a real-life example. The |scientific axes| create two axes, called |x axis| and |y axis|, respectively. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [scientific axes, x axis={attribute=people, length=2.5cm, ticks=few}, y axis={attribute=year}, @@ -228,7 +228,7 @@ \subsubsection{The Axis Attribute Range Interval} contain |0| -- even if the actual data points are all positive or all negative. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz \datavisualization [scientific axes, all axes={length=3cm}, visualize as line] data [format=function] { @@ -237,7 +237,7 @@ \subsubsection{The Axis Attribute Range Interval} }; \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz \datavisualization [scientific axes, all axes={length=3cm}, visualize as line, x axis={include value=20}, @@ -288,7 +288,7 @@ \subsubsection{Scaling: The General Mechanism} in order to map dates between 1900 and 2000 to the dimension interval $[0\mathrm{cm},5\mathrm{cm}]$. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [scientific axes, x axis={attribute=people, length=2.5cm, ticks=few}, @@ -417,7 +417,7 @@ \subsubsection{Scaling: The General Mechanism} % This specifies that the function $f$ is the logarithm function. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [scientific axes, x axis={ticks={major={at={1,10,100,1000}}}, @@ -431,7 +431,7 @@ \subsubsection{Scaling: The General Mechanism} % Another possibility might be to use the square-root function, instead: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [scientific axes, x axis={ticks=few, @@ -486,7 +486,10 @@ \subsubsection{Scaling: Logarithmic Axes} All told, to turn an axis into a logarithmic axis, you just need to add this option to the axis. % -\begin{codeexample}[width=8cm] +\begin{codeexample}[ + width=8cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, +] \tikz \datavisualization [scientific axes, x axis={logarithmic}, y axis={logarithmic}, @@ -500,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}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.polar}}] \tikz \datavisualization [new polar axes, angle axis={logarithmic, scaling=1 at 0 and 90 at 90}, @@ -511,7 +514,7 @@ \subsubsection{Scaling: Logarithmic Axes} }; \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.polar}}] \tikz \datavisualization [new polar axes, angle axis={degrees}, @@ -532,7 +535,7 @@ \subsubsection{Scaling: Setting the Length or Unit Length} that the range of all values of the axis's attribute will be mapped to an interval of exact length \meta{dimension}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [scientific axes, x axis={length=3cm}, y axis={length=2cm}, @@ -547,7 +550,7 @@ \subsubsection{Scaling: Setting the Length or Unit Length} }; \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [scientific axes, x axis={length=3cm}, y axis={length=4cm}, @@ -570,7 +573,7 @@ \subsubsection{Scaling: Setting the Length or Unit Length} is particularly useful when you wish to ensure that the same scaling is used across multiple axes or pictures. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [scientific axes, all axes={ticks=few, unit length=1mm}, visualize as line] @@ -582,6 +585,7 @@ \subsubsection{Scaling: Setting the Length or Unit Length} 13, 20 }; \end{codeexample} + % The optional |per |\meta{number}| units| allows you to apply more drastic scaling. Suppose that you want to plot a graph where one billion corresponds to one centimeter. Then the unit length would be need to be set @@ -589,7 +593,7 @@ \subsubsection{Scaling: Setting the Length or Unit Length} dimension. In this case, you can write |unit length=1cm per 1000000000 units|: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [scientific axes, x axis={unit length=1mm per 1000000000 units, ticks=few}, @@ -612,7 +616,7 @@ \subsubsection{Scaling: Setting the Length or Unit Length} to get a length of \meta{dimension}. Again, this key is useful for ensuring that the same scaling is used across multiple axes or pictures. % -\begin{codeexample}[width=8cm] +\begin{codeexample}[width=8cm,preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [scientific axes, y axis={logarithmic, power unit length=1mm, grid}, @@ -648,7 +652,7 @@ \subsubsection{Axis Label} say |node style| to configure the styling of a node, see Section~\ref{section-dv-style}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz \datavisualization [ scientific axes, x axis = {label, length=2.5cm}, @@ -704,7 +708,7 @@ \subsubsection{Reference: Axis Types} point that is at distance |1pt| from the origin and that points into the direction of the axis. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); @@ -792,7 +796,7 @@ \subsubsection{Usage} Here is an example that employs most of the above features: % -\begin{codeexample}[width=8.5cm] +\begin{codeexample}[width=8.5cm,preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [ scientific axes=clean, x axis={attribute=time, ticks={tick unit=ms}, @@ -820,7 +824,10 @@ \subsubsection{Reference: Scientific Axis Systems} This key installs a two-dimensional coordinate system based on the attributes |/data point/x| and |/data point/y|. % -\begin{codeexample}[width=7cm] +\begin{codeexample}[ + width=7cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, +] \begin{tikzpicture} \datavisualization [scientific axes, visualize as smooth line] @@ -850,7 +857,7 @@ \subsubsection{Reference: Scientific Axis Systems} on the two axis. If you wish the units on both axes to be equal, consider directly specifying the unit length ``by hand'': % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \begin{tikzpicture} \datavisualization [visualize as smooth line, scientific axes, @@ -902,7 +909,10 @@ \subsubsection{Reference: Scientific Axis Systems} This causes the ticks to be drawn `` on the outside'' of the frame so that they interfere as little as possible with the data. It is the default. % -\begin{codeexample}[width=7cm] +\begin{codeexample}[ + width=7cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, +] \begin{tikzpicture} \datavisualization [scientific axes=outer ticks, visualize as smooth line] @@ -919,7 +929,10 @@ \subsubsection{Reference: Scientific Axis Systems} This axis system works like |scientific axes|, only the ticks are on the ``inside'' of the frame. % -\begin{codeexample}[width=7cm] +\begin{codeexample}[ + width=7cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, +] \begin{tikzpicture} \datavisualization [scientific axes=inner ticks, visualize as smooth line] @@ -934,7 +947,7 @@ \subsubsection{Reference: Scientific Axis Systems} interfere with marks if they are near to the border as can be seen in the following example: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] \begin{tikzpicture} \datavisualization [scientific axes={inner ticks, width=3.2cm}, style sheet=cross marks, @@ -963,7 +976,10 @@ \subsubsection{Reference: Scientific Axis Systems} this axis system especially useful for scatter plots, but also for most other scientific plots. % -\begin{codeexample}[width=7.5cm] +\begin{codeexample}[ + width=7.5cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, +] \tikz \datavisualization [ scientific axes=clean, visualize as smooth line] @@ -986,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, @@ -1005,7 +1024,10 @@ \subsubsection{Reference: Scientific Axis Systems} Works like |scientific axes standard labels|, only the label of the $y$-axis is not rotated. % -\begin{codeexample}[width=8cm] +\begin{codeexample}[ + width=8cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, +] \tikz \datavisualization [ scientific axes={clean, upright labels}, visualize as smooth line, @@ -1027,7 +1049,10 @@ \subsubsection{Reference: Scientific Axis Systems} Places the labels at the end of the $x$- and the $y$-axis, similar to the axis labels of a school book axis system. % -\begin{codeexample}[width=8cm] +\begin{codeexample}[ + width=8cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, +] \tikz \datavisualization [ scientific axes={clean, end labels}, visualize as smooth line, @@ -1059,7 +1084,7 @@ \subsubsection{Reference: School Book Axis Systems} Finally, if the data is ``far removed'' from the origin, this axis system will also ``look bad''. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \begin{tikzpicture} \datavisualization [school book axes, visualize as smooth line] data [format=function] { @@ -1080,7 +1105,7 @@ \subsubsection{Reference: School Book Axis Systems} the same time, the stepping of the ticks will also be set to \meta{value}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \begin{tikzpicture} \datavisualization [school book axes={unit=10}, visualize as smooth line, @@ -1103,7 +1128,7 @@ \subsubsection{Reference: School Book Axis Systems} Currently, this is the only supported placement strategy for the school book axis system. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \begin{tikzpicture} \datavisualization [school book axes={standard labels}, visualize as smooth line, @@ -1135,7 +1160,7 @@ \subsubsection{Advanced Reference: Underlying Cartesian Axis Systems} This axis system creates two axes called |x axis| and |y axis| that point right and up, respectively. By default, one unit is mapped to one cm. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \begin{tikzpicture} \datavisualization [xy Cartesian, visualize as smooth line] data [format=function] { @@ -1251,7 +1276,7 @@ \subsubsection{The Main Options: Tick and Grid} |/tikz/data visualization/|. When the |ticks| key is used multiple times for an axis, the \meta{options} accumulate. % -\begin{codeexample}[width=6cm] +\begin{codeexample}[width=6cm,preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [ scientific axes, visualize as line, x axis={ticks={step=24, minor steps between steps=3}, @@ -1292,7 +1317,7 @@ \subsubsection{The Main Options: Tick and Grid} |grid| key. This is useful when you want to specify some special points explicitly where you wish a tick to be shown and also a grid line. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz \datavisualization [scientific axes, visualize as smooth line, @@ -1340,7 +1365,7 @@ \subsubsection{Semi-Automatic Computation of Tick and Grid Line Positions} Here is an example of the different stepping chosen when one varies the tick placement strategy: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \begin{tikzpicture} \datavisualization [scientific axes, visualize as smooth line] data [format=function] { @@ -1380,7 +1405,7 @@ \subsubsection{Semi-Automatic Computation of Tick and Grid Line Positions} Basically, all ticks are placed at all multiples of \meta{value} that lie in the attribute range interval. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz \datavisualization [ school book axes, visualize as smooth line, y axis={ticks={step=1.25}}, @@ -1400,7 +1425,7 @@ \subsubsection{Semi-Automatic Computation of Tick and Grid Line Positions} between two minor steps is exactly a tenth of the size of a major step. See also Section~\ref{section-dv-strategies} for further details. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \begin{tikzpicture} \datavisualization [school book axes, visualize as smooth line, x axis={ticks={minor steps between steps=3}}, @@ -1666,7 +1691,7 @@ \subsubsection{Manual Specification of Tick and Grid Line Positions} option) and also any special styling. The different possible options are described later in this section. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz \datavisualization [ school book axes, visualize as smooth line, x axis={ticks={major={at={1, 1.5, 2}}}}] @@ -1681,7 +1706,7 @@ \subsubsection{Manual Specification of Tick and Grid Line Positions} \begin{key}{/tikz/data visualization/minor=\meta{options}} Like |major|, only for minor ticks/grid lines. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz \datavisualization [ school book axes, visualize as smooth line, x axis={grid={minor={at={1, 1.5, 2}}}}] @@ -1704,7 +1729,7 @@ \subsubsection{Manual Specification of Tick and Grid Line Positions} tick at the same position), but it can be useful to configure, say, the size of all kinds of ticks: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz \datavisualization [ school book axes, visualize as smooth line, x axis={ticks={minor steps between steps, common={low=0}}} ] @@ -1728,7 +1753,7 @@ \subsubsection{Manual Specification of Tick and Grid Line Positions} ticks or grid lines on the axis will be placed exactly at the values in \meta{list}. Here is an example: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz \datavisualization [ school book axes, visualize as smooth line, x axis={ticks={major={at={-1,0.5,(pi/2)}}}}] @@ -1778,7 +1803,7 @@ \subsubsection{Manual Specification of Tick and Grid Line Positions} accumulate. However, when |at| is used after an |also at| key, the |at| key completely resets the positions where ticks or grid lines are shown. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz \datavisualization [ school book axes, visualize as smooth line, x axis={grid, ticks and grid={major={also at={0.5}}}}] @@ -1850,7 +1875,7 @@ \subsubsection{Styling Ticks and Grid Lines: The Style and Node Style Keys} executed whenever the data visualization engine calls the \tikzname\ layer to draw something (this placed will be indicated in the following). % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz \datavisualization [scientific axes, all axes={ticks={style=blue}, length=3cm}, @@ -1882,7 +1907,7 @@ \subsubsection{Styling Ticks and Grid Lines: The Style and Node Style Keys} created during a data visualization. This includes tick labels and axis labels: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz \datavisualization [scientific axes, all axes={ticks={node style=red}, length=3cm}, @@ -1936,7 +1961,7 @@ \subsubsection{Styling Ticks and Grid Lines: Styling Grid Lines} obscuring the more important data with the far less important grid lines. However, you can change this style to ``get the grid lines to the front'': % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz \datavisualization [scientific axes, all axes={ @@ -1973,7 +1998,7 @@ \subsubsection{Styling Ticks and Grid Lines: Styling Grid Lines} (which is not a good idea in general since it creates a distracting background pattern). % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz \datavisualization [scientific axes, all axes={length=3cm, grid}, @@ -1998,7 +2023,7 @@ \subsubsection{Styling Ticks and Grid Lines: Styling Grid Lines} % In the following example, we use thin major blue grid lines: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz \datavisualization [scientific axes, all axes={ @@ -2150,7 +2175,10 @@ \subsubsection{Styling Ticks and Grid Lines: Exceptional Ticks} This key causes the \meta{options} to be executed for any tick mark(s) at \meta{value} in addition to any options given already for this position: % -\begin{codeexample}[width=7cm] +\begin{codeexample}[ + width=7cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, +] \tikz \datavisualization [ scientific axes, visualize as smooth line, @@ -2202,7 +2230,7 @@ \subsubsection{Styling Ticks and Grid Lines: Styling and Typesetting a Value} \meta{text} rather than the automatically generated tick label. This automatic generation of tick labels is explained in the following. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz \datavisualization [scientific axes=clean, x axis={length=2.5cm, ticks={major at={ @@ -2246,7 +2274,7 @@ \subsubsection{Styling Ticks and Grid Lines: Styling and Typesetting a Value} \begin{key}{/tikz/data visualization/tick prefix=\meta{text} (initially \normalfont empty)} The \meta{text} will be put in front of every typeset tick: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz \datavisualization [scientific axes, all axes={ticks=few, length=2.5cm}, x axis={ticks={tick prefix=$\langle$, tick suffix=$]$}}, @@ -2267,7 +2295,7 @@ \subsubsection{Styling Ticks and Grid Lines: Styling and Typesetting a Value} \begin{key}{/tikz/data visualization/tick unit=\meta{roman math text}} A shorthand for |tick suffix={$\,\rm|\meta{roman math text}|$}|: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz \datavisualization [scientific axes, all axes={length=3cm}, x axis={ticks={tick unit=s}}, @@ -2292,7 +2320,7 @@ \subsubsection{Styling Ticks and Grid Lines: Styling and Typesetting a Value} mechanism is used. Here is a (not quite finished) example that shows how, say, numbers could be printed in terms of multiples of $\pi$: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \def\mytypesetter#1{% \pgfmathparse{#1/pi}% \pgfmathprintnumber{\pgfmathresult}$\pi$% @@ -2317,7 +2345,7 @@ \subsubsection{Stacked Ticks} Sometimes, the text of tick labels are so long or so numerous that the text of adjacent tick labels overlap (or have too little padding): % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz \datavisualization [scientific axes, all axes={length=2.5cm}, visualize as smooth line] @@ -2332,7 +2360,7 @@ \subsubsection{Stacked Ticks} \begin{itemize} \item One can rotate the labels on horizontal axes: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz \datavisualization [scientific axes, all axes={length=2.5cm}, x axis={ticks={node style={rotate=90, anchor=east}}}, @@ -2348,7 +2376,7 @@ \subsubsection{Stacked Ticks} \item One can specify different shifts of the nodes for the different ticks, whereby the ticks text no longer overlap. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz \datavisualization [scientific axes, all axes={length=2.5cm}, x axis={ticks={major at={0,4000,8000, @@ -2367,7 +2395,7 @@ \subsubsection{Stacked Ticks} automatically. Instead, the |stack| option can be used, which is much easier to use and gives better results: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz \datavisualization [scientific axes, all axes={length=2.5cm}, x axis={ticks=stack}, visualize as smooth line] @@ -2414,7 +2442,7 @@ \subsubsection{Stacked Ticks} \meta{distance} is added to the |low| value, see also Section~\ref{section-dv-visualize-ticks}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz \datavisualization [scientific axes, all axes={length=2.5cm}, x axis={ticks={tick text low even padding=-1em}}, @@ -2456,7 +2484,7 @@ \subsubsection{Stacked Ticks} \begin{key}{/tikz/data visualization/stack=\meta{dimension} (default 1em)} Shorthand for |tick text even padding=|\meta{dimension}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz \datavisualization [scientific axes, all axes={length=2.5cm}, x axis={ticks={stack=1.5em}}, @@ -2473,7 +2501,8 @@ \subsubsection{Stacked Ticks} Shorthand for |tick text odd padding=|\meta{dimension}. The difference to |stack| is that the set of value that are ``lowered'' is exactly exchanged with the set of value ``lowered'' by |stack|. -\begin{codeexample}[] + % +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz \datavisualization [scientific axes, all axes={length=2.5cm}, x axis={ticks=stack'}, @@ -2490,7 +2519,10 @@ \subsubsection{Stacked Ticks} special ticks that you may have added using the |also at| key. When using the |stack| key, you should specify a |tick text padding| explicitly for such keys: % -\begin{codeexample}[width=7cm] +\begin{codeexample}[ + width=7cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, +] \tikz \datavisualization [scientific axes, x axis={ticks={stack, many, major also at= @@ -2527,7 +2559,7 @@ \subsubsection{Reference: Basic Strategies} partition the interval between two mayor ticks into ten equally sized minor intervals. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] \begin{tikzpicture} \datavisualization [scientific axes={inner ticks, width=3cm}, @@ -2558,7 +2590,7 @@ \subsubsection{Reference: Basic Strategies} The minor steps are added in the same way as for |linear steps|. In particular, they interpolate \emph{linearly} between mayor steps. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] \begin{tikzpicture} \datavisualization [scientific axes, @@ -2607,7 +2639,7 @@ \subsubsection{Advanced: Defining New Placement Strategies} allows you to access the minimum and the maximum value stored in the |scaling mapper| of that axis. % -\begin{codeexample}[width=7cm] +\begin{codeexample}[width=7cm,preamble={\usetikzlibrary{datavisualization}}] \def\silly{ \tikzdatavisualizationset{major={at={ 2,3,5,7,11,13}}} @@ -2709,7 +2741,7 @@ \subsubsection{Creating the Axes} axes or ticks, but we will see the correct scaling of the attributes. Let us first define a data group: % -\begin{codeexample}[] +\begin{codeexample}[setup code] \tikz \datavisualization data group {people and money} = { data [set=people 1] { time, people @@ -2742,6 +2774,7 @@ \subsubsection{Creating the Axes} }; \end{codeexample} +\begin{codeexample}[setup code,hidden] \tikzdatavisualizationset{ our system/.style={ new Cartesian axis=x axis, @@ -2755,7 +2788,9 @@ \subsubsection{Creating the Axes} right axis={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}} } } -\begin{codeexample}[] +\end{codeexample} +% +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [ our system, x axis={attribute=time, length=4cm}, @@ -2809,7 +2844,7 @@ \subsubsection{Visualizing the Axes} attribute has attained along this axis. \item |max|: Like |min|. \item |padded min|: This will also set the \meta{attribute} - monitored by the axis to the same value as |min|. + monitored by the axis to the same value as |min|. Additionally, however, the subkey |/data point/|\meta{attribute}|/offset| is set to the current padding for the minimum, see the description of |padding min| @@ -2821,10 +2856,10 @@ \subsubsection{Visualizing the Axes} \end{key} The |right axis| would be visualized the same way, only at |goto=max|. The - $x$-axis actually need to be visualized \emph{twice}: Once at the bottom + $x$-axis actually needs to be visualized \emph{twice}: Once at the bottom and once at the top. Thus, we need to call |visualize axis| twice for this axis: -% + % \tikzdatavisualizationset{ our system/.style={ new Cartesian axis=x axis, @@ -2838,7 +2873,21 @@ \subsubsection{Visualizing the Axes} right axis={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}} } } -\begin{codeexample}[] +\begin{codeexample}[ + preamble={\usetikzlibrary{datavisualization}}, + pre={\tikzdatavisualizationset{ + our system/.style={ + new Cartesian axis=x axis, + new Cartesian axis=left axis, + new Cartesian axis=right axis, + x axis={attribute=x}, + left axis={unit vector={(0cm,1pt)}}, + right axis={unit vector={(0cm,1pt)}}, + x axis ={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/width}}, + left axis ={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}}, + right axis={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}} + } +}}] \tikzset{ data visualization/our system/.append style={ left axis= {visualize axis={x axis= {goto=min}}}, @@ -2878,7 +2927,21 @@ \subsubsection{Visualizing the Axes} corresponding to the fractional positions in the reasonable interval are not computed. % -\begin{codeexample}[] +\begin{codeexample}[ + preamble={\usetikzlibrary{datavisualization}}, + pre={\tikzdatavisualizationset{ + our system/.style={ + new Cartesian axis=x axis, + new Cartesian axis=left axis, + new Cartesian axis=right axis, + x axis={attribute=x}, + left axis={unit vector={(0cm,1pt)}}, + right axis={unit vector={(0cm,1pt)}}, + x axis ={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/width}}, + left axis ={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}}, + right axis={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}} + } +}}] \tikzset{ data visualization/our system/.append style={ x axis= {visualize axis={left axis={goto pos=0.25}}, @@ -2963,9 +3026,24 @@ \subsubsection{Visualizing the Axes} Recall that the |styling| key is set using the |style| key, see Section~\ref{section-dv-style}. % +% TODOsp: codeexamples: What is this empty `\tikzset` good for? \tikzset{ } -\begin{codeexample}[] +\begin{codeexample}[ + preamble={\usetikzlibrary{datavisualization}}, + pre={\tikzdatavisualizationset{ + our system/.style={ + new Cartesian axis=x axis, + new Cartesian axis=left axis, + new Cartesian axis=right axis, + x axis={attribute=x}, + left axis={unit vector={(0cm,1pt)}}, + right axis={unit vector={(0cm,1pt)}}, + x axis ={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/width}}, + left axis ={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}}, + right axis={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}} + } +}}] \tikzset{ data visualization/our system/.append style={ every axis/.style={style=black!50}, % make this the default @@ -3013,7 +3091,10 @@ \subsubsection{Visualizing the Axes} (because it starts at a smaller value). The standard axis systems set the padding to some default and take its value into account: % -\begin{codeexample}[width=8cm] +\begin{codeexample}[ + width=8cm, + preamble={\usetikzlibrary{datavisualization.formats.functions}}, +] \begin{tikzpicture} \datavisualization [scientific axes=clean, x axis={padding min=-1cm}, @@ -3028,7 +3109,30 @@ \subsubsection{Visualizing the Axes} Using padded and using the |padded| key, we can visualize our axis ``a little removed from the actual data'': % -\begin{codeexample}[] +\begin{codeexample}[ + preamble={\usetikzlibrary{datavisualization}}, + pre={\tikzdatavisualizationset{ + our system/.style={ + new Cartesian axis=x axis, + new Cartesian axis=left axis, + new Cartesian axis=right axis, + x axis={attribute=x}, + left axis={unit vector={(0cm,1pt)}}, + right axis={unit vector={(0cm,1pt)}}, + x axis ={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/width}}, + left axis ={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}}, + right axis={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}} + } +}% +\tikzset{ + data visualization/our system/.append style={ + every axis/.style={style=black!50}, % make this the default + left axis= {visualize axis={x axis= {goto=min}, style=red!75}}, + right axis={visualize axis={x axis= {goto=max}, style=blue!75}}, + x axis= {visualize axis={left axis={goto=min}}, + visualize axis={left axis={goto=max}}}, + } +}}] \tikzset{ data visualization/our system/.append style={ all axes= {padding=.5em}, @@ -3128,7 +3232,7 @@ \subsubsection{Visualizing Grid Lines} The |low| and |high| keys are the same as the ones used in the |visualize axis| key. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [ xyz Cartesian cabinet, all axes={visualize axis={low=0, style=->}}, @@ -3142,7 +3246,7 @@ \subsubsection{Visualizing Grid Lines} }; \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [ xyz Cartesian cabinet, all axes={visualize axis={low=0, style=->}, grid=many}, @@ -3183,7 +3287,7 @@ \subsubsection{Visualizing Grid Lines} lines -- are rather unlikely setting -- or when the styling should deviate from the usual settings. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] \tikz \datavisualization [ xy Cartesian, all axes={visualize axis={low=0, style=->}, @@ -3207,7 +3311,7 @@ \subsubsection{Visualizing Grid Lines} have the same range). For the other two axes, we visualize one grid independently of the other, using different colors. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] \tikzset{ data visualization/our system/.append style={ x axis= {visualize grid={direction axis=left axis}}, @@ -3242,7 +3346,7 @@ \subsubsection{Visualizing the Ticks and Tick Labels} at different places for the same axis. Consider for instance the |scientific axes|: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz \datavisualization [scientific axes, all axes={length=3cm}, x axis={ticks={stack}}, visualize as smooth line] @@ -3282,7 +3386,7 @@ \subsubsection{Visualizing the Ticks and Tick Labels} bottom and at the top. This corresponds to once setting the |left axis| to its minimal value and once to its maximal value: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] \tikzset{ data visualization/our system/.append style={ x axis={visualize ticks={direction axis=left axis, left axis={goto=min}}, @@ -3335,7 +3439,7 @@ \subsubsection{Visualizing the Ticks and Tick Labels} ticks the |low| value is |0pt|, while in the lower one the |high| value is |0pt|: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] \tikzset{ data visualization/our system/.append style={ x axis={ @@ -3375,7 +3479,7 @@ \subsubsection{Visualizing the Ticks and Tick Labels} Pass this option to |visualize ticks| when you want tick label nodes to be placed at the |low| position of each tick mark. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] \tikzset{ data visualization/our system/.append style={ x axis={ @@ -3403,7 +3507,7 @@ \subsubsection{Visualizing the Ticks and Tick Labels} \begin{key}{/tikz/data visualization/no tick text} Shorthand for |tick text at low=false, tick text at high=false|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz \datavisualization [scientific axes, all axes={length=3cm}, x axis={ticks={ major also at={6.5 as [no tick text]}}}, @@ -3457,7 +3561,7 @@ \subsubsection{Visualizing the Axis Labels} determine this position. Concerning the other axes, we want it to be placed at the minimum position of the |left axis| with a lot of padding. % -\begin{codeexample}[width=7cm] +\begin{codeexample}[width=7cm,preamble={\usetikzlibrary{datavisualization}}] \tikzdatavisualizationset{ our system/.append style={ x axis={visualize label={ @@ -3487,7 +3591,7 @@ \subsubsection{Visualizing the Axis Labels} be at the ``origin'', which is, however, the position computed by the |goto| keys for the axes: % -\begin{codeexample}[width=7cm] +\begin{codeexample}[width=7cm,preamble={\usetikzlibrary{datavisualization}}] \tikzdatavisualizationset{ our system/.append style={ x axis={visualize label={ @@ -3572,7 +3676,9 @@ \subsubsection{The Complete Axis System} }} \end{codeexample} -\tikzdatavisualizationset{ +\begin{codeexample}[ + preamble={\usetikzlibrary{datavisualization}}, + pre={\tikzdatavisualizationset{ our system/.style={ % The axes new Cartesian axis=x axis, @@ -3620,9 +3726,7 @@ \subsubsection{The Complete Axis System} right axis={goto pos=.5}, node style={ at={(0,0 -| data visualization bounding box.east)}, rotate=-90, anchor=south, blue!80!black}}}, } -} - -\begin{codeexample}[] +}}] \tikz \datavisualization [ our system, x axis={attribute=time, label=Year, diff --git a/doc/generic/pgf/text-en/pgfmanual-en-dv-examples.tex b/doc/generic/pgf/text-en/pgfmanual-en-dv-examples.tex index ce4c95a5e..a08a999b5 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-dv-examples.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-dv-examples.tex @@ -10,7 +10,7 @@ A first example: -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \begin{tikzpicture}[baseline] \datavisualization [ school book axes, @@ -37,7 +37,8 @@ }; \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] +% +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \begin{tikzpicture}[baseline] \datavisualization [ scientific axes=clean, @@ -58,9 +59,9 @@ 501, -2, 0 }; \end{tikzpicture} -\end{codeexample} +\end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}] \begin{tikzpicture}[baseline,mark=*] \datavisualization [ scientific axes=inner ticks, @@ -88,7 +89,7 @@ \end{codeexample} -%%% Local Variables: +%%% Local Variables: %%% mode: latex %%% TeX-master: "pgfmanual" -%%% End: +%%% End: 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 615048743..00b3ee1e9 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-dv-formats.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-dv-formats.tex @@ -120,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] { @@ -144,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}] { @@ -164,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] { @@ -186,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}, @@ -207,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] { @@ -307,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] { @@ -317,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}}, @@ -330,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 cd48bd5d6..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,7 +117,7 @@ \subsection{Concept: Visualization Pipeline} |scientific axes|, which selects a certain visualization pipeline that is appropriate for this kind of plot: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}] \begin{tikzpicture}[scale=.7] \datavisualization [school book axes, visualize as smooth line] data [format=function] { @@ -127,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 26a97fa4e..a0d57858f 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-dv-main.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-dv-main.tex @@ -75,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 { @@ -91,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] { @@ -173,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, @@ -187,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, @@ -216,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, @@ -230,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, @@ -275,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, @@ -418,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] { @@ -475,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]; @@ -487,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}}, @@ -535,7 +535,7 @@ \subsection{Usage} ``dummy'' data visualization is empty and used only for the definition of the data group. % -\begin{codeexample}[] +\begin{codeexample}[setup code] \tikz \datavisualization data group {points} = { data { x, y @@ -551,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}; @@ -593,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] { @@ -626,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 5d9f35180..31167b720 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-dv-polar.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-dv-polar.tex @@ -23,7 +23,13 @@ \subsection{Overview} direction) while a second attribute is used as a radius (a distance). The angle can be measured in degrees, radians, or can be scaled arbitrarily. % -\begin{codeexample}[width=8.5cm] +\begin{codeexample}[ + width=8.5cm, + preamble={\usetikzlibrary{ + datavisualization.formats.functions, + datavisualization.polar, +}}, +] \tikz \datavisualization [ scientific polar axes={0 to pi, clean}, all axes=grid, @@ -56,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}[] +\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}}, @@ -117,7 +126,13 @@ \subsection{Scientific Polar Axis System} attribute value zero is always placed at the center -- and for a logarithmic plot the value |0| cannot be mapped. % -\begin{codeexample}[width=8.8cm] +\begin{codeexample}[ + width=8.8cm, + preamble={\usetikzlibrary{ + datavisualization.formats.functions, + datavisualization.polar, +}}, +] \tikz \datavisualization [ scientific polar axes, radius axis={ @@ -151,7 +166,13 @@ \subsubsection{Tick Placements} This key, which is the default, causes ticks to be drawn ``outside'' the outer ``ring'' of the polar axes: % -\begin{codeexample}[width=8.8cm] +\begin{codeexample}[ + width=8.8cm, + preamble={\usetikzlibrary{ + datavisualization.formats.functions, + datavisualization.polar, +}}, +] \tikz \datavisualization [ scientific polar axes={outer ticks, 0 to 180}, visualize as smooth line] @@ -167,7 +188,13 @@ \subsubsection{Tick Placements} This key causes the ticks to be ``turned to the inside''. I do not recommend using this key. % -\begin{codeexample}[width=8.8cm] +\begin{codeexample}[ + width=8.8cm, + preamble={\usetikzlibrary{ + datavisualization.formats.functions, + datavisualization.polar, +}}, +] \tikz \datavisualization [ scientific polar axes={inner ticks, 0 to 180}, visualize as smooth line] @@ -184,7 +211,13 @@ \subsubsection{Tick Placements} ticks are shown. Usually, this is the best choice for the tick placement since it avoids a collision of data and explanations. % -\begin{codeexample}[width=8.8cm] +\begin{codeexample}[ + width=8.8cm, + preamble={\usetikzlibrary{ + datavisualization.formats.functions, + datavisualization.polar, +}}, +] \tikz \datavisualization [ scientific polar axes={clean, 0 to 180}, visualize as smooth line] @@ -241,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, @@ -343,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}, @@ -373,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}, @@ -394,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}, @@ -411,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 0e162cc1c..526992cf0 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-dv-stylesheets.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-dv-stylesheets.tex @@ -71,7 +71,7 @@ \subsection{Concepts: Style Sheets} For the following examples, let us first define a simple data set: % -\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]; @@ -92,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}, @@ -100,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}, @@ -129,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$}, @@ -142,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$}, @@ -176,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}, @@ -281,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. @@ -321,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} = { @@ -354,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, @@ -389,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}} } @@ -418,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}, @@ -452,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, @@ -533,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}, @@ -551,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}, @@ -575,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}, @@ -588,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}, @@ -616,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}, @@ -625,7 +924,35 @@ \subsection{Reference: Style Sheets for Scatter Plots} 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}, @@ -663,16 +990,72 @@ \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] -\tikz \datavisualization [ - visualize as smooth line/.list= - {1,2,3,4,5,6,7,8}, - example visualization, - style sheet=strong colors] -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}, + example visualization, + style sheet=strong colors] +data group {sin functions}; +\end{codeexample} + % +\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}, @@ -692,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}, @@ -706,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}, @@ -718,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}, @@ -732,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}, @@ -822,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$}, @@ -842,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$}, @@ -861,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$}, @@ -887,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}, @@ -930,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$}, @@ -964,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}, @@ -1009,7 +1594,28 @@ \subsubsection{Connecting a Label to a Data Set via a Pin} See the description of |pin angle|. \end{key} % -\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$}, @@ -1090,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= @@ -1115,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}, @@ -1139,11 +1787,32 @@ \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] -\tikz \datavisualization [ - scientific axes, x axis={label=$x$}, - visualize as smooth line/.list={log, lin, squared, exp}, - legend=below, +\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}, + legend=below, log= {label in legend={text=$\log x$}}, lin= {label in legend={text=$x/2$}}, squared={label in legend={text=$x^2$}}, @@ -1192,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= @@ -1256,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, @@ -1285,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, @@ -1295,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, @@ -1305,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, @@ -1315,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, @@ -1325,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, @@ -1335,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, @@ -1345,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, @@ -1365,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, @@ -1373,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, @@ -1381,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, @@ -1397,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, @@ -1405,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, @@ -1413,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, @@ -1441,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, @@ -1449,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, @@ -1457,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, @@ -1474,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, @@ -1482,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, @@ -1490,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, @@ -1540,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= @@ -1569,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= @@ -1592,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= @@ -1609,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= @@ -1627,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= @@ -1647,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= @@ -1663,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= @@ -1683,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= @@ -1703,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= @@ -1734,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= @@ -1796,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}, @@ -1823,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}, @@ -1839,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}, @@ -1897,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= @@ -1920,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= @@ -1945,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= @@ -1967,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= @@ -1997,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= @@ -2018,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= @@ -2096,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, @@ -2180,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, @@ -2189,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= @@ -2213,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, @@ -2251,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, @@ -2265,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, @@ -2279,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, @@ -2306,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}, @@ -2335,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}}]; @@ -2346,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, @@ -2363,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}, @@ -2377,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, @@ -2394,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}, @@ -2423,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}, @@ -2454,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}}, @@ -2467,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 3923339a1..2c6fc8481 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-dv-visualizers.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-dv-visualizers.tex @@ -70,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 { @@ -129,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, @@ -164,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, @@ -196,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}] @@ -236,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}, @@ -258,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, @@ -282,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}}, @@ -331,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}, @@ -379,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, @@ -410,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] @@ -435,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}] @@ -451,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}] @@ -472,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}] @@ -489,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}] @@ -507,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}] @@ -523,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}] @@ -540,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}}] @@ -562,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] @@ -715,6 +739,8 @@ \subsection{Advanced: Creating New Visualizers} Now, let's see how this works: +% TODOsp: codeexamples: This stuff is all needed for the next `codeexample` +% but cannot be stored (simply) in `setup code`, `preample` or `pre` \pgfooclass{circle visualizer} { % Stores the name of the visualizer. This is needed for filtering % and configuration @@ -765,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 39ecd659a..a1589109d 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-gd-overview.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-gd-overview.tex @@ -36,7 +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}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} +\usegdlibrary{trees}}] \tikz \graph [binary tree layout, level distance=5mm] { 4 -- { 3 -- 0 -- 1[second], @@ -48,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}}] @@ -88,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.spaced,graphs,graphdrawing} +\usegdlibrary{layered}}] \tikz [>=spaced stealth'] \graph [layered layout, components go right top aligned, nodes=draw, edges=rounded corners] { @@ -101,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{graphdrawing} +\usegdlibrary{trees}}] \tikz [grow'=up, binary tree layout, nodes={circle,draw}] \node {1} child { node {2} @@ -122,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,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 961f1e107..4f709b0a8 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 @@ -72,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} @@ -84,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 @@ -533,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}}; @@ -555,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{graphdrawing} +\usegdlibrary{trees}}] \begin{tikzpicture} \scoped [tree layout] \node {root} @@ -566,7 +569,8 @@ \subsection{Layout Keys} % Naturally, the above could have been written more succinctly as % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphdrawing} +\usegdlibrary{trees}}] \tikz [tree layout] \node {root} child { node {left child} } @@ -575,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 bbedfc01d..32cf24e59 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 @@ -89,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] { @@ -170,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} @@ -219,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{graphdrawing} +\usegdlibrary{force,trees}}] \tikz [spring layout] { \begin{scope}[tree layout] \node (a) {a}; @@ -258,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 }; @@ -270,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 }; @@ -294,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}; @@ -336,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 @@ -355,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] { @@ -377,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] { @@ -398,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} }; @@ -417,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} }; @@ -432,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} }; @@ -444,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-introduction.tex b/doc/generic/pgf/text-en/pgfmanual-en-introduction.tex index 7117552ef..424930106 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-introduction.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-introduction.tex @@ -238,7 +238,7 @@ \subsection{Getting Help} \item Read the manual, at least the part that has to do with your problem. \item If that does not solve the problem, try having a look at the - GitHub development page for \pgfname\ and \tikzname\ (see the + sourceforge development page for \pgfname\ and \tikzname\ (see the title of this document). Perhaps someone has already reported a similar problem and someone has found a solution. \item On the website you will find numerous forums for getting help. 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 76014f5e8..a8f91c730 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-3d.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-3d.tex @@ -15,6 +15,7 @@ \section{Three Dimensional Drawing Library} shapes. \end{tikzlibrary} + \subsection{Coordinate Systems} \begin{coordinatesystem}{xyz cylindrical} @@ -38,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); @@ -70,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); @@ -107,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)}, @@ -187,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] @@ -218,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 6f6c2e6ef..a011ea8b5 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-angles.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-angles.tex @@ -25,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} @@ -47,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) @@ -61,19 +61,19 @@ \section{Angle Library} following factor: % \begin{key}{/tikz/angle eccentricity=\meta{factor} (initially 0.6)} -\begin{codeexample}[] +\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}[] +\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}[] +\begin{codeexample}[preamble={\usetikzlibrary{angles,quotes}}] \tikz { \draw (2,0) coordinate (A) -- (0,0) coordinate (B) -- (1,1) coordinate (C) @@ -89,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 a0e73700f..b8241558e 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-automata.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-automata.tex @@ -43,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}[] +\begin{codeexample}[preamble={\usetikzlibrary{automata,positioning}}] \begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto] \draw[help lines] (0,0) grid (3,2); @@ -82,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); @@ -97,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$}; @@ -111,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}[] +\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}] @@ -166,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} @@ -236,7 +237,7 @@ \subsection{Initial and Accepting States} text. \end{stylekey} % -\begin{codeexample}[] +\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}, @@ -282,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}[] +\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}, @@ -304,7 +305,7 @@ \subsection{Examples} The next example is the current candidate for the five-state busiest beaver: % -\begin{codeexample}[] +\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-babel.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-babel.tex index dd8bb7b43..35d99396d 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-babel.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-babel.tex @@ -11,13 +11,13 @@ \section{Babel Library} \label{section-library-babel} -\begin{pgflibrary}{babel} +\begin{tikzlibrary}{babel} A tiny library that make the interaction with the |babel| package easier. Despite the name, it may also be useful in other contexts, namely whenever the catcodes of important symbols are changed globally. Normally, using this library is always a good idea; it is not always loaded by default since in some rare cases it may break old code. -\end{pgflibrary} +\end{tikzlibrary} The problems this library tries to fix have to do with the so-called ``catcodes'' of symbols used inside \tikzname. In normal \TeX\ operation, 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 b24a38860..7755003fb 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-backgrounds.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-backgrounds.tex @@ -30,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); @@ -62,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} @@ -84,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} @@ -130,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}, @@ -142,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}, @@ -163,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} @@ -174,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] @@ -186,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] @@ -205,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] @@ -218,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, @@ -238,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,% @@ -254,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 6d1f3a3f4..2696fe196 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-calendar.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-calendar.tex @@ -101,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} @@ -116,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} @@ -125,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} @@ -137,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} @@ -169,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) @@ -195,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} @@ -217,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]; @@ -231,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} @@ -255,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} @@ -266,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} @@ -280,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} @@ -305,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-]; @@ -385,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] @@ -394,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] @@ -407,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] @@ -496,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= @@ -523,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, @@ -555,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, @@ -583,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 @@ -619,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]; @@ -630,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]; @@ -643,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]; @@ -675,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]; @@ -701,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, @@ -730,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, @@ -743,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, @@ -758,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, @@ -770,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, @@ -785,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]; @@ -804,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]; @@ -821,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]; @@ -834,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]; @@ -845,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]; @@ -863,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] +\begin{codeexample}[ + leave comments, + preamble={\usetikzlibrary{calendar,shapes.misc}}, +] \begin{tikzpicture} \calendar [ @@ -882,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] +\begin{codeexample}[ + leave comments, + preamble={\usetikzlibrary{calendar,shapes.misc}}, +] \begin{tikzpicture} \calendar [ @@ -904,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} @@ -952,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 da8387415..1dc247866 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-chains.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-chains.tex @@ -74,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}; @@ -83,7 +83,7 @@ \subsection{Starting and Continuing a Chain} \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{chains,scopes}}] \begin{tikzpicture} % Same as above, using the scope shorthand { [start chain] @@ -94,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, @@ -123,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}; @@ -136,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}[] +\begin{codeexample}[preamble={\usetikzlibrary{chains,scopes}}] \begin{tikzpicture}[node distance=5mm, every node/.style=draw] { [start chain=1] @@ -231,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}; @@ -252,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}; @@ -263,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}; @@ -275,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}; @@ -326,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); @@ -347,7 +347,7 @@ \subsection{Nodes on a Chain} connected using a chain % {\catcode`\|=12 -\begin{codeexample}[] +\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] { @@ -391,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] {}; @@ -438,7 +438,7 @@ \subsection{Branches} to the fork node. \end{itemize} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{chains,scopes}}] \begin{tikzpicture}[every on chain/.style=join,every join/.style=->, node distance=2mm and 1cm] { [start chain=trunk] @@ -473,7 +473,7 @@ \subsection{Branches} chain}|/|\meta{branch name} is used as the chain name, rather than just \meta{branch name}. % -\begin{codeexample}[] +\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 c211fa49c..4ee105da6 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-circuits.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-circuits.tex @@ -22,11 +22,23 @@ \subsection{Introduction} of libraries that work in concert. The main design goal was to create a balance between ease-of-use and ease-of-extending, while creating high-quality graphical representations of circuits. +% +\begin{codeexample}[setup code,hidden] +\tikzset{ + % from `shape` library + shape example/.style= {color = black!30, + draw, + fill = yellow!30, + line width = .5cm, + inner xsep = 2.5cm, + inner ysep = 0.5cm} +} +\end{codeexample} \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, @@ -203,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] { @@ -223,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] { @@ -255,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); @@ -290,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] @@ -326,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); @@ -373,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}] @@ -458,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); @@ -488,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} @@ -503,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} @@ -511,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} @@ -519,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} @@ -527,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} @@ -558,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} @@ -570,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) {}; @@ -587,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); @@ -600,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); @@ -612,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); @@ -642,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} @@ -709,7 +721,13 @@ \subsubsection{Declaring and Using Annotations} {8pt} {(0pt,8pt) arc (-270:80:3.5pt)} } -\begin{codeexample}[] +\begin{codeexample}[ + preamble={\usetikzlibrary{circuits.ee.IEC}} + pre={\tikzset{circuit declare annotation= + {circular annotation} + {8pt} + {(0pt,8pt) arc (-270:80:3.5pt)} +}}] \tikz[circuit ee IEC] \draw (0,0) to [resistor={circular annotation}] (3,0); \end{codeexample} @@ -719,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)}] ()} } @@ -738,7 +756,12 @@ \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} + {(0pt,8pt) arc (-270:80:3.5pt)} +}}] \tikz[circuit ee IEC] \draw (0,0) to [resistor={circular annotation,ohm=5}] (2,0) to [resistor={circular annotation={ohm=5}}] (4,0); @@ -765,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}, @@ -784,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); @@ -801,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); @@ -818,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); @@ -826,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); @@ -864,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); @@ -923,7 +946,7 @@ \subsubsection{Overview} Since the |circuits.logic| library does not define any actual graphics, you need to use one of the following libraries, instead: -\begin{pgflibrary}{circuits.logic.IEC} +\begin{tikzlibrary}{circuits.logic.IEC} This library provides graphics based on gates recommended by the International Electrotechnical Commission. When you include this library, you can use the following key to set up a scope that contains a logical @@ -938,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, @@ -961,9 +984,9 @@ \subsubsection{Overview} \end{tikzpicture} \end{codeexample} \end{key} -\end{pgflibrary} +\end{tikzlibrary} -\begin{pgflibrary}{circuits.logic.US} +\begin{tikzlibrary}{circuits.logic.US} This library provides graphics showing ``American'' logic gates. It defines the following key: @@ -977,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={ @@ -1000,9 +1023,9 @@ \subsubsection{Overview} \end{tikzpicture} \end{codeexample} \end{key} -\end{pgflibrary} +\end{tikzlibrary} -\begin{pgflibrary}{circuits.logic.CDH} +\begin{tikzlibrary}{circuits.logic.CDH} This library provides graphics based on the logic symbols used in A. Croft, R. Davidson, and M. Hargreaves (1992), \emph{Engineering Mathematics}, Addison-Wesley, 82--95. They are identical to the US-style symbols, except @@ -1013,7 +1036,7 @@ \subsubsection{Overview} nand-gates, that is, it uses |set and gate graphic| with |and gate CDH graphic| and likewise for nand-gates. \end{key} -\end{pgflibrary} +\end{tikzlibrary} Inside |circuit logic XYZ| scopes, you can now use the keys shown in Section~\ref{section-logic-symbols}. We have a more detailed look at one of @@ -1025,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$}; @@ -1055,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} @@ -1133,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) {}; @@ -1150,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} @@ -1176,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}; @@ -1190,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}} @@ -1235,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} @@ -1274,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, @@ -1376,7 +1399,7 @@ \subsubsection{Implementation: The IEC-Style Logic Gates Shape Library} node and the outer edge of the symbol is determined by the values of the |inner xsep| and |inner ysep|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.gates.logic.IEC}}] \begin{tikzpicture}[minimum size=1cm, use IEC style logic gates] \tikzset{every node/.style={nor gate, draw}} \node (A) at (0,1.5) {}; @@ -1418,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, @@ -1503,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} @@ -1512,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} @@ -1521,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} @@ -1531,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) {}; @@ -1561,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); @@ -1594,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); @@ -1627,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} @@ -1644,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); @@ -1925,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] {}; @@ -1939,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, @@ -1982,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} @@ -2002,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 @@ -2032,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}} @@ -2053,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 @@ -2082,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 @@ -2108,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 @@ -2130,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] {}; @@ -2150,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} @@ -2161,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} @@ -2173,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 @@ -2193,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} @@ -2204,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 60a4801c7..91ce2fd87 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-decorations.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-decorations.tex @@ -131,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] @@ -155,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] @@ -177,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); @@ -198,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] @@ -219,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] @@ -246,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}; @@ -274,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] @@ -303,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] @@ -311,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); @@ -332,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] @@ -352,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] @@ -388,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}] @@ -410,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); @@ -430,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); @@ -458,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); @@ -479,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); @@ -494,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={ @@ -566,7 +566,7 @@ \subsection{Path Replacing Decorations} \end{command} % {\tikzexternaldisable -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathreplacing,shapes.misc}}] \tikzset{ show curve controls/.style={ decoration={ @@ -642,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 @@ -661,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 @@ -721,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};, @@ -736,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={ @@ -789,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); @@ -803,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}[] +\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, @@ -817,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, @@ -833,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 @@ -880,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 @@ -890,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 @@ -917,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};}, @@ -930,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}}, @@ -960,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); @@ -974,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} @@ -985,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} @@ -996,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} @@ -1006,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} @@ -1072,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); @@ -1093,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); @@ -1115,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}[] +\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}[] +\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}}} @@ -1144,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}[] +\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); @@ -1165,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}[] +\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}, @@ -1192,7 +1193,7 @@ \subsubsection{Shape Background Markings} shapes or between the edges of the \emph{boundaries} of the shape borders. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.shapes,shapes.symbols}}] \begin{tikzpicture}[ decoration={shape backgrounds,shape size=.5cm,shape=signal}, signal from=west, signal to=east, @@ -1218,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={ @@ -1243,7 +1244,7 @@ \subsubsection{Shape Background Markings} Internally this sets the \TeX-if |\ifpgfshapedecorationsloped| accordingly. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.shapes,shapes.geometric}}] \tikzset{ paint/.style={draw=#1!50!black, fill=#1!50} } @@ -1265,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}}, @@ -1301,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}}, @@ -1346,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}}] @@ -1397,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); @@ -1412,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, @@ -1438,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={[}{]}, @@ -1457,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, ->] @@ -1480,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] @@ -1521,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] @@ -1538,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] @@ -1556,7 +1557,7 @@ \subsection{Text Decorations} options (such as |text|, |scale| and |opacity|) can be used to create `text effects'. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text,math}}] \bfseries\large \begin{tikzpicture}[decoration={text effects along path, text={text effects along path!}, text align=center, @@ -1572,8 +1573,8 @@ \subsection{Text Decorations} \end{tikzpicture} \end{codeexample} - There are some important differences between this decoration and the |text - along path| decoration: + There are some important differences between this decoration and the + |text along path| decoration: % \begin{itemize} \item formatting (e.g., font and color) cannot be specified in the @@ -1606,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, @@ -1620,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, @@ -1664,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!}}] @@ -1741,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, @@ -1765,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, @@ -1783,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}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.text,math}}] \begin{tikzpicture}[decoration={text effects along path, text={text effects along path!}, text effects/.cd, @@ -1802,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, @@ -1825,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, @@ -1850,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, @@ -1870,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, @@ -1888,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, @@ -1905,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}}] @@ -1924,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}}] @@ -1944,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, @@ -1964,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, @@ -1984,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, @@ -2004,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, @@ -2031,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, @@ -2051,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!}, @@ -2075,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, @@ -2105,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) }}; @@ -2119,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) }}; @@ -2133,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) }}; @@ -2148,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 09666bece..08cb5934a 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-edges.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-edges.tex @@ -129,7 +129,7 @@ \subsection{Curves} If no \meta{angle} is given, the last given |bend left| or |bend right| angle is used. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{automata,positioning}}] \begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid] \node[state,initial] (q_0) {$q_0$}; \node[state] (q_1) [right=of q_0] {$q_1$}; 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 691d4e1d7..28939c1a5 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-er.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-er.tex @@ -34,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}[] +\begin{codeexample}[preamble={\usetikzlibrary{er,positioning}}] \begin{tikzpicture} \node[entity] (sheep) {Sheep}; \node[entity] (genome) [right=of sheep] {Genome}; @@ -47,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}[] +\begin{codeexample}[preamble={\usetikzlibrary{er,positioning}}] \begin{tikzpicture} [every entity/.style={draw=blue!50,fill=blue!20,thick}] \node[entity] (sheep) {Sheep}; @@ -67,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}; @@ -82,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}] @@ -104,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}} @@ -112,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} @@ -130,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 1e0fbbd8f..d528a2a4e 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-fit.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-fit.tex @@ -38,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); @@ -92,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); @@ -109,7 +109,7 @@ \section{Fitting Library} Here is a real-life example that uses fitting: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{fit,shapes.geometric}}] \begin{tikzpicture} [vertex/.style={minimum size=2pt,fill,draw,circle}, open/.style={fill=none}, @@ -144,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 238d0c16a..968db32b7 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-fixedpoint.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-fixedpoint.tex @@ -86,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 cd9092874..7deff0a55 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-folding.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-folding.tex @@ -18,7 +18,10 @@ \section{Paper-Folding Diagrams Library} Here is a big example that produces a diagram for a calendar: % -\begin{codeexample}[leave comments] +\begin{codeexample}[ + leave comments, + preamble={\usetikzlibrary{calendar,folding}}, +] \sffamily\scriptsize \tikz \pic [ transform shape, @@ -78,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, @@ -99,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, @@ -118,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} @@ -128,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} @@ -138,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} @@ -148,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} @@ -158,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} @@ -168,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} @@ -178,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} @@ -188,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} @@ -198,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} @@ -208,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} @@ -218,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} @@ -228,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} @@ -238,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 bdc58135e..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,8 +21,8 @@ \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} @@ -32,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.}% @@ -56,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} @@ -73,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} @@ -97,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} @@ -106,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} @@ -115,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} @@ -357,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!} @@ -650,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 c46b8ed5f..7d83ccb75 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-lsystems.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-lsystems.tex @@ -25,7 +25,10 @@ \subsection{Overview} 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} @@ -39,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, @@ -239,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. @@ -268,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} @@ -352,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} @@ -365,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 d090ccae9..afd853200 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-math.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-math.tex @@ -50,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) { @@ -82,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; @@ -96,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} @@ -116,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{ @@ -132,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; } @@ -142,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; } @@ -167,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; @@ -196,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; @@ -214,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; @@ -249,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); @@ -261,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); @@ -277,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); @@ -307,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; @@ -330,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; @@ -362,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; @@ -405,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; @@ -438,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); @@ -458,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 5eaed540f..d32d54547 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-matrices.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-matrices.tex @@ -31,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] { @@ -51,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] { @@ -67,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] { @@ -86,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] { @@ -103,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] { @@ -122,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] { @@ -140,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}] { @@ -151,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] { @@ -206,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}] { @@ -215,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}] { @@ -247,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=\}] { @@ -258,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$}; @@ -273,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}] @@ -300,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 47bc68db8..8c2ff1a18 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-mindmaps.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-mindmaps.tex @@ -48,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}}; @@ -61,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}}; @@ -121,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} @@ -152,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}; @@ -175,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] @@ -190,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}, @@ -225,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}} @@ -235,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= @@ -267,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}[] +\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}, @@ -321,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); @@ -336,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}] @@ -357,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}] @@ -402,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] {}; @@ -428,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] {}; @@ -459,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} @@ -498,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-patterns.tex b/doc/generic/pgf/text-en/pgfmanual-en-library-patterns.tex index d714b8fa8..281dee5b5 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-patterns.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-patterns.tex @@ -81,272 +81,6 @@ \subsection{Inherently Colored Patterns} \patternindexinherentlycolored{crosshatch dots light steel blue} \end{tabular} -\subsection{User-Defined Patterns} -\label{section-library-patterns-meta} - -\noindent\emph{by Mark Wibrow} - -\begin{pgflibrary}{patterns.meta} - Define your own patterns with a syntax similar to |arrows.meta|. -\end{pgflibrary} - -\emph{Caveat:} This library is currently experimental and might change without -notice. There are some known shortcomings that will hopefully be fixed in the -future. - -\begin{command}{\pgfdeclarepattern\marg{config}} - This command is used to declare a new pattern. In contrast to the normal - patterns and in the spirit of |arrows.meta| this command takes a list of - keys and values to define the pattern. The following keys are available: - % -\begin{key}{/pgf/patterns/name=\meta{name}} - The name of the pattern by which it can be used later on. -\end{key} - % -\begin{key}{/pgf/patterns/type=\meta{type} (default uncolored)} - The type of the pattern maps to what was called ``form only'' and ``inherently colored'' in the language of the normal patterns. - The available choices are: - \begin{itemize} - \item |uncolored| the pattern will obey the surrounding color. - \item |colored| the pattern will have an intrinsic color. - \item |form only| synonym for |uncolored| - \item |inherently colored| synonym for |colored| - \end{itemize} -\end{key} - % -\begin{key}{/pgf/patterns/x=\meta{dimension} (default 1cm)} - Unit vector of the coordinate system in the $x$-direction. -\end{key} - % -\begin{key}{/pgf/patterns/y=\meta{dimension} (default 1cm)} - Unit vector of the coordinate system in the $y$-direction. -\end{key} - % -\begin{key}{/pgf/patterns/parameters=\meta{comma separated list} (default empty)} - A list of parameters that are passed to the pattern. This is usually a - list of TeX macros. It is very important that these macros are fully - expandable because the values they hold are being used for deduplication in - the PDF file. -\end{key} - % -\begin{key}{/pgf/patterns/defaults=\meta{comma separated list} (default empty)} - This list holds default assignments to the parameters passed to the - pattern. The default keys can then be found under the |/pgf/pattern keys/| - prefix. -\end{key} - % -\begin{key}{/pgf/patterns/bottom left=\meta{pgfpoint}} - Bottom left corner of the pattern's bounding box, e.g.\ - |\pgfqpoint{-.1pt}{-.1pt}|. -\end{key} - % -\begin{key}{/pgf/patterns/top right=\meta{pgfpoint}} - Top right corner of the pattern's bounding box, e.g.\ - |\pgfqpoint{3.1pt}{3.1pt}|. -\end{key} - % -\begin{key}{/pgf/patterns/tile size=\meta{pgfpoint}} - Width and height of a single of the pattern as a \pgfname\ point - specification, i.e. the $x$ coordinate is the width and the $y$ coordinate - is the height, e.g.\ |\pgfqpoint{3pt}{3pt}|. -\end{key} - % -\begin{key}{/pgf/patterns/tile transformation=\meta{pgftransformation} (default empty)} - A \pgfname\ transformation, e.g.\ |\pgftransformrotate{30}|. -\end{key} - % -\begin{key}{/pgf/patterns/code=\meta{code}} - The code should be \pgfname\ code than can be protocolled. It should not - contain any color code or nodes. -\end{key} - % -\begin{key}{/pgf/patterns/set up code=\meta{code} (default empty)} - This code can be set if parameters have to be preprocessed before the - actual pattern code can be run. -\end{key} - % -\end{command} - -\begin{codeexample}[preamble={\usetikzlibrary{patterns.meta}}] -\pgfdeclarepattern{ - name=hatch, - parameters={\hatchsize,\hatchangle,\hatchlinewidth}, - bottom left={\pgfpoint{-.1pt}{-.1pt}}, - top right={\pgfpoint{\hatchsize+.1pt}{\hatchsize+.1pt}}, - tile size={\pgfpoint{\hatchsize}{\hatchsize}}, - tile transformation={\pgftransformrotate{\hatchangle}}, - code={ - \pgfsetlinewidth{\hatchlinewidth} - \pgfpathmoveto{\pgfpoint{-.1pt}{-.1pt}} - \pgfpathlineto{\pgfpoint{\hatchsize+.1pt}{\hatchsize+.1pt}} - \pgfpathmoveto{\pgfpoint{-.1pt}{\hatchsize+.1pt}} - \pgfpathlineto{\pgfpoint{\hatchsize+.1pt}{-.1pt}} - \pgfusepath{stroke} - } -} - -\tikzset{ - hatch size/.store in=\hatchsize, - hatch angle/.store in=\hatchangle, - hatch line width/.store in=\hatchlinewidth, - hatch size=5pt, - hatch angle=0pt, - hatch line width=.5pt, -} - -\begin{tikzpicture} -\foreach \r in {1,...,4} - \draw [pattern=hatch, pattern color=red] - (\r*3,0) rectangle ++(2,2); - -\foreach \r in {1,...,4} - \draw [pattern=hatch, pattern color=green, hatch size=2pt] - (\r*3,3) rectangle ++(2,2); - -\foreach \r in {1,...,4} - \draw [pattern=hatch, pattern color=blue, hatch size=10pt, hatch angle=21] - (\r*3,6) rectangle ++(2,2); - -\foreach \r in {1,...,4} - \draw [pattern=hatch, pattern color=orange, hatch line width=2pt] - (\r*3,9) rectangle ++(2,2); -\end{tikzpicture} -\end{codeexample} - -\begin{command}{\tikzdeclarepattern\marg{config}} - A pattern declared with |\pgfdeclarepattern| can only execute \pgfname\ - code. This command extends the functionality to also allow \tikzname\ - code. All the same keys of |\pgfdeclarepattern| are valid, but some of - them have been overloaded to give a more natural \tikzname\ syntax. - % -\begin{key}{/tikz/patterns/bottom left=\meta{point}} - Instead of a \pgfname\ name point, this key takes a \tikzname\ point, e.g.\ - |(-.1,-.1)|. -\end{key} - % -\begin{key}{/tikz/patterns/top right=\meta{point}} - Instead of a \pgfname\ name point, this key takes a \tikzname\ point, e.g.\ - |(3.1,3.1)|. -\end{key} - % -\begin{key}{/tikz/patterns/tile size=\meta{point}} - Instead of a \pgfname\ name point, this key takes a \tikzname\ point, e.g.\ - |(3,3)|. -\end{key} - % -\begin{key}{/tikz/patterns/tile transformation=\meta{transformation}} - Instead of a \pgfname\ transformation, this key takes a list of keys and - value and extracts the resulting transformation from them, e.g.\ - |rotate=30|. -\end{key} - - In addition to the overloaded keys, some new keys have been added. - % -\begin{key}{/tikz/patterns/bounding box=\meta{point} and \meta{point}} - This is a shorthand to set the bounding box. It will assign the first - point to |bottom left| and the second point to |top right|. -\end{key} - % -\begin{key}{/tikz/patterns/infer tile bounding box=\meta{dimension} (default 0pt)} - Instead of specifying the bounding box by hand, you can ask \tikzname\ to - infer the size of the bounding box for you. The \meta{dimension} parameter - is padding that is added around the bounding box. -\end{key} - % -\end{command} - -\begin{codeexample}[preamble={\usetikzlibrary{patterns.meta}}] -\tikzdeclarepattern{ - name=flower, - type=colored, - bottom left={(-.1pt,-.1pt)}, - top right={(10.1pt,10.1pt)}, - tile size={(10pt,10pt)}, - code={ - \tikzset{x=1pt,y=1pt} - \path [draw=green] (5,2.5) -- (5, 7.5); - \foreach \i in {0,60,...,300} - \path [fill=pink, shift={(5,7.5)}, rotate=-\i] - (0,0) .. controls ++(120:4) and ++(60:4) .. (0,0); - \path [fill=red] (5,7.5) circle [radius=1]; - \foreach \i in {-45,45} - \path [fill=green, shift={(5,2.5)}, rotate=-\i] - (0,0) .. controls ++(120:4) and ++(60:4) .. (0,0); - } -} - -\tikz\draw [pattern=flower] circle [radius=1]; -\end{codeexample} - -\begin{codeexample}[preamble={\usetikzlibrary{patterns.meta}}] -\tikzdeclarepattern{ - name=Stars, - type=uncolored, - bounding box={(-5pt,-5pt) and (5pt,5pt)}, - tile size={(\tikztilesize,\tikztilesize)}, - parameters={\tikzstarpoints,\tikzstarradius,\tikzstarrotate,\tikztilesize}, - tile transformation={rotate=\tikzstarrotate}, - defaults={ - points/.store in=\tikzstarpoints,points=5, - radius/.store in=\tikzstarradius,radius=3pt, - rotate/.store in=\tikzstarrotate,rotate=0, - tile size/.store in=\tikztilesize,tile size=10pt, - }, - code={ - \pgfmathparse{180/\tikzstarpoints}\let\a=\pgfmathresult - \fill (90:\tikzstarradius) \foreach \i in {1,...,\tikzstarpoints}{ - -- (90+2*\i*\a-\a:\tikzstarradius/2) -- (90+2*\i*\a:\tikzstarradius) - } -- cycle; - } -} - -\begin{tikzpicture} - \draw[pattern=Stars,pattern color=blue] (0,0) rectangle ++(2,2); - \draw[pattern={Stars[points=7,tile size=15pt]}] (2,0) rectangle ++(2,2); - \draw[pattern={Stars[rotate=45]},pattern color=red] (0,2) rectangle ++(2,2); - \draw[pattern={Stars[rotate=30,points=4,radius=5pt]}] (2,2) rectangle ++(2,2); -\end{tikzpicture} -\end{codeexample} - -Instead of macros you can also use \pgfname\ keys as parameters, if that is -what you prefer. -\begin{codeexample}[preamble={\usetikzlibrary{patterns.meta}}] -\tikzdeclarepattern{ - name=lines, - parameters={ - \pgfkeysvalueof{/pgf/pattern keys/size}, - \pgfkeysvalueof{/pgf/pattern keys/angle}, - \pgfkeysvalueof{/pgf/pattern keys/line width}, - }, - bounding box={(-.1pt,-.1pt) and - (\pgfkeysvalueof{/pgf/pattern keys/size}+.1pt, - \pgfkeysvalueof{/pgf/pattern keys/size}+.1pt)}, - tile size={(\pgfkeysvalueof{/pgf/pattern keys/size}, - \pgfkeysvalueof{/pgf/pattern keys/size})}, - tile transformation={rotate=\pgfkeysvalueof{/pgf/pattern keys/angle}}, - defaults={ - size/.initial=5pt, - angle/.initial=0, - line width/.initial=.4pt, - }, - code={ - \draw[line width=\pgfkeysvalueof{/pgf/pattern keys/line width}] - (0,0) -- (\pgfkeysvalueof{/pgf/pattern keys/size}, - \pgfkeysvalueof{/pgf/pattern keys/size}); - } -} - -\begin{tikzpicture} - \draw[pattern={lines[size=10pt,line width=.8pt,angle=10]}, - pattern color=red] (0,0) rectangle ++(2,2); - \draw[pattern={lines[size= 5pt,line width=.8pt,angle=40]}, - pattern color=blue] (2,0) rectangle ++(2,2); - \draw[pattern={lines[size=10pt,line width=.4pt,angle=90]}, - pattern color=green] (0,2) rectangle ++(2,2); - \draw[pattern={lines[size= 2pt,line width= 1pt,angle=70]}, - pattern color=orange] (2,2) rectangle ++(2,2); -\end{tikzpicture} -\end{codeexample} %%% Local Variables: %%% mode: latex 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 61ed10179..3d5c9b127 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-perspective.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-perspective.tex @@ -1,3 +1,4 @@ + \section{Three Point Perspective Drawing Library} \noindent\emph{by Max Snippe} @@ -7,6 +8,7 @@ \section{Three Point Perspective Drawing Library} vanishing points. \end{tikzlibrary} + \subsection{Coordinate Systems} \begin{coordinatesystem}{three point perspective} @@ -32,6 +34,7 @@ \subsection{Coordinate Systems} coordinate system. \end{coordinatesystem} + \subsection{Setting the view} \begin{key}{/tikz/3d view=\marg{azimuth}\marg{elevation} @@ -74,7 +77,8 @@ \subsection{Setting the view} For example, when both \meta{azimuth} and \meta{elevation} are 0$^\circ$, $+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}; @@ -88,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}; @@ -97,8 +102,14 @@ \subsection{Setting the view} \end{codeexample} \end{stylekey} + \subsection{Defining the perspective} +In this section, the following example cuboid will be used with various +scaling. As a reference, the axes will be shown too, without perspective +projection. +% +\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) @@ -112,18 +123,18 @@ \subsection{Defining the perspective} -- (tpp cs:x=0,y=0,z=#3) -- (tpp cs:x=#1,y=0,z=#3) -- (tpp cs:x=#1,y=0,z=0) -- cycle;} - \newcommand{\simpleaxes}[3]{% \draw[->] (-0.5,0,0) -- (#1,0,0) node[pos=1.1]{x}; \draw[->] (0,-0.5,0) -- (0,#2,0) node[pos=1.1]{y}; \draw[->] (0,0,-0.5) -- (0,0,#3) node[pos=1.1]{z};} -In this section, the following example cuboid will be used with various scaling. -As a reference, the axes will be shown too, without perspective projection. -\begingroup -\let\simplecuboid\relax -\let\simpleaxes\relax -\begin{codeexample}[] +\begin{tikzpicture}[3d view] + \simplecuboid{2}{2}{2} + \simpleaxes{2}{2}{2} +\end{tikzpicture} +\end{codeexample} + +\begin{codeexample}[setup code,hidden] \newcommand\simplecuboid[3]{% \fill[gray!80!white] (tpp cs:x=0,y=0,z=#3) -- (tpp cs:x=0,y=#2,z=#3) @@ -137,36 +148,34 @@ \subsection{Defining the perspective} -- (tpp cs:x=0,y=0,z=#3) -- (tpp cs:x=#1,y=0,z=#3) -- (tpp cs:x=#1,y=0,z=0) -- cycle;} + \newcommand{\simpleaxes}[3]{% \draw[->] (-0.5,0,0) -- (#1,0,0) node[pos=1.1]{x}; \draw[->] (0,-0.5,0) -- (0,#2,0) node[pos=1.1]{y}; \draw[->] (0,0,-0.5) -- (0,0,#3) node[pos=1.1]{z};} - -\begin{tikzpicture}[3d view] - \simplecuboid{2}{2}{2} - \simpleaxes{2}{2}{2} -\end{tikzpicture} \end{codeexample} -\endgroup \begin{key}{/tikz/perspective=\meta{vanishing points} (default p=\{(10,0,0)\},q=\{(0,10,0)\},r=\{(0,0,20)\})} The `strength' of the perspective can be determined by setting the location of 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} \end{tikzpicture} \end{codeexample} +% From this example it also shows that the maximum dimensions of the cuboid are no longer 2 by 2 by 2. This is inherent to the perspective projection. % \begin{key}{/tikz/perspective/p=\marg{x,y,z} (initially (0,0,0))} 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={ @@ -175,6 +184,7 @@ \subsection{Defining the perspective} \simpleaxes{2}{2}{2} \end{tikzpicture} \end{codeexample} + % Note also that when only |p| is provided, the perspective in $y$ and $z$ direction is turned off. @@ -185,7 +195,8 @@ \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={ @@ -194,7 +205,8 @@ \subsection{Defining the perspective} \simpleaxes{2}{2}{2} \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] + % +\begin{codeexample}[preamble={\usetikzlibrary{perspective}}] \begin{tikzpicture}[ 3d view, perspective={ @@ -203,7 +215,8 @@ \subsection{Defining the perspective} \simpleaxes{2}{2}{2} \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] + % +\begin{codeexample}[preamble={\usetikzlibrary{perspective}}] \begin{tikzpicture}[ 3d view, perspective={ @@ -212,12 +225,14 @@ \subsection{Defining the perspective} \simpleaxes{2}{2}{2} \end{tikzpicture} \end{codeexample} + % \end{key} % \begin{key}{/tikz/perspective/q=\marg{x,y,z} (initially (0,0,0))} 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={ @@ -226,12 +241,14 @@ \subsection{Defining the perspective} \simpleaxes{2}{2}{2} \end{tikzpicture} \end{codeexample} + % \end{key} % \begin{key}{/tikz/perspective/r=\marg{x,y,z} (initially (0,0,0))} 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={ @@ -240,29 +257,36 @@ \subsection{Defining the perspective} \simpleaxes{2}{2}{2} \end{tikzpicture} \end{codeexample} + % \end{key} \end{key} + \subsection{Shortcomings} - Currently a number of things are not working, mostly due to the fact that PGF - uses a 2D coordinate system underwater, and perspective projection is a - non-linear affine transformation which needs to be aware of all three - coordinates. These three coordinates are currently lost when processing a 3D - coordinate. - The issues include, but possibly are not limited to: - \begin{itemize} + +Currently a number of things are not working, mostly due to the fact that PGF +uses a 2D coordinate system underwater, and perspective projection is a +non-linear affine transformation which needs to be aware of all three +coordinates. These three coordinates are currently lost when processing a 3D +coordinate. +The issues include, but possibly are not limited to: +% +\begin{itemize} \item Keys like |shift|, |xshift|, |yshift| are not working \item Keys like |rotate around x|, |rotate around y|, and |rotate around z| are not working \item Units are not working \item Most keys from the |3d| library are unsupported, e.g. all the |canvas is .. plane| keys. - \end{itemize} +\end{itemize} + \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={ @@ -278,8 +302,9 @@ \subsection{Examples} A peculiar phenomenon inherent to perspective drawing, is that however great your coordinate will become in the direction of the vanishing point, it will never reach it. +% \nopagebreak -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{perspective}}] \begin{tikzpicture}[ isometric view, perspective={ @@ -300,8 +325,9 @@ \subsection{Examples} Even for simple examples, the added perspective might add another `dimension' to your drawing. In this case, two vanishing points give a more intuitive result then three would. +% \nopagebreak -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{perspective}}] \begin{tikzpicture}[ scale=0.7, 3d view, @@ -327,8 +353,9 @@ \subsection{Examples} With the vanishing points nearby, the distortion of parallel lines becomes very strong. This might lead to \texttt{Dimension too large} errors. +% \nopagebreak -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{perspective}}] \begin{tikzpicture}[ 3d view, perspective={ @@ -363,8 +390,9 @@ \subsection{Examples} Of course these examples can become as complex as desired, but as with any 3D drawing using \tikzname, the order of drawing commands is important and can become increasingly more complex. +% \nopagebreak -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{perspective}}] \begin{tikzpicture}[ cycle of vertices/.style 2 args={ insert path={ @@ -415,4 +443,4 @@ \subsection{Examples} \end{scope} \end{tikzpicture} \end{codeexample} -\fi \ No newline at end of file +\fi 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 ccf035609..87397dba3 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-petri.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-petri.tex @@ -26,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) {}; @@ -37,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) {}; @@ -61,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) {}; @@ -112,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) {}; @@ -143,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] @@ -166,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] @@ -181,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] @@ -206,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] @@ -221,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, @@ -238,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} % @@ -248,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, @@ -269,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 d972c80c5..c5d276aa0 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-rdf.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-rdf.tex @@ -566,7 +566,7 @@ \subsubsection{An Example Library for Drawing Finite Automata} The library could be used as follows: % -\begin{codeexample}[width=5cm] +\begin{codeexample}[width=5cm,preamble={\usetikzlibrary{graphs,rdf}}] \tikz [dfa] \graph [math nodes, grow right = 1.5cm] { q_0 [state, initial] -> [transition = a] @@ -895,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] +\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 5666c1a07..3f73bd926 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-shadings.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-shadings.tex @@ -42,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} @@ -60,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} @@ -89,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); @@ -107,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] @@ -137,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); @@ -155,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} % @@ -165,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} % @@ -179,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 @@ -205,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} @@ -214,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 93b6feace..989206465 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-shadows.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-shadows.tex @@ -11,10 +11,10 @@ \section{Shadows Library} \label{section-libs-shadows} -\begin{pgflibrary}{shadows} +\begin{tikzlibrary}{shadows} This library defines styles that help adding a (partly) transparent shadow to a path or node. -\end{pgflibrary} +\end{tikzlibrary} \subsection{Overview} @@ -63,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} @@ -71,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); @@ -81,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); @@ -108,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}[] +\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] @@ -137,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} @@ -163,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}[] +\begin{codeexample}[preamble={\usetikzlibrary{shadows,shapes.symbols}}] \begin{tikzpicture} \node [copy shadow,fill=blue!20,draw=blue,thick] {Hello World!}; @@ -189,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}[] +\begin{codeexample}[preamble={\usetikzlibrary{shadows,shapes.symbols}}] \begin{tikzpicture} \node [double copy shadow,fill=blue!20,draw=blue,thick] {Hello World!}; @@ -226,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] @@ -247,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] @@ -255,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] @@ -263,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] @@ -274,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 be536402d..92558a826 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-shapes.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-shapes.tex @@ -27,7 +27,7 @@ \subsection{Overview} In all of the examples presented in this section, the following |shape example| style is used: % -\begin{codeexample}[code only] +\begin{codeexample}[code only,setup code] \tikzset{ shape example/.style= {color = black!30, draw, @@ -52,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}; @@ -77,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}; @@ -117,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}; @@ -140,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}; @@ -169,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] @@ -199,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) {}; @@ -216,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); @@ -229,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} @@ -246,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); @@ -262,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] @@ -291,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] @@ -318,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); @@ -332,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); @@ -351,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] @@ -382,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); @@ -416,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] @@ -443,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) {}; @@ -467,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}} @@ -482,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}} @@ -501,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] @@ -545,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}; @@ -556,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] @@ -588,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}; @@ -611,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] @@ -638,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}, ] @@ -658,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] @@ -681,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} @@ -691,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}; @@ -706,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}; @@ -722,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}; @@ -740,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}; @@ -763,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, @@ -798,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} @@ -812,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} @@ -834,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} @@ -848,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}; @@ -880,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}; @@ -893,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); @@ -905,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, @@ -930,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} @@ -950,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] @@ -981,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, @@ -1011,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}; @@ -1054,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] @@ -1078,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}; @@ -1096,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) @@ -1112,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?}; @@ -1127,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, @@ -1142,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] @@ -1166,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} @@ -1176,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}; @@ -1189,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}; @@ -1200,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, @@ -1238,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}; @@ -1251,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, @@ -1276,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}; @@ -1290,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}; @@ -1301,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] @@ -1326,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} @@ -1337,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, @@ -1368,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}; @@ -1379,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] @@ -1403,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}] @@ -1417,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); @@ -1485,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, @@ -1526,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] { @@ -1540,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}; @@ -1562,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] { @@ -1573,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}; @@ -1597,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}; @@ -1618,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) @@ -1668,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 @@ -1693,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}; @@ -1730,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, @@ -1749,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, @@ -1786,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}] {}; @@ -1803,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, @@ -1844,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} @@ -1860,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}; @@ -1902,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}}} @@ -1930,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)}, @@ -1967,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)}, @@ -1994,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...}; @@ -2038,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, @@ -2073,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}; @@ -2082,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}; @@ -2111,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} @@ -2121,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} @@ -2134,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}; \\ @@ -2148,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}; \\ @@ -2174,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] @@ -2196,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!}; @@ -2209,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}; @@ -2225,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}; @@ -2254,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}; @@ -2266,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 b20b312e0..9bc7a69a9 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-spy.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-spy.tex @@ -24,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}] @@ -41,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) }}}}; @@ -146,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}] @@ -240,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}] @@ -283,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}] @@ -324,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}] @@ -364,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}] @@ -381,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}] @@ -399,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}] @@ -420,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}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.fractals,shadows,shapes.symbols,spy}}] \tikzset{spy using mag glass/.style={ spy scope={ every spy on node/.style={ @@ -442,7 +442,7 @@ \subsection{Examples} With the magnifying glass, you can also put it ``on top'' of the picture itself: % -\begin{codeexample}[] +\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 120eb1d9a..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 @@ -41,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 1222d1ec0..1d9e278f4 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-through.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-through.tex @@ -26,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 92f208092..c29dc7c55 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-trees.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-trees.tex @@ -41,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; @@ -54,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; @@ -66,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; @@ -94,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}, @@ -120,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] @@ -149,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] @@ -167,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 6c1187e0c..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,17 +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}[] +\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. @@ -40,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} @@ -69,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} @@ -107,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 c7724e72c..0a14a1016 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-library-views.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-library-views.tex @@ -50,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)}] @@ -59,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)}] @@ -73,7 +73,7 @@ \section{Views Library} the |meet| command as the target object and then animate its |:view| attribute: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{animations,views}}] \tikz [animate = { my scope:view = { begin on = { click, of next = here }, @@ -92,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}[] +\begin{codeexample}[preamble={\usetikzlibrary{animations,views}}] \tikz [animate = { my scope:view = { }}] { diff --git a/doc/generic/pgf/text-en/pgfmanual-en-main-body.tex b/doc/generic/pgf/text-en/pgfmanual-en-main-body.tex index 9abbb6f3d..7973f981b 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-main-body.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-main-body.tex @@ -284,7 +284,7 @@ \part{Installation and Configuration} \vskip1cm -\begin{codeexample}[graphic=white] +\begin{codeexample}[graphic=white,preamble={\usetikzlibrary{arrows,automata,positioning,shadows}}] \begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=2.8cm,on grid,semithick, every state/.style={fill=red,draw=none,circular drop shadow,text=white}] @@ -331,8 +331,7 @@ \part{Ti\emph{k}Z ist \emph{kein} Zeichenprogramm} \bigskip \noindent \vskip3cm -\begin{codeexample}[graphic=white] - +\begin{codeexample}[graphic=white,preamble={\usetikzlibrary{angles,calc,quotes}}] \begin{tikzpicture}[angle radius=.75cm] \node (A) at (-2,0) [red,left] {$A$}; @@ -395,7 +394,10 @@ \part{Graph Drawing} implement new algorithms in the Lua programming language. \vskip1cm \ifluatex -\begin{codeexample}[graphic=white] +\begin{codeexample}[ + graphic=white, + preamble={\usetikzlibrary{arrows.spaced,graphs,graphdrawing} +\usegdlibrary{layered}}] \tikz [nodes={text height=.7em, text depth=.2em, draw=black!20, thick, fill=white, font=\footnotesize}, >=spaced stealth', rounded corners, semithick] @@ -458,7 +460,7 @@ \part{Libraries} \medskip \noindent -\begin{codeexample}[graphic=white] +\begin{codeexample}[graphic=white,preamble={\usetikzlibrary{arrows,trees}}] \tikzset{ ld/.style={level distance=#1},lw/.style={line width=#1}, level 1/.style={ld=4.5mm, trunk, lw=1ex ,sibling angle=60}, @@ -566,7 +568,7 @@ \part{Data Visualization} \bigskip \noindent -\begin{codeexample}[graphic=white] +\begin{codeexample}[graphic=white,preamble={\usetikzlibrary{datavisualization.formats.functions}}] \tikz \datavisualization [scientific axes=clean] [ visualize as smooth line=Gaussian, diff --git a/doc/generic/pgf/text-en/pgfmanual-en-main-preamble.tex b/doc/generic/pgf/text-en/pgfmanual-en-main-preamble.tex index 090994556..b518e03d8 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-main-preamble.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-main-preamble.tex @@ -40,7 +40,6 @@ calc, fit, patterns, - patterns.meta, plotmarks, shapes.geometric, shapes.misc, diff --git a/doc/generic/pgf/text-en/pgfmanual-en-math-numberprinting.tex b/doc/generic/pgf/text-en/pgfmanual-en-math-numberprinting.tex index 9cd4a9a6d..2343d4105 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-math-numberprinting.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-math-numberprinting.tex @@ -344,7 +344,7 @@ \section{Number Printing} \begin{key}{/pgf/number format/frac} Displays numbers as fractionals. % -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{fpu}}] \pgfkeys{/pgf/number format/frac} \pgfmathprintnumber{0.333333333333333}\hspace{1em} \pgfmathprintnumber{0.5}\hspace{1em} @@ -370,7 +370,7 @@ \section{Number Printing} \begin{key}{/pgf/number format/frac denom=\meta{int} (initially empty)} Allows to provide a custom denominator for |frac|. % -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{fpu}}] \pgfkeys{/pgf/number format/.cd,frac, frac denom=10} \pgfmathprintnumber{0.1}\hspace{1em} \pgfmathprintnumber{0.5}\hspace{1em} @@ -385,7 +385,7 @@ \section{Number Printing} the fractional part. In this case, the fractional part will be less then $1$. Use |frac whole=false| to avoid whole number parts. % -\begin{codeexample}[width=3cm] +\begin{codeexample}[width=3cm,preamble={\usetikzlibrary{fpu}}] \pgfkeys{/pgf/number format/.cd,frac, frac whole=false} \pgfmathprintnumber{20.1}\hspace{1em} \pgfmathprintnumber{5.5}\hspace{1em} @@ -807,7 +807,7 @@ \subsection{Changing display styles}% A style which configures the number printer to produce verbatim text output, i.\,e., it doesn't contain \TeX\ macros. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{fpu}}] \pgfkeys{ /pgf/fpu, /pgf/number format/.cd, diff --git a/doc/generic/pgf/text-en/pgfmanual-en-math-parsing.tex b/doc/generic/pgf/text-en/pgfmanual-en-math-parsing.tex index 4b3f793da..249a67f4b 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-math-parsing.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-math-parsing.tex @@ -274,7 +274,7 @@ \subsubsection{Considerations Concerning Units} A typical use of this function is the following: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calc,quotes}}] \tikz{ \coordinate["$A$"] (A) at (2,2); \coordinate["$B$" below] (B) at (0,0); 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 1dfec36c2..334d9cd18 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-module-parser.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-module-parser.tex @@ -15,7 +15,7 @@ \section{Parser Module}% \begin{pgfmodule}{parser}% This module defines some commands for creating a simple letter-by-letter parser. -\end{pgfmodule}% +\end{pgfmodule} 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 @@ -45,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}% @@ -223,7 +223,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. @@ -244,13 +247,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}}% @@ -266,7 +275,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-pgfcalendar.tex b/doc/generic/pgf/text-en/pgfmanual-en-pgfcalendar.tex index c35a3b9a5..899682b3d 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-pgfcalendar.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-pgfcalendar.tex @@ -380,14 +380,14 @@ \subsection{Typesetting Calendars} In a first example, let us create a very simple calendar: It just lists the dates in a certain range. % -\begin{codeexample}[vbox,ignorespaces] +\begin{codeexample}[vbox,ignorespaces,preamble={\usepackage{pgfcalendar}}] \pgfcalendar{cal}{2007-01-20}{2007-02-10}{\pgfcalendarcurrentday\ } \end{codeexample} % Let us now make this a little more interesting: Let us add a line break after each Sunday. % -\begin{codeexample}[vbox,ignorespaces] +\begin{codeexample}[vbox,ignorespaces,preamble={\usepackage{pgfcalendar}}] \pgfcalendar{cal}{2007-01-20}{2007-02-10} { \pgfcalendarcurrentday\ @@ -399,7 +399,7 @@ \subsection{Typesetting Calendars} different approaches work. Here is one based positioning each day horizontally using a skip. % -\begin{codeexample}[vbox,ignorespaces] +\begin{codeexample}[vbox,ignorespaces,preamble={\usepackage{pgfcalendar}}] \pgfcalendar{cal}{2007-01-20}{2007-02-10} {% \leavevmode% @@ -410,7 +410,7 @@ \subsection{Typesetting Calendars} % Let us now typeset two complete months. % -\begin{codeexample}[vbox,ignorespaces] +\begin{codeexample}[vbox,ignorespaces,preamble={\usepackage{pgfcalendar}}] \pgfcalendar{cal}{2007-01-01}{2007-02-28}{% \ifdate{day of month=1}{ \par\bigskip\hbox to7.5cm{\itshape\hss\pgfcalendarshorthand mt\hss}\par @@ -429,7 +429,7 @@ \subsection{Typesetting Calendars} % For our final example, we use a |{tikzpicture}|. % -\begin{codeexample}[vbox,ignorespaces] +\begin{codeexample}[vbox,ignorespaces,preamble={\usepackage{pgfcalendar}}] \begin{tikzpicture} \pgfcalendar{cal}{2007-01-20}{2007-02-10}{% \ifdate{workday} @@ -470,7 +470,7 @@ \subsection{Typesetting Calendars} you can write |\%wt| instead of the much more cumbersome |\pgfcalendarshorthand{w}{t}|. % -\begin{codeexample}[leave comments] +\begin{codeexample}[leave comments,preamble={\usepackage{pgfcalendar}}] \let\%=\pgfcalendarshorthand \pgfcalendar{cal}{2007-01-20}{2007-01-20} { ISO form: \%y0-\%m0-\%d0, long form: \%wt, \%mt \%d-, \%y0} diff --git a/doc/generic/pgf/text-en/pgfmanual-en-pgfkeys.tex b/doc/generic/pgf/text-en/pgfmanual-en-pgfkeys.tex index 392e22981..5599a6807 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-pgfkeys.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-pgfkeys.tex @@ -376,13 +376,13 @@ \subsubsection{First Char Syntax Detection} An example where such a syntax reinterpretation is done is the |quotes| library, which allows you to write things like % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,quotes}}] \tikz \graph { a ->["1" red] b ->["0"] c }; \end{codeexample} % \noindent instead of the somewhat longer % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph { a ->[edge node={node[red,auto]{1}}] b ->[edge label=0] c }; \end{codeexample} diff --git a/doc/generic/pgf/text-en/pgfmanual-en-pgfkeysfiltered.tex b/doc/generic/pgf/text-en/pgfmanual-en-pgfkeysfiltered.tex index d93c8b8c0..2c08141ea 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-pgfkeysfiltered.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-pgfkeysfiltered.tex @@ -25,6 +25,7 @@ \subsubsection{Starting With An Example} |\pgfkeysfiltered|, a variant of |\pgfkeys|. Suppose we have the example key grouping +\begin{codeexample}[setup code,hidden] \pgfkeys{ /my group/A1/.code=(A1:#1), /my group/A2/.code=(A2:#1), @@ -37,7 +38,9 @@ \subsubsection{Starting With An Example} /my group/A3/.belongs to family=/my group/A, /pgf/key filters/active families/.install key filter, /my group/A/.activate family, -}% +} +\end{codeexample} +% \begin{codeexample}[code only] \pgfkeys{ /my group/A1/.code=(A1:#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 7ac5b4f79..85adcf902 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-pgfsys-animations.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-pgfsys-animations.tex @@ -11,6 +11,7 @@ \section{Animation System Layer} \label{section-pgfsys-anim} +\begin{codeexample}[setup code,hidden] \makeatletter \def\animationexample#1#2#3{% @@ -24,6 +25,7 @@ \section{Animation System Layer} (node) {Click \\ here}; }% } +\end{codeexample} In conjunction with the right output format (namely \textsc{svg}), you can specify that certain parts of you graphics can be animated. For this, there are @@ -159,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} @@ -213,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 { @@ -257,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} @@ -274,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} @@ -291,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} @@ -309,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} @@ -326,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} @@ -343,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} @@ -369,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}% @@ -396,7 +422,7 @@ \subsection{Commands for Animating an Attribute: Paths and Their Rendering} |\pgfsetarrows| and then animate the path, you will get an error message. \item Internally, the arrow tips that ``rotate and move along'' are - drawn using so-called \emph{markers.} These are little graphic + drawn using so-called \emph{markers}. These are little graphic objects that can be added to the start and end of paths and that are automatically rotated and move along with the path. @@ -464,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% @@ -503,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} @@ -520,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} @@ -530,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} @@ -540,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} @@ -612,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}% @@ -632,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}% @@ -650,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}} @@ -685,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}% @@ -703,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}% @@ -720,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}% @@ -738,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}% @@ -782,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} @@ -829,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{ @@ -871,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}% @@ -1122,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} @@ -1139,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} @@ -1157,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} @@ -1199,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} @@ -1259,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} @@ -1269,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} @@ -1279,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} @@ -1289,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} @@ -1299,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} @@ -1317,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} @@ -1350,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} @@ -1372,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} @@ -1389,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} @@ -1406,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} @@ -1427,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} @@ -1444,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} @@ -1471,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} @@ -1490,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-pgfsys-commands.tex b/doc/generic/pgf/text-en/pgfmanual-en-pgfsys-commands.tex index 47b876cd1..ae9829528 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-pgfsys-commands.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-pgfsys-commands.tex @@ -637,10 +637,8 @@ \subsection{Color System Commands} \subsection{Pattern System Commands} \begin{command}{\pgfsys@declarepattern - \marg{name}\marg{$x_1$}\marg{$y_1$}\marg{$x_2$}\marg{$y_2$}% - \marg{$x$ step}\marg{$y$ step}% - \marg{$a$}\marg{$b$}\marg{$c$}\marg{$d$}\allowbreak\marg{$e$}\marg{$f$}% - \marg{code}\marg{flag}% + \marg{name}\marg{$x_1$}\marg{$y_1$}\marg{$x_2$}\marg{$y_2$} + \marg{$x$ step}\marg{$y$ step}\marg{code}\marg{flag}% } This command declares a new colored or uncolored pattern, depending on whether \meta{flag} is |0|, which means uncolored, or |1|, which means @@ -654,66 +652,14 @@ \subsection{Pattern System Commands} The tiling step of the pattern is given by \meta{$x$ step} and \meta{$y$ step}. - The parameters \meta{$a$} to \meta{$f$} are entries of the transformation - matrix that is applied to the pattern, see |\pgfsys@patternmatrix| for more - information. - \example % \begin{codeexample}[code only] -\pgfsys@declarepattern - {hori}{-.5pt}{0pt}{.5pt}{3pt}{3pt}{3pt}% - {1.0}{0.0}{0.0}{1.0}{0.0pt}{0.0pt}% - {\pgfsys@moveto{0pt}{0pt}\pgfsys@lineto{0pt}{3pt}\pgfsys@stroke} - {0} -\end{codeexample} - % -\end{command} - - -\begin{command}{\pgfsys@patternmatrix} - For convenience \pgfname\ defines the transformation matrix that is applied - to all patterns defined with |\pgfdeclarepatternformonly| and - |\pgfdeclarepatterninherentlycolored| in a macro. This can be used as an - extension point for ad-hoc transformation of existing patterns. The - default definition is the - identity matrix: - % -\begin{codeexample}[code only] -\def\pgfsys@patternmatrix{{1.0}{0.0}{0.0}{1.0}{0.0pt}{0.0pt}} +\pgfsys@declarepattern{hori}{-.5pt}{0pt}{.5pt}{3pt}{3pt}{3pt} +{\pgfsys@moveto{0pt}{0pt}\pgfsys@lineto{0pt}{3pt}\pgfsys@stroke} +{0} \end{codeexample} % - The entries of the enclosed array - |{|\meta{$a$}|}{|\meta{$b$}|}{|\meta{$c$}|}{|\meta{$d$}|}{|\meta{$e$}|}{|\meta{$f$}|}| - are entries in the transformation matrix, identified as in the following - transformation prescription: - \begin{equation*} - \begin{pmatrix} - x' \\ - y' \\ - 1 \\ - \end{pmatrix} - = - \begin{pmatrix} - a & c & e \\ - b & d & f \\ - 0 & 0 & 1 \\ - \end{pmatrix} - \begin{pmatrix} - x \\ - y \\ - 1 \\ - \end{pmatrix} . - \end{equation*} - Carrying out the matrix multiplication results in the following system of - equations - \begin{align*} - x' &= a x + c y + e , \\ - y' &= b x + d y + f . - \end{align*} - Evidently, the parameters \marg{$a$} to \marg{$d$} have to be dimensionless - because they are scaling factors, but the parameters \marg{$e$} and - \marg{$f$} are offsets, therefore they have to carry a unit. \end{command} \begin{command}{\pgfsys@setpatternuncolored\marg{name}\marg{red}\marg{green}\marg{blue}} diff --git a/doc/generic/pgf/text-en/pgfmanual-en-tikz-actions.tex b/doc/generic/pgf/text-en/pgfmanual-en-tikz-actions.tex index 03c619eb9..31daf0a7f 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-tikz-actions.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-tikz-actions.tex @@ -361,25 +361,6 @@ \subsubsection{Graphic Parameters: Dash Pattern} % \end{key} -\begin{key}{/tikz/dash expand off} - Makes the |off| part of a dash pattern expandable such that it can stretch. - This only works when there is a single |on| and a single |off| field and - requires the |decorations| library. Right now this option has to be - specified on the path where it is supposed to take effect after the |dash - pattern| option because the dash pattern has to be known at the point where - it is applied. - % -\begin{codeexample}[] -\begin{tikzpicture}[|-|, dash pattern=on 4pt off 2pt] - \draw [dash expand off] (0pt,30pt) -- (26pt,30pt); - \draw [dash expand off] (0pt,20pt) -- (24pt,20pt); - \draw [dash expand off] (0pt,10pt) -- (22pt,10pt); - \draw [dash expand off] (0pt, 0pt) -- (20pt, 0pt); -\end{tikzpicture} -\end{codeexample} - % -\end{key} - As for the line thickness, some predefined styles allow you to set the dashing conveniently. @@ -582,17 +563,26 @@ \subsubsection{Graphic Parameters: Double Lines and Bordered Lines} This style selects a double line distance such that it corresponds to the distance of the two lines in an equal sign. % -\begin{codeexample}[] +\begin{codeexample}[ + preamble={\usepackage{amsmath} +\usetikzlibrary{arrows}} +] \Huge $=\implies$\tikz[baseline,double equal sign distance] \draw[double,thick,-implies](0,0.55ex) --++(3ex,0); \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[ + preamble={\usepackage{amsmath} +\usetikzlibrary{arrows}} +] \normalsize $=\implies$\tikz[baseline,double equal sign distance] \draw[double,-implies](0,0.6ex) --++(3ex,0); \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[ + preamble={\usepackage{amsmath} +\usetikzlibrary{arrows}} +] \tiny $=\implies$\tikz[baseline,double equal sign distance] \draw[double,very thin,-implies](0,0.5ex) -- ++(3ex,0); \end{codeexample} @@ -623,11 +613,11 @@ \subsection{Adding Arrow Tips to a Path} ``only'' arrow tips get drawn for a path without drawing the path itself. Here is an example: % -\begin{codeexample}[width=2cm] +\begin{codeexample}[width=2cm,preamble={\usetikzlibrary{arrows.meta,bending}}] \tikz \path[tips, -{Latex[open,length=10pt,bend]}] (0,0) to[bend left] (1,0); \end{codeexample} % -\begin{codeexample}[width=2cm] +\begin{codeexample}[width=2cm,preamble={\usetikzlibrary{arrows.meta,bending}}] \tikz \draw[tips, -{Latex[open,length=10pt,bend]}] (0,0) to[bend left] (1,0); \end{codeexample} @@ -714,7 +704,7 @@ \subsubsection{Graphic Parameters: Fill Pattern} instance the |patterns| library, see Section~\ref{section-library-patterns}, to install predefined patterns. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{patterns}}] \begin{tikzpicture} \draw[pattern=dots] (0,0) circle (1cm); \draw[pattern=fivepointed stars] (0,0) rectangle (3,1); @@ -727,14 +717,14 @@ \subsubsection{Graphic Parameters: Fill Pattern} This option is used to set the color to be used for form-only patterns. This option has no effect on inherently colored patterns. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{patterns}}] \begin{tikzpicture} \draw[pattern color=red,pattern=fivepointed stars] (0,0) circle (1cm); \draw[pattern color=blue,pattern=fivepointed stars] (0,0) rectangle (3,1); \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{patterns}}] \begin{tikzpicture} \def\mypath{(0,0) -- +(0,1) arc (180:0:1.5cm) -- +(0,-1)} \fill [red] \mypath; @@ -1317,7 +1307,7 @@ \subsection{Doing Multiple Actions on a Path} In the following example, we use one |preaction| to add a shadow and another to provide a shading, while the main action is to use a pattern. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{patterns}}] \begin{tikzpicture} \draw[help lines] (0,0) grid (3,2); \draw [pattern=fivepointed stars] @@ -1333,7 +1323,7 @@ \subsection{Doing Multiple Actions on a Path} is used several times with different fadings and shadings to create a special visual effect: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{fadings,patterns}}] \begin{tikzpicture} [ % Define an interesting style @@ -1396,7 +1386,7 @@ \subsection{Doing Multiple Actions on a Path} In another example, we use a postaction to ``colorize'' a path: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{fadings}}] \begin{tikzpicture} \draw[help lines] (0,0) grid (3,2); \draw @@ -1420,7 +1410,7 @@ \subsection{Decorating and Morphing a Path} the following example the path is drawn twice: Once normally and then in a morphed (=decorated) manner. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \begin{tikzpicture} \draw (0,0) rectangle (3,2); \draw [red, decorate, decoration=zigzag] @@ -1431,7 +1421,7 @@ \subsection{Decorating and Morphing a Path} Naturally, we could have combined this into a single command using pre- or postaction. It is also possible to deform shapes: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing,shadows}}] \begin{tikzpicture} \node [circular drop shadow={shadow scale=1.05},minimum size=3.13cm, decorate, decoration=zigzag, 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 6a7f606f4..8b0d4462f 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-tikz-animations.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-tikz-animations.tex @@ -24,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 = { @@ -66,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} @@ -150,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'' @@ -258,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}; @@ -277,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" }}} @@ -333,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, @@ -345,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, @@ -364,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, @@ -404,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}; @@ -412,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", @@ -452,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}; @@ -479,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 } @@ -557,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", @@ -600,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"} } @@ -746,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" } @@ -952,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!}; @@ -960,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 } @@ -971,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] @@ -980,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] @@ -1254,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}; @@ -1268,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 ] { @@ -1280,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 ] { @@ -1303,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} @@ -1314,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} @@ -1327,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} @@ -1340,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" }}] { @@ -1361,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} @@ -1378,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!}; @@ -1395,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} @@ -1408,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)}", @@ -1432,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) @@ -1505,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!}; @@ -1540,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} @@ -1549,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} @@ -1562,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} @@ -1575,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} @@ -1593,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!}; @@ -1613,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]; @@ -1631,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]; @@ -1655,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} @@ -1674,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} } @@ -1695,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, @@ -1724,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, @@ -1733,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, @@ -1782,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]; @@ -1793,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]; @@ -1806,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]; @@ -1842,7 +1990,11 @@ \subsubsection{Animating Transformations: Views} syntax as the views in the view library (though you only animate the to-be-viewed rectangle). % -\begin{codeexample}[animation list={0.5,1,1.5,2},animation bb={(1.1,-0.9) rectangle (2.9,0.9)}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations,views}}, + animation list={0.5,1,1.5,2}, + animation bb={(1.1,-0.9) rectangle (2.9,0.9)}, +] \tikz [very thick] { \node (node) [fill = blue!20, draw = blue, very thick, circle] {Click me!}; @@ -1879,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}; @@ -1895,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}; @@ -1905,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}; @@ -1918,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}; @@ -1968,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}; @@ -2005,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}; @@ -2021,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}; @@ -2050,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} @@ -2060,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} @@ -2070,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} @@ -2080,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} @@ -2091,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} @@ -2101,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} @@ -2113,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} @@ -2128,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 } @@ -2156,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 }, @@ -2200,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!}; @@ -2210,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!}; @@ -2237,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!}; @@ -2246,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!}; @@ -2256,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!}; @@ -2278,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!}; @@ -2354,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, @@ -2365,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, @@ -2376,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, @@ -2409,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" } @@ -2428,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, @@ -2446,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, @@ -2481,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]; @@ -2498,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); @@ -2522,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); @@ -2565,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 70aaf271c..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,7 +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}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta,bending,positioning}}] \tikz { \node [circle,draw] (A) {A}; \node [circle,draw] (B) [right=of A] {B}; @@ -93,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); @@ -115,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} @@ -224,6 +224,7 @@ \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} One common pitfall when arrow tips are added to a path should be addressed @@ -283,9 +284,9 @@ \subsection{Arrow Keys: Configuring the Appearance of a Single Arrow Tip} \subsubsection{Size} -The most important configuration parameter of an arrow tip is -undoubtedly its size. The following two keys are the main keys that -are important in this context: +The most important configuration parameter of an arrow tip is undoubtedly its +size. The following two keys are the main keys that are important in this +context: \begin{key}{/pgf/arrow keys/length=\meta{dimension}| |\opt{\meta{line width factor}}% | |\opt{\meta{outer factor}}} @@ -295,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); @@ -354,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} @@ -384,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); @@ -399,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); @@ -423,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} @@ -456,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} % @@ -480,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} @@ -509,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} % @@ -523,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} @@ -550,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); @@ -571,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); @@ -584,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); @@ -606,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); @@ -625,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); @@ -641,7 +642,7 @@ \subsubsection{Slanting} Here is another example where slanting is used to match italic text: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta,graphs}}] \tikz [>={[slant=.3] To[] To[]}] \graph [math nodes] { A -> B <-> C }; \end{codeexample} @@ -665,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} @@ -676,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} % @@ -695,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} % @@ -713,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} % @@ -743,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} @@ -754,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} @@ -767,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} @@ -781,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} @@ -800,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); @@ -810,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); @@ -830,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]}] @@ -843,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); @@ -878,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); @@ -906,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); @@ -935,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} @@ -949,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} @@ -972,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} % @@ -998,7 +1000,7 @@ \subsubsection{Bending and Flexing} situation: We have a ``gray wall'' at the $x$-coordinate of and a red line that ends in its middle. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{patterns}}] \def\wall{ \fill [fill=black!50] (1,-.5) rectangle (2,.5); \pattern [pattern=bricks] (1,-.5) rectangle (2,.5); \draw [line width=1pt] (1cm+.5pt,-.5) -- ++(0,1); } @@ -1012,10 +1014,13 @@ \subsubsection{Bending and Flexing} Now we wish to add a blue open arrow tip the red line like, say, |Stealth[length=1cm,open,blue]|: % +\begin{codeexample}[setup code,hidden] +\usetikzlibrary{patterns} \def\wall{ \fill [fill=black!50] (1,-.5) rectangle (2,.5); \pattern [pattern=bricks] (1,-.5) rectangle (2,.5); \draw [line width=1pt] (1cm+.5pt,-.5) -- ++(0,1); } -\begin{codeexample}[] +\end{codeexample} +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \begin{tikzpicture} \wall \draw [red,line width=1mm,-{Stealth[length=1cm,open,blue]}] @@ -1086,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); @@ -1153,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); @@ -1183,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); @@ -1191,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); @@ -1204,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); @@ -1216,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); @@ -1235,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); @@ -1251,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); @@ -1269,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); @@ -1294,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); @@ -1302,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); @@ -1310,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); @@ -1320,6 +1325,9 @@ \subsubsection{Bending and Flexing} \end{codeexample} % \end{key} +% TODOsp: codeexamples: `bending` library is needed up to here +% TODOsp: codeexamples: `\def\wall` + `patterns` library are needed up to here +% TODOsp: codeexamples: `arrows.meta` library needed up to here \subsection{Arrow Tip Specifications} @@ -1475,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); @@ -1489,7 +1497,7 @@ \subsubsection{Specifying Paddings} but will rather leave the specified amount of space. This is usually quite desirable. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta,positioning}}] \tikz { \node [draw] (A) {A}; \node [draw] (B) [right=of A] {B}; @@ -1550,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} % @@ -1583,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); @@ -1633,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} % @@ -1651,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} @@ -1680,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); @@ -1835,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); @@ -2138,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}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta,graphs}}] \tikz \graph [clockwise=3, math nodes, edges = {double equal sign distance, -Implies}] { "\alpha", "\beta", "\gamma"; @@ -2382,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} % @@ -2399,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); @@ -2408,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); @@ -2431,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); @@ -2439,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-coordinates.tex b/doc/generic/pgf/text-en/pgfmanual-en-tikz-coordinates.tex index c3921486e..047592f5c 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-tikz-coordinates.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-tikz-coordinates.tex @@ -380,7 +380,7 @@ \subsubsection{Node Coordinate System} \begin{key}{/tikz/anchor=\meta{anchor}} Specifies an anchor of the node. Here is an example: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \begin{tikzpicture} \node (shape) at (0,2) [draw] {|class Shape|}; \node (rect) at (-2,0) [draw] {|class Rectangle|}; @@ -401,7 +401,7 @@ \subsubsection{Node Coordinate System} This coordinate refers to a point of the node's border where a ray shot from the center in the given angle hits the border. Here is an example: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \begin{tikzpicture} \node (start) [draw,shape=ellipse] {start}; \foreach \angle in {-90, -80, ..., 90} @@ -415,7 +415,7 @@ \subsubsection{Node Coordinate System} |angle=| option. In this case, \tikzname\ will calculate an appropriate border position for you. Here is an example: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \begin{tikzpicture} \path (0,0) node(a) [ellipse,rotate=10,draw] {An ellipse} (3,-1) node(b) [circle,draw] {A circle}; @@ -465,7 +465,7 @@ \subsubsection{Node Coordinate System} Here is a more complete example: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \begin{tikzpicture}[fill=blue!20] \draw[help lines] (-1,-2) grid (6,3); \path (0,0) node(a) [ellipse,rotate=10,draw,fill] {An ellipse} @@ -621,7 +621,7 @@ \subsubsection{Tangent Coordinate Systems} \item |circle| \end{itemize} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calc}}] \begin{tikzpicture} \draw[help lines] (0,0) grid (3,2); @@ -746,11 +746,11 @@ \subsubsection{Intersections of Perpendicular Lines} of the line from $A$ to~$B$ and vertically at the middle of the line from $C$ to~$D$: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calc}}] \begin{tikzpicture} - \node (A) at (0,1) {A}; - \node (B) at (1,1.5) {B}; - \node (C) at (2,0) {C}; + \node (A) at (0,1) {A}; + \node (B) at (1,1.5) {B}; + \node (C) at (2,0) {C}; \node (D) at (2.5,-2) {D}; \draw (A) -- (B) node [midway] {x}; @@ -805,7 +805,7 @@ \subsubsection{Intersections of Arbitrary Paths} Optionally, the prefix |intersection| can be changed, and the total number of intersections stored in a \TeX-macro. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{intersections}}] \begin{tikzpicture}[every node/.style={opacity=1, black, above left}] \draw [help lines] grid (3,2); \draw [name path=ellipse] (2,0.5) ellipse (0.75cm and 1cm); @@ -833,7 +833,7 @@ \subsubsection{Intersections of Arbitrary Paths} stored in \meta{macro}. \end{key} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{intersections}}] \begin{tikzpicture} \clip (-2,-2) rectangle (2,2); \draw [name path=curve 1] (-2,-1) .. controls (8,-1) and (-8,1) .. (2,1); @@ -854,7 +854,7 @@ \subsubsection{Intersections of Arbitrary Paths} to the |\foreach| statement and for \meta{list member} a coordinate is created at the already-named intersection. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{intersections}}] \begin{tikzpicture} \clip (-2,-2) rectangle (2,2); \draw [name path=curve 1] (-2,-1) .. controls (8,-1) and (-8,1) .. (2,1); @@ -874,7 +874,7 @@ \subsubsection{Intersections of Arbitrary Paths} is created. A coordinate name can still, but need not, follow the options. This makes it easy to add labels to intersections: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{intersections}}] \begin{tikzpicture} \clip (-2,-2) rectangle (2,2); \draw [name path=curve 1] (-2,-1) .. controls (8,-1) and (-8,1) .. (2,1); @@ -895,7 +895,7 @@ \subsubsection{Intersections of Arbitrary Paths} should be one of the paths mentioned in the |/tikz/intersection/of| key. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{intersections}}] \begin{tikzpicture} \clip (-0.5,-0.75) rectangle (3.25,2.25); \foreach \pathname/\shift in {line/0cm, curve/2cm}{ @@ -1074,7 +1074,7 @@ \subsection{Coordinate Calculations} and do projections. For instance, |($(a) + 1/3*(1cm,0)$)| is the coordinate that is $1/3 \text{cm}$ to the right of the point |a|: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calc}}] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); @@ -1141,7 +1141,7 @@ \subsubsection{The Syntax of Factors} Here are some examples of coordinate specifications that consist of exactly one \meta{factor} and one \meta{coordinate}: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calc}}] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); @@ -1180,7 +1180,7 @@ \subsubsection{The Syntax of Partway Modifiers} is smaller than $0$ or larger than $1$. The \meta{number} is evaluated using the |\pgfmathparse| command and, thus, it can involve complicated computations. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calc}}] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); @@ -1201,7 +1201,7 @@ \subsubsection{The Syntax of Partway Modifiers} Here are two examples: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calc}}] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,3); @@ -1218,7 +1218,7 @@ \subsubsection{The Syntax of Partway Modifiers} \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calc}}] \begin{tikzpicture} \draw [help lines] (0,0) grid (4,4); @@ -1230,7 +1230,7 @@ \subsubsection{The Syntax of Partway Modifiers} You can repeatedly apply modifiers. That is, after any modifier you can add another (possibly different) modifier. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calc}}] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); @@ -1255,7 +1255,7 @@ \subsubsection{The Syntax of Distance Modifiers} following: Use the point that is distanced \meta{dimension} from \meta{a} on the straight line from \meta{a} to \meta{b}. Here is an example: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calc}}] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); @@ -1275,7 +1275,7 @@ \subsubsection{The Syntax of Distance Modifiers} you now wish to offset this point by |1cm| so that the distance from this offset point to the line is |1cm|. This can be achieved as follows: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calc}}] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); @@ -1313,7 +1313,7 @@ \subsubsection{The Syntax of Projection Modifiers} orthogonally onto the line from \meta{coordinate} to \meta{second coordinate}. This makes it easy to compute projected points: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calc}}] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); 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 009660a91..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,7 +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}[] +\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); @@ -28,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] @@ -36,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) } @@ -45,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}] @@ -65,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} @@ -78,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; @@ -106,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} @@ -122,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; @@ -144,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}] { @@ -187,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}] @@ -205,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}] @@ -230,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)}; @@ -254,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}] @@ -266,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] @@ -289,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}] @@ -306,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 }; @@ -341,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}[] +\begin{codeexample}[preamble={\usetikzlibrary{ + decorations.pathmorphing, + decorations.text, + shapes.geometric, +}}] \begin{tikzpicture}[decoration=zigzag] \draw [help lines] (0,0) grid (3,5); @@ -360,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}[] +\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= @@ -372,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, @@ -403,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); @@ -422,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}; @@ -445,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); @@ -475,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} @@ -494,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} @@ -523,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-design.tex b/doc/generic/pgf/text-en/pgfmanual-en-tikz-design.tex index 607a55fb4..002983b2a 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-tikz-design.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-tikz-design.tex @@ -171,7 +171,7 @@ \subsection{Special Syntax for Specifying Trees} way trees are drawn. Here are two examples of the above tree, redrawn with different options: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows,trees}}] \begin{tikzpicture} [edge from parent fork down, sibling distance=15mm, level distance=15mm, every node/.style={fill=red!30,rounded corners}, @@ -210,7 +210,7 @@ \subsection{Special Syntax for Graphs} syntax can be used, which is another syntax layer build ``on top'' of the node syntax. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [grow down, branch right] { root -> { left, right -> {child, child} } }; 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 7e4560d0d..3c8993cbf 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-tikz-graphs.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-tikz-graphs.tex @@ -26,11 +26,11 @@ \subsection{Overview} 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}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] \tikz \graph { subgraph I_nm [V={a, b, c}, W={1,...,4}]; @@ -40,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] @@ -48,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] @@ -56,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, @@ -85,10 +88,10 @@ \subsection{Overview} \end{codeexample} The nodes of a graph are normal \tikzname\ nodes, the edges are normal lines -drawn between nodes. There is nothing in the |graph| library that you cannot do -using the normal |\node| and the |edge| commands. Rather, its purpose is to +drawn between nodes. There is nothing in the |graphs| library that you cannot +do using the normal |\node| and the |edge| commands. Rather, its purpose is to offer a concise and powerful way of \emph{specifying} which nodes are present -and how they are connected. The |graph| library only offers simple methods for +and how they are connected. The |graphs| library only offers simple methods for specifying \emph{where} the nodes should be shown, its main strength is in specifying which nodes and edges are present in principle. The problem of finding ``good positions on the canvas'' for the nodes of a graph is left to @@ -131,12 +134,12 @@ \subsection{Overview} \medskip \fi -The |graph| library uses a syntax that is quite different from the normal +The |graphs| library uses a syntax that is quite different from the normal \tikzname\ syntax for specifying nodes. The reason for this is that for many medium-sized graphs it can become quite cumbersome to specify all the nodes using |\node| repeatedly and then using a great number of |edge| command; possibly with complicated |\foreach| statements. Instead, the syntax of the -|graph| library is loosely inspired by the \textsc{dot} format, which is quite +|graphs| library is loosely inspired by the \textsc{dot} format, which is quite useful for specifying medium-sized graphs, with some extensions on top. @@ -152,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} @@ -165,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; @@ -182,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; @@ -193,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$"; @@ -210,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, @@ -221,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] { @@ -269,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}; }; @@ -278,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}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,quotes}}] \tikz \graph { a ->[red, "foo"] b --[thick, "bar"] {c, d}; }; @@ -295,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}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,quotes}}] \tikz \graph { a -> b -- {c [> "foo"], d [> "bar"']}; }; @@ -304,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}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,quotes}}] \tikz \graph { a [< red] -> b -- {c [> blue], d [> "bar"']}; }; @@ -313,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}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,quotes}}] \tikz \graph [edge quotes={fill=white,inner sep=1pt}, grow down, branch right, nodes={circle,draw}] { @@ -340,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}; @@ -355,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}[] +\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}; @@ -375,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}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] \tikz \graph { subgraph K_n [n=6, clockwise] }; \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] \tikz \graph { subgraph C_n [n=5, clockwise] -> mid }; \end{codeexample} @@ -406,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}] @@ -480,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} % @@ -491,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} % @@ -506,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} @@ -523,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} @@ -531,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}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] \tikz \graph [edge label=out, edge label'=in] { subgraph C_n [clockwise, n=5] }; \end{codeexample} @@ -558,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; @@ -574,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] @@ -593,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 @@ -610,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} { @@ -644,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} @@ -652,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} { @@ -765,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} }; @@ -826,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; @@ -888,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 @@ -915,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 -> { @@ -939,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 -> { @@ -984,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} -- @@ -1009,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} -- @@ -1019,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} -- @@ -1051,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} % @@ -1098,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} @@ -1106,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}$ @@ -1121,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} @@ -1130,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} @@ -1149,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]; @@ -1251,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$}; @@ -1276,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$}; @@ -1298,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} @@ -1334,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, @@ -1350,7 +1353,7 @@ \subsubsection{Specifying Tries} libraries, which need Lua\TeX. % \ifluatex -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing}\usegdlibrary{layered}}] \tikz \graph [trie, simple, layered layout] { a -> b -> a, a -> b -> c, @@ -1361,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}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing}\usegdlibrary{layered}}] \tikz \graph [trie, simple, layered layout, typeset=\tikzgraphnodefullname] { a -> b -> a, @@ -1374,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 -> { @@ -1456,11 +1459,11 @@ \subsection{Quick Graphs} Here is a typical way this syntax might be used: % -\begin{codeexample}[] +\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]; }; @@ -1487,7 +1490,7 @@ \subsection{Quick Graphs} \subsection{Simple Versus Multi-Graphs} \label{section-library-graphs-simple} -The |graph| library allows you to construct both simple graphs and +The |graphs| library allows you to construct both simple graphs and multi-graphs. In a simple graph there can be at most one edge between any two vertices, while in a multi-graph there can be multiple edges (hence the name). The two keys |multi| and |simple| allow you to switch (even locally inside on @@ -1501,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; @@ -1523,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; @@ -1539,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}; @@ -1554,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}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] \tikz \graph [simple] { subgraph K_n [n=8, clockwise]; % Get rid of the following edges: @@ -1588,7 +1591,7 @@ \subsection{Simple Versus Multi-Graphs} \subsection{Graph Edges: Labeling and Styling} -When the |graph| library creates an edge between two nodes in a graph, the +When the |graphs| library creates an edge between two nodes in a graph, the appearance (called ``styling'' in \tikzname) can be specified in different ways. Sometimes you will simply wish to say ``the edges between these two groups of node should be red'', but sometimes you may wish to say ``this @@ -1607,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}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,quotes}}] \tikz \graph [edge quotes=near start] { { a, b } -> [red, "x", complete bipartite] { c, d }; @@ -1618,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}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,quotes}}] \tikz \graph { a ->["x"] b ->["y"'] c ->["z" red] d; }; @@ -1628,19 +1631,20 @@ \subsubsection{Options For All Edges Between Two Groups} this way: % \begin{key}{/tikz/graphs/edge quotes=\opt{\meta{options}}} - A shorthand for setting the style |every edge quotes| to \meta{options}. -\begin{codeexample}[] + A shorthand for setting the style |every edge quotes| to \meta{options}. + % +\begin{codeexample}[preamble={\usetikzlibrary{graphs,quotes}}] \tikz \graph [edge quotes={blue,auto}] { a ->["x"] b ->["y"'] c ->["b" red] d; }; \end{codeexample} -% + % \end{key} \begin{key}{/tikz/graphs/edge quotes center} A shorthand for |edge quotes| to |anchor=center|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,quotes}}] \tikz \graph [edge quotes center] { a ->["x"] b ->["y"] c ->["z" red] d; }; @@ -1651,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}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,quotes}}] \tikz \graph [edge quotes mid] { a ->["x"] b ->["y"] c ->["z" red] d; }; @@ -1664,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} @@ -1676,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; @@ -1695,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; @@ -1711,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 -> { @@ -1737,7 +1741,7 @@ \subsubsection{Options For Incoming and Outgoing Edges} also be phrased as follows: ``Make the edge leading to |b| red and make the edge leading to |c| blue''. -For this situation, the |graph| library offers a number of special keys, which +For this situation, the |graphs| library offers a number of special keys, which are documented in the following. However, most of the time you will not use these keys directly, but, rather, use a special syntax explained in Section~\ref{section-syntax-outgoing-incoming}. @@ -1748,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 } -> @@ -1762,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 } -> @@ -1774,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 } -> @@ -1793,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 }, @@ -1808,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 } -> @@ -1825,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 } -> @@ -1844,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 @@ -1902,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}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,quotes}}] \tikz \graph [edge quotes={fill=white,inner sep=1pt}, grow down, branch right] { @@ -1924,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}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,quotes}}] \tikz \graph [empty nodes] { root -> { @@ -1959,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} }; @@ -2015,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 @@ -2026,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}] @@ -2041,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}] @@ -2057,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}] @@ -2082,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}. @@ -2150,7 +2155,7 @@ \subsubsection{Graph Operators on Groups of Nodes} \begin{key}{/tikz/graphs/--} Sets the |default edge kind| to |--|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] \tikz \graph { subgraph K_n [--, n=5, clockwise, radius=6mm] }; \end{codeexample} \end{key} @@ -2158,7 +2163,7 @@ \subsubsection{Graph Operators on Groups of Nodes} \begin{key}{/tikz/graphs/->} Sets the |default edge kind| to |->|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] \tikz \graph { subgraph K_n [->, n=5, clockwise, radius=6mm] }; \end{codeexample} \end{key} @@ -2166,7 +2171,7 @@ \subsubsection{Graph Operators on Groups of Nodes} \begin{key}{/tikz/graphs/<-} Sets the |default edge kind| to |<-|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] \tikz \graph { subgraph K_n [<-, n=5, clockwise, radius=6mm] }; \end{codeexample} \end{key} @@ -2174,7 +2179,7 @@ \subsubsection{Graph Operators on Groups of Nodes} \begin{key}{/tikz/graphs/<->} Sets the |default edge kind| to |<->|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] \tikz \graph { subgraph K_n [<->, n=5, clockwise, radius=6mm] }; \end{codeexample} \end{key} @@ -2199,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} @@ -2232,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{ @@ -2336,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 @@ -2385,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] @@ -2414,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}] @@ -2461,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; @@ -2471,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]; }; @@ -2481,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, @@ -2514,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] @@ -2528,7 +2533,7 @@ \subsection{Graph Macros} \subsection{Online Placement Strategies} \label{section-library-graphs-placement} -The main job of the |graph| library is to make it easy to specify which nodes +The main job of the |graphs| library is to make it easy to specify which nodes are present in a graph and how they are connected. In contrast, it is \emph{not} the primary job of the library to compute good positions for nodes in a graph -- use for instance a |\matrix|, specify good positions ``by hand'' @@ -2562,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]; @@ -2577,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]; @@ -2587,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 -> @@ -2622,10 +2627,10 @@ \subsubsection{Placement on a Grid} This slightly confusing explanation is perhaps best exemplified. In the below example, the two numbers indicate the two logical width and depth of - each node as computed by the |graph| library. Just ignore the arcane code + 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] @@ -2656,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; @@ -2669,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; @@ -2684,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} % @@ -2693,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} % @@ -2702,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} % @@ -2711,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} % @@ -2722,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} % @@ -2733,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} % @@ -2741,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} % @@ -2749,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} % @@ -2766,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}[] +\begin{codeexample}[preamble={\usetikzlibrary{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}[] +\begin{codeexample}[preamble={\usetikzlibrary{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}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] % Directions can be changed \tikz \graph [grid placement, branch up, grow left] { subgraph Grid_n [n=9] }; \end{codeexample} @@ -2784,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 @@ -2809,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, @@ -2828,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$} -- @@ -2853,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, @@ -2869,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, @@ -2883,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} % @@ -2910,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; @@ -2924,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; @@ -2932,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)] { @@ -2948,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} @@ -2961,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} @@ -2979,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}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] \tikz \graph [clockwise] { subgraph K_n [n=5] }; \end{codeexample} % @@ -3006,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}] { @@ -3039,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}, @@ -3058,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}, @@ -3086,7 +3092,7 @@ \subsubsection{Defining New Online Placement Strategies} In the following the details of how to define a new placement strategy are explained. Most readers may wish to skip this section. -As a graph specification is being parsed, the |graph| library will keep track +As a graph specification is being parsed, the |graphs| library will keep track of different numbers that identify the positions of the nodes. Let us start with what happens on a chain. First, the following counter is increased for each element of the chain: @@ -3096,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= @@ -3142,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] @@ -3166,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}, @@ -3194,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= @@ -3246,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}{ @@ -3321,7 +3327,7 @@ \subsubsection{Graph Macros} |V={1,...,|\meta{number}|}, name shore V/.style={name=V}|. \end{key} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] \tikz \graph [branch right, nodes={draw, circle}] { subgraph I_n [V={a,b,c}] }; \end{codeexample} @@ -3330,7 +3336,7 @@ \subsubsection{Graph Macros} used to introduce nodes into a graph that are then connected as in the following example: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] \tikz \graph [clockwise, clique] { subgraph I_n [n=4] }; \end{codeexample} % @@ -3341,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}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] \tikz \graph { subgraph I_nm [V={1,2,3}, W={a,b,c}] }; \end{codeexample} % @@ -3371,7 +3377,7 @@ \subsubsection{Graph Macros} The main purpose of this subgraph is to setup the nodes in a bipartite graph: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] \tikz \graph { subgraph I_nm [n=3, m=4]; @@ -3386,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}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] \tikz \graph [clockwise] { subgraph K_n [n=7] }; \end{codeexample} % @@ -3396,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}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] \tikz \graph [branch right, grow down] { subgraph K_nm [V={6,...,9}, W={b,...,e}] }; \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] \tikz \graph [simple, branch right, grow down] { subgraph K_nm [V={1,2,3}, W={a,b,c,d}, ->]; @@ -3414,7 +3420,7 @@ \subsubsection{Graph Macros} \begin{graph}{subgraph P\_n} This graph is the path on the vertices in |V|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] \tikz \graph [branch right] { subgraph P_n [n=3] }; \end{codeexample} % @@ -3423,7 +3429,7 @@ \subsubsection{Graph Macros} \begin{graph}{subgraph C\_n} This graph is the cycle on the vertices in |V|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] \tikz \graph [clockwise] { subgraph C_n [n=7, ->] }; \end{codeexample} % @@ -3439,12 +3445,12 @@ \subsubsection{Graph Macros} created between the nodes of a |Grid_n| |subgraph| using different values for |wrap after|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{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}[] +\begin{codeexample}[preamble={\usetikzlibrary{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} @@ -3464,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} @@ -3481,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, @@ -3492,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] @@ -3506,7 +3512,8 @@ \subsubsection{Group Operators} current group having belonging to color class \meta{color}. More precisely, 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}[] + % +\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] \tikz \graph [simple] { subgraph K_n [<->, n=7, clockwise]; % create lots of edges @@ -3520,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 } @@ -3534,7 +3541,7 @@ \subsubsection{Group Operators} all other edges between the nodes of the cycle, provided we are constructing a |simple| graph. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] \tikz \graph [simple] { subgraph K_n [n=7, clockwise]; % create lots of edges @@ -3548,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 } @@ -3561,7 +3568,7 @@ \subsubsection{Group Operators} Works like |induced cycle|, only there is no edge from the last to the first vertex. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] \tikz \graph [simple] { subgraph K_n [n=7, clockwise]; % create lots of edges @@ -3582,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] @@ -3603,7 +3610,7 @@ \subsubsection{Joining Operators} edges between the vertices in either shore are removed (more precisely, they get replaced by |-!-| edges). % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs.standard}}] \tikz \graph [simple] { subgraph K_n [n=5, clockwise]; % Lots of edges @@ -3622,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] @@ -3641,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} % @@ -3661,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}[] +\begin{codeexample}[preamble={\usetikzlibrary{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 e8c5a77dc..f9b7a32d9 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-tikz-matrices.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-tikz-matrices.tex @@ -614,7 +614,7 @@ \subsection{Examples} redraw pictures from Timothy van Zandt's PStricks documentation: % {\catcode`\|=12 -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{matrix}}] \begin{tikzpicture} \matrix [matrix of math nodes,row sep=1cm] { @@ -633,7 +633,10 @@ \subsection{Examples} \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] +\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}, @@ -658,7 +661,7 @@ \subsection{Examples} \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{matrix}}] \begin{tikzpicture} \matrix (network) [matrix of nodes,% @@ -688,7 +691,7 @@ \subsection{Examples} Neurofuzzy identification of an autonomous underwater vehicle, \emph{International Journal of Systems Science}, 1999, 30, 901--913. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows,shapes.geometric}}] \begin{tikzpicture} [auto, decision/.style={diamond, draw=blue, thick, fill=blue!20, diff --git a/doc/generic/pgf/text-en/pgfmanual-en-tikz-paths.tex b/doc/generic/pgf/text-en/pgfmanual-en-tikz-paths.tex index ac0d0080b..ea65ad655 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-tikz-paths.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-tikz-paths.tex @@ -820,7 +820,7 @@ \subsection{The SVG Operation} The |svg| operation can be used to extend the current path by a path given in the \textsc{svg} path data syntax. This syntax is described in detail in -Section 8.3 of the \textsc{svg 1.1} specification, please consult this +Section~8.3 of the \textsc{svg 1.1} specification, please consult this specification for details. \begin{pathoperation}{svg}{\opt{\oarg{options}}\marg{path data}} @@ -832,7 +832,7 @@ \subsection{The SVG Operation} \meta{options} apply locally to this path operation, typically you will use them to set up, say, some transformations. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{svg.path}}] \begin{tikzpicture} \filldraw [fill=red!20] (0,1) svg[scale=2] {h 10 v 10 h -10} node [above left] {upper left} -- cycle; @@ -1184,7 +1184,7 @@ \subsection{The Let Operation} and a $y$-part measured in \TeX\ points (|pt|). In particular, point registers do not store nodes or node names. Here is an example: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calc}}] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); @@ -1224,7 +1224,7 @@ \subsection{The Let Operation} point. Naturally, using the \verb!|-! notation, this could be written much more compactly. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calc}}] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); @@ -1241,7 +1241,7 @@ \subsection{The Let Operation} operation. If you wish to access a computed coordinate outside the body, you must use a |coordinate| path operation: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calc}}] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); @@ -1263,7 +1263,7 @@ \subsection{The Let Operation} For a more useful application of the let operation, let us draw a circle that touches a given line: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calc}}] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,3); @@ -1336,7 +1336,7 @@ \subsection{The Attribute Animation Operation} This causes an animation of \meta{animate attribute} to be added to the current path, see Section~\ref{section-tikz-animations} for details. % -\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} % @@ -1392,10 +1392,10 @@ \subsection{The PGF-Extra Operation} \subsection{Interacting with the Soft Path subsystem} During construction \tikzname\ stores the path internally as a \emph{soft -path}. Sometimes it is desirable to save a path during the stage of -construction, restore it elsewhere and continue using it. There are two keys -to facilitate this operation, which are explained below. To learn more about -the soft path subsystem, refer to section~\ref{section-soft-paths}. +path}. Sometimes it is desirable to save a path during the stage of +construction, restore it elsewhere and continue using it. There are two keys to +facilitate this operation, which are explained below. To learn more about the +soft path subsystem, refer to section~\ref{section-soft-paths}. \begin{key}{/tikz/save path=\meta{macro}} Save the current soft path into \meta{macro}. @@ -1405,7 +1405,7 @@ \subsection{Interacting with the Soft Path subsystem} Set the current path to the soft path stored in \meta{macro}. \end{key} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{intersections}}] \begin{tikzpicture} \path[save path=\pathA,name path=A] (0,1) to [bend left] (1,0); \path[save path=\pathB,name path=B] 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 c18b7a617..674bde2d6 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-tikz-pics.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-tikz-pics.tex @@ -46,7 +46,13 @@ \subsection{Overview} \draw (-3mm,0) to [bend left] (0,0) to [bend left] (3mm,0); } } -\begin{codeexample}[] +\begin{codeexample}[ + pre={\tikzset{ + seagull/.pic={ + % Code for a "seagull". Do you see it?... + \draw (-3mm,0) to [bend left] (0,0) to [bend left] (3mm,0); + }, +}}] \tikz \fill [fill=blue!20] (1,1) -- (2,2) pic {seagull} @@ -126,7 +132,13 @@ \subsection{The Pic Syntax} this option behaves exactly like the |node contents| option and, indeed, the two are interchangeable.) % -\begin{codeexample}[] +\begin{codeexample}[ + pre={\tikzset{ + seagull/.pic={ + % Code for a "seagull". Do you see it?... + \draw (-3mm,0) to [bend left] (0,0) to [bend left] (3mm,0); + }, +}}] \tikz { \path (0,0) pic [pic type = seagull] (1,0) pic {seagull}; @@ -143,7 +155,13 @@ \subsection{The Pic Syntax} of the origin refers to the last position used on the path or to the specified |at|. % -\begin{codeexample}[] +\begin{codeexample}[ + pre={\tikzset{ + seagull/.pic={ + % Code for a "seagull". Do you see it?... + \draw (-3mm,0) to [bend left] (0,0) to [bend left] (3mm,0); + }, +}}] \tikz { % different ways of placing pics \draw [help lines] (0,0) grid (3,2); \pic at (1,0) {seagull}; @@ -157,7 +175,13 @@ \subsection{The Pic Syntax} using the |transform shape| option, which has the same effect as for nodes: The ``outer'' transformation gets applied to the node: % -\begin{codeexample}[] +\begin{codeexample}[ + pre={\tikzset{ + seagull/.pic={ + % Code for a "seagull". Do you see it?... + \draw (-3mm,0) to [bend left] (0,0) to [bend left] (3mm,0); + }, +}}] \tikz [scale=2] { \pic at (0,0) {seagull}; \pic at (1,0) [transform shape] {seagull}; @@ -167,7 +191,13 @@ \subsection{The Pic Syntax} When the \meta{options} contain transformation commands like |scale| or |rotate|, these transformations always apply to the pic: % -\begin{codeexample}[] +\begin{codeexample}[ + pre={\tikzset{ + seagull/.pic={ + % Code for a "seagull". Do you see it?... + \draw (-3mm,0) to [bend left] (0,0) to [bend left] (3mm,0); + }, +}}] \tikz [rotate=30] { \pic at (0,0) {seagull}; \pic at (1,0) [rotate=90] {seagull}; @@ -177,7 +207,13 @@ \subsection{The Pic Syntax} Just like nodes, pics can also be positioned implicitly and, somewhat unsurprisingly, the same rules concerning positioning and sloping apply: % -\begin{codeexample}[] +\begin{codeexample}[ + pre={\tikzset{ + seagull/.pic={ + % Code for a "seagull". Do you see it?... + \draw (-3mm,0) to [bend left] (0,0) to [bend left] (3mm,0); + }, +}}] \tikz \draw (0,0) to [bend left] pic [near start] {seagull} @@ -276,7 +312,14 @@ \subsection{The Pic Syntax} \draw (-3mm,-3mm) rectangle (3mm,3mm); } } -\begin{codeexample}[width=6cm] +\begin{codeexample}[ + width=6cm, + pre={\tikzset{ + my pic/.pic = { + \path [pic actions] (0,0) circle[radius=3mm]; + \draw (-3mm,-3mm) rectangle (3mm,3mm); + } +}}] \tikz \pic {my pic}; \space \tikz \pic [red] {my pic}; \space \tikz \pic [draw] {my pic}; \space @@ -297,7 +340,13 @@ \subsection{The Pic Syntax} regard), then comes the path, and then come all nodes and pics that are in front of the path in the order they appeared. % -\begin{codeexample}[] +\begin{codeexample}[ + pre={\tikzset{ + seagull/.pic={ + % Code for a "seagull". Do you see it?... + \draw (-3mm,0) to [bend left] (0,0) to [bend left] (3mm,0); + }, +}}] \tikz \fill [fill=blue!20] (1,1) -- (2,2) pic [behind path] {seagull} @@ -330,7 +379,13 @@ \subsection{The Pic Syntax} As for nodes, a pic specification may start with |foreach|. The effect and semantics are the same as for nodes. % -\begin{codeexample}[] +\begin{codeexample}[ + pre={\tikzset{ + seagull/.pic={ + % Code for a "seagull". Do you see it?... + \draw (-3mm,0) to [bend left] (0,0) to [bend left] (3mm,0); + }, +}}] \tikz \pic foreach \x in {1,2,3} at (\x,0) {seagull}; \end{codeexample} @@ -416,7 +471,20 @@ \subsection{The Pic Syntax} Just as for nodes, you can use the attribute--colon syntax to add an animation to a pic: % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, + pre={\tikzset{ + seagull/.pic={ + % Code for a "seagull". Do you see it?... + \coordinate (-left wing) at (-3mm,0); + \coordinate (-head) at (0,0); + \coordinate (-right wing) at (3mm,0); + % + \draw (-left wing) to [bend left] (0,0) (-head) to [bend left] (-right wing); + } +}}, +] \tikz { \pic :rotate={0s="0", 20s="90"} {seagull}; \pic at (1.5,1.5) {seagull}; @@ -425,7 +493,11 @@ \subsection{The Pic Syntax} % Naturally, you can also use animations in the code of a picture: % -\begin{codeexample}[animation list={0.5,1,1.5,2},width=3cm] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, + width=3cm, +] \begin{tikzpicture} [flapping seagull/.pic={ \draw (0,0) :path={ 0s= {"{(180:3mm) to [bend left] (0,0) to [bend left] (0:3mm)}"=base}, @@ -483,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-tikz-plots.tex b/doc/generic/pgf/text-en/pgfmanual-en-tikz-plots.tex index 3859a65f5..ecb4c99dc 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-tikz-plots.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-tikz-plots.tex @@ -723,7 +723,7 @@ \subsection{Smooth Plots, Sharp Plots, Jump Plots, Comb Plots and Bar Plots} \begin{key}{/tikz/xbar} This option works like |ybar| except that the bars are horizontal. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{patterns}}] \tikz \draw[pattern=north west lines] plot[xbar] coordinates{(1,0) (0.4,1) (1.7,2) (1.6,3)}; \end{codeexample} diff --git a/doc/generic/pgf/text-en/pgfmanual-en-tikz-scopes.tex b/doc/generic/pgf/text-en/pgfmanual-en-tikz-scopes.tex index 61f0aafb8..707640132 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-tikz-scopes.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-tikz-scopes.tex @@ -140,7 +140,7 @@ \subsubsection{Creating a Picture Using an Environment} $y$-coordinate of the resulting point. This makes it easy to reference the $y$-coordinate of, say, the baseline of nodes. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.misc}}] Hello \tikz[baseline=(X.base)] \node [cross out,draw] (X) {world.}; @@ -173,7 +173,7 @@ \subsubsection{Creating a Picture Using an Environment} accumulate. This option must also be given in the optional argument of the |{tikzpicture}| environment. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{backgrounds}}] \begin{tikzpicture}[execute at end picture=% { \begin{pgfonlayer}{background} @@ -358,7 +358,7 @@ \subsubsection{Shorthand for Scope Environments} \tikzname\ picture, it is allowed to start a scope just using a single brace, provided the single brace is followed by options in square brackets: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{scopes}}] \begin{tikzpicture} { [ultra thick] { [red] @@ -404,7 +404,7 @@ \subsubsection{Single Command Scopes} semicolon or it may contain multiple commands, but then they must be surrounded by curly braces. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{backgrounds}}] \begin{tikzpicture} \node [fill=white] at (1,1) {Hello world}; \scoped [on background layer] diff --git a/doc/generic/pgf/text-en/pgfmanual-en-tikz-shapes.tex b/doc/generic/pgf/text-en/pgfmanual-en-tikz-shapes.tex index 01af022c2..355ea263f 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-tikz-shapes.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-tikz-shapes.tex @@ -237,7 +237,7 @@ \subsubsection{Syntax of the Node Command} instead or an ellipse shape (you have to include one of the |shapes.geometric| library for the latter shape): % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \tikz \fill[fill=yellow!80!black] (0,0) node {first node} -- (1,1) node[ellipse,draw, behind path] {second node} @@ -275,7 +275,7 @@ \subsubsection{Syntax of the Node Command} Section~\ref{section-tikz-animations}. Here is a typical example of how this syntax can be used: % -\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 } @@ -632,7 +632,7 @@ \subsubsection{Common Options: Separations, Margins, Padding and Sets a desired aspect ratio for the shape. For the |diamond| shape, this option sets the ratio between width and height of the shape. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \begin{tikzpicture} \draw (0,0) node[shape aspect=1,diamond,draw] {aspect 1}; \draw (0,-2) node[shape aspect=2,diamond,draw] {aspect 2}; @@ -647,7 +647,7 @@ \subsubsection{Common Options: Separations, Margins, Padding and affects only the border of a shape and is independent of the node contents, but \emph{in addition} to any other transformations. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \tikzset{every node/.style={dart, shape border uses incircle, inner sep=1pt, draw}} \tikz \node foreach \a/\b/\c in {A/0/0, B/45/0, C/0/45, D/45/45} @@ -669,7 +669,7 @@ \subsubsection{Common Options: Separations, Margins, Padding and incircle, unrestricted rotation is possible, but the border will not make a very tight fit to the node contents. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \tikzset{every node/.style={isosceles triangle, draw}} \begin{tikzpicture} \node {abc}; @@ -699,7 +699,7 @@ \subsubsection{Common Options: Separations, Margins, Padding and `text box' anchors (including |mid east|, |base west|, and so on), \emph{do not rotate}, but the other anchors do: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \tikzset{every node/.style={shape=trapezium, draw, shape border uses incircle}} \begin{tikzpicture} \node at (0,0) (A) {A}; @@ -742,7 +742,7 @@ \subsection{Multi-Part Nodes} name} -- until another |\partname| is encountered or until the node \meta{text} ends. The \meta{options} will be local to this part. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.multipart}}] \begin{tikzpicture} \node [circle split,draw,double,fill=red!20] { @@ -763,7 +763,7 @@ \subsection{Multi-Part Nodes} This style is installed at the beginning of every node part named \meta{part name}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.multipart}}] \tikz [every lower node part/.style={red}] \node [circle split,draw] {$q_1$ \nodepart{lower} $00$}; \end{codeexample} @@ -851,7 +851,7 @@ \subsubsection{Text Parameters: Font} A useful example of how the |font| option can be used is the following: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.multipart}}] \tikz [every text node part/.style={font=\itshape}, every lower node part/.style={font=\footnotesize}] \node [circle split,draw] {state \nodepart{lower} output}; @@ -1424,7 +1424,7 @@ \subsubsection{Advanced Placement Options} node is shifted by the vertical component of this point. The anchor is set to |south|. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \begin{tikzpicture} \draw[help lines] (0,0) grid (2,2); \node at (1,1) [above=.2 and 3mm,draw] {above}; @@ -1447,7 +1447,7 @@ \subsubsection{Advanced Placement Options} Here is a basic example: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \begin{tikzpicture}[every node/.style=draw] \draw[help lines] (0,0) grid (2,2); \node (somenode) at (1,1) {some node}; @@ -1480,7 +1480,7 @@ \subsubsection{Advanced Placement Options} such a way that the distance between its south border and \meta{node name}'s north border is exactly the given distance. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \begin{tikzpicture}[every node/.style=draw] \draw[help lines] (0,0) grid (2,2); \node (some node) at (1,1) {some node}; @@ -1508,7 +1508,7 @@ \subsubsection{Advanced Placement Options} will result in nodes that are centered on ``grid coordinate'', hence the name of the option. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \begin{tikzpicture}[every node/.style=draw] \draw[help lines] (0,0) grid (2,3); @@ -1530,7 +1530,7 @@ \subsubsection{Advanced Placement Options} The value of this key is used as \meta{shifting part} is used if and only if a \meta{of-part} is present, but no \meta{shifting part}. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \begin{tikzpicture}[every node/.style=draw,node distance=5mm] \draw[help lines] (0,0) grid (2,3); @@ -1595,7 +1595,7 @@ \subsubsection{Advanced Placement Options} % The following example should help to illustrate the difference: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \begin{tikzpicture}[every node/.style={draw,circle}] \draw[help lines] (0,0) grid (2,5); \begin{scope}[node distance=5mm and 5mm] @@ -1615,7 +1615,7 @@ \subsubsection{Advanced Placement Options} \end{tikzpicture} \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \begin{tikzpicture}[every node/.style={draw,rectangle}] \draw[help lines] (0,0) grid (2,5); \begin{scope}[node distance=5mm and 5mm] @@ -1635,7 +1635,7 @@ \subsubsection{Advanced Placement Options} \end{tikzpicture} \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \begin{tikzpicture}[every node/.style={draw,rectangle},on grid] \draw[help lines] (0,0) grid (4,4); \begin{scope}[node distance=1] @@ -1679,7 +1679,7 @@ \subsubsection{Advanced Placement Options} This key is useful for chaining together nodes so that their base lines are aligned. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \begin{tikzpicture}[node distance=1ex] \draw[help lines] (0,0) grid (3,1); \huge @@ -1734,7 +1734,7 @@ \subsection{Fitting Nodes to a Set of Coordinates} the node's text area has exactly the necessary size so that it contains all the given coordinates. Here is an example: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{fit,shapes.geometric}}] \begin{tikzpicture}[level distance=8mm] \node (root) {root} child { node (a) {a} } @@ -1751,7 +1751,7 @@ \subsection{Fitting Nodes to a Set of Coordinates} If you want to fill the fitted node you will usually have to place it on a background layer. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{backgrounds,fit,shapes.geometric}}] \begin{tikzpicture}[level distance=8mm] \node (root) {root} child { node (a) {a} } @@ -1792,7 +1792,10 @@ \subsection{Transformations} \item You can give transformation options \emph{inside} the option list of the node. \emph{These} transformations always apply to the node. % -\begin{codeexample}[] +\begin{codeexample}[ + preamble={\usepgfmodule{nonlineartransformations}\usetikzlibrary{curvilinear}}, + pre={\makeatletter}, +] \begin{tikzpicture}[every node/.style={draw}] \draw[help lines](0,0) grid (3,2); \draw (1,0) node{A} @@ -1820,7 +1823,10 @@ \subsection{Transformations} Section~\ref{section-nonlinear-transformations}. % \makeatletter -\begin{codeexample}[] +\begin{codeexample}[ + preamble={\usepgfmodule{nonlineartransformations}\usetikzlibrary{curvilinear}}, + pre={\makeatletter}, +] \begin{tikzpicture} % Install a nonlinear transformation: \pgfsetcurvilinearbeziercurve @@ -1960,7 +1966,7 @@ \subsection{Placing Nodes on a Line or Curve Explicitly} placement. That is, if |left| is the current |auto| placement, |right| is set instead and the other way round. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{automata}}] \begin{tikzpicture}[auto] \draw[help lines,use as bounding box] (0,-.5) grid (4,5); @@ -1972,7 +1978,7 @@ \subsection{Placing Nodes on a Line or Curve Explicitly} \end{tikzpicture} \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{automata}}] \begin{tikzpicture}[shorten >=1pt,node distance=2cm,auto] \draw[help lines] (0,0) grid (3,2); @@ -2132,7 +2138,7 @@ \subsubsection{Overview} be used to ``add a node next to another node''. As an example, suppose we want to draw a graph in which the nodes are small circles: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \tikz [circle] { \node [draw] (s) {}; \node [draw] (a) [right=of s] {} edge (s); @@ -2149,7 +2155,7 @@ \subsubsection{Overview} option allow us to do exactly this without having to use the cumbersome |node| syntax: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \tikz [circle] { \node [draw] (s) [label=$s$] {}; \node [draw] (a) [right=of s] {} edge (s); @@ -2338,7 +2344,7 @@ \subsubsection{The Pin Option} \begin{stylekey}{/tikz/every pin edge (initially help lines)} This style is used in every edge created by the |pin| options. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \tikz [pin distance=15mm, every pin edge/.style={<-,shorten <=1pt,decorate, decoration={snake,pre length=4pt}}] @@ -2403,7 +2409,7 @@ \subsubsection{The Quotes Syntax} Let us have a look at an example: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{quotes}}] \tikz \node ["my label" red, draw] {my node}; \end{codeexample} % @@ -2417,7 +2423,7 @@ \subsubsection{The Quotes Syntax} |label|, one where a position is specified, and examples with more complicated options in curly braces: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{quotes}}] \begin{tikzpicture} \matrix [row sep=5mm] { \node [draw, "label"] {A}; \\ @@ -2470,7 +2476,7 @@ \subsubsection{The Quotes Syntax} the \meta{text} relative to the main node you can just put something like |left| or |above right| inside the \meta{options}: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{quotes}}] \tikz \node ["$90^\circ$" above, "$180^\circ$" left, circle, draw] {circle}; \end{codeexample} @@ -2479,7 +2485,7 @@ \subsubsection{The Quotes Syntax} your \meta{text}. This works since the |label| command allows you to specify a direction at the beginning when it is separated by a colon: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{quotes}}] \tikz \node ["90:$90^\circ$", "left:$180^\circ$", circle, draw] {circle}; \end{codeexample} @@ -2491,7 +2497,7 @@ \subsubsection{The Quotes Syntax} following style is also executed: % \begin{stylekey}{/tikz/every label quotes} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{quotes}}] \tikz [every label quotes/.style=red] \node ["90:$90^\circ$", "left:$180^\circ$", circle, draw] {circle}; \end{codeexample} @@ -2505,7 +2511,7 @@ \subsubsection{The Quotes Syntax} just add curly braces around either the comma or just around the whole \meta{text}: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{quotes}}] \tikz \node ["{yes, we can}", draw] {foo}; \end{codeexample} % @@ -2513,7 +2519,7 @@ \subsubsection{The Quotes Syntax} specifically the colon by curly braces to stop the |label| option from interpreting everything before the colon as a direction: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{quotes}}] \tikz \node ["yes{:} we can", draw] {foo}; \end{codeexample} @@ -2542,7 +2548,7 @@ \subsubsection{The Quotes Syntax} instead of transforming quoted text to the |label| option, they get transformed to the |pin| option: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{quotes}}] \tikz [quotes mean pin] \node ["$90^\circ$" above, "$180^\circ$" left, circle, draw] {circle}; \end{codeexample} @@ -2577,7 +2583,7 @@ \subsubsection{The Quotes Syntax} Here is an example, where the quotes are used to define labels that are automatically named according to the |text|: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{quotes}}] \tikzset{node quotes mean={label={[#2,name={#1}]#1}}} \tikz { @@ -2783,14 +2789,14 @@ \subsubsection{Nodes on Edges: Quotes Syntax} quotes-syntax to be placed next to the edges. Unless the setting of |auto| has been changed, they will be placed to the left. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{quotes}}] \tikz \draw (0,0) edge ["left", ->] (2,0); \end{codeexample} In order to place all labels to the right by default, change this style to |auto=right|: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{quotes}}] \tikz [every edge quotes/.style={auto=right}] \draw (0,0) edge ["right", ->] (2,0); \end{codeexample} @@ -2798,7 +2804,7 @@ \subsubsection{Nodes on Edges: Quotes Syntax} To place all nodes ``on'' the edge, just make this style empty (and, possibly, make your labels opaque): % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{quotes}}] \tikz [every edge quotes/.style={fill=white,font=\footnotesize}] \draw (0,0) edge ["mid", ->] (2,1); \end{codeexample} @@ -2815,7 +2821,7 @@ \subsubsection{Nodes on Edges: Quotes Syntax} another option like |near end| after the apostrophe without having to add curly braces and commas: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{quotes}}] \tikz \draw (0,0) edge ["left", "right"', "start" near start, @@ -2825,7 +2831,7 @@ \subsubsection{Nodes on Edges: Quotes Syntax} In order to modify the distance between the edge labels and the edge, you should consider introducing some styles: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{quotes}}] \tikz [tight/.style={inner sep=1pt}, loose/.style={inner sep=.7em}] \draw (0,0) edge ["left" tight, "right"' loose, diff --git a/doc/generic/pgf/text-en/pgfmanual-en-tikz-transparency.tex b/doc/generic/pgf/text-en/pgfmanual-en-tikz-transparency.tex index b93d2f200..cc9e6f081 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-tikz-transparency.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-tikz-transparency.tex @@ -425,7 +425,7 @@ \subsubsection{Creating Fadings} left to right, but is 50\% transparent for a large circle in the middle. % {\tikzexternaldisable -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{fadings,patterns}}] \begin{tikzfadingfrompicture}[name=fade right] \shade[left color=transparent!0, right color=transparent!100] (0,0) rectangle (2,2); @@ -446,7 +446,7 @@ \subsubsection{Creating Fadings} In the next example we create a fading picture that contains some text. When the fading is used, we only see the shading ``through it''. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{fadings,patterns}}] \begin{tikzfadingfrompicture}[name=tikz] \node [text=transparent!20] {\fontencoding{T1}\fontfamily{ptm}\fontsize{45}{45}\bfseries\selectfont Ti\emph{k}Z}; @@ -491,7 +491,7 @@ \subsubsection{Creating Fadings} % Then, a new fading named \meta{name} will be created based on the shading. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{fadings,patterns}}] \tikzfading[name=fade right, left color=transparent!0, right color=transparent!100] @@ -507,7 +507,7 @@ \subsubsection{Creating Fadings} \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{fadings,patterns}}] \tikzfading[name=fade out, inner color=transparent!0, outer color=transparent!100] @@ -550,7 +550,7 @@ \subsubsection{Fading a Path} fading for the path will be switched off in case it has been switched on by previous options or styles. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{fadings,patterns}}] \begin{tikzpicture}[path fading=south] % Checker board \fill [black!20] (0,0) rectangle (4,3); @@ -579,7 +579,12 @@ \subsubsection{Fading a Path} is used. For instance, if \meta{transformation options} is set to |rotate=90|, the fading is rotated by 90 degrees. % -\begin{codeexample}[] +\begin{codeexample}[ + preamble={\usetikzlibrary{fadings,patterns}}, + pre={\pgfdeclarefading{fade down}{% + \tikzset{top color=pgftransparent!0,bottom color=pgftransparent!100} + \pgfuseshading{axis} +}}] \begin{tikzpicture}[path fading=fade down] % Checker board \fill [black!20] (0,0) rectangle (4,1.5); @@ -600,7 +605,7 @@ \subsubsection{Fading a Path} Note that you can ``fade just about anything''. In particular, you can fade a shading. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{fadings,patterns}}] \begin{tikzpicture} % Checker board \fill [black!20] (0,0) rectangle (4,4); @@ -613,7 +618,7 @@ \subsubsection{Fading a Path} The |fade inside| of the following example is more transparent in the middle than on the outside. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{fadings,patterns}}] \tikzfading[name=fade inside, inner color=transparent!80, outer color=transparent!30] @@ -635,7 +640,7 @@ \subsubsection{Fading a Path} Note that using fadings in conjunction with patterns can create visually rather pleasing effects: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{fadings,patterns,shadows}}] \tikzfading[name=middle, top color=transparent!50, bottom color=transparent!50, @@ -680,7 +685,7 @@ \subsubsection{Fading a Scope} be used. You have to explicitly provide the |scope fading| with a path to actually install a fading. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{fadings,patterns}}] \begin{tikzpicture} \fill [black!20] (-2,-2) rectangle (2,2); \pattern [pattern=checkerboard,pattern color=black!30] @@ -701,7 +706,7 @@ \subsubsection{Fading a Scope} In the following example we resize the fading to the size of the whole picture: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{fadings,patterns}}] \begin{tikzpicture} \fill [black!20] (-2,-2) rectangle (2,2); \pattern [pattern=checkerboard,pattern color=black!30] @@ -717,7 +722,7 @@ \subsubsection{Fading a Scope} Scope fadings are also needed if you wish to fade a node. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{fadings}}] \tikz \node [scope fading=south,fading angle=45,text width=3.5cm] { This is some text that will fade out as we go right @@ -742,7 +747,7 @@ \subsection{Transparency Groups} \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] \begin{tikzpicture} \node at (0,0) [forbidden sign,line width=2ex,draw=red,fill=white] {Smoking}; @@ -762,7 +767,7 @@ \subsection{Transparency Groups} \end{tikzpicture} \end{codeexample} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.symbols}}] \begin{tikzpicture} \node at (0,0) [forbidden sign,line width=2ex,draw=red,fill=white] {Smoking}; @@ -789,7 +794,7 @@ \subsection{Transparency Groups} end, so this red color will be blended with whatever is ``behind'' the group on the page. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{patterns,shapes.symbols}}] \begin{tikzpicture} \pattern[pattern=checkerboard,pattern color=black!15](-1,-1) rectangle (3,1); \node at (0,0) [forbidden sign,line width=2ex,draw=red,fill=white] {Smoking}; @@ -808,7 +813,7 @@ \subsection{Transparency Groups} open another scope inside it or use the |opacity| key with a command inside the group: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{patterns,shapes.symbols}}] \begin{tikzpicture} \pattern[pattern=checkerboard,pattern color=black!15](-1,-1) rectangle (3,1); \node at (0,0) [forbidden sign,line width=2ex,draw=red,fill=white] {Smoking}; diff --git a/doc/generic/pgf/text-en/pgfmanual-en-tikz-trees.tex b/doc/generic/pgf/text-en/pgfmanual-en-tikz-trees.tex index 91d2030c3..e2c3dc2e3 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-tikz-trees.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-tikz-trees.tex @@ -141,7 +141,7 @@ \subsection{Child Paths and Child Nodes} As for any normal node, you can give the child node a name, shift it around, or use options to influence how it is rendered. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.geometric}}] \begin{tikzpicture}[sibling distance=15mm] \node[rectangle,draw] {root} child {node[circle,draw,yshift=-5mm] (left node) {left}} diff --git a/doc/generic/pgf/text-en/pgfmanual-en-tutorial-Euclid.tex b/doc/generic/pgf/text-en/pgfmanual-en-tutorial-Euclid.tex index ace6c5d88..d3819aa52 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-tutorial-Euclid.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-tutorial-Euclid.tex @@ -226,7 +226,7 @@ \subsubsection{The Circle Around \emph{A}} Euclid would write the following: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calc}}] \begin{tikzpicture} \coordinate [label=left:$A$] (A) at (0,0); \coordinate [label=right:$B$] (B) at (1.25,0.25); @@ -267,7 +267,7 @@ \subsubsection{The Circle Around \emph{A}} ``point''). The assignment of a number should be followed by a number in curly braces. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calc}}] \begin{tikzpicture} \coordinate [label=left:$A$] (A) at (0,0); \coordinate [label=right:$B$] (B) at (1.25,0.25); @@ -288,7 +288,7 @@ \subsubsection{The Circle Around \emph{A}} the digits following these macros are just normal \TeX\ parameters. We could also use a longer name, but then we have to use curly braces: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calc}}] \begin{tikzpicture} \coordinate [label=left:$A$] (A) at (0,0); \coordinate [label=right:$B$] (B) at (1.25,0.25); @@ -314,7 +314,7 @@ \subsubsection{The Circle Around \emph{A}} parameter given to |circle through|. This radius is computed in essentially the same way as above. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{through}}] \begin{tikzpicture} \coordinate [label=left:$A$] (A) at (0,0); \coordinate [label=right:$B$] (B) at (1.25,0.25); @@ -339,7 +339,7 @@ \subsubsection{The Intersection of the Circles} of the two circles (which happen to be the same names as the nodes themselves, but nodes and their paths live in different ``namespaces''). % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{intersections,through}}] \begin{tikzpicture} \coordinate [label=left:$A$] (A) at (0,0); \coordinate [label=right:$B$] (B) at (1.25,0.25); @@ -364,7 +364,7 @@ \subsubsection{The Intersection of the Circles} it for the current picture, it is just a small step to computing the bisection of the line $AB$: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{intersections,through}}] \begin{tikzpicture} \coordinate [label=left:$A$] (A) at (0,0); \coordinate [label=right:$B$] (B) at (1.25,0.25); @@ -389,7 +389,7 @@ \subsubsection{The Complete Code} |\A| macro for typesetting a blue $A$. He also uses the |background| layer for drawing the triangle behind everything at the end. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{backgrounds,calc,intersections,through}}] \begin{tikzpicture}[thick,help lines/.style={thin,draw=black!50}] \def\A{\textcolor{input}{$A$}} \def\B{\textcolor{input}{$B$}} \def\C{\textcolor{output}{$C$}} \def\D{$D$} @@ -524,7 +524,7 @@ \subsubsection{Using Partway Calculations for the Construction of \emph{D}} Here is the computation of the point in the middle of the line $AB$: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calc}}] \begin{tikzpicture} \coordinate [label=left:$A$] (A) at (0,0); \coordinate [label=right:$B$] (B) at (1.25,0.25); @@ -543,7 +543,7 @@ \subsubsection{Using Partway Calculations for the Construction of \emph{D}} computed normally (as if no angle were given), but the resulting point is rotated by this angle around the first point. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calc}}] \begin{tikzpicture} \coordinate [label=left:$A$] (A) at (0,0); \coordinate [label=right:$B$] (B) at (1.25,0.25); @@ -558,7 +558,7 @@ \subsubsection{Using Partway Calculations for the Construction of \emph{D}} Finally, it is not necessary to explicitly name the point $X$. Rather, again like in the |xcolor| package, it is possible to chain partway modifiers: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calc}}] \begin{tikzpicture} \coordinate [label=left:$A$] (A) at (0,0); \coordinate [label=right:$B$] (B) at (1.25,0.25); @@ -577,7 +577,7 @@ \subsubsection{Intersecting a Line and a Circle} lines $DA$ and $DB$ can be done using partway calculations, but this time with a part value outside the range $[0,1]$: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calc,through}}] \begin{tikzpicture} \coordinate [label=left:$A$] (A) at (0,0); \coordinate [label=right:$B$] (B) at (0.75,0.25); @@ -604,8 +604,9 @@ \subsubsection{Intersecting a Line and a Circle} by the radius of the circle~$H$. Here is the code for computing $H$: % {\tikzexternaldisable -\begin{codeexample}[pre={ -\begin{tikzpicture} +\begin{codeexample}[ + preamble={\usetikzlibrary{calc,through}}, + pre={\begin{tikzpicture} \coordinate [label=left:$A$] (A) at (0,0); \coordinate [label=right:$B$] (B) at (0.75,0.25); \coordinate [label=above:$C$] (C) at (1,1.5); @@ -613,8 +614,9 @@ \subsubsection{Intersecting a Line and a Circle} \coordinate [label=above:$D$] (D) at ($ (A) ! .5 ! (B) ! {sin(60)*2} ! 90:(B) $) {}; \draw (D) -- ($ (D) ! 3.5 ! (B) $) coordinate [label=below:$F$] (F); - \draw (D) -- ($ (D) ! 2.5 ! (A) $) coordinate [label=below:$E$] (E); -},post={\end{tikzpicture}}] + \draw (D) -- ($ (D) ! 2.5 ! (A) $) coordinate [label=below:$E$] (E);}, + post={\end{tikzpicture}}, +] \node (H) [label=135:$H$,draw,circle through=(C)] at (B) {}; \path let \p1 = ($ (B) - (C) $) in coordinate [label=left:$G$] (G) at ($ (B) ! veclen(\x1,\y1) ! (F) $); @@ -625,8 +627,9 @@ \subsubsection{Intersecting a Line and a Circle} of the line in question and then use |name intersections| to compute the intersections. % -\begin{codeexample}[pre={ -\begin{tikzpicture} +\begin{codeexample}[ + preamble={\usetikzlibrary{calc,intersections,through}}, + pre={\begin{tikzpicture} \coordinate [label=left:$A$] (A) at (0,0); \coordinate [label=right:$B$] (B) at (0.75,0.25); \coordinate [label=above:$C$] (C) at (1,1.5); @@ -634,8 +637,9 @@ \subsubsection{Intersecting a Line and a Circle} \coordinate [label=above:$D$] (D) at ($ (A) ! .5 ! (B) ! {sin(60)*2} ! 90:(B) $) {}; \draw (D) -- ($ (D) ! 3.5 ! (B) $) coordinate [label=below:$F$] (F); - \draw (D) -- ($ (D) ! 2.5 ! (A) $) coordinate [label=below:$E$] (E); -},post={\end{tikzpicture}}] + \draw (D) -- ($ (D) ! 2.5 ! (A) $) coordinate [label=below:$E$] (E);}, + post={\end{tikzpicture}}, +] \node (H) [name path=H,label=135:$H$,draw,circle through=(C)] at (B) {}; \path [name path=B--F] (B) -- (F); \path [name intersections={of=H and B--F,by={[label=left:$G$]G}}]; @@ -646,7 +650,7 @@ \subsubsection{Intersecting a Line and a Circle} \subsubsection{The Complete Code} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calc,intersections,through}}] \begin{tikzpicture}[thick,help lines/.style={thin,draw=black!50}] \def\A{\textcolor{orange}{$A$}} \def\B{\textcolor{input}{$B$}} \def\C{\textcolor{input}{$C$}} \def\D{$D$} 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 023efec08..bc4335359 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-tutorial-chains.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-tutorial-chains.tex @@ -21,37 +21,34 @@ \section{Tutorial: Diagrams as Simple Graphs} \footnote{The shown diagram was not scanned, but rather typeset using \tikzname. The jittering lines were created using the |random steps| decoration.}: -% -\begin{codeexample}[setup code, hidden] -\tikzset{ - nonterminal/.style={ - % The shape: - rectangle, - % The size: - minimum size=6mm, - % The border: - very thick, - draw=red!50!black!50, % 50% red and 50% black, - % and that mixed with 50% white - % The filling: - top color=white, % a shading that is white at the top... - bottom color=red!50!black!20, % and something else at the bottom - % Font - font=\itshape - }, - terminal/.style={ - % The shape: - rounded rectangle, - minimum size=6mm, - % The rest - very thick,draw=black!50, - top color=white,bottom color=black!20, - font=\ttfamily}, - skip loop/.style={to path={-- ++(0,#1) -| (\tikztotarget)}} -} -\end{codeexample} { + \tikzset{ + nonterminal/.style={ + % The shape: + rectangle, + % The size: + minimum size=6mm, + % The border: + very thick, + draw=red!50!black!50, % 50% red and 50% black, + % and that mixed with 50% white + % The filling: + top color=white, % a shading that is white at the top... + bottom color=red!50!black!20, % and something else at the bottom + % Font + font=\itshape + }, + terminal/.style={ + % The shape: + rounded rectangle, + minimum size=6mm, + % The rest + very thick,draw=black!50, + top color=white,bottom color=black!20, + font=\ttfamily}, + skip loop/.style={to path={-- ++(0,#1) -| (\tikztotarget)}} + } \tikzset{terminal/.append style={text height=1.5ex,text depth=.25ex}} \tikzset{nonterminal/.append style={text height=1.5ex,text depth=.25ex}} \medskip @@ -178,7 +175,7 @@ \subsection{Styling the Nodes} Ilka starts with the simpler nonterminals, as there are no rounded corners involved. Naturally, she sets up a style: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \begin{tikzpicture}[ nonterminal/.style={ % The shape: @@ -212,7 +209,7 @@ \subsection{Styling the Nodes} the shapes are, indeed, exactly 6mm by 6mm and otherwise half circles on the sides: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \begin{tikzpicture}[node distance=5mm, terminal/.style={ % The shape: @@ -233,7 +230,7 @@ \subsection{Styling the Nodes} instance, she could have an arc only on the left side, but she will not need this. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning,shapes.misc}}] \begin{tikzpicture}[node distance=5mm, terminal/.style={ % The shape: @@ -252,7 +249,20 @@ \subsection{Styling the Nodes} At this point, she notices a problem. The baseline of the text in the nodes is not aligned: % -\begin{codeexample}[] +\begin{codeexample}[setup code,hidden] +\tikzset{ + terminal/.style={ + % The shape: + rounded rectangle, + minimum size=6mm, + % The rest + very thick,draw=black!50, + top color=white,bottom color=black!20, + font=\ttfamily}, +} +\end{codeexample} +% +\begin{codeexample}[preamble={\usetikzlibrary{calc,positioning,shapes.misc}}] \begin{tikzpicture}[node distance=5mm] \node (dot) [terminal] {.}; \node (digit) [terminal,right=of dot] {digit}; @@ -280,9 +290,9 @@ \subsection{Styling the Nodes} the baseline is right of the baseline of the other object). However, this does not have the desired effect: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning,shapes.misc}}] \begin{tikzpicture}[node distance=5mm] - \node (dot) [terminal] {.}; + \node (dot) [terminal] {.}; \node (digit) [terminal,base right=of dot] {digit}; \node (E) [terminal,base right=of digit] {E}; \end{tikzpicture} @@ -296,7 +306,7 @@ \subsection{Styling the Nodes} use the |text height| and |text depth| options to explicitly specify a height and depth for the nodes. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning,shapes.misc}}] \begin{tikzpicture}[node distance=5mm, text height=1.5ex,text depth=.25ex] \node (dot) [terminal] {.}; @@ -306,7 +316,7 @@ \subsection{Styling the Nodes} \end{codeexample} -\subsection{Aligning the Nodes Using Positioning Options} +\subsection{Aligning the Nodes Using Positioning Options} Ilka now has the ``styling'' of the nodes ready. The next problem is to place them in the right places. There are several ways to do this. The most @@ -336,11 +346,30 @@ \subsection{Aligning the Nodes Using Positioning Options} Ilka can use this to draw the place the nodes in a long row: % \begin{codeexample}[setup code,hidden] -\tikzset{terminal/.append style={text height=1.5ex,text depth=.25ex}} -\tikzset{nonterminal/.append style={text height=1.5ex,text - depth=.25ex}} +\tikzset{ + nonterminal/.style={ + % The shape: + rectangle, + % The size: + minimum size=6mm, + % The border: + very thick, + draw=red!50!black!50, % 50% red and 50% black, + % and that mixed with 50% white + % The filling: + top color=white, % a shading that is white at the top... + bottom color=red!50!black!20, % and something else at the bottom + % Font + font=\itshape, + }, +} +\tikzset{ + terminal/.append style={text height=1.5ex,text depth=.25ex}, + nonterminal/.append style={text height=1.5ex,text depth=.25ex}, +} \end{codeexample} -\begin{codeexample}[] +% +\begin{codeexample}[preamble={\usetikzlibrary{positioning,shapes.misc}}] \begin{tikzpicture}[node distance=5mm and 5mm] \node (ui1) [nonterminal] {unsigned integer}; \node (dot) [terminal,right=of ui1] {.}; @@ -363,7 +392,7 @@ \subsection{Aligning the Nodes Using Positioning Options} There are several ways of fixing this problem. The easiest way is to simply add a little bit of horizontal shift by hand: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning,shapes.misc}}] \begin{tikzpicture}[node distance=5mm and 5mm] \node (E) [terminal] {E}; \node (plus) [terminal,above right=of E,xshift=5mm] {+}; @@ -376,7 +405,7 @@ \subsection{Aligning the Nodes Using Positioning Options} terminals, but with rounded corners. Since corner rounding does not affect anchors, she gets the following result: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning,shapes.misc}}] \begin{tikzpicture}[node distance=5mm and 5mm,terminal/.append style={rectangle,rounded corners=3mm}] \node (E) [terminal] {E}; \node (plus) [terminal,above right=of E] {+}; @@ -394,7 +423,7 @@ \subsection{Aligning the Nodes Using Positioning Options} the left and finally ends at a point a little to the left of |digit|''. Ilka can put this into code as follows: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calc,positioning,shapes.misc}}] \begin{tikzpicture}[node distance=5mm and 5mm] \node (dot) [terminal] {.}; \node (digit) [terminal,right=of dot] {digit}; @@ -421,7 +450,7 @@ \subsection{Aligning the Nodes Using Positioning Options} of |to path| to the path. So, Ilka can set up a style that contains the correct path: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calc,positioning,shapes.misc}}] \begin{tikzpicture}[node distance=5mm and 5mm, skip loop/.style={to path={-- ++(0,-.5) -| (\tikztotarget)}}] \node (dot) [terminal] {.}; @@ -435,12 +464,12 @@ \subsection{Aligning the Nodes Using Positioning Options} \end{tikzpicture} \end{codeexample} -Ilka can even go a step further and make her |skip look| style parameterized. +Ilka can even go a step further and make her |skip loop| style parameterized. For this, the skip loop's vertical offset is passed as parameter |#1|. Also, in the following code Ilka specifies the start and targets differently, namely as the positions that are ``in the middle between the nodes''. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{calc,positioning,shapes.misc}}] \begin{tikzpicture}[node distance=5mm and 5mm, skip loop/.style={to path={-- ++(0,#1) -| (\tikztotarget)}}] \node (dot) [terminal] {.}; @@ -455,7 +484,7 @@ \subsection{Aligning the Nodes Using Positioning Options} \end{codeexample} -\subsection{Aligning the Nodes Using Matrices} +\subsection{Aligning the Nodes Using Matrices} Ilka is still bothered a bit by the placement of the plus and minus nodes. Somehow, having to add an explicit |xshift| seems too much like cheating. @@ -470,7 +499,7 @@ \subsection{Aligning the Nodes Using Matrices} node, one row containing the main nodes and one row containing only the minus node. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.misc}}] \begin{tikzpicture} \matrix[row sep=1mm,column sep=5mm] { % First row: @@ -496,7 +525,7 @@ \subsection{Aligning the Nodes Using Matrices} be invisible) at all the places where she would like connections to start and end. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{shapes.misc}}] \begin{tikzpicture}[point/.style={circle,inner sep=0pt,minimum size=2pt,fill=red}, skip loop/.style={to path={-- ++(0,#1) -| (\tikztotarget)}}] \matrix[row sep=1mm,column sep=2mm] { @@ -543,6 +572,7 @@ \subsubsection{Connecting Already Positioned Nodes} |\matrixcontent| contains exactly the matrix content from the previous example; no need to repeat it here): % +\begin{codeexample}[setup code,hidden] \def\matrixcontent{ % First row: \& \& \& \& \& \& \& \& \& \& \& \node (plus) [terminal] {+};\\ @@ -558,7 +588,12 @@ \subsubsection{Connecting Already Positioned Nodes} % Third row: \& \& \& \& \& \& \& \& \& \& \& \node (minus)[terminal] {-};\\ } -\begin{codeexample}[pre={\tikzset{ampersand replacement=\&,point/.style={coordinate}}}] +\end{codeexample} +% +\begin{codeexample}[ + preamble={\usetikzlibrary{graphs,shapes.misc}}, + pre={\tikzset{ampersand replacement=\&,point/.style={coordinate}}}, +] \begin{tikzpicture}[skip loop/.style={to path={-- ++(0,#1) -| (\tikztotarget)}}, hv path/.style={to path={-| (\tikztotarget)}}, vh path/.style={to path={|- (\tikztotarget)}}] @@ -570,8 +605,8 @@ \subsubsection{Connecting Already Positioned Nodes} (p4) ->[skip loop=-5mm] (p3); (p2) ->[skip loop=5mm] (p5); (p6) ->[skip loop=-11mm] (p9); - (p7) ->[vh path] (plus) -> [hv path] (p8); - (p7) ->[vh path] (minus) -> [hv path] (p8); + (p7) ->[vh path] (plus) -> [hv path] (p8); + (p7) ->[vh path] (minus) -> [hv path] (p8); }; \end{tikzpicture} \end{codeexample} @@ -592,11 +627,17 @@ \subsubsection{Connecting Already Positioned Nodes} |use existing nodes| option, Ilka can also leave out all the parentheses (again, some options have been moved outside to keep the examples shorter): % -\begin{codeexample}[pre={\tikzset{ampersand replacement=\&,point/.style={coordinate}, - skip loop/.style={to path={-- ++(0,##1) -| (\tikztotarget)}}, - hv path/.style={to path={-| (\tikztotarget)}}, - vh path/.style={to path={|- (\tikztotarget)}}}}] -\begin{tikzpicture}[,>=stealth',thick,black!50,text=black, +\begin{codeexample}[ + preamble={\usetikzlibrary{arrows,graphs,shapes.misc}}, + pre={\tikzset{ + ampersand replacement=\&, + point/.style={coordinate}, + skip loop/.style={to path={-- ++(0,##1) -| (\tikztotarget)}}, + hv path/.style={to path={-| (\tikztotarget)}}, + vh path/.style={to path={|- (\tikztotarget)}}, +}}, +] +\begin{tikzpicture}[>=stealth',thick,black!50,text=black, every new ->/.style={shorten >=1pt}, graphs/every graph/.style={edges=rounded corners}] \matrix[column sep=4mm] { \matrixcontent }; @@ -620,7 +661,7 @@ \subsubsection{Creating Nodes Using the Graph Command} by parentheses, then \tikzname\ will actually create a node whose name and text is the node name: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs}}] \tikz \graph [grow right=2cm] { unsigned integer -> d -> digit -> E }; \end{codeexample} % @@ -633,8 +674,8 @@ \subsubsection{Creating Nodes Using the Graph Command} \tikzname, so she had to choose a different name -- which is not good, since she wants a dot to be shown! The trick is to put the dot in quotation marks, this allows you to use ``quite arbitrary text'' as a node name: - -\begin{codeexample}[] +% +\begin{codeexample}[preamble={\usetikzlibrary{graphs,shapes.misc}}] \tikz \graph [grow right sep] { unsigned integer[nonterminal] -> "."[terminal] -> digit[terminal] -> E[terminal] }; @@ -643,7 +684,7 @@ \subsubsection{Creating Nodes Using the Graph Command} Now comes the fork to the plus and minus signs. Here, Ilka can use the grouping mechanism of the |graph| command to create a split: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,shapes.misc}}] \tikz \graph [grow right sep] { unsigned integer [nonterminal] -> "." [terminal] -> @@ -677,10 +718,14 @@ \subsubsection{Creating Nodes Using the Graph Command} Next, Ilka needs to add some coordinates in between of some nodes where the back-loops should got and she needs to shift the nodes a bit: % -\begin{codeexample}[pre={\tikzset{ - skip loop/.style={to path={-- ++(0,##1) -| (\tikztotarget)}}, - hv path/.style={to path={-| (\tikztotarget)}}, - vh path/.style={to path={|- (\tikztotarget)}}}}] +\begin{codeexample}[ + preamble={\usetikzlibrary{arrows,graphs,shapes.misc}}, + pre={\tikzset{ + skip loop/.style={to path={-- ++(0,##1) -| (\tikztotarget)}}, + hv path/.style={to path={-| (\tikztotarget)}}, + vh path/.style={to path={|- (\tikztotarget)}}, +}}, +] \begin{tikzpicture}[>=stealth', thick, black!50, text=black, every new ->/.style={shorten >=1pt}, graphs/every graph/.style={edges=rounded corners}] @@ -726,7 +771,7 @@ \subsubsection{Creating Nodes Using the Graph Command} specification ``win''. Thus, by adding two more lines that ``correct'' these edges, we get the final diagram with its complete code: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows,graphs,shapes.misc}}] \tikz [>=stealth', black!50, text=black, thick, every new ->/.style = {shorten >=1pt}, graphs/every graph/.style = {edges=rounded corners}, diff --git a/doc/generic/pgf/text-en/pgfmanual-en-tutorial-map.tex b/doc/generic/pgf/text-en/pgfmanual-en-tutorial-map.tex index e3af1d3b5..d38468cb8 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-tutorial-map.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-tutorial-map.tex @@ -164,30 +164,33 @@ \subsection{Introduction to Trees} Johannes redraws the tree, but this time with some more appropriate options set, which he found more or less by trial-and-error: % -\begin{codeexample}[render instead={ -\tikz [font=\footnotesize, - grow=right, level 1/.style={sibling distance=6em}, - level 2/.style={sibling distance=1em}, level distance=5cm] - \node {Computational Complexity} % root - child { node {Computational Problems} - child { node {Problem Measures} } child { node {Problem Aspects} } - child { node {Problem Domains} } child { node {Key Problems} } - } - child { node {Computational Models} - child { node {Turing Machines} } child { node {Random-Access Machines} } - child { node {Circuits} } child { node {Binary Decision Diagrams} } - child { node {Oracle Machines} } child { node {Programming in Logic} } - } - child { node {Measuring Complexity} - child { node {Complexity Measures} } child { node {Classifying Complexity} } - child { node {Comparing Complexity} } child { node {Describing Complexity} } - } - child { node {Solving Problems} - child { node {Exact Algorithms} } child { node {Randomization} } - child { node {Fixed-Parameter Algorithms} } child { node {Parallel Computation} } - child { node {Partial Solutions} } child { node {Approximation} } - }; - }] +\begin{codeexample}[ + preamble={\usetikzlibrary{trees}}, + render instead={ + \tikz [font=\footnotesize, + grow=right, level 1/.style={sibling distance=6em}, + level 2/.style={sibling distance=1em}, level distance=5cm] + \node {Computational Complexity} % root + child { node {Computational Problems} + child { node {Problem Measures} } child { node {Problem Aspects} } + child { node {Problem Domains} } child { node {Key Problems} } + } + child { node {Computational Models} + child { node {Turing Machines} } child { node {Random-Access Machines} } + child { node {Circuits} } child { node {Binary Decision Diagrams} } + child { node {Oracle Machines} } child { node {Programming in Logic} } + } + child { node {Measuring Complexity} + child { node {Complexity Measures} } child { node {Classifying Complexity} } + child { node {Comparing Complexity} } child { node {Describing Complexity} } + } + child { node {Solving Problems} + child { node {Exact Algorithms} } child { node {Randomization} } + child { node {Fixed-Parameter Algorithms} } child { node {Parallel Computation} } + child { node {Partial Solutions} } child { node {Approximation} } + }; + }, +] \tikz [font=\footnotesize, grow=right, level 1/.style={sibling distance=6em}, level 2/.style={sibling distance=1em}, level distance=5cm] @@ -224,31 +227,34 @@ \subsection{Introduction to Trees} key for a single child or a whole level. By including the |trees| library you also get access to additional growth strategies such as a ``circular'' growth: % -\begin{codeexample}[render instead={ -\tikz [text width=2.7cm, align=flush center, - grow cyclic, - level 1/.style={level distance=2.5cm,sibling angle=90}, - level 2/.style={text width=2cm, font=\footnotesize, level distance=3cm,sibling angle=30}] - \node[font=\bfseries] {Computational Complexity} % root - child { node {Computational Problems} - child { node {Problem Measures} } child { node {Problem Aspects} } - child { node {Problem Domains} } child { node {Key Problems} } - } - child { node {Computational Models} - child { node {Turing Machines} } child { node {Random-Access Machines} } - child { node {Circuits} } child { node {Binary Decision Diagrams} } - child { node {Oracle Machines} } child { node {Programming in Logic} } - } - child { node {Measuring Complexity} - child { node {Complexity Measures} } child { node {Classifying Complexity} } - child { node {Comparing Complexity} } child { node {Describing Complexity} } - } - child { node {Solving Problems} - child { node {Exact Algorithms} } child { node {Randomization} } - child { node {Fixed-Parameter Algorithms} } child { node {Parallel Computation} } - child { node {Partial Solutions} } child { node {Approximation} } - }; - }] +\begin{codeexample}[ + preamble={\usetikzlibrary{trees}}, + render instead={ + \tikz [text width=2.7cm, align=flush center, + grow cyclic, + level 1/.style={level distance=2.5cm,sibling angle=90}, + level 2/.style={text width=2cm, font=\footnotesize, level distance=3cm,sibling angle=30}] + \node[font=\bfseries] {Computational Complexity} % root + child { node {Computational Problems} + child { node {Problem Measures} } child { node {Problem Aspects} } + child { node {Problem Domains} } child { node {Key Problems} } + } + child { node {Computational Models} + child { node {Turing Machines} } child { node {Random-Access Machines} } + child { node {Circuits} } child { node {Binary Decision Diagrams} } + child { node {Oracle Machines} } child { node {Programming in Logic} } + } + child { node {Measuring Complexity} + child { node {Complexity Measures} } child { node {Classifying Complexity} } + child { node {Comparing Complexity} } child { node {Describing Complexity} } + } + child { node {Solving Problems} + child { node {Exact Algorithms} } child { node {Randomization} } + child { node {Fixed-Parameter Algorithms} } child { node {Parallel Computation} } + child { node {Partial Solutions} } child { node {Approximation} } + }; + }, +] \tikz [text width=2.7cm, align=flush center, grow cyclic, level 1/.style={level distance=2.5cm,sibling angle=90}, @@ -292,40 +298,44 @@ \subsection{Creating the Lecture Map} The third step is to set up the sibling \emph{angle} (rather than a sibling distance) to specify the angle between sibling concepts. % -\begin{codeexample}[render instead={ -\tikz [mindmap, every node/.style=concept, concept color=black!20, - grow cyclic, - level 1/.append style={level distance=4.5cm,sibling angle=90}, - level 2/.append style={level distance=3cm,sibling angle=45}] - \node [root concept] {Computational Complexity} % root - child { node {\hbox to 2cm{Computational\hss} Problems} - child { node {Problem Measures} } - child { node {Problem Aspects} } - child { node {Problem Domains} } - child { node {Key Problems} } - } - child { node {\hbox to 2cm{Computational\hss} Models} - child { node {Turing Machines} } - child { node {Random-Access Machines} } - child { node {Circuits} } - child { node {Binary Decision Diagrams} } - child { node {Oracle Machines} } - child { node {\hbox to1.5cm{Programming\hss} in Logic} } - } - child { node {Measuring Complexity} - child { node {Complexity Measures} } - child { node {Classifying Complexity} } - child { node {Comparing Complexity} } - child { node {Describing Complexity} } - } - child { node {Solving Problems} - child { node {Exact Algorithms} } - child { node {\hbox to 1.5cm{Randomization\hss}} } - child { node {Fixed-Parameter Algorithms} } - child { node {Parallel Computation} } - child { node {Partial Solutions} } - child { node {\hbox to1.5cm{Approximation\hss}} } - };}] +\begin{codeexample}[ + preamble={\usetikzlibrary{mindmap}}, + render instead={ + \tikz [mindmap, every node/.style=concept, concept color=black!20, + grow cyclic, + level 1/.append style={level distance=4.5cm,sibling angle=90}, + level 2/.append style={level distance=3cm,sibling angle=45}] + \node [root concept] {Computational Complexity} % root + child { node {\hbox to 2cm{Computational\hss} Problems} + child { node {Problem Measures} } + child { node {Problem Aspects} } + child { node {Problem Domains} } + child { node {Key Problems} } + } + child { node {\hbox to 2cm{Computational\hss} Models} + child { node {Turing Machines} } + child { node {Random-Access Machines} } + child { node {Circuits} } + child { node {Binary Decision Diagrams} } + child { node {Oracle Machines} } + child { node {\hbox to1.5cm{Programming\hss} in Logic} } + } + child { node {Measuring Complexity} + child { node {Complexity Measures} } + child { node {Classifying Complexity} } + child { node {Comparing Complexity} } + child { node {Describing Complexity} } + } + child { node {Solving Problems} + child { node {Exact Algorithms} } + child { node {\hbox to 1.5cm{Randomization\hss}} } + child { node {Fixed-Parameter Algorithms} } + child { node {Parallel Computation} } + child { node {Partial Solutions} } + child { node {\hbox to1.5cm{Approximation\hss}} } + }; + }, +] \tikz [mindmap, every node/.style=concept, concept color=black!20, grow cyclic, level 1/.append style={level distance=4.5cm,sibling angle=90}, @@ -350,46 +360,49 @@ \subsection{Creating the Lecture Map} each node, he uses the |execute at begin node| option to make \tikzname\ insert this text with every node. % -\begin{codeexample}[render instead={ -\begin{tikzpicture} - [mindmap, - every node/.style={concept, execute at begin node=\hskip0pt}, - concept color=black!20, - grow cyclic, - level 1/.append style={level distance=4.5cm,sibling angle=90}, - level 2/.append style={level distance=3cm,sibling angle=45}] - \clip (-1,2) rectangle ++ (-4,5); - \node [root concept] {Computational Complexity} % root - child { node {Computational Problems} - child { node {Problem Measures} } - child { node {Problem Aspects} } - child { node {Problem Domains} } - child { node {Key Problems} } - } - child { node {Computational Models} - child { node {Turing Machines} } - child { node {Random-Access Machines} } - child { node {Circuits} } - child { node {Binary Decision Diagrams} } - child { node {Oracle Machines} } - child { node {Programming in Logic} } - } - child { node {Measuring Complexity} - child { node {Complexity Measures} } - child { node {Classifying Complexity} } - child { node {Comparing Complexity} } - child { node {Describing Complexity} } - } - child { node {Solving Problems} - child { node {Exact Algorithms} } - child { node {Randomization} } - child { node {Fixed-Parameter Algorithms} } - child { node {Parallel Computation} } - child { node {Partial Solutions} } - child { node {Approximation} } - }; -\end{tikzpicture} -}] +\begin{codeexample}[ + preamble={\usetikzlibrary{mindmap}}, + render instead={ + \begin{tikzpicture} + [mindmap, + every node/.style={concept, execute at begin node=\hskip0pt}, + concept color=black!20, + grow cyclic, + level 1/.append style={level distance=4.5cm,sibling angle=90}, + level 2/.append style={level distance=3cm,sibling angle=45}] + \clip (-1,2) rectangle ++ (-4,5); + \node [root concept] {Computational Complexity} % root + child { node {Computational Problems} + child { node {Problem Measures} } + child { node {Problem Aspects} } + child { node {Problem Domains} } + child { node {Key Problems} } + } + child { node {Computational Models} + child { node {Turing Machines} } + child { node {Random-Access Machines} } + child { node {Circuits} } + child { node {Binary Decision Diagrams} } + child { node {Oracle Machines} } + child { node {Programming in Logic} } + } + child { node {Measuring Complexity} + child { node {Complexity Measures} } + child { node {Classifying Complexity} } + child { node {Comparing Complexity} } + child { node {Describing Complexity} } + } + child { node {Solving Problems} + child { node {Exact Algorithms} } + child { node {Randomization} } + child { node {Fixed-Parameter Algorithms} } + child { node {Parallel Computation} } + child { node {Partial Solutions} } + child { node {Approximation} } + }; + \end{tikzpicture} + }, +] \begin{tikzpicture} [mindmap, every node/.style={concept, execute at begin node=\hskip0pt}, @@ -434,49 +447,53 @@ \subsection{Creating the Lecture Map} with a thick black line and the children are connected to the central concept via bars. % -\begin{codeexample}[render instead={ -\begin{tikzpicture} - [mindmap, - every node/.style={concept, execute at begin node=\hskip0pt}, - root concept/.append style={ - concept color=black, - fill=white, line width=1ex, - text=black}, - text=white, - grow cyclic, - level 1/.append style={level distance=4.5cm,sibling angle=90}, - level 2/.append style={level distance=3cm,sibling angle=45}] - \clip (0,-1) rectangle ++(4,5); - \node [root concept] {Computational Complexity} % root - child [concept color=red] { node {Computational Problems} - child { node {Problem Measures} } - child { node {Problem Aspects} } - child { node {Problem Domains} } - child { node {Key Problems} } - } - child [concept color=blue] { node {Computational Models} - child { node {Turing Machines} } - child { node {Random-Access Machines} } - child { node {Circuits} } - child { node {Binary Decision Diagrams} } - child { node {Oracle Machines} } - child { node {Programming in Logic} } - } - child [concept color=orange] { node {Measuring Complexity} - child { node {Complexity Measures} } - child { node {Classifying Complexity} } - child { node {Comparing Complexity} } - child { node {Describing Complexity} } - } - child [concept color=green!50!black] { node {Solving Problems} - child { node {Exact Algorithms} } - child { node {Randomization} } - child { node {Fixed-Parameter Algorithms} } - child { node {Parallel Computation} } - child { node {Partial Solutions} } - child { node {Approximation} } - }; - \end{tikzpicture}}] +\begin{codeexample}[ + preamble={\usetikzlibrary{mindmap}}, + render instead={ + \begin{tikzpicture} + [mindmap, + every node/.style={concept, execute at begin node=\hskip0pt}, + root concept/.append style={ + concept color=black, + fill=white, line width=1ex, + text=black}, + text=white, + grow cyclic, + level 1/.append style={level distance=4.5cm,sibling angle=90}, + level 2/.append style={level distance=3cm,sibling angle=45}] + \clip (0,-1) rectangle ++(4,5); + \node [root concept] {Computational Complexity} % root + child [concept color=red] { node {Computational Problems} + child { node {Problem Measures} } + child { node {Problem Aspects} } + child { node {Problem Domains} } + child { node {Key Problems} } + } + child [concept color=blue] { node {Computational Models} + child { node {Turing Machines} } + child { node {Random-Access Machines} } + child { node {Circuits} } + child { node {Binary Decision Diagrams} } + child { node {Oracle Machines} } + child { node {Programming in Logic} } + } + child [concept color=orange] { node {Measuring Complexity} + child { node {Complexity Measures} } + child { node {Classifying Complexity} } + child { node {Comparing Complexity} } + child { node {Describing Complexity} } + } + child [concept color=green!50!black] { node {Solving Problems} + child { node {Exact Algorithms} } + child { node {Randomization} } + child { node {Fixed-Parameter Algorithms} } + child { node {Parallel Computation} } + child { node {Partial Solutions} } + child { node {Approximation} } + }; + \end{tikzpicture} + }, +] \begin{tikzpicture} [mindmap, every node/.style={concept, execute at begin node=\hskip0pt}, @@ -517,53 +534,57 @@ \subsection{Creating the Lecture Map} |circular drop shadow|, defined in the |shadows| library, to the concepts, just to make things look a bit more fancy. % -\begin{codeexample}[render instead={ -\begin{tikzpicture}[mindmap] - \begin{scope}[ - every node/.style={concept, circular drop shadow,execute at begin node=\hskip0pt}, - root concept/.append style={ - concept color=black, - fill=white, line width=1ex, - text=black, font=\large\scshape}, - text=white, - computational problems/.style={concept color=red,faded/.style={concept color=red!50}}, - computational models/.style={concept color=blue,faded/.style={concept color=blue!50}}, - measuring complexity/.style={concept color=orange,faded/.style={concept color=orange!50}}, - solving problems/.style={concept color=green!50!black,faded/.style={concept color=green!50!black!50}}, - grow cyclic, - level 1/.append style={level distance=4.5cm,sibling angle=90,font=\scshape}, - level 2/.append style={level distance=3cm,sibling angle=45,font=\scriptsize}] - \node [root concept] {Computational Complexity} % root - child [computational problems] { node {Computational Problems} - child { node {Problem Measures} } - child { node {Problem Aspects} } - child [faded] { node {Problem Domains} } - child { node {Key Problems} } - } - child [computational models] { node {Computational Models} - child { node {Turing Machines} } - child [faded] { node {Random-Access Machines} } - child { node {Circuits} } - child [faded] { node {Binary Decision Diagrams} } - child { node {Oracle Machines} } - child { node {Programming in Logic} } - } - child [measuring complexity] { node {Measuring Complexity} - child { node {Complexity Measures} } - child { node {Classifying Complexity} } - child { node {Comparing Complexity} } - child [faded] { node {Describing Complexity} } - } - child [solving problems] { node {Solving Problems} - child { node {Exact Algorithms} } - child { node {Randomization} } - child { node {Fixed-Parameter Algorithms} } - child { node {Parallel Computation} } - child { node {Partial Solutions} } - child { node {Approximation} } - }; - \end{scope} -\end{tikzpicture}}] +\begin{codeexample}[ + preamble={\usetikzlibrary{mindmap,shadows}}, + render instead={ + \begin{tikzpicture}[mindmap] + \begin{scope}[ + every node/.style={concept, circular drop shadow,execute at begin node=\hskip0pt}, + root concept/.append style={ + concept color=black, + fill=white, line width=1ex, + text=black, font=\large\scshape}, + text=white, + computational problems/.style={concept color=red,faded/.style={concept color=red!50}}, + computational models/.style={concept color=blue,faded/.style={concept color=blue!50}}, + measuring complexity/.style={concept color=orange,faded/.style={concept color=orange!50}}, + solving problems/.style={concept color=green!50!black,faded/.style={concept color=green!50!black!50}}, + grow cyclic, + level 1/.append style={level distance=4.5cm,sibling angle=90,font=\scshape}, + level 2/.append style={level distance=3cm,sibling angle=45,font=\scriptsize}] + \node [root concept] {Computational Complexity} % root + child [computational problems] { node {Computational Problems} + child { node {Problem Measures} } + child { node {Problem Aspects} } + child [faded] { node {Problem Domains} } + child { node {Key Problems} } + } + child [computational models] { node {Computational Models} + child { node {Turing Machines} } + child [faded] { node {Random-Access Machines} } + child { node {Circuits} } + child [faded] { node {Binary Decision Diagrams} } + child { node {Oracle Machines} } + child { node {Programming in Logic} } + } + child [measuring complexity] { node {Measuring Complexity} + child { node {Complexity Measures} } + child { node {Classifying Complexity} } + child { node {Comparing Complexity} } + child [faded] { node {Describing Complexity} } + } + child [solving problems] { node {Solving Problems} + child { node {Exact Algorithms} } + child { node {Randomization} } + child { node {Fixed-Parameter Algorithms} } + child { node {Parallel Computation} } + child { node {Partial Solutions} } + child { node {Approximation} } + }; + \end{scope} + \end{tikzpicture} + }, +] \begin{tikzpicture}[mindmap] \begin{scope}[ every node/.style={concept, circular drop shadow,execute at begin node=\hskip0pt}, @@ -626,64 +647,68 @@ \subsection{Adding the Lecture Annotations} shape of appropriate size. Johannes configures the style by defining |every annotation| appropriately. % -\begin{codeexample}[render instead={ -\begin{tikzpicture}[mindmap] - \clip (-5.25,-3) rectangle ++ (4,5); - \begin{scope}[ - every node/.style={concept, circular drop shadow,execute at begin node=\hskip0pt}, - root concept/.append style={ - concept color=black, - fill=white, line width=1ex, - text=black, font=\large\scshape}, - text=white, - computational problems/.style={concept color=red,faded/.style={concept color=red!50}}, - computational models/.style={concept color=blue,faded/.style={concept color=blue!50}}, - measuring complexity/.style={concept color=orange,faded/.style={concept color=orange!50}}, - solving problems/.style={concept color=green!50!black,faded/.style={concept color=green!50!black!50}}, - grow cyclic, - level 1/.append style={level distance=4.5cm,sibling angle=90,font=\scshape}, - level 2/.append style={level distance=3cm,sibling angle=45,font=\scriptsize}] - \node [root concept] (Computational Complexity) {Computational Complexity} % root - child [computational problems] { node (Computational Problems) {Computational Problems} - child { node (Problem Measures) {Problem Measures} } - child { node (Problem Aspects) {Problem Aspects} } - child [faded] { node (problem Domains) {Problem Domains} } - child { node (Key Problems) {Key Problems} } - } - child [computational models] { node (Computational Models) {Computational Models} - child { node (Turing Machines) {Turing Machines} } - child [faded] { node (Random-Access Machines) {Random-Access Machines} } - child { node (Circuits) {Circuits} } - child [faded] { node (Binary Decision Diagrams) {Binary Decision Diagrams} } - child { node (Oracle Machines) {Oracle Machines} } - child { node (Programming in Logic) {Programming in Logic} } - } - child [measuring complexity] { node (Measuring Complexity) {Measuring Complexity} - child { node (Complexity Measures) {Complexity Measures} } - child { node (Classifying Complexity) {Classifying Complexity} } - child { node (Comparing Complexity) {Comparing Complexity} } - child [faded] { node (Describing Complexity) {Describing Complexity} } - } - child [solving problems] { node (Solving Problems) {Solving Problems} - child { node (Exact Algorithms) {Exact Algorithms} } - child { node (Randomization) {Randomization} } - child { node (Fixed-Parameter Algorithms) {Fixed-Parameter Algorithms} } - child { node (Parallel Computation) {Parallel Computation} } - child { node (Partial Solutions) {Partial Solutions} } - child { node (Approximation) {Approximation} } - }; - \end{scope} - \begin{scope}[every annotation/.style={fill=black!40}] - \node [annotation, above] at (Computational Problems.north) { - Lecture 1: Computational Problems - \begin{itemize} - \item Knowledge of several key problems - \item Knowledge of problem encodings - \item Being able to formalize problems - \end{itemize} - }; - \end{scope} -\end{tikzpicture}}] +\begin{codeexample}[ + preamble={\usetikzlibrary{mindmap,shadows}}, + render instead={ + \begin{tikzpicture}[mindmap] + \clip (-5.25,-3) rectangle ++ (4,5); + \begin{scope}[ + every node/.style={concept, circular drop shadow,execute at begin node=\hskip0pt}, + root concept/.append style={ + concept color=black, + fill=white, line width=1ex, + text=black, font=\large\scshape}, + text=white, + computational problems/.style={concept color=red,faded/.style={concept color=red!50}}, + computational models/.style={concept color=blue,faded/.style={concept color=blue!50}}, + measuring complexity/.style={concept color=orange,faded/.style={concept color=orange!50}}, + solving problems/.style={concept color=green!50!black,faded/.style={concept color=green!50!black!50}}, + grow cyclic, + level 1/.append style={level distance=4.5cm,sibling angle=90,font=\scshape}, + level 2/.append style={level distance=3cm,sibling angle=45,font=\scriptsize}] + \node [root concept] (Computational Complexity) {Computational Complexity} % root + child [computational problems] { node (Computational Problems) {Computational Problems} + child { node (Problem Measures) {Problem Measures} } + child { node (Problem Aspects) {Problem Aspects} } + child [faded] { node (problem Domains) {Problem Domains} } + child { node (Key Problems) {Key Problems} } + } + child [computational models] { node (Computational Models) {Computational Models} + child { node (Turing Machines) {Turing Machines} } + child [faded] { node (Random-Access Machines) {Random-Access Machines} } + child { node (Circuits) {Circuits} } + child [faded] { node (Binary Decision Diagrams) {Binary Decision Diagrams} } + child { node (Oracle Machines) {Oracle Machines} } + child { node (Programming in Logic) {Programming in Logic} } + } + child [measuring complexity] { node (Measuring Complexity) {Measuring Complexity} + child { node (Complexity Measures) {Complexity Measures} } + child { node (Classifying Complexity) {Classifying Complexity} } + child { node (Comparing Complexity) {Comparing Complexity} } + child [faded] { node (Describing Complexity) {Describing Complexity} } + } + child [solving problems] { node (Solving Problems) {Solving Problems} + child { node (Exact Algorithms) {Exact Algorithms} } + child { node (Randomization) {Randomization} } + child { node (Fixed-Parameter Algorithms) {Fixed-Parameter Algorithms} } + child { node (Parallel Computation) {Parallel Computation} } + child { node (Partial Solutions) {Partial Solutions} } + child { node (Approximation) {Approximation} } + }; + \end{scope} + \begin{scope}[every annotation/.style={fill=black!40}] + \node [annotation, above] at (Computational Problems.north) { + Lecture 1: Computational Problems + \begin{itemize} + \item Knowledge of several key problems + \item Knowledge of problem encodings + \item Being able to formalize problems + \end{itemize} + }; + \end{scope} + \end{tikzpicture} + }, +] \begin{tikzpicture}[mindmap] \clip (-5,-5) rectangle ++ (4,5); \begin{scope}[ @@ -717,6 +742,7 @@ \subsection{Adding the Lecture Annotations} and the sixth is a date when the lecture will be held (this parameter is not yet needed, we will, however, need it later on). % +% TODOsp: codeexamples: redo `\lecture` definition*s* when `preamble` can be emptied \begin{codeexample}[code only] \def\lecture#1#2#3#4#5#6{ \node [annotation, #3, scale=0.65, text width=4cm, inner sep=2mm] at (#4) { @@ -729,6 +755,8 @@ \subsection{Adding the Lecture Annotations} }; } \end{codeexample} +% TODOsp: codeexamples: this definition can most likely be deleted, +% because it is moved to the `pre` key in the `codeexamples` \def\lecture#1#2#3#4#5#6{ \node [annotation, #3, scale=0.65, text width=4cm, inner sep=2mm] at (#4) { Lecture #1: \textcolor{orange}{\textbf{#2}} @@ -740,59 +768,74 @@ \subsection{Adding the Lecture Annotations} }; } -\begin{codeexample}[render instead={ -\begin{tikzpicture}[mindmap,every annotation/.style={fill=white}] - \clip (-5.25,-3) rectangle ++ (4,5); - \begin{scope}[ - every node/.style={concept, circular drop shadow,execute at begin node=\hskip0pt}, - root concept/.append style={ - concept color=black, - fill=white, line width=1ex, - text=black, font=\large\scshape}, - text=white, - computational problems/.style={concept color=red,faded/.style={concept color=red!50}}, - computational models/.style={concept color=blue,faded/.style={concept color=blue!50}}, - measuring complexity/.style={concept color=orange,faded/.style={concept color=orange!50}}, - solving problems/.style={concept color=green!50!black,faded/.style={concept color=green!50!black!50}}, - grow cyclic, - level 1/.append style={level distance=4.5cm,sibling angle=90,font=\scshape}, - level 2/.append style={level distance=3cm,sibling angle=45,font=\scriptsize}] - \node [root concept] (Computational Complexity) {Computational Complexity} % root - child [computational problems] { node (Computational Problems) {Computational Problems} - child { node (Problem Measures) {Problem Measures} } - child { node (Problem Aspects) {Problem Aspects} } - child [faded] { node (problem Domains) {Problem Domains} } - child { node (Key Problems) {Key Problems} } - } - child [computational models] { node (Computational Models) {Computational Models} - child { node (Turing Machines) {Turing Machines} } - child [faded] { node (Random-Access Machines) {Random-Access Machines} } - child { node (Circuits) {Circuits} } - child [faded] { node (Binary Decision Diagrams) {Binary Decision Diagrams} } - child { node (Oracle Machines) {Oracle Machines} } - child { node (Programming in Logic) {Programming in Logic} } - } - child [measuring complexity] { node (Measuring Complexity) {Measuring Complexity} - child { node (Complexity Measures) {Complexity Measures} } - child { node (Classifying Complexity) {Classifying Complexity} } - child { node (Comparing Complexity) {Comparing Complexity} } - child [faded] { node (Describing Complexity) {Describing Complexity} } - } - child [solving problems] { node (Solving Problems) {Solving Problems} - child { node (Exact Algorithms) {Exact Algorithms} } - child { node (Randomization) {Randomization} } - child { node (Fixed-Parameter Algorithms) {Fixed-Parameter Algorithms} } - child { node (Parallel Computation) {Parallel Computation} } - child { node (Partial Solutions) {Partial Solutions} } - child { node (Approximation) {Approximation} } - }; - \end{scope} - \lecture{1}{Computational Problems}{above,xshift=-3mm}{Computational Problems.north}{ - \item Knowledge of several key problems - \item Knowledge of problem encodings - \item Being able to formalize problems - }{2009-04-08} -\end{tikzpicture}}] +\begin{codeexample}[ + preamble={\usetikzlibrary{mindmap,shadows}}, + pre={ % !!! replace all `##x` with `#x` +\def\lecture##1##2##3##4##5##6{ + \node [annotation, ##3, scale=0.65, text width=4cm, inner sep=2mm] at (##4) { + Lecture ##1: \textcolor{orange}{\textbf{##2}} + \list{--}{\topsep=2pt\itemsep=0pt\parsep=0pt + \parskip=0pt\labelwidth=8pt\leftmargin=8pt + \itemindent=0pt\labelsep=2pt} + ##5 + \endlist + }; +}}, + render instead={ + \begin{tikzpicture}[mindmap,every annotation/.style={fill=white}] + \clip (-5.25,-3) rectangle ++ (4,5); + \begin{scope}[ + every node/.style={concept, circular drop shadow,execute at begin node=\hskip0pt}, + root concept/.append style={ + concept color=black, + fill=white, line width=1ex, + text=black, font=\large\scshape}, + text=white, + computational problems/.style={concept color=red,faded/.style={concept color=red!50}}, + computational models/.style={concept color=blue,faded/.style={concept color=blue!50}}, + measuring complexity/.style={concept color=orange,faded/.style={concept color=orange!50}}, + solving problems/.style={concept color=green!50!black,faded/.style={concept color=green!50!black!50}}, + grow cyclic, + level 1/.append style={level distance=4.5cm,sibling angle=90,font=\scshape}, + level 2/.append style={level distance=3cm,sibling angle=45,font=\scriptsize}] + \node [root concept] (Computational Complexity) {Computational Complexity} % root + child [computational problems] { node (Computational Problems) {Computational Problems} + child { node (Problem Measures) {Problem Measures} } + child { node (Problem Aspects) {Problem Aspects} } + child [faded] { node (problem Domains) {Problem Domains} } + child { node (Key Problems) {Key Problems} } + } + child [computational models] { node (Computational Models) {Computational Models} + child { node (Turing Machines) {Turing Machines} } + child [faded] { node (Random-Access Machines) {Random-Access Machines} } + child { node (Circuits) {Circuits} } + child [faded] { node (Binary Decision Diagrams) {Binary Decision Diagrams} } + child { node (Oracle Machines) {Oracle Machines} } + child { node (Programming in Logic) {Programming in Logic} } + } + child [measuring complexity] { node (Measuring Complexity) {Measuring Complexity} + child { node (Complexity Measures) {Complexity Measures} } + child { node (Classifying Complexity) {Classifying Complexity} } + child { node (Comparing Complexity) {Comparing Complexity} } + child [faded] { node (Describing Complexity) {Describing Complexity} } + } + child [solving problems] { node (Solving Problems) {Solving Problems} + child { node (Exact Algorithms) {Exact Algorithms} } + child { node (Randomization) {Randomization} } + child { node (Fixed-Parameter Algorithms) {Fixed-Parameter Algorithms} } + child { node (Parallel Computation) {Parallel Computation} } + child { node (Partial Solutions) {Partial Solutions} } + child { node (Approximation) {Approximation} } + }; + \end{scope} + \lecture{1}{Computational Problems}{above,xshift=-3mm}{Computational Problems.north}{ + \item Knowledge of several key problems + \item Knowledge of problem encodings + \item Being able to formalize problems + }{2009-04-08} + \end{tikzpicture} + }, +] \begin{tikzpicture}[mindmap,every annotation/.style={fill=white}] \clip (-5,-5) rectangle ++ (4,5); \begin{scope}[ @@ -839,7 +882,7 @@ \subsection{Adding the Background} In the following code, only the central concept is shown to save some space: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{backgrounds,mindmap,shadows}}] \begin{tikzpicture}[ mindmap, concept color=black, @@ -902,7 +945,10 @@ \subsection{Adding the Calendar} |day list downward| will be a nice option since it produces a list of days that go ``downward''. % -\begin{codeexample}[leave comments] +\begin{codeexample}[ + leave comments, + preamble={\usetikzlibrary{calendar}}, +] \tiny \begin{tikzpicture} \calendar [day list downward, @@ -955,7 +1001,13 @@ \subsection{Adding the Calendar} Johannes can now use this new |\lecture| command as follows (in the example, only the new part of the definition is used): % -\begin{codeexample}[] +\begin{codeexample}[ + preamble={\usetikzlibrary{calendar}}, + pre={ % !!! replace all `##x` with `#x` +\def\lecture##1##2##3##4##5##6{ + \node [anchor=base west] at (cal-##6.base east) {\textcolor{orange}{\textbf{##2}}}; +}}, +] \tiny \begin{tikzpicture} \calendar [day list downward, @@ -979,7 +1031,14 @@ \subsection{Adding the Calendar} is rendered (see Section~\ref{section-calender} for details) and then typesets the month text at a special position at the beginning of each month. % -\begin{codeexample}[leave comments] +\begin{codeexample}[ + leave comments, + preamble={\usetikzlibrary{calendar}}, + pre={ % !!! replace all `##x` with `#x` +\def\lecture##1##2##3##4##5##6{ + \node [anchor=base west] at (cal-##6.base east) {\textcolor{orange}{\textbf{##2}}}; +}}, +] \tiny \begin{tikzpicture} \calendar [day list downward, @@ -1053,7 +1112,9 @@ \subsection{The Complete Code} level 1/.append style={level distance=4.5cm,sibling angle=90,font=\scshape}, level 2/.append style={level distance=3cm,sibling angle=45,font=\scriptsize}] \end{codeexample} +% \dots and contents: +% \begin{codeexample}[code only] \node [root concept] (Computational Complexity) {Computational Complexity} % root child [computational problems] { node [yshift=-1cm] (Computational Problems) {Computational Problems} 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 26f9805b6..af0613266 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-tutorial-nodes.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-tutorial-nodes.tex @@ -402,22 +402,25 @@ \subsection{Naming Nodes} operation. Hagen thinks that this second method seems strange, but he will soon change his opinion. % -{ -\tikzset{place/.style={circle,draw=blue!50,fill=blue!20,thick, - inner sep=0pt,minimum size=6mm}, -transition/.style={rectangle,draw=black!50,fill=black!20,thick, - inner sep=0pt,minimum size=4mm}} +\begin{codeexample}[setup code,hidden] +\tikzset{ + place/.style={circle,draw=blue!50,fill=blue!20,thick, + inner sep=0pt,minimum size=6mm}, + transition/.style={rectangle,draw=black!50,fill=black!20,thick, + inner sep=0pt,minimum size=4mm} +} +\end{codeexample} +% \begin{codeexample}[] % ... set up styles \begin{tikzpicture} - \node (waiting 1) at ( 0,2) [place] {}; - \node (critical 1) at ( 0,1) [place] {}; - \node (semaphore) at ( 0,0) [place] {}; + \node (waiting 1) at ( 0,2) [place] {}; + \node (critical 1) at ( 0,1) [place] {}; + \node (semaphore) at ( 0,0) [place] {}; \node (leave critical) at ( 1,1) [transition] {}; \node (enter critical) at (-1,1) [transition] {}; \end{tikzpicture} \end{codeexample} -} Hagen is pleased to note that the names help in understanding the code. Names for nodes can be pretty arbitrary, but they should not contain commas, periods, @@ -430,11 +433,6 @@ \subsection{Naming Nodes} braces, they accumulate. You can rearrange them arbitrarily and perhaps the following might be preferable: % -{ -\tikzset{place/.style={circle,draw=blue!50,fill=blue!20,thick, - inner sep=0pt,minimum size=6mm}, -transition/.style={rectangle,draw=black!50,fill=black!20,thick, - inner sep=0pt,minimum size=4mm}} \begin{codeexample}[] \begin{tikzpicture} \node[place] (waiting 1) at ( 0,2) {}; @@ -444,7 +442,6 @@ \subsection{Naming Nodes} \node[transition] (enter critical) at (-1,1) {}; \end{tikzpicture} \end{codeexample} -} \subsection{Placing Nodes Using Relative Placement} @@ -457,12 +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: % -{ -\tikzset{place/.style={circle,draw=blue!50,fill=blue!20,thick, - inner sep=0pt,minimum size=6mm}, -transition/.style={rectangle,draw=black!50,fill=black!20,thick, - inner sep=0pt,minimum size=4mm}} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \begin{tikzpicture} \node[place] (waiting) {}; \node[place] (critical) [below=of waiting] {}; @@ -471,7 +463,6 @@ \subsection{Placing Nodes Using Relative Placement} \node[transition] (enter critical) [left=of critical] {}; \end{tikzpicture} \end{codeexample} -} With the |positioning| library loaded, when an option like |below| is followed by |of|, then the position of the node is shifted in such a manner that it is @@ -494,12 +485,8 @@ \subsection{Adding Labels Next to Nodes} \begin{enumerate} \item Hagen can just add a new node above the |north| anchor of the |semaphore| node. -{ -\tikzset{place/.style={circle,draw=blue!50,fill=blue!20,thick, - inner sep=0pt,minimum size=6mm}, -transition/.style={rectangle,draw=black!50,fill=black!20,thick, - inner sep=0pt,minimum size=4mm}} -\begin{codeexample}[] + % +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \begin{tikzpicture} \node[place] (waiting) {}; \node[place] (critical) [below=of waiting] {}; @@ -510,7 +497,6 @@ \subsection{Adding Labels Next to Nodes} \node [red,above] at (semaphore.north) {$s\le 3$}; \end{tikzpicture} \end{codeexample} -} % This is a general approach that will ``always work''. @@ -524,12 +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|. % -{ -\tikzset{place/.style={circle,draw=blue!50,fill=blue!20,thick, - inner sep=0pt,minimum size=6mm}, -transition/.style={rectangle,draw=black!50,fill=black!20,thick, - inner sep=0pt,minimum size=4mm}} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \begin{tikzpicture} \node[place] (waiting) {}; \node[place] (critical) [below=of waiting] {}; @@ -539,7 +520,6 @@ \subsection{Adding Labels Next to Nodes} \node[transition] (enter critical) [left=of critical] {}; \end{tikzpicture} \end{codeexample} -} % It is also possible to give multiple |label| options, this causes multiple labels to be drawn. @@ -559,12 +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. % -{ -\tikzset{place/.style={circle,draw=blue!50,fill=blue!20,thick, - inner sep=0pt,minimum size=6mm}, -transition/.style={rectangle,draw=black!50,fill=black!20,thick, - inner sep=0pt,minimum size=4mm}} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \begin{tikzpicture}[every label/.style={red}] \node[place] (waiting) {}; \node[place] (critical) [below=of waiting] {}; @@ -574,7 +549,6 @@ \subsection{Adding Labels Next to Nodes} \node[transition] (enter critical) [left=of critical] {}; \end{tikzpicture} \end{codeexample} -} \end{enumerate} @@ -590,12 +564,7 @@ \subsection{Connecting Nodes} a coordinate that contains the node's name followed by a dot, followed by the anchor's name: % -{ -\tikzset{place/.style={circle,draw=blue!50,fill=blue!20,thick, - inner sep=0pt,minimum size=6mm}, -transition/.style={rectangle,draw=black!50,fill=black!20,thick, - inner sep=0pt,minimum size=4mm}} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \begin{tikzpicture} \node[place] (waiting) {}; \node[place] (critical) [below=of waiting] {}; @@ -605,17 +574,11 @@ \subsection{Connecting Nodes} \draw [->] (critical.west) -- (enter critical.east); \end{tikzpicture} \end{codeexample} -} Next, let us tackle the curve from |waiting| to |enter critical|. This can be specified using curves and controls: % -{ -\tikzset{place/.style={circle,draw=blue!50,fill=blue!20,thick, - inner sep=0pt,minimum size=6mm}, -transition/.style={rectangle,draw=black!50,fill=black!20,thick, - inner sep=0pt,minimum size=4mm}} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \begin{tikzpicture} \node[place] (waiting) {}; \node[place] (critical) [below=of waiting] {}; @@ -627,7 +590,6 @@ \subsection{Connecting Nodes} .. (enter critical.north); \end{tikzpicture} \end{codeexample} -} Hagen sees how he can now add all his edges, but the whole process seems a but awkward and not very flexible. Again, the code seems to obscure the structure @@ -636,12 +598,7 @@ \subsection{Connecting Nodes} So, let us start improving the code for the edges. First, Hagen can leave out the anchors: % -{ -\tikzset{place/.style={circle,draw=blue!50,fill=blue!20,thick, - inner sep=0pt,minimum size=6mm}, -transition/.style={rectangle,draw=black!50,fill=black!20,thick, - inner sep=0pt,minimum size=4mm}} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \begin{tikzpicture} \node[place] (waiting) {}; \node[place] (critical) [below=of waiting] {}; @@ -653,7 +610,6 @@ \subsection{Connecting Nodes} .. (enter critical); \end{tikzpicture} \end{codeexample} -} Hagen is a bit surprised that this works. After all, how did \tikzname\ know that the line from |enter critical| to |critical| should actually start on the @@ -671,12 +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: % -{ -\tikzset{place/.style={circle,draw=blue!50,fill=blue!20,thick, - inner sep=0pt,minimum size=6mm}, -transition/.style={rectangle,draw=black!50,fill=black!20,thick, - inner sep=0pt,minimum size=4mm}} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \begin{tikzpicture} \node[place] (waiting) {}; \node[place] (critical) [below=of waiting] {}; @@ -687,18 +638,12 @@ \subsection{Connecting Nodes} \draw [->] (waiting) to [out=180,in=90] (enter critical); \end{tikzpicture} \end{codeexample} -} There is another option for the |to| operation, that is even better suited to 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: % -{ -\tikzset{place/.style={circle,draw=blue!50,fill=blue!20,thick, - inner sep=0pt,minimum size=6mm}, -transition/.style={rectangle,draw=black!50,fill=black!20,thick, - inner sep=0pt,minimum size=4mm}} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \begin{tikzpicture} \node[place] (waiting) {}; \node[place] (critical) [below=of waiting] {}; @@ -710,7 +655,6 @@ \subsection{Connecting Nodes} \draw [->] (enter critical) to [bend right=45] (semaphore); \end{tikzpicture} \end{codeexample} -} It is now time for Hagen to learn about yet another way of specifying edges: Using the |edge| path operation. This operation is very similar to the |to| @@ -721,12 +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: % -{ -\tikzset{place/.style={circle,draw=blue!50,fill=blue!20,thick, - inner sep=0pt,minimum size=6mm}, -transition/.style={rectangle,draw=black!50,fill=black!20,thick, - inner sep=0pt,minimum size=4mm}} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{positioning}}] \begin{tikzpicture} \node[place] (waiting) {}; \node[place] (critical) [below=of waiting] {}; @@ -738,7 +677,6 @@ \subsection{Connecting Nodes} edge [->,bend right=45] (semaphore); \end{tikzpicture} \end{codeexample} -} Each |edge| caused a new path to be constructed, consisting of a |to| between the node |enter critical| and the node following the |edge| command. @@ -746,12 +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: % -{ -\tikzset{place/.style={circle,draw=blue!50,fill=blue!20,thick, - inner sep=0pt,minimum size=6mm}, -transition/.style={rectangle,draw=black!50,fill=black!20,thick, - inner sep=0pt,minimum size=4mm}} -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows,positioning}}] % Styles place and transition as before \begin{tikzpicture} [bend angle=45, @@ -772,7 +705,6 @@ \subsection{Connecting Nodes} edge [post,bend right] (semaphore); \end{tikzpicture} \end{codeexample} -} \subsection{Adding Labels Next to Lines} @@ -783,7 +715,7 @@ \subsection{Adding Labels Next to Lines} they are not on the curve but next to it. Adding |swap| will mirror the label with respect to the line. Here is a general example: % -{ +% TODOsp: codeexamples: styles not needed here \begin{codeexample}[] \begin{tikzpicture}[auto,bend right] \node (a) at (0:1) {$0^\circ$}; @@ -795,7 +727,6 @@ \subsection{Adding Labels Next to Lines} (c) to node {3} node [swap] {3'} (a); \end{tikzpicture} \end{codeexample} -} What is happening here? The nodes are given somehow inside the |to| operation! When this is done, the node is placed on the middle of the curve or line @@ -807,14 +738,13 @@ \subsection{Adding Labels Next to Lines} could also easily be placed ``by hand''. However, in a complicated plot with numerous edges automatic placement can be a blessing. % -{ -\tikzset{place/.style={circle,draw=blue!50,fill=blue!20,thick, - inner sep=0pt,minimum size=6mm}, -transition/.style={rectangle,draw=black!50,fill=black!20,thick, - inner sep=0pt,minimum size=4mm}, -pre/.style={<-,shorten <=1pt,>=stealth',semithick}, -post/.style={->,shorten >=1pt,>=stealth',semithick}} -\begin{codeexample}[] +\begin{codeexample}[ + preamble={\usetikzlibrary{arrows,positioning}}, + pre={\tikzset{ + pre/.style={<-,shorten <=1pt,>=stealth',semithick}, + post/.style={->,shorten >=1pt,>=stealth',semithick}, +}}, +] % Styles as before \begin{tikzpicture}[bend angle=45] \node[place] (waiting) {}; @@ -831,7 +761,7 @@ \subsection{Adding Labels Next to Lines} edge [post,bend right] (semaphore); \end{tikzpicture} \end{codeexample} -} +% TODOsp: codeexamples: styles and `positioning` are needed up to here \subsection{Adding the Snaked Line and Multi-Line Text} @@ -844,7 +774,7 @@ \subsection{Adding the Snaked Line and Multi-Line Text} This causes all lines of the path to be replaced by snakes. It is also possible to use snakes only in certain parts of a path, but Hagen will not need this. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \begin{tikzpicture} \draw [->,decorate,decoration=snake] (0,0) -- (2,0); \end{tikzpicture} @@ -855,7 +785,7 @@ \subsection{Adding the Snaked Line and Multi-Line Text} there is an option that helps here. Also, the snake should be a bit smaller, which can be influenced by even more options. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \begin{tikzpicture} \draw [->,decorate, decoration={snake,amplitude=.4mm,segment length=2mm,post length=1mm}] @@ -868,7 +798,7 @@ \subsection{Adding the Snaked Line and Multi-Line Text} specify an |align=center| and then use the |\\| command to enforce the line breaks at the desired positions. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \begin{tikzpicture} \draw [->,decorate, decoration={snake,amplitude=.4mm,segment length=2mm,post length=1mm}] @@ -885,7 +815,7 @@ \subsection{Adding the Snaked Line and Multi-Line Text} Instead of specifying the line breaks ``by hand'', Hagen can also specify a width for the text and let \TeX\ perform the line breaking for him: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{decorations.pathmorphing}}] \begin{tikzpicture} \draw [->,decorate, decoration={snake,amplitude=.4mm,segment length=2mm,post length=1mm}] @@ -924,14 +854,14 @@ \subsection{Using Layers: The Background Rectangles} node, causes the node to be resized and shifted such that it exactly covers all the nodes and coordinates given as parameters to the |fit| option. % -{ -\tikzset{place/.style={circle,draw=blue!50,fill=blue!20,thick, - inner sep=0pt,minimum size=6mm}, -transition/.style={rectangle,draw=black!50,fill=black!20,thick, - inner sep=0pt,minimum size=4mm}, -pre/.style={<-,shorten <=1pt,>=stealth',semithick}, -post/.style={->,shorten >=1pt,>=stealth',semithick}} -\begin{codeexample}[] +% TODOsp: codeexamples: redo/add styles starting from here +\begin{codeexample}[ + preamble={\usetikzlibrary{arrows,backgrounds,fit,positioning}}, + pre={\tikzset{ + pre/.style={<-,shorten <=1pt,>=stealth',semithick}, + post/.style={->,shorten >=1pt,>=stealth',semithick}, +}}, +] % Styles as before \begin{tikzpicture}[bend angle=45] \node[place] (waiting) {}; @@ -953,7 +883,6 @@ \subsection{Using Layers: The Background Rectangles} \end{scope} \end{tikzpicture} \end{codeexample} -} \subsection{The Complete Code} @@ -978,15 +907,18 @@ \subsection{The Complete Code} Now comes the code for the nets: % -{ -\tikzset{ - every place/.style={minimum size=6mm,thick,draw=blue!75,fill=blue!20}, - 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}} \tikzexternaldisable -\begin{codeexample}[pre=\begin{tikzpicture},post=\end{tikzpicture}] +\begin{codeexample}[ + preamble={\usetikzlibrary{arrows,petri,positioning}}, + pre={\tikzset{ + every place/.style={minimum size=6mm,thick,draw=blue!75,fill=blue!20}, + 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}}, +] \node [place,tokens=1] (w1) {}; \node [place] (c1) [below=of w1] {}; \node [place] (s) [below=of c1,label=above:$s\le 3$] {}; @@ -1010,17 +942,20 @@ \subsection{The Complete Code} edge [pre,bend right] (s) edge [post,bend left] node {2} (w2); \end{codeexample} -} -{ -\tikzset{ -every place/.style={minimum size=6mm,thick,draw=blue!75,fill=blue!20}, -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}} \tikzexternaldisable -\begin{codeexample}[pre=\begin{tikzpicture},post=\end{tikzpicture}] +\begin{codeexample}[ + preamble={\usetikzlibrary{arrows,petri,positioning}}, + pre={\tikzset{ + every place/.style={minimum size=6mm,thick,draw=blue!75,fill=blue!20}, + 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}, +}% +\begin{tikzpicture}}, + post={\end{tikzpicture}}, +] \begin{scope}[xshift=6cm] \node [place,tokens=1] (w1') {}; \node [place] (c1') [below=of w1'] {}; @@ -1053,7 +988,6 @@ \subsection{The Complete Code} edge [post,bend left] node {2} (w2'); \end{scope} \end{codeexample} -} The code for the background and the snake is the following: % @@ -1070,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} +% ----------------------------------------------------------------------------- diff --git a/doc/generic/pgf/text-en/pgfmanual-en-tutorial.tex b/doc/generic/pgf/text-en/pgfmanual-en-tutorial.tex index 614177a7f..11a4f8fcd 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-tutorial.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-tutorial.tex @@ -609,6 +609,7 @@ \subsection{Parabola and Sine Path Construction} The operations |sin| and |cos| add a sine or cosine curve in the interval $[0,\pi/2]$ such that the previous current point is at the start of the curve and the curve ends at the given end point. Here are two examples: +% \begin{codeexample}[] A sine \tikz \draw[x=1ex,y=1ex] (0,0) sin (1.57,1); curve. \end{codeexample} @@ -868,7 +869,7 @@ \subsection{Adding Arrow Tips} It turns out that adding arrow tips is pretty easy: Karl adds the option |->| to the drawing commands for the axes: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{intersections}}] \begin{tikzpicture}[scale=3] \clip (-0.1,-0.2) rectangle (1.1,1.51); \draw[step=.5cm,gray,very thin] (-1.4,-1.4) grid (1.4,1.4); @@ -918,7 +919,7 @@ \subsection{Adding Arrow Tips} that he would like ``stealth-fighter-like'' arrow tips: \todosp{remaining instance of bug \#473} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{arrows.meta}}] \begin{tikzpicture}[>=Stealth] \draw [->] (0,0) arc [start angle=180, end angle=30, radius=10pt]; \draw [<<-,very thick] (1,0) -- (1.5cm,10pt) -- (2cm,0pt) -- (2.5cm,10pt); @@ -1232,7 +1233,7 @@ \subsection{Adding Text} used to modify this. Also, options like |near start| and |near end| can be used to modify this position: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{intersections}}] \begin{tikzpicture}[scale=3] \clip (-2,-0.2) rectangle (2,0.8); \draw[step=.5cm,gray,very thin] (-1.4,-1.4) grid (1.4,1.4); @@ -1369,7 +1370,7 @@ \subsection{Pics: The Angle Revisited} $B$, and $C$ are three coordinates. In our case, $B$ is the origin, $A$ is somewhere on the $x$-axis and $C$ is somewhere on a line at $30^\circ$. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{angles,quotes}}] \begin{tikzpicture}[scale=3] \coordinate (A) at (1,0); \coordinate (B) at (0,0); diff --git a/doc/generic/pgf/text-en/pgfmanual-en-xxcolor.tex b/doc/generic/pgf/text-en/pgfmanual-en-xxcolor.tex index 2a114913a..527c2f021 100644 --- a/doc/generic/pgf/text-en/pgfmanual-en-xxcolor.tex +++ b/doc/generic/pgf/text-en/pgfmanual-en-xxcolor.tex @@ -33,7 +33,7 @@ \section{Extended Color Support} |90!blue| will mix in 10\% of blue into everything, whereas |25!white| will make everything nearly white. % -\begin{codeexample}[width=4cm] +\begin{codeexample}[width=4cm,preamble={\usepackage{xxcolor}}] \begin{minipage}{3.5cm}\raggedright \color{red}Red text,% \begin{colormixin}{25!white} @@ -67,7 +67,8 @@ \section{Extended Color Support} Expands to the current accumulated mix-in. Each nesting of a |colormixin| adds a mix-in to this list. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usepackage{xxcolor} +\usepackage{calc}}] \begin{minipage}{\linewidth-6pt}\raggedright \begin{colormixin}{75!white} \colorcurrentmixin\ should be ``!75!white''\par diff --git a/doc/generic/pgf/version-for-luatex/en/pgfmanual-test.tex b/doc/generic/pgf/version-for-luatex/en/pgfmanual-test.tex index 3afefe5c9..00c7aa45b 100644 --- a/doc/generic/pgf/version-for-luatex/en/pgfmanual-test.tex +++ b/doc/generic/pgf/version-for-luatex/en/pgfmanual-test.tex @@ -17,6 +17,6 @@ \begin{document} -\include{pgfmanual-en-tutorial-chains} +\include{pgfmanual-en-base-patterns} \end{document} diff --git a/tex/generic/pgf/basiclayer/pgfcorepatterns.code.tex b/tex/generic/pgf/basiclayer/pgfcorepatterns.code.tex index cda5b1db3..d2186d66b 100644 --- a/tex/generic/pgf/basiclayer/pgfcorepatterns.code.tex +++ b/tex/generic/pgf/basiclayer/pgfcorepatterns.code.tex @@ -123,7 +123,6 @@ \expandafter\pgf@marshal\expandafter{\pgf@pattern@tempvars}{#2}{#3}{#4}{#5}{3}% } -\def\pgfsys@patternmatrix{{1.0}{0.0}{0.0}{1.0}{0.0pt}{0.0pt}} \def\pgf@declarepattern#1#2#3#4#5#6{% \pgfutil@ifundefined{pgf@pattern@name@#1}{% \pgfsysprotocol@getcurrentprotocol\pgf@pattern@temp% @@ -157,11 +156,8 @@ \expandafter\xdef\csname pgf@pattern@name@#1\endcsname{\the\pgfutil@tempcnta}% \expandafter\gdef\csname pgf@pattern@type@#1\endcsname{#6}% \xdef\pgf@marshal{\noexpand\pgfsys@declarepattern - {\csname pgf@pattern@name@#1\endcsname}% name - {\the\pgf@xa}{\the\pgf@ya}{\the\pgf@xb}{\the\pgf@yb}% bbox - {\the\pgf@xc}{\the\pgf@yc}% x/y step - \pgfsys@patternmatrix% transformation matrix - {\pgf@pattern@code}{#6}}% + {\csname pgf@pattern@name@#1\endcsname} + {\the\pgf@xa}{\the\pgf@ya}{\the\pgf@xb}{\the\pgf@yb}{\the\pgf@xc}{\the\pgf@yc}{\pgf@pattern@code}{#6}}% }% \pgfsysprotocol@setcurrentprotocol\pgf@pattern@temp% \expandafter\global\expandafter\let\csname pgf@pattern@instantiate@#1\endcsname=\pgf@marshal% diff --git a/tex/generic/pgf/frontendlayer/tikz/libraries/graphs/tikzlibrarygraphs.standard.code.tex b/tex/generic/pgf/frontendlayer/tikz/libraries/graphs/tikzlibrarygraphs.standard.code.tex index bfceb3769..c7f2daf74 100644 --- a/tex/generic/pgf/frontendlayer/tikz/libraries/graphs/tikzlibrarygraphs.standard.code.tex +++ b/tex/generic/pgf/frontendlayer/tikz/libraries/graphs/tikzlibrarygraphs.standard.code.tex @@ -10,6 +10,7 @@ \ProvidesFileRCS{tikzlibrarygraphs.standard.code.tex} +\usetikzlibrary{graphs}% % % Basic graphs diff --git a/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarypatterns.meta.code.tex b/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarypatterns.meta.code.tex index 432776818..3b52136f7 100644 --- a/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarypatterns.meta.code.tex +++ b/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarypatterns.meta.code.tex @@ -45,7 +45,7 @@ \let\tikz@transform=\relax\pgfkeys{/tikz/.cd,#1}}% }, infer tile bounding box/.code={ - \def\pgf@pat@codeafter{% + \def\pgf@pat@codeafterhook{% \xdef\tikz@pat@installbb{% \noexpand\pgfkeys{/tikz/patterns/bounding box={% (\the\pgf@picminx-#1,\the\pgf@picminy-#1) and @@ -62,13 +62,13 @@ \def\tikzdeclarepattern#1{% \begingroup% - \def\pgf@pat@codebefore{% + \def\pgf@pat@codebeforehook{% \let\tikz@transform=\relax% \pgftransformreset% <- Hmm? \tikz@declarepattern@install% \ifnum\pgf@pat@type=0\relax% - \let\pgfsetstrokecolor=\pgfutil@gobble% - \let\pgfsetfillcolor=\pgfutil@gobble% + \let\pgfsetstrokecolor=\tikz@pat@gobbleone% + \let\pgfsetfillcolor=\tikz@pat@gobbleone% \fi% \def\tikz@fig{% \tikzerror{You cannot use nodes inside a pattern}% @@ -76,7 +76,7 @@ \tikzset{pattern/.code={\tikzerror{You cannot nest patterns}}, pattern color/.style={pattern}}% }% - \pgfdeclarepattern{/tikz/patterns/.cd,#1}% + \pgfdeclarepattern{/tikz/patterns/.cd, #1}% \endgroup% }% diff --git a/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarytopaths.code.tex b/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarytopaths.code.tex index 2051fce8f..b719271d5 100644 --- a/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarytopaths.code.tex +++ b/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarytopaths.code.tex @@ -34,7 +34,9 @@ \pgfmathsetmacro\tikz@to@bend{#1}% \fi% \let\tikz@to@out=\tikz@to@bend% - \pgfmathsetmacro\tikz@to@in{180-\tikz@to@out}% + \c@pgf@counta=180\relax% + \advance\c@pgf@counta by-\tikz@to@out\relax% + \edef\tikz@to@in{\the\c@pgf@counta}% \tikz@to@switch@on% \tikz@to@relativetrue% } diff --git a/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex b/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex index 5f67167ad..99a478eb1 100644 --- a/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex +++ b/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex @@ -148,42 +148,6 @@ \expandafter\def\expandafter\tikz@dashpattern\expandafter{\tikz@dashpattern{#1}}% \pgfutil@ifnextchar\@nil{\pgfutil@gobble}{\tikz@scandashon}}% -% use a decoration to expand the `off' section of a dash pattern. -% https://tex.stackexchange.com/a/133357 -\tikzset{ - dash expand off/.code={% - \ifcsname tikz@library@decorations@loaded\endcsname\else - \tikzerror{You need \string\usetikzlibrary{decorations} for ``dash offexpand''}% - \fi - \tikz@addoption{% - \pgfgetpath\currentpath - \pgfprocessround{\currentpath}{\currentpath}% - \pgf@decorate@parsesoftpath{\currentpath}{\currentpath}% - % Parse \on and \off from the current path - \edef\on{\expandafter\pgfutil@firstoftwo\tikz@dashpattern}% - \edef\off{\expandafter\pgfutil@secondoftwo\tikz@dashpattern}% - % \dashphase = max(\on - \dashphase, 0) - \pgfmathsubtract@{\on}{\tikz@dashphase}% - \pgfmathmax@{\pgfmathresult}{0}% - \edef\dashphase{\the\dimexpr\pgfmathresult pt\relax}% - % \rest = \pgf@decorate@totalpathlength - \on - \edef\rest{\expandafter\pgf@sys@tonumber\dimexpr\pgf@decorate@totalpathlength - \on + 2\dimexpr\dashphase\relax\relax}% - % \onoff = \on + \off - \edef\onoff{\expandafter\pgf@sys@tonumber\dimexpr\on+\off\relax}% - % \nfullonoff = max(floor(\rest/\onoff), 1) - \pgfmathdivide@{\rest}{\onoff}% - \pgfmathfloor@{\pgfmathresult}% - \pgfmathmax@{\pgfmathresult}{1}% - % \offexpand = max(\rest/\nfullonoff - \on, \off) - \pgfmathdivide@{\rest}{\pgfmathresult}% - \pgfmathsubtract@{\pgfmathresult}{\on}% - \pgfmathmax@{\pgfmathresult}{\off}% - \edef\tikz@marshal{\noexpand\pgfsetdash{{\on}{\pgfmathresult}}{\dashphase}}% - \tikz@marshal - }% - } -} - \tikzoption{draw opacity}{\tikz@addoption{\pgfsetstrokeopacity{#1}}}% % Double draw options @@ -1622,7 +1586,6 @@ % ID callbacks \newif\iftikz@is@node -\let\tikz@id@name\pgfutil@empty \let\tikz@id@hook\pgfutil@empty \def\tikz@call@id@hook{\ifx\tikz@id@hook\pgfutil@empty\else\tikz@id@hook\pgfuseid{\tikz@id@name}\fi}% diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/circular/doc.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/circular/doc.lua index 0bd9090a1..ba0a1c282 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/circular/doc.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/circular/doc.lua @@ -14,7 +14,6 @@ local documentation = require 'pgf.gd.doc'.documentation local summary = require 'pgf.gd.doc'.summary local example = require 'pgf.gd.doc'.example - -------------------------------------------------------------------- key "simple necklace layout" @@ -45,7 +44,9 @@ clockwise). The order of the nodes is the order in which they appear in the graph, the edges are not taken into consideration, unless the |componentwise| option is given. % -\begin{codeexample}[] +\begin{codeexample}[ + preamble={\usetikzlibrary{arrows.spaced,graphs,graphdrawing} + \usegdlibrary{circular}}] \tikz[>=spaced stealth'] \graph [simple necklace layout, grow'=down, node sep=1em, nodes={draw,circle}, math nodes] @@ -60,14 +61,16 @@ decomposed into connected components, which are then laid out individually and packed using the usual component packing mechanisms: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{circular}}] \tikz \graph [simple necklace layout] { a -- b -- c -- d -- a, 1 -- 2 -- 3 -- 1 }; \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{circular}}] \tikz \graph [simple necklace layout, componentwise] { a -- b -- c -- d -- a, 1 -- 2 -- 3 -- 1 @@ -78,7 +81,7 @@ The nodes are placed in such a way that % \begin{enumerate} \item The (angular) distance between the centers of consecutive - nodes is at least |node distance|, + nodes is at least |node distance|, \item the distance between the borders of consecutive nodes is at least |node sep|, and \item the radius is at least |radius|. diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentAlign.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentAlign.lua index 5e5b0635b..72a82be97 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentAlign.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentAlign.lua @@ -47,7 +47,6 @@ local declare = require "pgf.gd.interface.InterfaceToAlgorithms".declare -- -- @end - --- declare { @@ -86,7 +85,8 @@ declare { the first node of the component encountered during specification of the component. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees}}] \tikz \graph [binary tree layout, nodes={draw}, component align=first node] { a, b -- c, d -- e[second] -- f }; @@ -99,13 +99,15 @@ declare { between the maximum and minimum value that the projected nodes have on the shift line. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees}}] \tikz \graph [binary tree layout, nodes={draw}, component align=center] { a, b -- c, d -- e[second] -- f }; \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees}}] \tikz \graph [binary tree layout, nodes={draw}, component direction=90, component align=center] @@ -119,13 +121,15 @@ declare { through the center of the node whose center has the highest projected value. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees}}] \tikz \graph [binary tree layout, nodes={draw}, component align=counterclockwise] { a, b -- c, d -- e[second] -- f }; \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees}}] \tikz \graph [binary tree layout, nodes={draw}, component direction=90, component align=counterclockwise] @@ -138,13 +142,15 @@ declare { Works like |counterclockwise|, only in the other direction: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees}}] \tikz \graph [binary tree layout, nodes={draw}, component align=clockwise] { a, b -- c, d -- e[second] -- f }; \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees}}] \tikz \graph [binary tree layout, nodes={draw}, component direction=90, component align=clockwise] @@ -160,7 +166,8 @@ declare { packing, this means that the components are aligned so that the bounding boxes of the components are aligned at the top. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees}}] \tikz \graph [tree layout, nodes={draw, align=center}, component sep=0pt, component align=counterclockwise] @@ -211,8 +218,8 @@ declare { summary = [[" Like |components go right top aligned|, but with - |component align| set to |counterclockwise| |bounding box|. - This means that the components will be aligned with their bounding + |component align| set to |counterclockwise| |bounding box|. + This means that the components will be aligned with their bounding boxed being top-aligned. "]], examples = [[" @@ -530,4 +537,4 @@ declare { -return Components \ No newline at end of file +return Components diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentDistance.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentDistance.lua index 7ba4d000a..a2d04a178 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentDistance.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentDistance.lua @@ -23,7 +23,6 @@ local declare = require "pgf.gd.interface.InterfaceToAlgorithms".declare -- -- @end - --- declare { @@ -42,7 +41,8 @@ declare { are then shifted such that the padding (separating distance) between the two boxes is the current value of |component sep|. % - \begin{codeexample}[] + \begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees}}] \tikz \graph [tree layout, nodes={draw}, component sep=0pt, component packing=rectangular] { a -- long text, longer text -- b}; @@ -60,7 +60,8 @@ declare { padding |component sep| can be used to avoid the nodes actually touching each other. % - \begin{codeexample}[] + \begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees}}] \tikz \graph [tree layout, nodes={draw}, component sep=0pt, level distance=1.5cm, component packing=skyline] @@ -89,7 +90,8 @@ declare { which the line was moved. This means that the holes are ``filled up by slanted roofs''. % - \begin{codeexample}[] + \begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees}}] \begin{tikzpicture} \graph [tree layout, nodes={draw}, component sep=0pt, component packing=skyline] @@ -103,4 +105,4 @@ declare { } -return Components \ No newline at end of file +return Components diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/doc.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/doc.lua index c7adfab83..19bfd52fd 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/doc.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/doc.lua @@ -31,7 +31,8 @@ Now, when you set this key for a single node of a graph, then, by shifting the graph around, this ``wish'' can obviously always be fulfill: % -\begin{codeexample}[] +\begin{codeexample}[preamble={ \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{force}}] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); \graph [spring layout] @@ -41,7 +42,8 @@ always be fulfill: \end{tikzpicture} \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={ \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{force}}] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); \graph [spring layout] @@ -61,7 +63,8 @@ by a graph drawing algorithm.) A nice side effect of this is that you can use the |x| and |y| keys (see Section~\ref{section-graphs-xy}) to specify desired positions: % -\begin{codeexample}[] +\begin{codeexample}[preamble={ \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{force}}] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); \graph [spring layout] @@ -71,7 +74,8 @@ Section~\ref{section-graphs-xy}) to specify desired positions: \end{tikzpicture} \end{codeexample} % -\begin{codeexample}[] +\begin{codeexample}[preamble={ \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{layered}}] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); \graph [layered layout] @@ -94,6 +98,11 @@ sense that some nodes are ``nailed to the canvas'' while other nodes can ``move freely''. ]] +--[[ +% TODOsp: codeexamples: the following 3 examples need these libraries +% \usetikzlibrary{graphs,graphdrawing} +% \usegdlibrary{force} +--]] example [[ \begin{tikzpicture} @@ -158,6 +167,11 @@ Note how in the last example |c| is placed at |(1,1)| rather than |b| as would happen by default. ]] +--[[ +% TODOsp: codeexamples: the following 4 examples need these libraries +% \usetikzlibrary{graphs,graphdrawing} +% \usegdlibrary{layered} +--]] example [[ \tikz \draw (0,0) diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/examples/SimpleEdgeDemo.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/examples/SimpleEdgeDemo.lua index c22c4decf..3ff5f4ea2 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/examples/SimpleEdgeDemo.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/examples/SimpleEdgeDemo.lua @@ -40,7 +40,8 @@ declare { option is declared and how we use it to look up a vertex in the graph by its name. % -\begin{codeexample}[] +\begin{codeexample}[preamble={ \usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{examples}}] \tikz [simple edge demo layout] \graph [radius=2cm] { a, b, c, d, e, f; @@ -140,4 +141,4 @@ function SimpleEdgeDemo:run() end end -return SimpleEdgeDemo \ No newline at end of file +return SimpleEdgeDemo diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/examples/SimpleHuffman.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/examples/SimpleHuffman.lua index f81abf110..6aa9bffb7 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/examples/SimpleHuffman.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/examples/SimpleHuffman.lua @@ -51,7 +51,8 @@ declare { HuffmanNode/.style={/tikz/.cd,circle,inner sep=0pt,outer sep=0pt,draw,minimum size=3pt} } -\begin{codeexample}[] +\begin{codeexample}[preamble={ \usetikzlibrary{graphs,graphdrawing,quotes} + \usegdlibrary{examples}}] \tikz \graph [simple Huffman layout, level distance=7mm, sibling distance=8mm, grow'=up] { @@ -178,6 +179,7 @@ function SimpleHuffman:run() % Ok, we are mainly done now. Finish by computing vertical placements and do formal cleanup. + % \begin{codeexample}[code only, tikz syntax=false] layered.arrange_layers_by_baselines(layers, self.adjusted_bb, self.ugraph) end @@ -282,4 +284,4 @@ function SimpleHuffman:run() layered.arrange_layers_by_baselines(layer, self.adjusted_bb, self.ugraph) end -return SimpleHuffman \ No newline at end of file +return SimpleHuffman diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlSprings.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlSprings.lua index 45b9c9ef5..71005d852 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlSprings.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlSprings.lua @@ -26,13 +26,15 @@ local declare = require("pgf.gd.interface.InterfaceToAlgorithms").declare -- The following examples shows how a simple graph can be scaled by -- changing the |node distance|: -- % --- \begin{codeexample}[] +-- \begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} +-- \usegdlibrary{force}}] -- \tikz \graph [spring layout, node distance=7mm] { subgraph C_n[n=3] }; -- \tikz \graph [spring layout] { subgraph C_n[n=3] }; -- \tikz \graph [spring layout, node distance=15mm]{ subgraph C_n[n=3] }; -- \end{codeexample} -- % --- \begin{codeexample}[] +-- \begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} +-- \usegdlibrary{force}}] -- \tikz \graph [spring electrical layout, node distance=0.7cm] { subgraph C_n[n=3] }; -- \tikz \graph [spring electrical layout] { subgraph C_n[n=3] }; -- \tikz \graph [spring electrical layout, node distance=1.5cm] { subgraph C_n[n=3] }; @@ -41,7 +43,6 @@ local declare = require("pgf.gd.interface.InterfaceToAlgorithms").declare -- @end - --- declare { @@ -56,5 +57,3 @@ declare { the nodes they connect. "]] } - - diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlStart.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlStart.lua index 269b81a3d..85a64b0a5 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlStart.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlStart.lua @@ -14,8 +14,6 @@ local declare = require("pgf.gd.interface.InterfaceToAlgorithms").declare - - --- -- @section subsubsection {Start Configuration} -- @@ -23,19 +21,21 @@ local declare = require("pgf.gd.interface.InterfaceToAlgorithms").declare -- random distribution of the vertices. You can influence it by -- changing the |random seed|: -- % ---\begin{codeexample}[] ---\tikz \graph [random seed=10, spring layout] { --- a -- {b, c, d} -- e -- f -- {g,h} -- {a,b,e}; ---}; ---\end{codeexample} +-- \begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} +-- \usegdlibrary{force}}] +-- \tikz \graph [random seed=10, spring layout] { +-- a -- {b, c, d} -- e -- f -- {g,h} -- {a,b,e}; +-- }; +-- \end{codeexample} -- % ---\begin{codeexample}[] ---\tikz \graph [random seed=11, spring layout] { --- a -- {b, c, d} -- e -- f -- {g,h} -- {a,b,e}; ---}; ---\end{codeexample} +-- \begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} +-- \usegdlibrary{force}}] +-- \tikz \graph [random seed=11, spring layout] { +-- a -- {b, c, d} -- e -- f -- {g,h} -- {a,b,e}; +-- }; +-- \end{codeexample} -- -- Other methods, like a planar preembedding, are not implemented -- currently. -- --- @end \ No newline at end of file +-- @end diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/trees/ChildSpec.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/trees/ChildSpec.lua index 5af364288..815f90d26 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/trees/ChildSpec.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/trees/ChildSpec.lua @@ -13,7 +13,6 @@ --- -- @section subsection {Specifying Missing Children} --- -- \label{section-gd-missing-children} -- -- In the present section we discuss keys for specifying missing children @@ -38,7 +37,8 @@ -- \item When you use the |child| syntax, you can use the |missing| key -- with the |child| command to indicate a missing child: -- % --- \begin{codeexample}[] +-- \begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} +-- \usegdlibrary{trees}}] -- \tikz [binary tree layout, level distance=5mm] -- \node {a} -- child { node {b} @@ -57,7 +57,8 @@ -- which really must be completely empty and may not even contain a -- slash, to indicate a missing node: -- % --- \begin{codeexample}[] +-- \begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} +-- \usegdlibrary{trees}}] -- \tikz [binary tree layout, level distance=5mm] -- \graph { a -> { b -> c -> d, e -> { , f -> { , g} } } }; -- \end{codeexample} diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/trees/SpanningTreeComputation.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/trees/SpanningTreeComputation.lua index 8951ce053..dacf63486 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/trees/SpanningTreeComputation.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/trees/SpanningTreeComputation.lua @@ -35,14 +35,17 @@ -- Selects the (sub)algorithm that is to be used for computing spanning -- trees whenever this is requested by a tree layout algorithm. The -- default algorithm is |breadth first spanning tree|. --- ---\begin{codeexample}[] +--% +--\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} +-- \usegdlibrary{trees}}] --\tikz \graph [tree layout, breadth first spanning tree] --{ -- 1 -- {2,3,4,5} -- 6; --}; --\end{codeexample} ---\begin{codeexample}[] +--% +--\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} +-- \usegdlibrary{trees}}] --\tikz \graph [tree layout, depth first spanning tree] --{ -- 1 --[bend right] {2,3,4,5 [>bend left]} -- 6; diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/trees/doc.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/trees/doc.lua index 169c7ff5e..7710862c0 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/trees/doc.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/trees/doc.lua @@ -83,7 +83,8 @@ When the subtrees of the children of a node are arranged, each position with a missing child is treated as if a zero-width, zero-height subtree were present at that positions: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees}}] \tikz [tree layout, nodes={draw,circle}] \node {r} child { node {a} @@ -95,7 +96,8 @@ zero-height subtree were present at that positions: % or in |graph| syntax: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees}}] \tikz \graph [tree layout, nodes={draw,circle}] { r -> { @@ -109,7 +111,8 @@ or in |graph| syntax: % More than one child can go missing: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees}}] \tikz \graph [tree layout, nodes={draw,circle}, sibling sep=0pt] { r -> { a, , ,b -> {c,d}, ,e} }; \end{codeexample} @@ -122,7 +125,8 @@ root node, they are usually \emph{not} considered as part of the key ensures that |b|, |c|, |e|, and |f| all have a missing right child): % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees}}] \tikz \graph [tree layout, minimum number of children=2, nodes={draw,circle}] { a -> { b -> c -> d, e -> f -> g } }; @@ -136,7 +140,8 @@ Br\"uggemann-Klein and Wood have proposed an extension of the Reingold--Tilford method that is intended to better highlight the overall structure of a tree. Consider the following two trees: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees}}] \tikz [baseline=(a.base), tree layout, minimum number of children=2, sibling distance=5mm, level distance=5mm] \graph [nodes={circle, inner sep=0pt, minimum size=2mm, fill, as=}]{ @@ -165,7 +170,8 @@ minimum distance is encountered on any level other than the first level. Thus, in the first example there is no significant pair, while in the second example |a| and |b| form such a pair. % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{graphs,graphdrawing} + \usegdlibrary{trees}}] \tikz \graph [tree layout, minimum number of children=2, level distance=5mm, nodes={circle,draw}] { / -> { a -> / -> /, b -> /[second] -> /[second] }}; @@ -287,6 +293,9 @@ example }; ]] +--[[ +% TODOsp: codeexamples: the next example needs the library `arrows.spaced` +--]] example [[ \tikz \graph [binary tree layout] { diff --git a/tex/generic/pgf/libraries/luamath/pgflibraryluamath.code.tex b/tex/generic/pgf/libraries/luamath/pgflibraryluamath.code.tex index 7a94b6f8f..300ba52e9 100644 --- a/tex/generic/pgf/libraries/luamath/pgflibraryluamath.code.tex +++ b/tex/generic/pgf/libraries/luamath/pgflibraryluamath.code.tex @@ -299,7 +299,7 @@ \pgfluamath@install@function\pgfmathsubtract@=\pgfluamathsubtract@% \pgfluamath@install@function\pgfmathneg@=\pgfluamathneg@% \pgfluamath@install@function\pgfmathmultiply@=\pgfluamathmultiply@% - \pgfluamath@install@function\pgfmath@iftrue=\pgfmathluamath@iftrue% + \pgfmathfloat@install\pgfmath@iftrue=\pgfmathluamath@iftrue% \pgfluamath@install@function\pgfmathdivide@=\pgfluamathdivide@% % \pgfluamath@install@function\pgfmathdiv@=\pgfluamathdiv@% \pgfluamath@install@function\pgfmathfactorial@=\pgfluamathfactorial@% @@ -406,7 +406,7 @@ \def\pgfluamathadd@#1#2{% \pgfluamathgetresult{pgfluamathfunctions.add(#1,#2)}}% \def\pgfluamathsubtract@#1#2{% - \pgfluamathgetresult{pgfluamathfunctions.subtract(#1,#2)}}% + \pgfluamathgetresult{pgfluamathfunctions.substract(#1,#2)}}% \def\pgfluamathneg@#1{% \pgfluamathgetresult{pgfluamathfunctions.neg(#1)}}% \def\pgfluamathmultiply@#1#2{% diff --git a/tex/generic/pgf/libraries/pgflibrarycurvilinear.code.tex b/tex/generic/pgf/libraries/pgflibrarycurvilinear.code.tex index 941704d17..42217aadf 100644 --- a/tex/generic/pgf/libraries/pgflibrarycurvilinear.code.tex +++ b/tex/generic/pgf/libraries/pgflibrarycurvilinear.code.tex @@ -106,7 +106,7 @@ \pgf@curvilinear@length@a\pgfmathresult pt% \ifdim\pgf@curvilinear@length@a>1pt\relax% % Ok, too large, let us make this smaller - \pgfmathdivide@{\pgf@sys@tonumber\pgf@curvilinear@time@a}{\pgf@sys@tonumber\pgf@curvilinear@length@a}% + \pgfmathdivide@{\pgf@curvilinear@time@a}{\pgf@curvilinear@length@a}% \pgf@curvilinear@time@a\pgfmathresult pt% \pgf@process{\pgfpointcurveattime{\pgf@curvilinear@time@a}{\pgf@curvilinear@line@a}{\pgf@curvilinear@line@b}{\pgf@curvilinear@line@c}{\pgf@curvilinear@line@d}} \pgf@xb=-\pgf@x% diff --git a/tex/generic/pgf/libraries/pgflibrarypatterns.meta.code.tex b/tex/generic/pgf/libraries/pgflibrarypatterns.meta.code.tex index 479992ad3..d3a381524 100644 --- a/tex/generic/pgf/libraries/pgflibrarypatterns.meta.code.tex +++ b/tex/generic/pgf/libraries/pgflibrarypatterns.meta.code.tex @@ -39,9 +39,9 @@ x=1cm, y=1cm, parameters=, defaults=, - bottom left=, - top right=, - tile size=, + bottom left=\pgfpointorigin, + top right=\pgfpointorigin, + tile size=\pgfpointorigin, tile transformation=, code=, set up code=, @@ -86,26 +86,11 @@ \begingroup% \nullfont% \def\pgf@pat@options{#1}% - \pgfkeys{/pgf/patterns/.cd,#1}% - \ifx\pgf@pat@name\pgfutil@empty - \pgferror{Declaring unnamed pattern}% - \fi - \ifx\pgf@pat@bottomleft\pgfutil@empty - \pgferror{Bottom left corner of the bounding box unset}% - \fi - \ifx\pgf@pat@topright\pgfutil@empty - \pgferror{Top right corner of the bounding box unset}% - \fi - \ifx\pgf@pat@tilesize\pgfutil@empty - \pgferror{Tile size unset}% - \fi - \ifx\pgf@pat@code\pgfutil@empty - \pgferror{Pattern code is empty}% - \fi - \pgf@declarepattern@meta% + \pgfkeys{/pgf/patterns/.cd, #1}% + \pgf@declarepattern% \endgroup% }% -\def\pgf@declarepattern@meta{% +\def\pgf@declarepattern{% \pgfifpatternundefined{\pgf@pat@name}{% \ifx\pgf@pat@parameters\pgfutil@empty% % No parameters, so pattern is declared now. @@ -143,13 +128,13 @@ \pgfsysprotocol@setcurrentprotocol\pgfutil@empty% \pgfsysprotocol@bufferedtrue% \pgfsys@beginscope% - \pgfinterruptboundingbox% - \pgfsetarrows{-}% - \pgf@pat@doifnotempty\pgf@pat@codebefore - \pgf@pat@code% - \pgf@pat@doifnotempty\pgf@pat@codeafter% - \endpgfinterruptboundingbox% + \pgfinterruptboundingbox% + \pgfsetarrows{-}% + \pgf@pat@doifnotempty\pgf@pat@codebefore + \pgf@pat@code% + \pgf@pat@doifnotempty\pgf@pat@codeafter% \pgfsys@endscope% + \endpgfinterruptboundingbox% \pgfsysprotocol@getcurrentprotocol\pgf@pattern@code% \global\let\pgf@pattern@code=\pgf@pattern@code% \endpgfinterruptpath% @@ -173,7 +158,7 @@ \pgfutil@tempcnta=\pgf@pattern@number\relax% \advance\pgfutil@tempcnta by1\relax% \xdef\pgf@pattern@number{\the\pgfutil@tempcnta}% - \xdef\pgf@marshal{\noexpand\pgfsys@declarepattern% + \xdef\pgf@marshal{\noexpand\pgfsys@declarepattern@meta% {\pgf@pattern@number}% {\the\pgf@xa}{\the\pgf@ya}{\the\pgf@xb}{\the\pgf@yb}{\the\pgf@xc}{\the\pgf@yc}\pgf@pattern@matrix{\pgf@pattern@code}{\pgf@pat@type}}% }% @@ -246,7 +231,7 @@ %\ifpgf@pat@makepatternimmutable% \let\pgf@pat@parameters=\pgfutil@empty% %\fi% - \pgf@declarepattern@meta% + \pgf@declarepattern% }{}% \expandafter% \endgroup% diff --git a/tex/generic/pgf/math/pgfmathfunctions.random.code.tex b/tex/generic/pgf/math/pgfmathfunctions.random.code.tex index 03be2abfd..531383dfd 100644 --- a/tex/generic/pgf/math/pgfmathfunctions.random.code.tex +++ b/tex/generic/pgf/math/pgfmathfunctions.random.code.tex @@ -180,8 +180,9 @@ % \def\pgfmathrandominteger#1#2#3{% \begingroup% - \pgfmathsetcount\c@pgfmath@counta{#2}% - \pgfmathsetcount\c@pgfmath@countb{#3}% + \pgfmathgeneratepseudorandomnumber% + \c@pgfmath@counta#2\relax% + \c@pgfmath@countb#3\relax% \c@pgfmath@countc\c@pgfmath@countb% % OK. Maybe #2 > #3. \ifnum\c@pgfmath@counta>\c@pgfmath@countb\relax% @@ -191,13 +192,12 @@ \fi% \advance\c@pgfmath@countc1\relax% \advance\c@pgfmath@countc-\c@pgfmath@counta% - \pgfmathgeneratepseudorandomnumber% \c@pgfmath@counta\pgfmathresult\relax% \c@pgfmath@countb\c@pgfmath@counta% \divide\c@pgfmath@countb\c@pgfmath@countc% \multiply\c@pgfmath@countb-\c@pgfmath@countc% \advance\c@pgfmath@counta\c@pgfmath@countb% - \pgfmathaddtocount\c@pgfmath@counta{#2}% + \advance\c@pgfmath@counta#2\relax% \edef\pgfmathresult{\the\c@pgfmath@counta}% \pgfmath@smuggleone{\pgfmathresult}% \endgroup% diff --git a/tex/generic/pgf/math/pgfmathparser.code.tex b/tex/generic/pgf/math/pgfmathparser.code.tex index c16d07005..f9afe04d7 100755 --- a/tex/generic/pgf/math/pgfmathparser.code.tex +++ b/tex/generic/pgf/math/pgfmathparser.code.tex @@ -10,11 +10,6 @@ \newif\ifpgfmathmathunitsdeclared \newif\ifpgfmathignoreunitscale -\let\pgfmath@protected@edef=\edef -\ifcsname protected@edef\endcsname - \let\pgfmath@protected@edef=\protected@edef -\fi - \def\pgfmathprint#1{\pgfmathparse{#1}\pgfmathresult} \def\pgfmathparse{% @@ -48,7 +43,7 @@ \global\pgfmathmathunitsdeclaredfalse % Expand expression so any remaining CSs are registers % or box dimensions (i.e. |\wd|, |\ht|, |\dp|). - \pgfmath@protected@edef\pgfmath@expression{#1}% + \edef\pgfmath@expression{#1}% % \expandafter\pgfmathparse@trynumber@loop\pgfmath@expression\pgfmath@parse@stop % @@ -911,7 +906,7 @@ % Begin and end parenthesis (). % -\def\pgfmath@startgroup@#1{\pgfmath@protected@edef\pgfmathresult{#1}} +\def\pgfmath@startgroup@#1{\edef\pgfmathresult{#1}} \def\pgfmath@endgroup@{}% Never actually called. % Begin and end array access []. diff --git a/tex/generic/pgf/systemlayer/pgfsys-common-postscript.def b/tex/generic/pgf/systemlayer/pgfsys-common-postscript.def index 803ed71cd..775878ddd 100644 --- a/tex/generic/pgf/systemlayer/pgfsys-common-postscript.def +++ b/tex/generic/pgf/systemlayer/pgfsys-common-postscript.def @@ -289,7 +289,7 @@ % -\def\pgfsys@declarepattern#1#2#3#4#5#6#7{% +\def\pgfsys@declarepattern#1#2#3#4#5#6#7#8#9{% % Start building the pattern dictionary: \pgf@xa=#2\relax% \pgf@ya=#3\relax% @@ -303,14 +303,6 @@ \pgf@sys@bp@correct\pgf@yb% \pgf@sys@bp@correct\pgf@xc% \pgf@sys@bp@correct\pgf@yc% - \pgfsys@@declarepattern{#1}% -} - -\def\pgfsys@@declarepattern#1#2#3#4#5#6#7#8#9{% - \pgfutil@tempdima=#6\relax% - \pgfutil@tempdimb=#7\relax% - \pgf@sys@bp@correct\pgfutil@tempdima% - \pgf@sys@bp@correct\pgfutil@tempdimb% \edef\pgf@sys@marshal{% \noexpand\pgfutil@insertatbegincurrentpage{\noexpand\pgfsys@outerinvoke{ save true setglobal globaldict begin /pgfpat#1 @@ -327,7 +319,6 @@ /BBox [\pgf@sys@tonumber\pgf@xa\space\pgf@sys@tonumber\pgf@ya\space\pgf@sys@tonumber\pgf@xb\space\pgf@sys@tonumber\pgf@yb] /XStep \pgf@sys@tonumber\pgf@xc\space /YStep \pgf@sys@tonumber\pgf@yc\space - /Matrix [#2\space#3\space#4\space#5\space\pgf@sys@tonumber\pgfutil@tempdima\space\pgf@sys@tonumber\pgfutil@tempdimb] /PaintProc { begin 2 dict begin #8\space end end } bind >> diff --git a/tex/generic/pgf/systemlayer/pgfsys-common-svg.def b/tex/generic/pgf/systemlayer/pgfsys-common-svg.def index 9dcb2e0e7..bc60f32c1 100644 --- a/tex/generic/pgf/systemlayer/pgfsys-common-svg.def +++ b/tex/generic/pgf/systemlayer/pgfsys-common-svg.def @@ -674,7 +674,7 @@ % Patterns -\def\pgfsys@declarepattern#1#2#3#4#5#6#7{% +\def\pgfsys@declarepattern#1#2#3#4#5#6#7#8#9{% % Start building the pattern dictionary: \pgf@xa=#2\relax% \pgf@ya=#3\relax% @@ -682,12 +682,6 @@ \pgf@yb=#5\relax% \pgf@xc=#6\relax% \pgf@yc=#7\relax% - \pgfsys@@declarepattern{#1}% -} - -\def\pgfsys@@declarepattern#1#2#3#4#5#6#7#8#9{% - \pgfutil@tempdima=#6\relax% - \pgfutil@tempdimb=#7\relax% \ifnum#9=1\relax% % Colored. That's easy: \pgf@sys@svg@make@defs{#1}{ @@ -695,8 +689,7 @@ id="pgfpat#1" patternUnits="userSpaceOnUse" width="\pgf@sys@tonumber\pgf@xc" - height="\pgf@sys@tonumber\pgf@yc" - patternTransform="matrix(#2\space#3\space#4\space#5\space\pgf@sys@tonumber\pgfutil@tempdima\space\pgf@sys@tonumber\pgfutil@tempdimb)"> + height="\pgf@sys@tonumber\pgf@yc"> #8 }% \else% @@ -706,8 +699,7 @@ id="pgfpat#1" patternUnits="userSpaceOnUse" width="\pgf@sys@tonumber\pgf@xc" - height="\pgf@sys@tonumber\pgf@yc" - patternTransform="matrix(#2\space#3\space#4\space#5\space\pgf@sys@tonumber\pgfutil@tempdima\space\pgf@sys@tonumber\pgfutil@tempdimb)"/> + height="\pgf@sys@tonumber\pgf@yc"/> #8 }% diff --git a/tex/generic/pgf/systemlayer/pgfsys-dvipdfmx.def b/tex/generic/pgf/systemlayer/pgfsys-dvipdfmx.def index 67b6cd87b..e63ee19f3 100644 --- a/tex/generic/pgf/systemlayer/pgfsys-dvipdfmx.def +++ b/tex/generic/pgf/systemlayer/pgfsys-dvipdfmx.def @@ -86,21 +86,30 @@ \def\pgfsys@hboxsynced#1{% \pgfsys@begin@idscope% \pgfsys@beginscope% - \setbox#1=\hbox{\box#1}% - \wd#1=0pt% - \ht#1=0pt% - \dp#1=0pt% - \pgfsys@dvipdfmx@suspendcontent% - \pgfsys@invoke{0 J [] 0 d}% reset line cap and dash - \pgfsys@dvipdfmx@start@force@reset@color% - \pgf@sys@bp@correct\pgf@pt@x% - \pgf@sys@bp@correct\pgf@pt@y% - \special{pdf:btrans matrix \pgf@pt@aa\space \pgf@pt@ab\space \pgf@pt@ba\space \pgf@pt@bb\space - \pgf@sys@tonumber{\pgf@pt@x} \pgf@sys@tonumber{\pgf@pt@y}}% - \box#1% - \special{pdf:etrans}% - \pgfsys@dvipdfmx@stop@force@reset@color% - \pgfsys@dvipdfmx@unsuspendcontent% + \setbox\pgf@hbox=\hbox{% + \hskip\pgf@pt@x% + \raise\pgf@pt@y\hbox{% + \pgf@pt@x=0pt% + \pgf@pt@y=0pt% + \wd#1=0pt% + \ht#1=0pt% + \dp#1=0pt% + \pgflowlevelsynccm% + \special{pdf: content q}% + \pgfsys@invoke{q -1 0 0 -1 0 0 cm}% + \special{pdf: content -1 0 0 -1 0 0 cm q}% \pgfsys@dvipdfmx@suspendcontent + \pgfsys@invoke{0 J [] 0 d}% reset line cap and dash + \pgfsys@dvipdfmx@start@force@reset@color% + \box#1% + \pgfsys@dvipdfmx@stop@force@reset@color% + \pgfsys@invoke{n Q Q Q}% \pgfsys@dvipdfmx@unsuspendcontent + }% + \hss% + }% + \wd\pgf@hbox=0pt% + \ht\pgf@hbox=0pt% + \dp\pgf@hbox=0pt% + \box\pgf@hbox% \pgfsys@endscope% \pgfsys@end@idscope% } @@ -336,7 +345,7 @@ % Patterns came from pgfsys-pdftex.def % dvipdfmx provides a new special `pdf:stream' for a stream object. -\def\pgfsys@declarepattern#1#2#3#4#5#6#7{% +\def\pgfsys@declarepattern#1#2#3#4#5#6#7#8#9{% % Start building the pattern dictionary: \pgf@xa=#2\relax% \pgf@ya=#3\relax% @@ -350,14 +359,6 @@ \pgf@sys@bp@correct\pgf@yb% \pgf@sys@bp@correct\pgf@xc% \pgf@sys@bp@correct\pgf@yc% - \pgfsys@@declarepattern{#1}% -} - -\def\pgfsys@@declarepattern#1#2#3#4#5#6#7#8#9{% - \pgfutil@tempdima=#6\relax% - \pgfutil@tempdimb=#7\relax% - \pgf@sys@bp@correct\pgfutil@tempdima% - \pgf@sys@bp@correct\pgfutil@tempdimb% % Now create the pattern object: \pgfsys@dvipdfmx@patternobj{% \pgfsys@dvipdfmx@stream{@pgfpatternobject#1}{#8}{% @@ -368,7 +369,6 @@ /BBox [\pgf@sys@tonumber\pgf@xa\space\pgf@sys@tonumber\pgf@ya\space\pgf@sys@tonumber\pgf@xb\space\pgf@sys@tonumber\pgf@yb] /XStep \pgf@sys@tonumber\pgf@xc\space /YStep \pgf@sys@tonumber\pgf@yc\space - /Matrix [#2\space#3\space#4\space#5\space\pgf@sys@tonumber\pgfutil@tempdima\space\pgf@sys@tonumber\pgfutil@tempdimb] /Resources << >> %<< }% }% diff --git a/tex/generic/pgf/systemlayer/pgfsys-luatex.def b/tex/generic/pgf/systemlayer/pgfsys-luatex.def index a0b63c1ca..ffd5e35c6 100644 --- a/tex/generic/pgf/systemlayer/pgfsys-luatex.def +++ b/tex/generic/pgf/systemlayer/pgfsys-luatex.def @@ -186,7 +186,7 @@ % Patterns -\def\pgfsys@declarepattern#1#2#3#4#5#6#7{% +\def\pgfsys@declarepattern#1#2#3#4#5#6#7#8#9{% % Start building the pattern dictionary: \pgf@xa=#2\relax% \pgf@ya=#3\relax% @@ -200,14 +200,6 @@ \pgf@sys@bp@correct\pgf@yb% \pgf@sys@bp@correct\pgf@xc% \pgf@sys@bp@correct\pgf@yc% - \pgfsys@@declarepattern{#1}% -} - -\def\pgfsys@@declarepattern#1#2#3#4#5#6#7#8#9{% - \pgfutil@tempdima=#6\relax% - \pgfutil@tempdimb=#7\relax% - \pgf@sys@bp@correct\pgfutil@tempdima% - \pgf@sys@bp@correct\pgfutil@tempdimb% % Now create the pattern object: \immediate\pdfextension obj stream attr @@ -219,7 +211,6 @@ /BBox [\pgf@sys@tonumber\pgf@xa\space\pgf@sys@tonumber\pgf@ya\space\pgf@sys@tonumber\pgf@xb\space\pgf@sys@tonumber\pgf@yb] /XStep \pgf@sys@tonumber\pgf@xc\space /YStep \pgf@sys@tonumber\pgf@yc\space - /Matrix [#2\space#3\space#4\space#5\space\pgf@sys@tonumber\pgfutil@tempdima\space\pgf@sys@tonumber\pgfutil@tempdimb] /Resources << >> %<< } {#8}% @@ -234,6 +225,54 @@ \pgfsysprotocol@literal{/Pattern cs /pgfpat#1\space scn}% } +% System layer for meta patterns +% Takes 15(!) arguments +% #1 pattern name +% #2 #3 bounding box lower left +% #4 #5 bounding box upper right +% #6 #7 tile size +% #8 #9 #10 #11 #12 #13 transformation matrix +% #14 protocoled text +% #15 pattern type +\def\pgfsys@declarepattern@meta#1#2#3#4#5#6#7{% + % Start building the pattern dictionary: + \pgf@xa=#2\relax% + \pgf@ya=#3\relax% + \pgf@xb=#4\relax% + \pgf@yb=#5\relax% + \pgf@xc=#6\relax% + \pgf@yc=#7\relax% + \pgf@sys@bp@correct\pgf@xa% + \pgf@sys@bp@correct\pgf@ya% + \pgf@sys@bp@correct\pgf@xb% + \pgf@sys@bp@correct\pgf@yb% + \pgf@sys@bp@correct\pgf@xc% + \pgf@sys@bp@correct\pgf@yc% + \pgfsys@@declarepattern@meta{#1}} + +\def\pgfsys@@declarepattern@meta#1#2#3#4#5#6#7#8#9{% + \pgfutil@tempdima=#6\relax% + \pgfutil@tempdimb=#7\relax% + \pgf@sys@bp@correct\pgf@xa% + \pgf@sys@bp@correct\pgf@ya% + % Now create the pattern object: + \immediate\pdfextension obj stream + attr + { + /Type /Pattern + /PatternType 1 + /PaintType \ifnum#9=0 2 \else 1 \fi + /TilingType 1 + /BBox [\pgf@sys@tonumber\pgf@xa\space\pgf@sys@tonumber\pgf@ya\space\pgf@sys@tonumber\pgf@xb\space\pgf@sys@tonumber\pgf@yb] + /XStep \pgf@sys@tonumber\pgf@xc\space + /YStep \pgf@sys@tonumber\pgf@yc\space + /Matrix [#2\space#3\space#4\space#5\space\pgf@sys@tonumber\pgfutil@tempdima\space\pgf@sys@tonumber\pgfutil@tempdimb] + /Resources << >> %<< + } + {#8}% + \pgfutil@addpdfresource@patterns{/pgfpat#1\space \the\numexpr\pdffeedback lastobj\relax\space 0 R}% + } + \def\pgfsys@papersize#1#2{\pageheight#2\relax\pagewidth#1\relax} diff --git a/tex/generic/pgf/systemlayer/pgfsys-pdftex.def b/tex/generic/pgf/systemlayer/pgfsys-pdftex.def index b74e005a7..58b414b69 100644 --- a/tex/generic/pgf/systemlayer/pgfsys-pdftex.def +++ b/tex/generic/pgf/systemlayer/pgfsys-pdftex.def @@ -183,7 +183,7 @@ % Patterns -\def\pgfsys@declarepattern#1#2#3#4#5#6#7{% +\def\pgfsys@declarepattern#1#2#3#4#5#6#7#8#9{% % Start building the pattern dictionary: \pgf@xa=#2\relax% \pgf@ya=#3\relax% @@ -197,14 +197,6 @@ \pgf@sys@bp@correct\pgf@yb% \pgf@sys@bp@correct\pgf@xc% \pgf@sys@bp@correct\pgf@yc% - \pgfsys@@declarepattern{#1}% -} - -\def\pgfsys@@declarepattern#1#2#3#4#5#6#7#8#9{% - \pgfutil@tempdima=#6\relax% - \pgfutil@tempdimb=#7\relax% - \pgf@sys@bp@correct\pgfutil@tempdima% - \pgf@sys@bp@correct\pgfutil@tempdimb% % Now create the pattern object: \immediate\pdfobj stream attr @@ -216,7 +208,6 @@ /BBox [\pgf@sys@tonumber\pgf@xa\space\pgf@sys@tonumber\pgf@ya\space\pgf@sys@tonumber\pgf@xb\space\pgf@sys@tonumber\pgf@yb] /XStep \pgf@sys@tonumber\pgf@xc\space /YStep \pgf@sys@tonumber\pgf@yc\space - /Matrix [#2\space#3\space#4\space#5\space\pgf@sys@tonumber\pgfutil@tempdima\space\pgf@sys@tonumber\pgfutil@tempdimb] /Resources << >> %<< } {#8}% @@ -231,6 +222,54 @@ \pgfsysprotocol@literal{/Pattern cs /pgfpat#1\space scn}% } +% System layer for meta patterns +% Takes 15(!) arguments +% #1 pattern name +% #2 #3 bounding box lower left +% #4 #5 bounding box upper right +% #6 #7 tile size +% #8 #9 #10 #11 #12 #13 transformation matrix +% #14 protocoled text +% #15 pattern type +\def\pgfsys@declarepattern@meta#1#2#3#4#5#6#7{% + % Start building the pattern dictionary: + \pgf@xa=#2\relax% + \pgf@ya=#3\relax% + \pgf@xb=#4\relax% + \pgf@yb=#5\relax% + \pgf@xc=#6\relax% + \pgf@yc=#7\relax% + \pgf@sys@bp@correct\pgf@xa% + \pgf@sys@bp@correct\pgf@ya% + \pgf@sys@bp@correct\pgf@xb% + \pgf@sys@bp@correct\pgf@yb% + \pgf@sys@bp@correct\pgf@xc% + \pgf@sys@bp@correct\pgf@yc% + \pgfsys@@declarepattern@meta{#1}} + +\def\pgfsys@@declarepattern@meta#1#2#3#4#5#6#7#8#9{% + \pgfutil@tempdima=#6\relax% + \pgfutil@tempdimb=#7\relax% + \pgf@sys@bp@correct\pgf@xa% + \pgf@sys@bp@correct\pgf@ya% + % Now create the pattern object: + \immediate\pdfobj stream + attr + { + /Type /Pattern + /PatternType 1 + /PaintType \ifnum#9=0 2 \else 1 \fi + /TilingType 1 + /BBox [\pgf@sys@tonumber\pgf@xa\space\pgf@sys@tonumber\pgf@ya\space\pgf@sys@tonumber\pgf@xb\space\pgf@sys@tonumber\pgf@yb] + /XStep \pgf@sys@tonumber\pgf@xc\space + /YStep \pgf@sys@tonumber\pgf@yc\space + /Matrix [#2\space#3\space#4\space#5\space\pgf@sys@tonumber\pgfutil@tempdima\space\pgf@sys@tonumber\pgfutil@tempdimb] + /Resources << >> %<< + } + {#8}% + \pgfutil@addpdfresource@patterns{/pgfpat#1\space \the\pdflastobj\space 0 R}% + } + \def\pgfsys@papersize#1#2{\pdfpageheight#2\relax\pdfpagewidth#1\relax} diff --git a/tex/generic/pgf/utilities/pgffor.code.tex b/tex/generic/pgf/utilities/pgffor.code.tex index 4e351c902..5ff18417b 100644 --- a/tex/generic/pgf/utilities/pgffor.code.tex +++ b/tex/generic/pgf/utilities/pgffor.code.tex @@ -202,7 +202,7 @@ \def\pgffor@invokebody{% - \pgffor@begingroup% + \pgffor@begingroup% \expandafter\pgfutil@in@\expandafter/\expandafter{\pgffor@var}% \ifpgfutil@in@% \expandafter\def\expandafter\pgffor@valuerest\expandafter{\pgffor@value//\relax}% @@ -520,12 +520,12 @@ \def\pgffor@atendforeach{% \global\edef\pgffor@remember@expanded{\pgffor@remember@code}% - \ifx\pgffor@remember@expanded\pgfutil@empty% - \else% - \pgffor@remember@expanded% - \global\let\pgffor@remember@expanded=\pgfutil@empty% - \fi% - \endgroup% + \endgroup% + \ifx\pgffor@remember@expanded\pgfutil@empty% + \else% + \pgffor@remember@expanded% + \global\let\pgffor@remember@expanded=\pgfutil@empty% + \fi% } \def\pgffor@default@begingroup{% \begingroup% diff --git a/tex/generic/pgf/utilities/pgfutil-common.tex b/tex/generic/pgf/utilities/pgfutil-common.tex index 6fbaf2687..4eba7a978 100644 --- a/tex/generic/pgf/utilities/pgfutil-common.tex +++ b/tex/generic/pgf/utilities/pgfutil-common.tex @@ -75,9 +75,9 @@ \def\pgfutil@letfirst@end{} \long\def\pgfutil@secondoftwo#1#2{#2} \def\pgfutil@empty{} -\long\def\pgfutil@gobble@until@relax#1\relax{} -\long\def\pgfutil@gobble#1{} -\long\def\pgfutil@gobbletwo#1#2{} +\def\pgfutil@gobble@until@relax#1\relax{} +\def\pgfutil@gobble#1{} +\def\pgfutil@gobbletwo#1#2{} \def\pgfutil@namedef#1{\expandafter\def\csname #1\endcsname} \def\pgfutil@namelet#1{\expandafter\pgfutil@@namelet\csname#1\endcsname} \def\pgfutil@@namelet#1#2{\expandafter\let\expandafter#1\csname#2\endcsname}