本例所繪圖形選自《Go語言程式設計》(作者:Alan A. A. Donovan與Brian W. Kernighan)。 完整代碼 效果 說明 1、這裡對節點與箭頭線段style的定義放在了tikzpicture環境定義的參數設置中。實際工作中,對於 ...
本例所繪圖形選自《Go語言程式設計》(作者:Alan A. A. Donovan與Brian W. Kernighan)一書的前言部分。
完整代碼
\documentclass{article}
%
\usepackage{ctex} % 漢字支持
\usepackage{geometry} % 頁面佈局支持
\usepackage{tikz} % 繪圖支持
%
% 載入TikZ內的各種庫
\usetikzlibrary{positioning, arrows.meta, chains}
%
\begin{document}
% 博客園陸巍的博客https://www.cnblogs.com/atthefirst/
\textbf{Go語言起源圖}
\begin{center}
\begin{tikzpicture}[
every node/.style={text width=4cm,align=center},
arrow1/.style={-{stealth[angle'=45]},thick},
node distance=1.0cm,
]
\renewcommand{\baselinestretch}{1.0}% 修改行間距為1倍
% -------------------- 中間節點 --------------------
\node(c1){\textbf{ALGOL 60}\\\small (Backus et al., 1960)};
\node[below=of c1](c2){\textbf{Pascal}\\\small (Wirth, 1970)};
\node[below=of c2](c3){\textbf{Modula-2}\\\small (Wirth, 1980)};
\node[below=of c3](c4){\textbf{Oberon}\\\small (Wirth \& Gutknecht,\\ 1986)};
\node[right=0.5cm of c4,yshift=-1cm](c41){\textbf{Object Oberonn}\\\small (Mössenböck, Templ \& Griesemer, 1990)};
\node[below=of c4](c5){\textbf{Oberon-2}\\\small (Wirth \& Mössenböck,\\ 1991)};
\node[text width = 6.0cm,below=2cm of c5](c6){\textbf{Go}\\\small (Griesemer, Pike \& Thompson, 2009)};
% -------------------- 左側節點 --------------------
\node at(-5cm,-3cm)(l1){\textbf{CSP}\\\small (Hoare, 1978)};
\node[below=of l1](l2){\textbf{Squeak}\\\small (Cardelli \& Pike, 1985)};
\node[below=of l2](l3){\textbf{Newsqueak}\\\small (Pike, 1989)};
\node[below=of l3](l4){\textbf{Alef}\\\small (Winterbottom, 1992)};
% -------------------- 右側節點 --------------------
\node at(7cm,-2cm)(r1){\textbf{C}\\\small (Ritchie, 1972)};
% -------------------- 連線 --------------------
\draw[arrow1](c1)--(c2);
\draw[arrow1](c2)--(c3);
\draw[arrow1](c3)--(c4);
\draw[arrow1](c4)--(c41);
\draw[arrow1](c41)--(c5);
\draw[arrow1](c4)--(c5);
\draw[arrow1](c5)--(c6);
\draw[arrow1](l1)--(l2);
\draw[arrow1](l2)--(l3);
\draw[arrow1](l3)--(l4);
\draw[arrow1](l4)--(c6);
\draw[arrow1](c1)--(r1);
\draw[arrow1](c2)--(l3);
\draw[arrow1](r1)(c6)(node cs:name=r1) .. controls +(1,-10) and +(1.2,1) .. (node cs:name=c6);
\end{tikzpicture}
\end{center}
效果
說明
1、這裡對節點與箭頭線段style的定義放在了tikzpicture環境定義的參數設置中。實際工作中,對於經常使用的style應該單獨用文件保存,方便管理維護。
2、註意從C到Go的那根曲線繪製方法的原理,使用過矢量圖繪製軟體的朋友應該不會陌生。