[过时] [LaTeX 绘图] 编通 tikz 文档中的一个 \graph 例子
过时提醒:2019 年 12 月 19 日发布的 tikz v3.1.5 给文档中的所有例子添加了完整依赖信息,本文内容已无价值。
本文已加入专栏文章目录,归入「示例」文章系列。
PGF/TikZ 文档中例子丰富,但不少例子缺乏编译所需的完整依赖信息,主要是 tikz 的库依赖。本文介绍如何编译 PGF/TikZ 文档第 4 部分首页的例子。
完整例子
% !TeX program = lualatex
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.spaced, graphs, graphdrawing}
\usegdlibrary{layered}
\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";
};
\end{document}
输出结果
注意点
- 从文档中复制例子源码,得到的 arrow tip 是
spaced stealth’
,需要将末尾的’
改为'
spaced stealth'
是过时库arrows.spaced
定义的 arrow tip,见 [pgflibraryarrows.spaced.code.tex
, L33](源码链接)。这个库- PGF/TikZ 的文档已经不介绍它的具体使用方法
- 仍能通过
\usetikzlibrary{arrows.spaced}
正常调用,见 [tikz, sec. 42] - 因为使用了库
graphdrawing
,所以文档只支持 LuaTeX 引擎,见 [tikz, sec. 28]
编辑于 2020-01-12 01:40