Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing inclusion of libraries in graphdrawing examples #1335

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/generic/pgf/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
164 changes: 84 additions & 80 deletions tex/generic/pgf/graphdrawing/lua/pgf/gd/control/doc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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}
]]
}
--------------------------------------------------------------------


Expand Down Expand Up @@ -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}
]]
}
--------------------------------------------------------------------


Expand All @@ -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}
]]
}
--------------------------------------------------------------------


Expand All @@ -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}
]]
}
--------------------------------------------------------------------
7 changes: 4 additions & 3 deletions tex/generic/pgf/graphdrawing/lua/pgf/gd/doc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
46 changes: 25 additions & 21 deletions tex/generic/pgf/graphdrawing/lua/pgf/gd/trees/doc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
};
]]
}
--------------------------------------------------------------------


Expand Down