答案1
这里还有一个解决方案,使用graphdrawing
TikZ 中强大的库。需要用 进行编译lualatex
。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{graphs,graphdrawing}
\usegdlibrary{layered}
\begin{document}
\begin{tikzpicture}[vert/.style={minimum layers=0},>=stealth]
\graph[layered layout,orient=0]{
1 -> 2 -> 3 -> {4,5} -> 6 -> 7 -> 8 -> 9 -> [vert] 14,
9 -> 10 -> 11 ->[vert]{16,17},
11 -> 12 ->[vert] 15,
12 -> 13,
17 -> 18 -> 19};
\end{tikzpicture}
\end{document}
答案2
根据评论的建议,您可以使用tikz
绘图包来执行此操作:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[node distance=1cm]
\node (1) {1};
\node (2) [right of=1] {2};
\node (4) [above right of=2] {4};
\node (5) [below right of=2] {5};
\node (6) [below right of=4] {6};
\node (7) [right of=6] {7};
\node (16) [above of=7] {16};
\node (17) [below of=7] {17};
\draw[->,thick,>=stealth] (1) -- (2);
\draw[->,thick,>=stealth] (2) -- (4);
\draw[->,thick,>=stealth] (2) -- (5);
\draw[->,thick,>=stealth] (4) -- (6);
\draw[->,thick,>=stealth] (5) -- (6);
\draw[->,thick,>=stealth] (6) -- (7);
\draw[->,thick,>=stealth] (7) -- (16);
\draw[->,thick,>=stealth] (7) -- (17);
\end{tikzpicture}
\end{document}
注意:在写作开始时,请避免提问,而是在网上搜索并尝试调整找到的示例。如果您遇到困难,请在此处提问。
答案3
为何没有tikz-cd
答案?
\documentclass{article}
\usepackage{tikz-cd}
\tikzcdset{
arrow style=tikz,
arrows={thick},
diagrams={>=stealth}
}
\begin{document}
\begin{tikzcd}[sep=1em]
& & 4 \arrow[dr] & & && 14 && 16 & 15 & \\
1 \arrow[r] & 2 \arrow[ur]\arrow[dr] & & 6 \arrow[r]& 7\arrow[r] & 8\arrow[r] & 9\arrow[r]\arrow[u] & 10\arrow[r] & 11\arrow[r]\arrow[u]\arrow[d] & 12\arrow[r]\arrow[u] & 13\\
&& 5 \arrow[ur] & & &&&& 17\arrow[r] & 18\arrow[r] & 19
\end{tikzcd}
\end{document}
答案4
轻松适应psmatrix
环境pst-node
:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}%
\usepackage{lmodern}
\usepackage{ pst-node}
\usepackage{auto-pst-pdf}
\pagestyle{empty}
\begin{document}
\psset{arrowinset=0.15, arrows=->, nodesep=2pt}
\[
\begin{psmatrix}[shortput=nab, colsep=0.8cm, rowsep=0.5cm]
%%% nodes
& & & 4 & & & &14 & & 16 & 15 \\
1 & 2 & 3 & & 6 & 7 & 8 & 9 & 10 & 11 & 12 & 13 \\
& & & 5 & & & & & & 17 & 18 & 19 \\
%%% arrows
\ncline{2,1}{2,2}\ncline{2,2}{2,3}
\ncline{2,3}{1,4}\ncline{2,3}{3,4}\ncline{1,4}{2,5}\ncline{3,4}{2,5}
\ncline{2,8}{1,8}\ncline{2,10}{1,10}\ncline{2,10}{3,10}
\ncline{2,11}{1,11}
\ncline{3,10}{3,11}\ncline{3,11}{3,12}
\ncline{2,5}{2,6}\ncline{2,6}{2,7}\ncline{2,7}{2,8}\ncline{2,8}{2,9}\ncline{2,9}{2,10}\ncline{2,10}{2,11} \ncline{2,11}{2,12}
\end{psmatrix} \]
\end{document}