diff --git a/doc/generic/pgf/CHANGELOG.md b/doc/generic/pgf/CHANGELOG.md index bd8a8ab28..af999ff80 100644 --- a/doc/generic/pgf/CHANGELOG.md +++ b/doc/generic/pgf/CHANGELOG.md @@ -18,6 +18,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Output bounding box adjustment in pgfsys-dvisvgm.def #1275 - Fix shadings under LuaMetaTeX - Resolve missing `gnuplot` plots in manual #1238 +- Fix missing inclusion of libraries in `graphdrawing` examples +- Fix mis-spelled Kellermann to Kellerman ### Changed @@ -40,6 +42,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Yukai Chou (@muzimuzhi) - Alexander Grahn - Max Chernoff +- Hanson Char ## [3.1.10] - 2023-01-13 Henri Menke 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 19bfd52fd..9a5704406 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/doc.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/doc.lua @@ -98,46 +98,47 @@ 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} - \draw [help lines] (0,0) grid (3,2); - \graph [spring layout] - { - a[x=1] -- { b, c, d, e -- {f,g,h} }; - { h, g } -- a; - }; -\end{tikzpicture} -]] - -example -[[ -\begin{tikzpicture} - \draw [help lines] (0,0) grid (3,2); - \graph [spring layout] - { - a -- { b, c, d[x=0], e -- {f[x=2], g, h[x=1]} }; - { h, g } -- a; - }; -\end{tikzpicture} -]] - -example -[[ -\begin{tikzpicture} - \draw [help lines] (0,0) grid (3,2); - \graph [spring layout] - { - a -- { b, c, d[x=0], e -- {f[x=2,y=1], g, h[x=1]} }; - { h, g } -- a; - }; -\end{tikzpicture} -]] +example { + options = [[ preamble={\usetikzlibrary{graphs,graphdrawing} \usegdlibrary{force}} ]], + code = [[ + \begin{tikzpicture} + \draw [help lines] (0,0) grid (3,2); + \graph [spring layout] + { + a[x=1] -- { b, c, d, e -- {f,g,h} }; + { h, g } -- a; + }; + \end{tikzpicture} + ]] +} + +example { + options = [[ preamble={\usetikzlibrary{graphs,graphdrawing} \usegdlibrary{force}} ]], + code = [[ + \begin{tikzpicture} + \draw [help lines] (0,0) grid (3,2); + \graph [spring layout] + { + a -- { b, c, d[x=0], e -- {f[x=2], g, h[x=1]} }; + { h, g } -- a; + }; + \end{tikzpicture} + ]] +} + +example { + options = [[ preamble={\usetikzlibrary{graphs,graphdrawing} \usegdlibrary{force}} ]], + code = [[ + \begin{tikzpicture} + \draw [help lines] (0,0) grid (3,2); + \graph [spring layout] + { + a -- { b, c, d[x=0], e -- {f[x=2,y=1], g, h[x=1]} }; + { h, g } -- a; + }; + \end{tikzpicture} + ]] +} -------------------------------------------------------------------- @@ -167,28 +168,27 @@ 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) - -- (1,0.5) graph [edges=red, layered layout, anchor node=a] { a -> {b,c} } - -- (1.5,0) graph [edges=blue, layered layout, - anchor node=y, anchor at={(2,0)}] { x -> {y,z} }; -]] - -example -[[ -\begin{tikzpicture} - \draw [help lines] (0,0) grid (3,2); - - \graph [layered layout, anchor node=c, edges=rounded corners] - { a -- {b [x=1,y=1], c [x=1,y=1] } -- d -- a}; -\end{tikzpicture} -]] +example { + options = [[ preamble={\usetikzlibrary{graphs,graphdrawing} \usegdlibrary{layered}} ]], + code = [[ + \tikz \draw (0,0) + -- (1,0.5) graph [edges=red, layered layout, anchor node=a] { a -> {b,c} } + -- (1.5,0) graph [edges=blue, layered layout, + anchor node=y, anchor at={(2,0)}] { x -> {y,z} }; + ]] +} + +example { + options = [[ preamble={\usetikzlibrary{graphs,graphdrawing} \usegdlibrary{layered}} ]], + code = [[ + \begin{tikzpicture} + \draw [help lines] (0,0) grid (3,2); + + \graph [layered layout, anchor node=c, edges=rounded corners] + { a -- {b [x=1,y=1], c [x=1,y=1] } -- d -- a}; + \end{tikzpicture} + ]] +} -------------------------------------------------------------------- @@ -203,15 +203,17 @@ The coordinate at which the graph should be anchored when no explicit anchor is given for any node. The initial value is the origin. ]] -example -[[ -\begin{tikzpicture} - \draw [help lines] (0,0) grid (2,2); - - \graph [layered layout, edges=rounded corners, anchor at={(1,2)}] - { a -- {b, c [anchor here] } -- d -- a}; -\end{tikzpicture} -]] +example { + options = [[ preamble={\usetikzlibrary{graphs,graphdrawing} \usegdlibrary{layered}} ]], + code = [[ + \begin{tikzpicture} + \draw [help lines] (0,0) grid (2,2); + + \graph [layered layout, edges=rounded corners, anchor at={(1,2)}] + { a -- {b, c [anchor here] } -- d -- a}; + \end{tikzpicture} + ]] +} -------------------------------------------------------------------- @@ -233,13 +235,15 @@ In the example, |c| is placed at the origin since this is the default |anchor at| position. ]] -example -[[ -\begin{tikzpicture} - \draw [help lines] (0,0) grid (2,2); - - \graph [layered layout, edges=rounded corners] - { a -- {b, c [anchor here] } -- d -- a}; -\end{tikzpicture} -]] +example { + options = [[ preamble={\usetikzlibrary{graphs,graphdrawing} \usegdlibrary{layered}} ]], + code = [[ + \begin{tikzpicture} + \draw [help lines] (0,0) grid (2,2); + + \graph [layered layout, edges=rounded corners] + { a -- {b, c [anchor here] } -- d -- a}; + \end{tikzpicture} + ]] +} -------------------------------------------------------------------- diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/doc.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/doc.lua index 78b68bbcb..7571452b7 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/doc.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/doc.lua @@ -112,11 +112,12 @@ end -- Adds an example to the |examples| field of the last key selected -- through the |key| command. -- --- @param string An additional example string. +-- @param input Either a string of example or a table with two fields: +-- "code" and "options". -function doc.example (string) +function doc.example (input) local examples = rawget(current_key, "examples") or {} - examples[#examples + 1] = string + examples[#examples + 1] = input current_key.examples = examples end 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 a44fd4703..597091c3a 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/trees/doc.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/trees/doc.lua @@ -293,28 +293,32 @@ example }; ]] ---[[ -% TODOsp: codeexamples: the next example needs the library `arrows.meta` ---]] -example -[[ -\tikz \graph [binary tree layout] { - Knuth -> { - Beeton -> Kellermann [second] -> Carnes, - Tobin -> Plass -> { Lamport, Spivak } - } -};\qquad -\tikz [>={Stealth[round,sep]}] - \graph [binary tree layout, grow'=right, level sep=1.5em, - nodes={right, fill=blue!50, text=white, chamfered rectangle}, - edges={decorate,decoration={snake, post length=5pt}}] - { - Knuth -> { - Beeton -> Kellermann [second] -> Carnes, - Tobin -> Plass -> { Lamport, Spivak } +example { + options = [[ + preamble = { + \usetikzlibrary{shapes.misc,arrows.meta,graphs,graphdrawing,decorations.pathmorphing} + \usegdlibrary{trees} } - }; -]] + ]], + code = [[ + \tikz \graph [binary tree layout] { + Knuth -> { + Beeton -> Kellerman [second] -> Carnes, + Tobin -> Plass -> { Lamport, Spivak } + } + };\qquad + \tikz [>={Stealth[round,sep]}] + \graph [binary tree layout, grow'=right, level sep=1.5em, + nodes={right, fill=blue!50, text=white, chamfered rectangle}, + edges={decorate,decoration={snake, post length=5pt}}] + { + Knuth -> { + Beeton -> Kellerman [second] -> Carnes, + Tobin -> Plass -> { Lamport, Spivak } + } + }; + ]] +} --------------------------------------------------------------------