I suppose I have quite some experience with vanilla latex (which I have used to write several documents), but I am making my first baby steps with tikz.
In particular, I am trying to reproduce the diagram on page 363 of the Manual for Version 3.0.1a by Till Tantau. I suppose I am not setting up my environment correctly.
Here is the code I am using (a copy and paste from the book as far as the part after begin{document} is concerned)
\documentclass{article} % say
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{angles}
\usetikzlibrary{trees}
\usetikzlibrary{arrows,decorations.pathmorphing,
backgrounds,positioning,fit,petri}
\usetikzlibrary{graphs}
\usetikzlibrary{bending}
\usetikzlibrary{automata}
% \usetikzlibrary{graphdrawing,graphs}
% \usegdlibrary{layered}
\usetikzlibrary{shapes.multipart}
\begin{document}
\tikz [nodes={text height=.7em, text depth=.2em,
draw=black!20, thick, fill=white, font=\footnotesize},
>=spaced stealth’, rounded corners, semithick]
\graph [layered layout, level distance=1cm, sibling
sep=.5em,sibling distance=1cm] {
"5th Edition" -> { "6th Edition", "PWB 1.0" };
"6th Edition" -> { "LSX" [>child anchor=45], "1 BSD", "Mini Unix",
"Wollongong", "Interdata" };
"Interdata" -> { "Unix/TS 3.0", "PWB 2.0", "7th Edition" };
"7th Edition" -> { "8th Edition", "32V", "V7M", "Ultrix-11",
"Xenix", "UniPlus+" };
"V7M" -> "Ultrix-11";
"8th Edition" -> "9th Edition";
"1 BSD" -> "2 BSD" -> "2.8 BSD" -> { "Ultrix-11", "2.9 BSD" };
"32V" -> "3 BSD" -> "4 BSD" -> "4.1 BSD" -> { "4.2 BSD", "2.8 BSD",
"8th Edition" };
"4.2 BSD" -> { "4.3 BSD", "Ultrix-32" };
"PWB 1.0" -> { "PWB 1.2" -> "PWB 2.0", "USG 1.0" -> { "CB Unix 1",
"USG 2.0" }};
"CB Unix 1" -> "CB Unix 2" -> "CB Unix 3" -> { "Unix/TS++", "PDP-11
Sys V" };
{ "USG 2.0" -> "USG 3.0", "PWB 2.0", "Unix/TS 1.0" } -> "Unix/TS 3.0";
{ "Unix/TS++", "CB Unix 3", "Unix/TS 3.0" } -> "TS 4.0" -> "System
V.0" -> "System V.2" -> "System V.3";
};
but this leads me to a number of errors when I pdflatex the script, in particular this one
! Package pgf Error: Unknown arrow tip kind 'spaced stealth’'.
However, even if I remove the stealth bit, I still get this error message
! Package pgfkeys Error: I do not know the key '/tikz/graphs
/layered layout' and I am going to ignore it. Perhaps you
misspelled it.
According to what I found here
How do I use TikZ graphdrawing package with KTikZ+LuaLaTeX?
it is a matter of using \usegdlibrary{layered} in the script. In that case, though, pdflatex tells me I need to resort to lualatex.
Bottom line: I am very confused at this point. Any suggestions to make my life easier?
Best Answer
The graph drawing library is probably one of the more complex parts and on top of this, this particular diagram is a particularly complex diagram too.
Looking through your code, there are a few issues I can identify:
lualatex document.tex
instead ofpdflatex document.tex
, or if you are using an IDE, then there should (hopefully) be an option to selectlualatex
as the compiler;spaced stealth
arrow:stealth
and the correspondingstealth'
, but nospaced stealth
so I actually don't know why they use it in the documentation (edit: it appears that this has been deprecated and should actually have been removed from the documentation, see comment from @cfr);spaced stealth’
which is different tospaced stealth'
(notice the slight difference in the apostrophe, they are actuall distinct unicode characters). This is a bug in the documentation at the moment whereby'
gets modified within theverbatim
-like environment as if it was a text environment. As a result, copy-pasting doesn't actually work properly at this stage. (They also had an issue whereby--
would become an en-dash–
.)"System\nV.0"
. This will (most likely) interfer with the graphing algorithm as it is will treat that node as being distinct to the"System V.0"
vertex.I would recommend that you start with simpler example. Start by getting a feel of simple layouts and then start building more and more complex layouts. For example, have a look at how the following layouts change:
and so on. Also have a look at how different algorithms work with each of the above layouts (
layered layout
,spring layout
, etc.)Coming back to your original example, here is the fixed code and reformatted to make it more legible:
and here is the corresponding output:
Note: There is an incompatibility between in the
standalone
class and LuaLaTeX. Until thestandalone
class is updated, you will need to add\RequirePackage{luatex85}
before the document class declaration.