### TiKz Arrow Setup Code Example Source: https://tikz.dev/base-arrows An example demonstrating how to include dimension registers and true-false conditionals within the 'parameters' key of an arrow tip. This ensures that the setup code can react to different arrow tip configurations by appending unique identifiers. ```TeX parameters = { \the\pgfarrowlength,\ \ifpgfarrowharpoon h\fi\ \ifpgfarrowroundjoin j\fi} ``` -------------------------------- ### Lua Example: External Documentation File Structure Source: https://tikz.dev/gd-algorithm-layer An example of an external Lua file ('documentation_file.lua') used for Ti_k_Z documentation. It includes setup for 'pgf.gd.doc' functions and defines documentation for specific keys like 'very simple demo layout' and 'radius'. ```lua -- File documentation_file.lua local key = require 'pgf.gd.doc'.key local documentation = require 'pgf.gd.doc'.documentation local summary = require 'pgf.gd.doc'.summary local example = require 'pgf.gd.doc'.example key "very simple demo layout" documentation "This layout is a very simple layout that, ..." key "radius" summary "Specifies the radius of a circle on which the nodes are placed." documentation [[ This key can be used together with |very simple example layout|. An important feature is that... ]] ``` -------------------------------- ### Understanding TiKz Decorations Source: https://tikz.dev/base-decorations Explains the core concept of TiKz decorations, how they can be used to modify paths, and provides an example of a basic decoration setup. ```APIDOC ## TiKz Decorations Overview ### Description TiKz decorations allow for the modification of paths by applying various effects or patterns. This section details the `pgfdecoration` environment and its associated macros for custom path manipulation. ### Usage Decorations can be defined using the `pgfdecoration` environment, which takes a name and enclosed path commands. Several macros are available within and after the environment to access and manipulate path components. ### Key Macros * `\pgfdecorateexistingpath`: Refers to the path before the decoration environment. * `\pgfdecoratedpath`: The input path created by the environment's contents. * `\pgfdecorationpath`: The output path generated by the decoration. * `\pgfpointdecoratedpathlast`: The final point of the input path. * `\pgfpointdecorationpathlast`: The final point of the output path. ### Example Usage ```latex \usetikzlibrary {decorations,decorations.pathmorphing} \begin{tikzpicture} \draw [help lines] grid (3,2); \begin{pgfdecoration}{ {curveto}{\pgfdecoratedpathlength/3} {} { \pgfusepath{stroke} }, {zigzag}{\pgfdecoratedpathlength/3} { \pgfpathmoveto{\pgfpointdecoratedpathfirst} \pgfdecorationsegmentlength=5pt } { \pgfsetstrokecolor{red} \pgfusepath{stroke} \pgfpathmoveto{\pgfpointdecoratedpathlast} \pgfsetstrokecolor{black} }, {curveto}{\pgfdecoratedremainingdistance} } \pgfpathmoveto{\pgfpointorigin} \pgfpathcurveto {\pgfpoint{0cm}{2cm}}{\pgfpoint{3cm}{2cm}}{\pgfpoint{3cm}{0cm}} \end{pgfdecoration} \pgfusepath{stroke} \end{tikzpicture} ``` ``` -------------------------------- ### PGF Move-To and Line-To Path Construction Source: https://tikz.dev/base-paths Illustrates the use of \pgfpathmoveto and \pgfpathlineto commands to construct a path. The example shows how to start a path, draw straight segments, and then fill and stroke the resulting shape. ```tex \begin{pgfpicture} \pgfpathmoveto{\pgfpointorigin} \pgfpathlineto{\pgfpoint{1cm}{1cm}} \pgfpathlineto{\pgfpoint{2cm}{1cm}} \pgfpathlineto{\pgfpoint{3cm}{0.5cm}} \pgfpathlineto{\pgfpoint{3cm}{0cm}} \pgfsetfillcolor{yellow!80!black} \pgfusepath{fill,stroke} \end{pgfpicture} ``` -------------------------------- ### Configure and Use Profiler Library in TeX Code Source: https://tikz.dev/library-profiler This example demonstrates how to configure the profiler library to measure specific environments and commands. It shows the setup in the preamble and the expected summary output in the log file after profiling. ```TeX \usepgflibrary{profiler} \pgfprofilenewforenvironment{tikzpicture} \pgfprofilenewforcommand{\pgfkeys}1} ``` -------------------------------- ### PGF Line-To Operation Example Source: https://tikz.dev/base-paths Shows a basic implementation of the \pgfpathlineto command to draw a straight line segment within a PGF picture. It includes a preceding \pgfpathmoveto to establish a starting point for the path. ```tex \begin{pgfpicture} \pgfpathmoveto{\pgfpointorigin} \pgfpathlineto{\pgfpoint{1cm}{1cm}} \pgfpathlineto{\pgfpoint{2cm}{1cm}} \pgfsetfillcolor{yellow!80!black} \pgfusepath{fill,stroke} \end{pgfpicture} ``` -------------------------------- ### PGF Path Construction with New Path Part Source: https://tikz.dev/base-paths Demonstrates starting a new part of a path using \pgfpathmoveto after previously constructing segments. This example shows how \pgfpathmoveto can be used to separate distinct sections of a path before filling and stroking. ```tex \begin{pgfpicture} \pgfpathmoveto{\pgfpointorigin} \pgfpathlineto{\pgfpoint{1cm}{1cm}} \pgfpathlineto{\pgfpoint{2cm}{1cm}} \pgfpathmoveto{\pgfpoint{2cm}{1cm}} % New part \pgfpathlineto{\pgfpoint{3cm}{0.5cm}} \pgfpathlineto{\pgfpoint{3cm}{0cm}} \pgfsetfillcolor{yellow!80!black} \pgfusepath{fill,stroke} \end{pgfpicture} ``` -------------------------------- ### ConTeXt Environment Setup for Ti_k_Z Source: https://tikz.dev/tutorial-nodes This code snippet shows the ConTeXt syntax for setting up and using Ti_k_Z. It details the module and library loading process specific to ConTeXt, enabling the creation of Ti_k_Z graphics within ConTeXt documents. ```context %% ConTeXt file \usemodule[tikz] \usetikzlibrary[arrows.meta,decorations.pathmorphing,backgrounds,positioning,fit,petri] \starttext \starttikzpicture \draw (0,0) -- (1,1); \stoptikzpicture \stoptext ``` -------------------------------- ### PGFPlots: Basic Plotting Example Source: https://tikz.dev/pgfplots/reference-specifyrange A simple PGFPlots example demonstrating a basic plot of a cubic function. It includes the necessary preamble and TikZ environment setup. ```latex % Preamble: \pgfplotsset{width=7cm,compat=1.18} \begin{tikzpicture} \begin{axis}[ small, ] \addplot {5 * x^3 - x^2 + 4*x -2}; \end{axis} \end{tikzpicture} ``` -------------------------------- ### Setup TikZ Environment with Libraries (LaTeX, Plain TeX, ConTeXt) Source: https://tikz.dev/tutorial-Euclid Demonstrates how to load the TikZ package and necessary libraries (calc, intersections, through, backgrounds) for different TeX formats. Ensure these libraries are available for the specified functionality. ```latex \usepackage{tikz} \usetikzlibrary{calc,intersections,through,backgrounds} ``` ```plaintex \input tikz.tex \usetikzlibrary{calc,intersections,through,backgrounds} ``` ```context \usemodule[tikz] \usetikzlibrary[calc,intersections,through,backgrounds] ``` -------------------------------- ### TikZ PGF/3D Signal Class Connection Example Source: https://tikz.dev/oo Example demonstrating how to connect methods of a custom class to signals, including obtaining the object handle using `get handle`. ```tikz \pgfooclass{some class}{ \method some class() { \pgfoothis.get handle(\me) \somesignal.connect(\me,foo) \anothersignal.connect(\me,bar) } \method foo () {} \method bar (#1,#2) {} } \pgfoonew \objA=new some class() \pgfoonew \objB=new some class() ``` -------------------------------- ### Plain TeX Environment Setup for Ti_k_Z Source: https://tikz.dev/tutorial-nodes This code illustrates the setup for using Ti_k_Z within a Plain TeX document. It shows how to input the Ti_k_Z package and load the required libraries, ensuring all necessary definitions are available for creating Ti_k_Z graphics in Plain TeX. ```tex %% Plain TeX file \input tikz.tex \usetikzlibrary{arrows.meta,decorations.pathmorphing,backgrounds,positioning,fit,petri} \baselineskip=12pt \hsize=6.3truein \vsize=8.7truein \tikzpicture \draw (0,0) -- (1,1); \end{tikzpicture} \bye ``` -------------------------------- ### LaTeX Environment Setup for Ti_k_Z Source: https://tikz.dev/tutorial-nodes This code demonstrates how to set up a LaTeX document to use the Ti_k_Z package. It includes loading essential Ti_k_Z libraries for advanced functionalities. This setup is crucial for creating complex graphics within LaTeX documents. ```latex \documentclass{article} \usepackage{tikz} \usetikzlibrary{arrows.meta,decorations.pathmorphing,backgrounds,positioning,fit,petri} \begin{document} \begin{tikzpicture} \draw (0,0) -- (1,1); \end{tikzpicture} \end{document} ``` -------------------------------- ### Start a TiKZ Chain with Nodes Source: https://tikz.dev/library-chains This example demonstrates how to start a TiKZ chain and populate it with nodes using a 'foreach' loop. The 'on chain' key places each node sequentially, and the chain is named 'circle'. The 'start chain' option defines the initial placement direction and offset. ```tikz \usetikzlibrary {chains} \begin{tikzpicture}[start chain=circle placed {at=(\tikzchaincount*30:1.5)] \foreach \i in {1,...,10} \node [on chain] {\i}; \draw (circle-1) -- (circle-10); \end{tikzpicture} ``` -------------------------------- ### PgfplotsTable Data Example Source: https://tikz.dev/pgfplots/pgfplotstable-load-data An example of a plain text table file format compatible with PgfplotsTable. Entries are separated by whitespace, and lines starting with '#' are treated as comments. This format is commonly used throughout the Pgfplots documentation. ```text # Convergence results # fictional source, generated 2008 level dof error1 error2 info grad(log(dof),log(error2)) quot(error1) 1 4 2.50000000e-01 7.57858283e-01 48 0 0 2 16 6.25000000e-02 5.00000000e-01 25 -3.00000000e-01 4 3 64 1.56250000e-02 2.87174589e-01 41 -3.99999999e-01 4 4 256 3.90625000e-03 1.43587294e-01 8 -5.00000003e-01 4 5 1024 9.76562500e-04 4.41941738e-02 22 -8.49999999e-01 4 6 4096 2.44140625e-04 1.69802322e-02 46 -6.90000001e-01 4 7 16384 6.10351562e-05 8.20091159e-03 40 -5.24999999e-01 4 8 65536 1.52587891e-05 3.90625000e-03 48 -5.35000000e-01 3.99999999e+00 9 262144 3.81469727e-06 1.95312500e-03 33 -5.00000000e-01 4.00000001e+00 10 1048576 9.53674316e-07 9.76562500e-04 2 -5.00000000e-01 4.00000001e+00 ``` -------------------------------- ### Include Headers for OGDF Integration Source: https://tikz.dev/gd-algorithms-in-c Includes necessary headers for using OGDF and the scripting interface. These are the initial setup steps before defining custom OGDF runners and declarations. ```cpp #include .h> #include .h> using namespace ogdf; using namespace scripting; ``` -------------------------------- ### TikZ Node Positioning Styles Example Source: https://tikz.dev/tikz-shapes This TikZ code snippet illustrates various predefined styles for positioning nodes along a path, such as 'at end', 'very near end', 'near end', 'midway', 'near start', 'very near start', and 'at start'. These styles correspond to specific 'pos' values. ```tikz \tikz \draw (0,0) .. controls +(up:2cm) and +(left:3cm) .. (1,5) node[at end] {\texttt{at end}} node[very near end] {\texttt{very near end}} node[near end] {\texttt{near end}} node[midway] {\texttt{midway}} node[near start] {\texttt{near start}} node[very near start] {\texttt{very near start}} node[at start] {\texttt{at start}}; ``` -------------------------------- ### Set up Lua Entry Point for OGDF Algorithm Source: https://tikz.dev/gd-algorithms-in-c Provides the C++ entry point for Lua to load and use the OGDF-based graph drawing algorithm. It initializes a script object with the Lua state and declares the custom `FastLayoutOGDF` algorithm. ```cpp extern "C" int luaopen_pgf_gd_examples_c_SimpleDemoOGDF (struct lua_State *state) { script (state).declare (new FastLayoutOGDF); return 0; } ``` -------------------------------- ### TikZ: Place Path Length Info with Markings Source: https://tikz.dev/library-decorations This TikZ example utilizes the 'decorations.markings' library to display the distance of each mark from the start of the path. It uses '/pgf/decoration/mark info/distance from start' within the 'with' clause to retrieve and display this information as text near the path. The code places marks at intervals and also at the start of the path for reference. ```tex \usetikzlibrary {decorations.markings} \begin{tikzpicture}[decoration={markings, mark=between positions 0 and 1 step 40pt with { \draw [help lines] (0,0) -- (0,0.5) node[above,font=\tiny]{ \pgfkeysvalueof{/pgf/decoration/mark info/distance from start}}; }, mark=at position -0.1pt with { \draw [help lines] (0,0) -- (0,0.5) node[above,font=\tiny]{ \pgfkeysvalueof{/pgf/decoration/mark info/distance from start}}; }] \draw [help lines] grid (5,3); \draw [postaction={decorate}] (0,0) .. controls (8,3) and (0,3) .. (5,0) ; \end{tikzpicture} ``` -------------------------------- ### TiKz: Using 'current subpath start' Coordinate Source: https://tikz.dev/tikz-paths Demonstrates the use of the 'current subpath start' coordinate, which refers to the position of the most recent move-to operation. This example shows drawing a path that returns to the origin without explicitly closing the path. ```tikz \tikz [line width=2mm] \draw (0,0) -- (1,0) -- (1,1) -- (0,1) -- (current subpath start); ``` -------------------------------- ### Synchronized Ti_k_Z and pgfplots Graphic Example Source: https://tikz.dev/pgfplots/reference-tikzinteroperability Demonstrates how to configure pgfplots to synchronize its coordinate system with Ti_k_Z. It uses keys like 'anchor=origin', 'at={(0pt,0pt)}', 'disabledatascaling', 'x=1cm', 'y=1cm', and axis limits to match the Ti_k_Z example. ```pgfplots % Preamble: \pgfplotsset{width=7cm,compat=1.18} \begin{tikzpicture} \coordinate (Point) at (1,2); \begin{axis}[ % tell pgfplots to "grab" the axis at its % internal (0,0) coord: anchor=origin, % tell pgfplots to place its anchor at (0,0): % (This is actually the default and can % be omitted) at={(0pt,0pt)}, % tell pgfplots to use the "natural" dimensions: disabledatascaling, % tell pgfplots to use the same unit vectors % as tikz: x=1cm,y=1cm, % % this is just as usual in pgfplots. I guess % it is only useful if (0,0) is part of the % range... try it out. xmin=-1,xmax=3, ymin=-1,ymax=3,grid=both, ] % this uses the point defined OUTSIDE of the axis \draw [blue,fill] (Point) circle (2pt) node [right] {(1,2)}; % this uses a TIKZ coordinate (2,0) in the axis: \draw [blue,fill] (2,0) circle (2pt) node [right] {(2,0)}; % this here will always work inside of an axis: \draw [blue,fill] (-1,0) circle (2pt) node [right] {(-1,0)}; \end{axis} \end{tikzpicture} ``` -------------------------------- ### Ti_k_Z 'show path construction' Decoration Example Source: https://tikz.dev/library-decorations Demonstrates the 'show path construction' decoration, which allows different actions for each segment type (moveto, lineto, curveto, closepath). This is useful for visualizing path creation steps. ```LaTeX \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{decorations.pathreplacing} \begin{document} \begin{tikzpicture}[>=stealth, every node/.style={midway, sloped, font=\tiny}, decoration={show path construction, moveto code={\fill [red] (\tikzinputsegmentfirst) circle (2pt) node [fill=none, below] {moveto};}, lineto code={ \draw [blue,->] (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast) node [above] {lineto};}, curveto code={ % Example for curveto, can be expanded } }] \draw [help lines] grid (3,2); \draw [decorate] (0,0) -- (3,1) .. controls (1,2) and (2,0) .. (3,1); \end{tikzpicture} \end{document} ``` -------------------------------- ### Load Petri-Net Library in LaTeX and ConTeXt Source: https://tikz.dev/library-petri Demonstrates how to load the 'petri' library for Ti_k_Z diagrams in both LaTeX/plain TeX and ConTeXt environments. No specific inputs or outputs are associated with the loading command itself. ```tex \usetikzlibrary{petri} % LaTeX and plain TeX ``` ```tex \usetikzlibrary[petri] % ConTeXt ``` -------------------------------- ### Install 'not' Key Filter in TiKz Source: https://tikz.dev/pgfkeys Installs a key filter that logically inverts the result of another key filter. This example uses 'not' in conjunction with 'is descendant of=/group 1' to exclude keys from '/group 1'. ```tikz \usepgfkeyslibrary {filtered} \pgfkeys{ /group 1/A/.code={(A:#1)}, /group 1/foo/bar/B/.code={(B:#1)}, /group 2/C/.code={(C:#1)}, /pgf/key filters/not/.install key filter= {/pgf/key filters/is descendant of=/group 1} } \pgfkeysfiltered{/group 1/A=a,/group 1/foo/bar/B=b,/group 2/C=c} ``` -------------------------------- ### Install 'equals' Key Filter in TiKz Source: https://tikz.dev/pgfkeys Installs a key filter that processes only a fully qualified option. The filter returns true for unknown keys or if the key matches the specified full key. This example filters for '/group 1/A'. ```tikz \usepgfkeyslibrary {filtered} \pgfkeys{ /group 1/A/.code={(A:#1)}, /group 1/B/.code={(B:#1)}, /pgf/key filters/equals/.install key filter=/group 1/A } \pgfqkeysfiltered{/group 1}{A=a,B=b} ``` -------------------------------- ### Defining and Using Styles with .style (LaTeX) Source: https://tikz.dev/pgfkeys Illustrates the concept of 'styles' in pgfKeys, where a key can execute a list of other keys. This is achieved using the /.style handler. Styles can also be parameterized. The example defines two simple keys, a style that uses them, and then executes the style with a parameter. ```latex \pgfkeys{/a/.code=(a:#1)} \pgfkeys{/b/.code=(b:#1)} \pgfkeys{/my style/.style={/a=foo,/b=bar,/a=#1}} \pgfkeys{/my style=wow} ``` -------------------------------- ### TikZ Quick Graph Syntax Example Source: https://tikz.dev/tikz-graphs Demonstrates the basic usage of the 'quick' graph syntax in TikZ. It shows how to define nodes and a simple edge with options, using the mandatory quotation marks for node names and allowing options like 'x=1' for node styling. ```tikz \usetikzlibrary {graphs,quotes} \tikz \graph [quick] { "a" --["foo"] "b"[x=1] }; ``` -------------------------------- ### TiKZ Decorations: Controlling Start and End with 'pre' and 'post' Source: https://tikz.dev/tikz-decorations Example showing how to use 'pre length' and 'post length' with a 'snake' decoration to control its start and end points. A custom style 'line around' is defined for convenience. Requires 'decorations.pathmorphing' library. ```tikz \usetikzlibrary {decorations.pathmorphing} \begin{tikzpicture} [decoration=snake, line around/.style={decoration={pre length=#1,post length=#1}}] \draw[->,decorate] (0,0) -- ++(3,0); \draw[->,decorate,line around=5pt] (0,-5mm) -- ++(3,0); \draw[->,decorate,line around=1cm] (0,-1cm) -- ++(3,0); \end{tikzpicture} ``` -------------------------------- ### TiKZ Animation Keys and Timeline Example Source: https://tikz.dev/pgfsys-animations This example demonstrates how to set animation keys for repeating indefinitely and trigger animations on specific events like clicks. It defines timelines with start and end times, specifying scalar and dimension values for attributes like fill opacity and line width. ```tex \pgfsysanimkeyrepeatindefinite % Both of the following animations % repeat indefinitely { \pgfsysanimkeywhom{\someid}{}% The id of a later object \pgfsysanimkeyevent{}{}{click}{0}{begin}% Begin on a click ... \pgfsysanimkeytime{5}{1}{1}{0}{0} % Timeline starts after 5s \pgfsysanimvalscalar{0} % With a value of 0 \pgfsysanimkeytime{8}{1}{1}{0}{0} % Timeline ends after 8s \pgfsysanimvalscalar{0.9} % With a value of 0.9 \pgfsysanimate{fillopacity}% ... and the attribute is the fill opacity } { \pgfsysanimkeywhom{\someid}{}% The id of a later object \pgfsysanimkeyoffset{0}{begin}% Begin right away ... \pgfsysanimkeytime{1}{1}{1}{0}{0} % Timeline starts after 1s \pgfsysanimvalcurrent % With the current value \pgfsysanimkeytime{5}{1}{1}{0}{0} % Timeline ends after 5s \pgfsysanimvaldimension{5pt} % With a value of 5pt \pgfsysanimate{linewidth}% ... and the attribute is the line width } ``` -------------------------------- ### Ti_k_Z Setup in Plain TeX Source: https://tikz.dev/tutorial Demonstrates how to include and use Ti_k_Z in a Plain TeX document. Requires inputting 'tikz.tex' and using \tikzpicture and \endtikzpicture environments. Supports pdftex or tex with dvips. For dvipdfm, a configuration modification or specific definition is needed. ```TeX %% Plain TeX file \input tikz.tex \baselineskip=12pt \hsize=6.3truein \vsize=8.7truein We are working on \tikzpicture \draw (-1.5,0) -- (1.5,0); \draw (0,-1.5) -- (0,1.5); \endtikzpicture. \bye ``` -------------------------------- ### Offset Animation Timing with \pgfsysanimkeyoffset Source: https://tikz.dev/pgfsys-animations This command specifies an offset in seconds for the animation's timeline, allowing it to start or end at a time relative to the graphic display or other triggers. It can be called multiple times to define several possible beginnings or endings. The example shows an animation that starts after 5 seconds or when a button is pressed. ```tikz \animationexample{node}{}{ \pgfsysanimkeytime{0}{1}{1}{0}{0} \pgfsysanimvaltranslate{0cm}{0cm} \pgfsysanimkeytime{2}{1}{1}{0}{0} \pgfsysanimvaltranslate{0cm}{-1cm} \pgfsysanimkeyoffset{5}{begin} \pgfsysanimkeyoffset{}{begin} \pgfsysanimimate{translate} } ``` -------------------------------- ### Load Ti_k_Z 3D Library for LaTeX and ConTeXt Source: https://tikz.dev/library-3d Demonstrates how to load the Ti_k_Z 3D drawing library. It shows the syntax for both LaTeX/plain TeX and ConTeXt environments. This is a prerequisite for using any 3D drawing functionalities. ```latex \usetikzlibrary{3d} % LaTeX and plain TeX ``` ```context \usetikzlibrary[3d] % ConTeXt ``` -------------------------------- ### Ti_k_Z Plotting: Draw plot with marks starting from Pth point, every Nth Source: https://tikz.dev/tikz-plots This example illustrates drawing a plot with marks placed starting from a specific point and then every Nth point thereafter. The 'mark phase' option defines the starting point index (p), and 'mark repeat' defines the interval (r) for subsequent marks. 'smooth' ensures a smooth curve, and 'file' specifies the data source. ```Ti_k_Z \tikz \draw plot[mark=x,mark repeat=3,mark phase=6,smooth] file {plots/pgfmanual-sine.table}; ``` -------------------------------- ### Load Lindenmayer Systems Library for PGF/Ti_k_Z Source: https://tikz.dev/library-lsystems Provides the necessary commands to load the 'lindenmayersystems' library for PGF and Ti_k_Z across different TeX distributions. It shows the specific commands for LaTeX, plain TeX, and ConTeXt. ```latex \usepgflibrary{lindenmayersystems} % LaTeX and plain TeX and pure pgf ``` ```latex \usepgflibrary[lindenmayersystems] % ConTeXt and pure pgf ``` ```latex \usetikzlibrary{lindenmayersystems} % LaTeX and plain TeX when using Ti_k_Z ``` ```latex \usetikzlibrary[lindenmayersystems] % ConTeXt when using Ti_k_ Z ``` -------------------------------- ### Install 'is descendant of' Key Filter in TiKz Source: https://tikz.dev/pgfkeys Installs a key filter that processes only options belonging to a specified key tree. It returns true for keys within the tree and for unknown keys, which are then handled by standard unknown handlers. This example demonstrates filtering within '/group 1'. ```tikz \usepgfkeyslibrary {filtered} \pgfkeys{ /group 1/A/.code={(A:#1)}, /group 1/foo/bar/B/.code={(B:#1)}, /group 2/C/.code={(C:#1)}, /pgf/key filters/is descendant of/.install key filter=/group 1 } \pgfkeysfiltered{/group 1/A=a,/group 1/foo/bar/B=b,/group 2/C=c} ``` -------------------------------- ### Draw Petri Net Transitions and Connect to Places Source: https://tikz.dev/library-petri Demonstrates drawing Petri net transitions using the 'transition' style and connecting them to places using the 'edge' command with 'pre' and 'post' styles. Requires 'petri' and 'positioning' libraries. ```tex \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) {}; \node[transition,below right=of p1,label=below:$t_1$] {} edge[pre] (p1) edge[post] node[auto] {2} (p2); \end{tikzpicture} ``` -------------------------------- ### Install an Equality Key Filter using \pgfkeys Source: https://tikz.dev/pgfkeys This example demonstrates installing an equality key filter using the '.install key filter' handler. The '/pgf/key filters/equals' handler is configured to filter based on '/my group/A1'. When \pgfkeysfiltered is called, only options matching '/my group/A1' will be processed. ```latex \usepgfkeyslibrary {filtered} \pgfkeys{/pgf/key filters/equals/.install key filter={/my group/A1}} \pgfkeysfiltered{/my group/A1=a1, /my group/A2=a2, /my group/B=b, /my group/C=c, /tikz/color=blue, /my group/A3=a3} ``` -------------------------------- ### Basic Ti_k_Z Graphic Example Source: https://tikz.dev/pgfplots/reference-tikzinteroperability A simple Ti_k_Z graphic that draws a grid and a node at a specified coordinate. This serves as a baseline for demonstrating synchronization with pgfplots. ```tikz \begin{tikzpicture} \coordinate (Point) at (1,2); \draw [gray] (-1,-1) grid (3,3); \draw [blue,fill] (Point) circle (2pt) node [right] {(1,2)}; \end{tikzpicture} ``` -------------------------------- ### Picture Box Synchronization Example (LaTeX) Source: https://tikz.dev/pgfsys-commands An example of how \pgfsys@pictureboxsynced might be implemented to ensure hyperlinks survive translations, by using \pgfsys@beginscope, \pgflowlevelsynccm, and \pgfsys@endscope. ```latex \pgfsys@beginscope \pgflowlevelsynccm \box#1 \pgfsys@endscope ``` -------------------------------- ### Defining and Executing a Simple Key with .code (LaTeX) Source: https://tikz.dev/pgfkeys Shows how to define the code associated with a key using the /.code handler. The code can use '#1' to refer to the parameter passed when the key is executed. The example defines '/my key' and then executes it with a parameter. ```latex \pgfkeys{/my key/.code=The value is '#1'.} \pgfkeys{/my key=hi!} ``` -------------------------------- ### Ti_k_Z: Adjusting Snapshot Start Time with 'begin snapshot' Source: https://tikz.dev/tikz-animations This code illustrates how to use the '/tikz/animate/options/begin snapshot=' key to control the starting point of a timeline specifically for snapshot generation. In this example, the first rectangle's fill color is set to change from black at 0s to white at 2s, but with 'begin snapshot = 1s', the animation effectively starts at 1s for the snapshot at 1s. The second rectangle's animation proceeds normally. This provides finer control over snapshot timing when dealing with offset animations. ```tex \usetikzlibrary {animations} \tikz [make snapshot of = 1s] { \fill :fill = { 0s = "black", 2s = "white", begin snapshot = 1s } (0,0) rectangle ++(1,1); \fill :fill = { 1s = "black", 3s = "white" } (2,0) rectangle ++(1,1); } ``` -------------------------------- ### Loading pgfkeys Package in LaTeX, Plain TeX, and ConTeXt Source: https://tikz.dev/pgfkeys Demonstrates how to load the pgfkeys package in different TeX-based systems. This package is essential for key-value management and is automatically loaded by Ti_k_Z and PGF. ```latex \usepackage{pgfkeys} % LaTeX ``` ```tex \input pgfkeys.tex % plain TeX ``` ```context \usemodule[pgfkeys] % ConTeXt ``` -------------------------------- ### Basic TikZ Drawing Command Source: https://tikz.dev/tutorials-guidelines This code snippet demonstrates a basic TikZ drawing command. It uses thick lines and rounded corners to create a shape. This is a fundamental example for users starting with Ti_k_Z. ```tikz \tikz \draw[thick,rounded corners=8pt] (0,0) -- (0,2) -- (1,3.25) -- (2,2) -- (2,0) -- (0,2) -- (2,2) -- (0,0) -- (2,0); ``` -------------------------------- ### Install Specific FPU Definitions within a Group Source: https://tikz.dev/library-fpu This example demonstrates how to use `/pgf/fpu/install only` to selectively install FPU definitions within a Ti§k path, which acts as an implicit group. This is useful for avoiding errors with large numbers in specific operations like division, while using standard math for others. It requires loading the 'fpu' library. ```tikz \usepgflibrary {fpu} \begingroup \pgfkeys{/pgf/fpu/install only={divide}} \pgfmathparse{12.34/0.001234}\pgfmathresult (good) \pgfmathparse{12/4}\pgfmathresult (bad) \endgroup ``` -------------------------------- ### Graph Drawing Library Examples (LaTeX/TeX/ConTeXt) Source: https://tikz.dev/gd-algorithm-layer Includes example implementations for various aspects of the graph drawing engine. These examples are primarily intended for educational purposes, allowing users to study and adapt the algorithms for their specific needs, rather than direct use for graph layout. Usage requires including the appropriate library command. ```tex \usegdlibrary{examples} % LaTeX and plain TeX ``` ```tex \usegdlibrary[examples] % ConTeXt ``` -------------------------------- ### Documenting C Algorithm Keys with Lua Source: https://tikz.dev/gd-algorithms-in-c This code shows how to document C algorithm keys using separate Lua files. The `pgfgd_key_documentation_in` function in C specifies the Lua file to load for documentation. This allows for multi-line descriptions and examples. ```C pgfgd_key_documentation_in (d, "pgf.gd.doc.examples.SimpleDemoC"); ``` -------------------------------- ### TikZ AND Gate with US Logic Style Source: https://tikz.dev/library-circuits Shows how to draw AND gates using the 'circuits.logic.US' library. This example utilizes 'point down' and 'info=center:$A$' options for specific node configurations. It requires loading the 'circuits.logic.US' library. ```LaTeX \usetikzlibrary {circuits.logic.US} \tikz [circuit logic US] { \node [and gate,point down] {$A$}; \node [and gate,point down,info=center:$A$] at (1,0) {}; } ``` -------------------------------- ### Draw Petri Net Places with Labels and Tokens Source: https://tikz.dev/library-petri Illustrates the usage of the 'place' style for drawing Petri net places. It shows how to add labels using the 'label' option and tokens using the 'tokens' option. Requires the 'petri' and 'positioning' libraries. ```tex \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) {}; \end{tikzpicture} ``` -------------------------------- ### TikZ Animation: Smooth Exit Control Example Source: https://tikz.dev/tikz-animations Demonstrates using 'exit control' to create a smooth transition out of the initial keyframe in a TikZ animation. The 'exit control' specifies how quickly the attribute leaves the starting value. ```tikz \tikz { \foreach \i in {0,0.125,...,1} \draw (-0.9,.9-\i) -- ++(1.8,0); \node :yshift = { begin on = click, 0s = { exit control = {1}{0}, "0cm" }, 1s = "-5mm", 2s = "-10mm" } [fill = blue!20, draw = blue, very thick, circle] {Click me!}; } ``` -------------------------------- ### TiKz Partway Modifier Example Source: https://tikz.dev/tikz-coordinates Demonstrates the partway modifier syntax `(coordinate)!factor!(second coordinate)` to find points along a line segment. The factor determines the position from 0 (start) to 1 (end). ```tikz \usetikzlibrary {calc} \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); \draw (1,0) -- (3,2); \foreach \i in {0,0.2,0.5,0.9,1} \node at ($(1,0)!\i!(3,2)$) {\i}; \end{tikzpicture} ```