[xyz-ips snippet=”intro”]
[xyz-ips snippet=”img1″]06/01[xyz-ips snippet=”img2″]
[xyz-ips snippet=”fig1″]Figure 6.1 – A simple tree[xyz-ips snippet=”fig2″]
\documentclass[tikz,border=10pt]{standalone}
\begin{document}
\begin{tikzpicture}
\node {A} child { node {1} edge from parent };
\end{tikzpicture}
\end{document}
[xyz-ips snippet=”img1″]06/02[xyz-ips snippet=”img2″]
[xyz-ips snippet=”fig1″]Figure 6.2 – A customized edge in a tree[xyz-ips snippet=”fig2″]
\documentclass[tikz,border=10pt]{standalone}
\begin{document}
\begin{tikzpicture}
\node {A} child { node {1}
edge from parent [dashed, ->]
node[above, sloped, font=\tiny] {down} };
\end{tikzpicture}
\end{document}
[xyz-ips snippet=”img1″]06/03[xyz-ips snippet=”img2″]
[xyz-ips snippet=”fig1″]Figure 6.3 – A tree with five children[xyz-ips snippet=”fig2″]
\documentclass[tikz,border=10pt]{standalone}
\begin{document}
\begin{tikzpicture}
\node {A}
child { node {1} }
child { node {2} }
child { node {3} }
child { node {4} }
child { node {5} }
;
\end{tikzpicture}
\end{document}
[xyz-ips snippet=”img1″]06/04[xyz-ips snippet=”img2″]
[xyz-ips snippet=”fig1″]Figure 6.4 – A tree with custom style options[xyz-ips snippet=”fig2″]
\documentclass[tikz,border=10pt]{standalone}
\begin{document}
\begin{tikzpicture}[thick]
\node [draw, black, rectangle] {A}
[red, ->]
child { node {1} }
child { node {2} }
child [densely dashed]
{ node [draw, blue, circle] {3} }
child { node {4} }
child { node {5} }
;
\end{tikzpicture}
\end{document}
[xyz-ips snippet=”img1″]06/05[xyz-ips snippet=”img2″]
[xyz-ips snippet=”fig1″]Figure 6.5 – A minimal TeX relationship tree [xyz-ips snippet=”fig2″]
\documentclass[tikz,border=10pt]{standalone}
\usepackage{hvlogos}
\begin{document}
\begin{tikzpicture}
\node {\TeX}
child { node {\LaTeX} }
child { node {\ConTeXt} }
;
\end{tikzpicture}
\end{document}
[xyz-ips snippet=”img1″]06/06[xyz-ips snippet=”img2″]
[xyz-ips snippet=”fig1″]Figure 6.6 – A TeX and LaTeX relationship tree [xyz-ips snippet=”fig2″]
\documentclass[tikz,border=10pt]{standalone}
\usepackage{hvlogos}
\begin{document}
\begin{tikzpicture}
\node {\TeX}
child { node {\LaTeX}
child { node {\pdfLaTeX} }
child { node {\XeLaTeX} }
child { node {\LuaLaTeX} }
}
child { node {\ConTeXt} }
;
\end{tikzpicture}
\end{document}
[xyz-ips snippet=”img1″]06/07[xyz-ips snippet=”img2″]
[xyz-ips snippet=”fig1″]Figure 6.7 – Adjusted distances in a tree[xyz-ips snippet=”fig2″]
\documentclass[tikz,border=10pt]{standalone}
\usepackage{hvlogos}
\begin{document}
\begin{tikzpicture}[
level 1/.style = { level distance = 8mm,
sibling distance = 20mm },
level 2/.style = { level distance = 10mm,
sibling distance = 20mm } ]
\node {\TeX}
child { node {\LaTeX}
child { node {\pdfLaTeX} }
child { node {\XeLaTeX} }
child { node {\LuaLaTeX} }
}
child { node {\ConTeXt} }
;
\end{tikzpicture}
\end{document}
[xyz-ips snippet=”img1″]06/08[xyz-ips snippet=”img2″]
[xyz-ips snippet=”fig1″]Figure 6.8 – A colored tree[xyz-ips snippet=”fig2″]
\documentclass[tikz,border=10pt]{standalone}
\usepackage{hvlogos}
\begin{document}
\begin{tikzpicture}[
level 1/.style = { level distance = 8mm,
sibling distance = 20mm },
level 2/.style = { level distance = 10mm,
sibling distance = 20mm },
treenode/.style = {shape = rectangle,
rounded corners, draw,
top color=white, bottom color=blue!30},
every child node/.style = {treenode},
engine/.style = {inner sep = 1pt, font=\tiny, above}
]
\node [treenode] {\TeX}
child { node {\LaTeX}
child { node {\pdfLaTeX}
edge from parent node[engine, sloped] {\pdfTeX}}
child { node {\XeLaTeX}
edge from parent node[engine, left] {\XeTeX} }
child { node {\LuaLaTeX}
edge from parent node[engine, sloped] {\LuaTeX}}
}
child { node {\ConTeXt} }
;
\end{tikzpicture}
\end{document}
[xyz-ips snippet=”img1″]06/09[xyz-ips snippet=”img2″]
[xyz-ips snippet=”fig1″]Figure 6.9 – A tree from left to right [xyz-ips snippet=”fig2″]
\documentclass[tikz,border=10pt]{standalone}
\usepackage{hvlogos}
\begin{document}
\begin{tikzpicture}[
level 1/.style = { level distance = 16mm,
sibling distance = 10mm },
level 2/.style = { level distance = 30mm,
sibling distance = 10mm },
treenode/.style = {shape = rectangle,
rounded corners, draw,
top color=white, bottom color=blue!30},
every child node/.style = {treenode},
engine/.style = {inner sep=1pt, font = \tiny, sloped, above},
grow = right
]
\node [treenode] {\TeX}
child { node {\LaTeX}
child { node {\pdfLaTeX} edge from parent node[engine] {\pdfTeX}}
child { node {\XeLaTeX} edge from parent node[engine] {\XeTeX} }
child { node {\LuaLaTeX} edge from parent node[engine] {\LuaTeX}}
}
child { node {\ConTeXt} }
;
\end{tikzpicture}
\end{document}
[xyz-ips snippet=”img1″]06/10[xyz-ips snippet=”img2″]
[xyz-ips snippet=”fig1″]Figure 6.10 – A tree growing up[xyz-ips snippet=”fig2″]
\documentclass[tikz,border=10pt]{standalone}
\begin{document}
\begin{tikzpicture}[grow=up]
\node {A}
child { node {1} }
child { node {2} }
child { node {3} }
child { node {4} }
child { node {5} }
;
\end{tikzpicture}
\end{document}
[xyz-ips snippet=”img1″]06/11[xyz-ips snippet=”img2″]
[xyz-ips snippet=”fig1″]Figure 6.11 – A tree growing up with children in inverted order[xyz-ips snippet=”fig2″]
\documentclass[tikz,border=10pt]{standalone}
\begin{document}
\begin{tikzpicture}[grow'=up]
\node {A}
child { node {1} }
child { node {2} }
child { node {3} }
child { node {4} }
child { node {5} }
;
\end{tikzpicture}
\end{document}
[xyz-ips snippet=”img1″]06/12[xyz-ips snippet=”img2″]
[xyz-ips snippet=”fig1″]Figure 6.12 – A tree with a circular child node arrangement[xyz-ips snippet=”fig2″]
\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{trees}
\begin{document}
\begin{tikzpicture}[clockwise from = 180,
sibling angle=45]
\node {A} child { node {1} };
\node {A}
child { node {1} }
child { node {2} }
child { node {3} }
child { node {4} }
child { node {5} }
;
\end{tikzpicture}
\end{document}
[xyz-ips snippet=”img1″]06/13[xyz-ips snippet=”img2″]
[xyz-ips snippet=”fig1″]Figure 6.13 – A minimal mind map[xyz-ips snippet=”fig2″]
\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{mindmap}
\begin{document}
\begin{tikzpicture}[
mindmap,
concept color = blue!50,
text = white,
]
\node [concept, font=\Huge\sffamily\bfseries] {TikZ}
child [clockwise from = 0] {
node [concept, font=\Large\sffamily] {Graphs}
};
\end{tikzpicture}
\end{document}
[xyz-ips snippet=”img1″]06/14[xyz-ips snippet=”img2″]
[xyz-ips snippet=”fig1″]Figure 6.14 – A mind map with root and two levels[xyz-ips snippet=”fig2″]
\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{mindmap}
\begin{document}
\begin{tikzpicture}[
mindmap,
text = white,
concept color = blue!50,
nodes = {concept},
root/.append style = {
font = \Huge\sffamily\bfseries},
level 1 concept/.append style =
{font = \Large\sffamily, sibling angle=90},
level 2 concept/.append style =
{font = \normalsize\sffamily}
]
\node [root] {TikZ} [clockwise from=0]
child [concept color=blue] {
node {Graphs} [clockwise from=90]
child { node {Trees} }
child { node {Mind maps} }
child { node {DOT syntax} }
child { node {Algorithms} }
};
\end{tikzpicture}
\end{document}
[xyz-ips snippet=”img1″]06/15[xyz-ips snippet=”img2″]
[xyz-ips snippet=”fig1″]Figure 6.15 – A comprehensive mind map[xyz-ips snippet=”fig2″]
\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{mindmap}
\begin{document}
\begin{tikzpicture}[
mindmap,
text = white,
concept color = blue!50,
nodes = {concept},
root/.append style = {
font = \Huge\sffamily\bfseries},
level 1 concept/.append style =
{font = \Large\sffamily, sibling angle=90},
level 2 concept/.append style =
{font = \normalsize\sffamily}
]
\node [root] {TikZ} [clockwise from=0]
child [concept color=blue] {
node {Graphs} [clockwise from=90]
child { node {Trees} }
child { node {Mind maps} }
child { node {DOT syntax} }
child { node {Algorithms} }
}
child [concept color=green] {
node {Basics} [clockwise from=30]
child { node {Drawing} }
child { node {Colors} }
child { node {Nodes} }
child { node {Edges} }
child { node {Styles} }
}
child [concept color=red] {
node {Diagrams} [clockwise from=-90]
child { node {Flow charts} }
child { node {Bar charts} }
child { node {Pie charts} }
child { node {Venn diagrams} }
}
child [concept color=orange!80] {
node {Advanced} [clockwise from=180]
child { node {Shading\\Fading} }
child { node {Deco\-rations} }
child { node {Transfor\-mations} }
child { node {Scopes\\Overlays} }
};
\end{tikzpicture}
\end{document}
Producing graphs
[xyz-ips snippet=”img1″]06/16[xyz-ips snippet=”img2″]
[xyz-ips snippet=”fig1″]Figure 6.16 – A simple graph[xyz-ips snippet=”fig2″]
\documentclass[tikz,border = 10pt]{standalone}
\usetikzlibrary{graphs}
\begin{document}
\begin{tikzpicture}[nodes = {text depth = 1ex,
text height = 2ex}]
\graph { tex -> dvi -> ps -> pdf };
\end{tikzpicture}
\end{document}
[xyz-ips snippet=”img1″]06/17[xyz-ips snippet=”img2″]
[xyz-ips snippet=”fig1″]Figure 6.17 – Node chains in a graph[xyz-ips snippet=”fig2″]
\documentclass[tikz,border = 10pt]{standalone}
\usetikzlibrary{graphs}
\begin{document}
\begin{tikzpicture}[nodes = {text depth = 1ex,
text height = 2ex}]
\graph { tex -> dvi -> ps -> pdf,
bib -> bbl,
bbl -> dvi };
\end{tikzpicture}
\end{document}
[xyz-ips snippet=”img1″]06/18[xyz-ips snippet=”img2″]
[xyz-ips snippet=”fig1″]Figure 6.18 – Node groups[xyz-ips snippet=”fig2″]
\documentclass[tikz,border = 10pt]{standalone}
\usetikzlibrary{graphs}
\begin{document}
\begin{tikzpicture}[nodes = {text depth = 1ex,
text height = 2ex}]
\graph { tex -> {dvi, pdf } -> html };
\end{tikzpicture}
\end{document}
[xyz-ips snippet=”img1″]06/19[xyz-ips snippet=”img2″]
[xyz-ips snippet=”fig1″]Figure 6.19 – Node distance in a graph[xyz-ips snippet=”fig2″]
\documentclass[tikz,border = 10pt]{standalone}
\usetikzlibrary{graphs}
\begin{document}
\begin{tikzpicture}[nodes = {text depth = 1ex,
text height = 2ex}]
\graph [grow right = 2cm] { tex -> dvi -> ps -> pdf };
\end{tikzpicture}
\end{document}
[xyz-ips snippet=”img1″]06/20[xyz-ips snippet=”img2″]
[xyz-ips snippet=”fig1″]Figure 6.20 – Edge quotes in a graph[xyz-ips snippet=”fig2″]
\documentclass[tikz,border = 10pt]{standalone}
\usetikzlibrary{graphs,quotes}
\begin{document}
\begin{tikzpicture}[nodes = {text depth = 1ex,
text height = 2ex},
every edge quotes/.style = {font=\tiny\ttfamily,
above, inner sep = 0pt}]
\graph [grow right = 2cm]
{ tex -> ["latex"] dvi
-> ["dvips"] ps -> ["ps2pdf"] pdf };
\end{tikzpicture}
\end{document}
Positioning in a matrix
[xyz-ips snippet=”img1″]06/21[xyz-ips snippet=”img2″]
[xyz-ips snippet=”fig1″]Figure 6.21 – A simple matrix node[xyz-ips snippet=”fig2″]
\documentclass[tikz,border = 10pt]{standalone}
\begin{document}
\begin{tikzpicture}
\node[matrix,draw] {
\node{A}; & \node{B}; & \node{C}; \\
\node{D}; & \node{E}; & \node{F}; \\
};
\end{tikzpicture}
\end{document}
With the matrix library
\documentclass[tikz,border = 10pt]{standalone}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix[matrix of nodes, draw] {
A & B & C \\
D & E & F \\
};
\end{tikzpicture}
\end{document}
[xyz-ips snippet=”img1″]06/22[xyz-ips snippet=”img2″]
[xyz-ips snippet=”fig1″]Figure 6.22 – Matrix cell nodes with style options[xyz-ips snippet=”fig2″]
\documentclass[tikz,border = 10pt]{standalone}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix [matrix of nodes, draw,
nodes = {circle, draw, minimum width=2em} ] {
A & B & C \\
D & E & |[red]|F \\
};
\end{tikzpicture}
\end{document}
[xyz-ips snippet=”img1″]06/23[xyz-ips snippet=”img2″]
[xyz-ips snippet=”fig1″]Figure 6.23 – A matrix diagram with arrows[xyz-ips snippet=”fig2″]
\documentclass[tikz,border = 10pt]{standalone}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix (m) [matrix of nodes,
row sep = 2em, column sep = 2em,
nodes = {text depth = 1ex, text height = 2ex}
]
{
tex & dvi & ps \\
& pdf & \\
};
\draw [-stealth]
(m-1-1) edge (m-1-2)
(m-1-2) edge (m-1-3)
(m-1-1) edge (m-2-2)
(m-1-2) edge (m-2-2)
(m-1-3) edge (m-2-2)
;
\end{tikzpicture}
\end{document}
Named matrix nodes
\documentclass[tikz,border = 10pt]{standalone}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix (m) [matrix of nodes,
row sep = 2em, column sep = 2em,
nodes = {text depth = 1ex, text height = 2ex}
]
{
tex & |(d)|dvi & ps \\
& |(p)|pdf & \\
};
\draw (d) -- (p);
\end{tikzpicture}
\end{document}
[xyz-ips snippet=”chapter1″]07[xyz-ips snippet=”chapter2″]