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 4 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 the examples at https://tikz.dev/gd-trees and https://tikz.dev/gd-usage-tikz
hansonchar marked this conversation as resolved.
Show resolved Hide resolved
- 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
66 changes: 49 additions & 17 deletions tex/generic/pgf/graphdrawing/lua/pgf/gd/control/doc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ 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
example({options =
[[
preamble=\usetikzlibrary{graphs,graphdrawing}
\usegdlibrary{force}
]],
code =
hansonchar marked this conversation as resolved.
Show resolved Hide resolved
[[
\begin{tikzpicture}
\draw [help lines] (0,0) grid (3,2);
Expand All @@ -114,8 +114,14 @@ example
};
\end{tikzpicture}
]]
})

example
example({options =
[[
preamble=\usetikzlibrary{graphs,graphdrawing}
\usegdlibrary{force}
]],
code =
[[
\begin{tikzpicture}
\draw [help lines] (0,0) grid (3,2);
Expand All @@ -126,8 +132,14 @@ example
};
\end{tikzpicture}
]]
})

example
example({options =
[[
preamble=\usetikzlibrary{graphs,graphdrawing}
\usegdlibrary{force}
]],
code =
[[
\begin{tikzpicture}
\draw [help lines] (0,0) grid (3,2);
Expand All @@ -138,6 +150,7 @@ example
};
\end{tikzpicture}
]]
})
--------------------------------------------------------------------


Expand Down Expand Up @@ -167,20 +180,26 @@ 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
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
example({options =
[[
preamble=\usetikzlibrary{graphs,graphdrawing}
\usegdlibrary{layered}
]],
code =
[[
\begin{tikzpicture}
\draw [help lines] (0,0) grid (3,2);
Expand All @@ -189,6 +208,7 @@ example
{ a -- {b [x=1,y=1], c [x=1,y=1] } -- d -- a};
\end{tikzpicture}
]]
})
--------------------------------------------------------------------


Expand All @@ -203,7 +223,12 @@ 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
example({options =
[[
preamble=\usetikzlibrary{graphs,graphdrawing}
\usegdlibrary{layered}
]],
code =
[[
\begin{tikzpicture}
\draw [help lines] (0,0) grid (2,2);
Expand All @@ -212,6 +237,7 @@ example
{ a -- {b, c [anchor here] } -- d -- a};
\end{tikzpicture}
]]
})
--------------------------------------------------------------------


Expand All @@ -233,7 +259,12 @@ In the example, |c| is placed at the origin since this is the
default |anchor at| position.
]]

example
example({options =
[[
preamble=\usetikzlibrary{graphs,graphdrawing}
\usegdlibrary{layered}
]],
code =
[[
\begin{tikzpicture}
\draw [help lines] (0,0) grid (2,2);
Expand All @@ -242,4 +273,5 @@ example
{ 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
14 changes: 8 additions & 6 deletions tex/generic/pgf/graphdrawing/lua/pgf/gd/trees/doc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,15 @@ example
};
]]

--[[
% TODOsp: codeexamples: the next example needs the library `arrows.meta`
--]]
example
example({options =
[[
preamble=\usetikzlibrary{shapes.misc, arrows.meta, decorations.pathmorphing}
]],
code =
[[
\tikz \graph [binary tree layout] {
Knuth -> {
Beeton -> Kellermann [second] -> Carnes,
Beeton -> Kellerman [second] -> Carnes,
Tobin -> Plass -> { Lamport, Spivak }
}
};\qquad
Expand All @@ -310,11 +311,12 @@ example
edges={decorate,decoration={snake, post length=5pt}}]
{
Knuth -> {
Beeton -> Kellermann [second] -> Carnes,
Beeton -> Kellerman [second] -> Carnes,
Tobin -> Plass -> { Lamport, Spivak }
}
};
]]
})
--------------------------------------------------------------------


Expand Down