Tikz graphdrawing library with tree layout throws error
When I compile the following snippet
documentclass[tikz,border=0pt]{standalone}
usetikzlibrary{graphdrawing}
usetikzlibrary{graphs}
usetikzlibrary{shapes.misc}
usegdlibrary{trees}
begin{document}
begin{tikzpicture}
graph [tree layout]
{
A -- {
B[draw,cross out]
}
};
end{tikzpicture}
end{document}
I get the following error:
ERROR: LuaTeX error ...graphdrawing/lua/pgf/gd/interface/InterfaceToDisplay.lua:213:
--- TeX said ---
...9/tex/generic/pgf/graphdrawing/lua/pgf/gd/model/Path.lua:704: memoization tab
le filled incorrectly
stack traceback:
[C]: in function 'assert'
...graphdrawing/lua/pgf/gd/interface/InterfaceToDisplay.lua:213: in function 'r
esumeGraphDrawingCoroutine'
...graphdrawing/lua/pgf/gd/interface/InterfaceToDisplay.lua:182: in function 'r
unGraphDrawingAlgorithm'
[string "directlua "]:1: in main chunk.
pgfgdendscope ...lay.runGraphDrawingAlgorithm() }
endgroup directlua {pgf...
l.14 }
However, when I leave out the tree laylout
argument, it's fine. It seems that I can have either cross out
or tree layout
, but not both.
Am I doing something wrong here or is this a bug? Is there another way to cross out a node?
errors luatex tikz-trees
add a comment |
When I compile the following snippet
documentclass[tikz,border=0pt]{standalone}
usetikzlibrary{graphdrawing}
usetikzlibrary{graphs}
usetikzlibrary{shapes.misc}
usegdlibrary{trees}
begin{document}
begin{tikzpicture}
graph [tree layout]
{
A -- {
B[draw,cross out]
}
};
end{tikzpicture}
end{document}
I get the following error:
ERROR: LuaTeX error ...graphdrawing/lua/pgf/gd/interface/InterfaceToDisplay.lua:213:
--- TeX said ---
...9/tex/generic/pgf/graphdrawing/lua/pgf/gd/model/Path.lua:704: memoization tab
le filled incorrectly
stack traceback:
[C]: in function 'assert'
...graphdrawing/lua/pgf/gd/interface/InterfaceToDisplay.lua:213: in function 'r
esumeGraphDrawingCoroutine'
...graphdrawing/lua/pgf/gd/interface/InterfaceToDisplay.lua:182: in function 'r
unGraphDrawingAlgorithm'
[string "directlua "]:1: in main chunk.
pgfgdendscope ...lay.runGraphDrawingAlgorithm() }
endgroup directlua {pgf...
l.14 }
However, when I leave out the tree laylout
argument, it's fine. It seems that I can have either cross out
or tree layout
, but not both.
Am I doing something wrong here or is this a bug? Is there another way to cross out a node?
errors luatex tikz-trees
1
Welcome to TeX.SX!
– Christian Hupfer
Oct 13 '14 at 14:24
There is some bad interaction withshapes.misc
it seems, it works if you removecross out
.
– Torbjørn T.
Oct 13 '14 at 14:29
Yes, I can either havetree layout
orcross out
. I need tree layout, so can you think of a workaround to cross out a node?
– S1lentSt0rm
Oct 13 '14 at 14:30
add a comment |
When I compile the following snippet
documentclass[tikz,border=0pt]{standalone}
usetikzlibrary{graphdrawing}
usetikzlibrary{graphs}
usetikzlibrary{shapes.misc}
usegdlibrary{trees}
begin{document}
begin{tikzpicture}
graph [tree layout]
{
A -- {
B[draw,cross out]
}
};
end{tikzpicture}
end{document}
I get the following error:
ERROR: LuaTeX error ...graphdrawing/lua/pgf/gd/interface/InterfaceToDisplay.lua:213:
--- TeX said ---
...9/tex/generic/pgf/graphdrawing/lua/pgf/gd/model/Path.lua:704: memoization tab
le filled incorrectly
stack traceback:
[C]: in function 'assert'
...graphdrawing/lua/pgf/gd/interface/InterfaceToDisplay.lua:213: in function 'r
esumeGraphDrawingCoroutine'
...graphdrawing/lua/pgf/gd/interface/InterfaceToDisplay.lua:182: in function 'r
unGraphDrawingAlgorithm'
[string "directlua "]:1: in main chunk.
pgfgdendscope ...lay.runGraphDrawingAlgorithm() }
endgroup directlua {pgf...
l.14 }
However, when I leave out the tree laylout
argument, it's fine. It seems that I can have either cross out
or tree layout
, but not both.
Am I doing something wrong here or is this a bug? Is there another way to cross out a node?
errors luatex tikz-trees
When I compile the following snippet
documentclass[tikz,border=0pt]{standalone}
usetikzlibrary{graphdrawing}
usetikzlibrary{graphs}
usetikzlibrary{shapes.misc}
usegdlibrary{trees}
begin{document}
begin{tikzpicture}
graph [tree layout]
{
A -- {
B[draw,cross out]
}
};
end{tikzpicture}
end{document}
I get the following error:
ERROR: LuaTeX error ...graphdrawing/lua/pgf/gd/interface/InterfaceToDisplay.lua:213:
--- TeX said ---
...9/tex/generic/pgf/graphdrawing/lua/pgf/gd/model/Path.lua:704: memoization tab
le filled incorrectly
stack traceback:
[C]: in function 'assert'
...graphdrawing/lua/pgf/gd/interface/InterfaceToDisplay.lua:213: in function 'r
esumeGraphDrawingCoroutine'
...graphdrawing/lua/pgf/gd/interface/InterfaceToDisplay.lua:182: in function 'r
unGraphDrawingAlgorithm'
[string "directlua "]:1: in main chunk.
pgfgdendscope ...lay.runGraphDrawingAlgorithm() }
endgroup directlua {pgf...
l.14 }
However, when I leave out the tree laylout
argument, it's fine. It seems that I can have either cross out
or tree layout
, but not both.
Am I doing something wrong here or is this a bug? Is there another way to cross out a node?
errors luatex tikz-trees
errors luatex tikz-trees
edited Oct 14 '14 at 9:20
asked Oct 13 '14 at 14:20
S1lentSt0rm
1755
1755
1
Welcome to TeX.SX!
– Christian Hupfer
Oct 13 '14 at 14:24
There is some bad interaction withshapes.misc
it seems, it works if you removecross out
.
– Torbjørn T.
Oct 13 '14 at 14:29
Yes, I can either havetree layout
orcross out
. I need tree layout, so can you think of a workaround to cross out a node?
– S1lentSt0rm
Oct 13 '14 at 14:30
add a comment |
1
Welcome to TeX.SX!
– Christian Hupfer
Oct 13 '14 at 14:24
There is some bad interaction withshapes.misc
it seems, it works if you removecross out
.
– Torbjørn T.
Oct 13 '14 at 14:29
Yes, I can either havetree layout
orcross out
. I need tree layout, so can you think of a workaround to cross out a node?
– S1lentSt0rm
Oct 13 '14 at 14:30
1
1
Welcome to TeX.SX!
– Christian Hupfer
Oct 13 '14 at 14:24
Welcome to TeX.SX!
– Christian Hupfer
Oct 13 '14 at 14:24
There is some bad interaction with
shapes.misc
it seems, it works if you remove cross out
.– Torbjørn T.
Oct 13 '14 at 14:29
There is some bad interaction with
shapes.misc
it seems, it works if you remove cross out
.– Torbjørn T.
Oct 13 '14 at 14:29
Yes, I can either have
tree layout
or cross out
. I need tree layout, so can you think of a workaround to cross out a node?– S1lentSt0rm
Oct 13 '14 at 14:30
Yes, I can either have
tree layout
or cross out
. I need tree layout, so can you think of a workaround to cross out a node?– S1lentSt0rm
Oct 13 '14 at 14:30
add a comment |
1 Answer
1
active
oldest
votes
According to the SourceForge bug tracker for pgf
, this appears to be a bug that was claimed to be fixed at the end of 2015. At the end of 2018, I still have this behavior in MiKTeX... plus another issue, which seems to be another bug (introduce after the OP?). There are two edits you can make to work around these problems, but they aren't exactly pretty.
Issue #1:
Using usegdlibrary{trees}
results in the following error for me on MiKTeX (up-to-date as of 2018-12-13):
! Package pgf Error: Graph drawing library 'trees' not found.
To fix this, this answer from @henri-menke (for TexLive 2018 and posted in Sep 2018) helped me also on MiKTex. Before loading usegdlibrary{trees}
, you basically need to load this Lua code:
usepackage{luacode}
begin{luacode}
function pgf_lookup_and_require(name)
local sep = '/'
if string.find(os.getenv('PATH'),';') then
sep = 'string\'
end
local function lookup(name)
local sub = name:gsub('%.',sep)
local find_func = function (name, suffix)
if resolvers then
local n = resolvers.findfile (name.."."..suffix, suffix) -- changed
return (not (n == '')) and n or nil
else
return kpse.find_file(name,suffix)
end
end
if find_func(sub, 'lua') then
require(name)
elseif find_func(sub, 'clua') then
collectgarbage('stop')
require(name)
collectgarbage('restart')
else
return false
end
return true
end
return
lookup('pgf.gd.' .. name .. '.library') or
lookup('pgf.gd.' .. name) or
lookup(name .. '.library') or
lookup(name)
end
end{luacode}
Issue #2:
Unfortunately, this only allowed me to reach the point of getting the same error as your OP inquired about. To address this, I turn back to the SourceForge bug tracker. There is a post on 2015-08-17 by JP-Ellis who has a workaround which requires you manually changing a file within the pgf
package.
That fix involves adding these lines of code to the beginning of the InterfaceToDisplay.createVertex
function of the InterfaceToDisplay.lua
file:
-- The path should never be empty, so we create a trivial path in the provided
-- path is empty. This occurs with the `coordinate` shape for example.
if #path == 0 then
path:appendMoveto(0, 0)
path:appendClosepath()
end
Because this can be difficult for those with little or no experience. Let me explain the steps to add this chunk of code.
- Locate
[YOUR TEX INSTALLATION]/tex/generic/pgf/graphdrawing/lua/pgf/gd/interface
folder - Copy and backup the
InterfaceToDisplay.lua
file - Open
InterfaceToDisplay.lua
- Locate
function InterfaceToDisplay.createVertex(name, shape, path, height, binding_infos, anchors)
in the file
Immediately below that line (and above
-- Setup
) add
-- The path should never be empty, so we create a trivial path in the provided
-- path is empty. This occurs with the ``coordinate`` shape for example.
if #path == 0 then
path:appendMoveto(0, 0)
path:appendClosepath()
end
Save the file (you may need admin rights, depending on the installation)
Result after fixing issues #1 and #2:
Now your updated file from OP will look like this:
documentclass[tikz,border=0pt]{standalone}
usetikzlibrary{graphdrawing}
usetikzlibrary{graphs}
usetikzlibrary{shapes.misc}
%%% ADDED TO FIX ISSUE #1, (NOT ABLE TO FILE TREE GRAPH DRAWING LIBRARY)
usepackage{luacode}
begin{luacode}
function pgf_lookup_and_require(name)
local sep = '/'
if string.find(os.getenv('PATH'),';') then
sep = 'string\'
end
local function lookup(name)
local sub = name:gsub('%.',sep)
local find_func = function (name, suffix)
if resolvers then
local n = resolvers.findfile (name.."."..suffix, suffix) -- changed
return (not (n == '')) and n or nil
else
return kpse.find_file(name,suffix)
end
end
if find_func(sub, 'lua') then
require(name)
elseif find_func(sub, 'clua') then
collectgarbage('stop')
require(name)
collectgarbage('restart')
else
return false
end
return true
end
return
lookup('pgf.gd.' .. name .. '.library') or
lookup('pgf.gd.' .. name) or
lookup(name .. '.library') or
lookup(name)
end
end{luacode}
usegdlibrary{trees}
begin{document}
begin{tikzpicture}
graph [tree layout]
{
A -- {
B[draw,cross out]
}
};
end{tikzpicture}
end{document}
And the resulting image looks like this:
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f206928%2ftikz-graphdrawing-library-with-tree-layout-throws-error%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
According to the SourceForge bug tracker for pgf
, this appears to be a bug that was claimed to be fixed at the end of 2015. At the end of 2018, I still have this behavior in MiKTeX... plus another issue, which seems to be another bug (introduce after the OP?). There are two edits you can make to work around these problems, but they aren't exactly pretty.
Issue #1:
Using usegdlibrary{trees}
results in the following error for me on MiKTeX (up-to-date as of 2018-12-13):
! Package pgf Error: Graph drawing library 'trees' not found.
To fix this, this answer from @henri-menke (for TexLive 2018 and posted in Sep 2018) helped me also on MiKTex. Before loading usegdlibrary{trees}
, you basically need to load this Lua code:
usepackage{luacode}
begin{luacode}
function pgf_lookup_and_require(name)
local sep = '/'
if string.find(os.getenv('PATH'),';') then
sep = 'string\'
end
local function lookup(name)
local sub = name:gsub('%.',sep)
local find_func = function (name, suffix)
if resolvers then
local n = resolvers.findfile (name.."."..suffix, suffix) -- changed
return (not (n == '')) and n or nil
else
return kpse.find_file(name,suffix)
end
end
if find_func(sub, 'lua') then
require(name)
elseif find_func(sub, 'clua') then
collectgarbage('stop')
require(name)
collectgarbage('restart')
else
return false
end
return true
end
return
lookup('pgf.gd.' .. name .. '.library') or
lookup('pgf.gd.' .. name) or
lookup(name .. '.library') or
lookup(name)
end
end{luacode}
Issue #2:
Unfortunately, this only allowed me to reach the point of getting the same error as your OP inquired about. To address this, I turn back to the SourceForge bug tracker. There is a post on 2015-08-17 by JP-Ellis who has a workaround which requires you manually changing a file within the pgf
package.
That fix involves adding these lines of code to the beginning of the InterfaceToDisplay.createVertex
function of the InterfaceToDisplay.lua
file:
-- The path should never be empty, so we create a trivial path in the provided
-- path is empty. This occurs with the `coordinate` shape for example.
if #path == 0 then
path:appendMoveto(0, 0)
path:appendClosepath()
end
Because this can be difficult for those with little or no experience. Let me explain the steps to add this chunk of code.
- Locate
[YOUR TEX INSTALLATION]/tex/generic/pgf/graphdrawing/lua/pgf/gd/interface
folder - Copy and backup the
InterfaceToDisplay.lua
file - Open
InterfaceToDisplay.lua
- Locate
function InterfaceToDisplay.createVertex(name, shape, path, height, binding_infos, anchors)
in the file
Immediately below that line (and above
-- Setup
) add
-- The path should never be empty, so we create a trivial path in the provided
-- path is empty. This occurs with the ``coordinate`` shape for example.
if #path == 0 then
path:appendMoveto(0, 0)
path:appendClosepath()
end
Save the file (you may need admin rights, depending on the installation)
Result after fixing issues #1 and #2:
Now your updated file from OP will look like this:
documentclass[tikz,border=0pt]{standalone}
usetikzlibrary{graphdrawing}
usetikzlibrary{graphs}
usetikzlibrary{shapes.misc}
%%% ADDED TO FIX ISSUE #1, (NOT ABLE TO FILE TREE GRAPH DRAWING LIBRARY)
usepackage{luacode}
begin{luacode}
function pgf_lookup_and_require(name)
local sep = '/'
if string.find(os.getenv('PATH'),';') then
sep = 'string\'
end
local function lookup(name)
local sub = name:gsub('%.',sep)
local find_func = function (name, suffix)
if resolvers then
local n = resolvers.findfile (name.."."..suffix, suffix) -- changed
return (not (n == '')) and n or nil
else
return kpse.find_file(name,suffix)
end
end
if find_func(sub, 'lua') then
require(name)
elseif find_func(sub, 'clua') then
collectgarbage('stop')
require(name)
collectgarbage('restart')
else
return false
end
return true
end
return
lookup('pgf.gd.' .. name .. '.library') or
lookup('pgf.gd.' .. name) or
lookup(name .. '.library') or
lookup(name)
end
end{luacode}
usegdlibrary{trees}
begin{document}
begin{tikzpicture}
graph [tree layout]
{
A -- {
B[draw,cross out]
}
};
end{tikzpicture}
end{document}
And the resulting image looks like this:
add a comment |
According to the SourceForge bug tracker for pgf
, this appears to be a bug that was claimed to be fixed at the end of 2015. At the end of 2018, I still have this behavior in MiKTeX... plus another issue, which seems to be another bug (introduce after the OP?). There are two edits you can make to work around these problems, but they aren't exactly pretty.
Issue #1:
Using usegdlibrary{trees}
results in the following error for me on MiKTeX (up-to-date as of 2018-12-13):
! Package pgf Error: Graph drawing library 'trees' not found.
To fix this, this answer from @henri-menke (for TexLive 2018 and posted in Sep 2018) helped me also on MiKTex. Before loading usegdlibrary{trees}
, you basically need to load this Lua code:
usepackage{luacode}
begin{luacode}
function pgf_lookup_and_require(name)
local sep = '/'
if string.find(os.getenv('PATH'),';') then
sep = 'string\'
end
local function lookup(name)
local sub = name:gsub('%.',sep)
local find_func = function (name, suffix)
if resolvers then
local n = resolvers.findfile (name.."."..suffix, suffix) -- changed
return (not (n == '')) and n or nil
else
return kpse.find_file(name,suffix)
end
end
if find_func(sub, 'lua') then
require(name)
elseif find_func(sub, 'clua') then
collectgarbage('stop')
require(name)
collectgarbage('restart')
else
return false
end
return true
end
return
lookup('pgf.gd.' .. name .. '.library') or
lookup('pgf.gd.' .. name) or
lookup(name .. '.library') or
lookup(name)
end
end{luacode}
Issue #2:
Unfortunately, this only allowed me to reach the point of getting the same error as your OP inquired about. To address this, I turn back to the SourceForge bug tracker. There is a post on 2015-08-17 by JP-Ellis who has a workaround which requires you manually changing a file within the pgf
package.
That fix involves adding these lines of code to the beginning of the InterfaceToDisplay.createVertex
function of the InterfaceToDisplay.lua
file:
-- The path should never be empty, so we create a trivial path in the provided
-- path is empty. This occurs with the `coordinate` shape for example.
if #path == 0 then
path:appendMoveto(0, 0)
path:appendClosepath()
end
Because this can be difficult for those with little or no experience. Let me explain the steps to add this chunk of code.
- Locate
[YOUR TEX INSTALLATION]/tex/generic/pgf/graphdrawing/lua/pgf/gd/interface
folder - Copy and backup the
InterfaceToDisplay.lua
file - Open
InterfaceToDisplay.lua
- Locate
function InterfaceToDisplay.createVertex(name, shape, path, height, binding_infos, anchors)
in the file
Immediately below that line (and above
-- Setup
) add
-- The path should never be empty, so we create a trivial path in the provided
-- path is empty. This occurs with the ``coordinate`` shape for example.
if #path == 0 then
path:appendMoveto(0, 0)
path:appendClosepath()
end
Save the file (you may need admin rights, depending on the installation)
Result after fixing issues #1 and #2:
Now your updated file from OP will look like this:
documentclass[tikz,border=0pt]{standalone}
usetikzlibrary{graphdrawing}
usetikzlibrary{graphs}
usetikzlibrary{shapes.misc}
%%% ADDED TO FIX ISSUE #1, (NOT ABLE TO FILE TREE GRAPH DRAWING LIBRARY)
usepackage{luacode}
begin{luacode}
function pgf_lookup_and_require(name)
local sep = '/'
if string.find(os.getenv('PATH'),';') then
sep = 'string\'
end
local function lookup(name)
local sub = name:gsub('%.',sep)
local find_func = function (name, suffix)
if resolvers then
local n = resolvers.findfile (name.."."..suffix, suffix) -- changed
return (not (n == '')) and n or nil
else
return kpse.find_file(name,suffix)
end
end
if find_func(sub, 'lua') then
require(name)
elseif find_func(sub, 'clua') then
collectgarbage('stop')
require(name)
collectgarbage('restart')
else
return false
end
return true
end
return
lookup('pgf.gd.' .. name .. '.library') or
lookup('pgf.gd.' .. name) or
lookup(name .. '.library') or
lookup(name)
end
end{luacode}
usegdlibrary{trees}
begin{document}
begin{tikzpicture}
graph [tree layout]
{
A -- {
B[draw,cross out]
}
};
end{tikzpicture}
end{document}
And the resulting image looks like this:
add a comment |
According to the SourceForge bug tracker for pgf
, this appears to be a bug that was claimed to be fixed at the end of 2015. At the end of 2018, I still have this behavior in MiKTeX... plus another issue, which seems to be another bug (introduce after the OP?). There are two edits you can make to work around these problems, but they aren't exactly pretty.
Issue #1:
Using usegdlibrary{trees}
results in the following error for me on MiKTeX (up-to-date as of 2018-12-13):
! Package pgf Error: Graph drawing library 'trees' not found.
To fix this, this answer from @henri-menke (for TexLive 2018 and posted in Sep 2018) helped me also on MiKTex. Before loading usegdlibrary{trees}
, you basically need to load this Lua code:
usepackage{luacode}
begin{luacode}
function pgf_lookup_and_require(name)
local sep = '/'
if string.find(os.getenv('PATH'),';') then
sep = 'string\'
end
local function lookup(name)
local sub = name:gsub('%.',sep)
local find_func = function (name, suffix)
if resolvers then
local n = resolvers.findfile (name.."."..suffix, suffix) -- changed
return (not (n == '')) and n or nil
else
return kpse.find_file(name,suffix)
end
end
if find_func(sub, 'lua') then
require(name)
elseif find_func(sub, 'clua') then
collectgarbage('stop')
require(name)
collectgarbage('restart')
else
return false
end
return true
end
return
lookup('pgf.gd.' .. name .. '.library') or
lookup('pgf.gd.' .. name) or
lookup(name .. '.library') or
lookup(name)
end
end{luacode}
Issue #2:
Unfortunately, this only allowed me to reach the point of getting the same error as your OP inquired about. To address this, I turn back to the SourceForge bug tracker. There is a post on 2015-08-17 by JP-Ellis who has a workaround which requires you manually changing a file within the pgf
package.
That fix involves adding these lines of code to the beginning of the InterfaceToDisplay.createVertex
function of the InterfaceToDisplay.lua
file:
-- The path should never be empty, so we create a trivial path in the provided
-- path is empty. This occurs with the `coordinate` shape for example.
if #path == 0 then
path:appendMoveto(0, 0)
path:appendClosepath()
end
Because this can be difficult for those with little or no experience. Let me explain the steps to add this chunk of code.
- Locate
[YOUR TEX INSTALLATION]/tex/generic/pgf/graphdrawing/lua/pgf/gd/interface
folder - Copy and backup the
InterfaceToDisplay.lua
file - Open
InterfaceToDisplay.lua
- Locate
function InterfaceToDisplay.createVertex(name, shape, path, height, binding_infos, anchors)
in the file
Immediately below that line (and above
-- Setup
) add
-- The path should never be empty, so we create a trivial path in the provided
-- path is empty. This occurs with the ``coordinate`` shape for example.
if #path == 0 then
path:appendMoveto(0, 0)
path:appendClosepath()
end
Save the file (you may need admin rights, depending on the installation)
Result after fixing issues #1 and #2:
Now your updated file from OP will look like this:
documentclass[tikz,border=0pt]{standalone}
usetikzlibrary{graphdrawing}
usetikzlibrary{graphs}
usetikzlibrary{shapes.misc}
%%% ADDED TO FIX ISSUE #1, (NOT ABLE TO FILE TREE GRAPH DRAWING LIBRARY)
usepackage{luacode}
begin{luacode}
function pgf_lookup_and_require(name)
local sep = '/'
if string.find(os.getenv('PATH'),';') then
sep = 'string\'
end
local function lookup(name)
local sub = name:gsub('%.',sep)
local find_func = function (name, suffix)
if resolvers then
local n = resolvers.findfile (name.."."..suffix, suffix) -- changed
return (not (n == '')) and n or nil
else
return kpse.find_file(name,suffix)
end
end
if find_func(sub, 'lua') then
require(name)
elseif find_func(sub, 'clua') then
collectgarbage('stop')
require(name)
collectgarbage('restart')
else
return false
end
return true
end
return
lookup('pgf.gd.' .. name .. '.library') or
lookup('pgf.gd.' .. name) or
lookup(name .. '.library') or
lookup(name)
end
end{luacode}
usegdlibrary{trees}
begin{document}
begin{tikzpicture}
graph [tree layout]
{
A -- {
B[draw,cross out]
}
};
end{tikzpicture}
end{document}
And the resulting image looks like this:
According to the SourceForge bug tracker for pgf
, this appears to be a bug that was claimed to be fixed at the end of 2015. At the end of 2018, I still have this behavior in MiKTeX... plus another issue, which seems to be another bug (introduce after the OP?). There are two edits you can make to work around these problems, but they aren't exactly pretty.
Issue #1:
Using usegdlibrary{trees}
results in the following error for me on MiKTeX (up-to-date as of 2018-12-13):
! Package pgf Error: Graph drawing library 'trees' not found.
To fix this, this answer from @henri-menke (for TexLive 2018 and posted in Sep 2018) helped me also on MiKTex. Before loading usegdlibrary{trees}
, you basically need to load this Lua code:
usepackage{luacode}
begin{luacode}
function pgf_lookup_and_require(name)
local sep = '/'
if string.find(os.getenv('PATH'),';') then
sep = 'string\'
end
local function lookup(name)
local sub = name:gsub('%.',sep)
local find_func = function (name, suffix)
if resolvers then
local n = resolvers.findfile (name.."."..suffix, suffix) -- changed
return (not (n == '')) and n or nil
else
return kpse.find_file(name,suffix)
end
end
if find_func(sub, 'lua') then
require(name)
elseif find_func(sub, 'clua') then
collectgarbage('stop')
require(name)
collectgarbage('restart')
else
return false
end
return true
end
return
lookup('pgf.gd.' .. name .. '.library') or
lookup('pgf.gd.' .. name) or
lookup(name .. '.library') or
lookup(name)
end
end{luacode}
Issue #2:
Unfortunately, this only allowed me to reach the point of getting the same error as your OP inquired about. To address this, I turn back to the SourceForge bug tracker. There is a post on 2015-08-17 by JP-Ellis who has a workaround which requires you manually changing a file within the pgf
package.
That fix involves adding these lines of code to the beginning of the InterfaceToDisplay.createVertex
function of the InterfaceToDisplay.lua
file:
-- The path should never be empty, so we create a trivial path in the provided
-- path is empty. This occurs with the `coordinate` shape for example.
if #path == 0 then
path:appendMoveto(0, 0)
path:appendClosepath()
end
Because this can be difficult for those with little or no experience. Let me explain the steps to add this chunk of code.
- Locate
[YOUR TEX INSTALLATION]/tex/generic/pgf/graphdrawing/lua/pgf/gd/interface
folder - Copy and backup the
InterfaceToDisplay.lua
file - Open
InterfaceToDisplay.lua
- Locate
function InterfaceToDisplay.createVertex(name, shape, path, height, binding_infos, anchors)
in the file
Immediately below that line (and above
-- Setup
) add
-- The path should never be empty, so we create a trivial path in the provided
-- path is empty. This occurs with the ``coordinate`` shape for example.
if #path == 0 then
path:appendMoveto(0, 0)
path:appendClosepath()
end
Save the file (you may need admin rights, depending on the installation)
Result after fixing issues #1 and #2:
Now your updated file from OP will look like this:
documentclass[tikz,border=0pt]{standalone}
usetikzlibrary{graphdrawing}
usetikzlibrary{graphs}
usetikzlibrary{shapes.misc}
%%% ADDED TO FIX ISSUE #1, (NOT ABLE TO FILE TREE GRAPH DRAWING LIBRARY)
usepackage{luacode}
begin{luacode}
function pgf_lookup_and_require(name)
local sep = '/'
if string.find(os.getenv('PATH'),';') then
sep = 'string\'
end
local function lookup(name)
local sub = name:gsub('%.',sep)
local find_func = function (name, suffix)
if resolvers then
local n = resolvers.findfile (name.."."..suffix, suffix) -- changed
return (not (n == '')) and n or nil
else
return kpse.find_file(name,suffix)
end
end
if find_func(sub, 'lua') then
require(name)
elseif find_func(sub, 'clua') then
collectgarbage('stop')
require(name)
collectgarbage('restart')
else
return false
end
return true
end
return
lookup('pgf.gd.' .. name .. '.library') or
lookup('pgf.gd.' .. name) or
lookup(name .. '.library') or
lookup(name)
end
end{luacode}
usegdlibrary{trees}
begin{document}
begin{tikzpicture}
graph [tree layout]
{
A -- {
B[draw,cross out]
}
};
end{tikzpicture}
end{document}
And the resulting image looks like this:
answered Dec 13 '18 at 17:19
whatisit
887313
887313
add a comment |
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f206928%2ftikz-graphdrawing-library-with-tree-layout-throws-error%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Welcome to TeX.SX!
– Christian Hupfer
Oct 13 '14 at 14:24
There is some bad interaction with
shapes.misc
it seems, it works if you removecross out
.– Torbjørn T.
Oct 13 '14 at 14:29
Yes, I can either have
tree layout
orcross out
. I need tree layout, so can you think of a workaround to cross out a node?– S1lentSt0rm
Oct 13 '14 at 14:30