这是我第一次使用 TikZ,我看了很多例子,设法拼凑出我想要的东西。然而,图表中有一个不规则的箭头,我似乎无法摆脱它。即使我删除最后一组框,不规则的箭头仍然存在。我确信这是一个非常简单的修复,但我不知道该改变什么。我应该提到,在使用代码之前\draw [-{Latex[length=3mm]}]
一切\usetikzlibrary{arrows.meta}
都很好,只是箭头非常小。
以下是示例代码和生成的图像,谢谢!
\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{trees, matrix}
\usetikzlibrary{arrows.meta}
\tikzset{
every matrix/.style={
inner sep=-\pgflinewidth,
matrix of math nodes,
column sep=-\pgflinewidth,
nodes={
draw=black,
font=\color{black},
minimum size=.75cm,
anchor=center
}
}
}
\begin{document}
\begin{center}
\begin{tikzpicture}
\tikzstyle{root} = [circle,draw=black, thick]
\node[root] (root) at (0,2){root};
\matrix (l0) at (0,0) {a & ... & z\\};
\matrix (l10) at (-2,-2) {a & ... & z\\};
\matrix (l11) at (1,-2) {a & ... & z\\};
\matrix (l12) at (4,-2) {a & ... & z\\};
\matrix (l20) at (-3,-4) {a & ... & z\\};
\matrix (l21) at (0,-4) {a & ... & z\\};
\matrix (l22) at (3,-4) {a & ... & z\\};
\matrix (l23) at (6,-4) {a & ... & z\\};
\draw [-{Latex[length=3mm]}]
(root.south) edge (l0-1-2.north)
(l0-1-1.south) edge (l10-1-2.north)
(l0-1-2.south) edge (l11-1-2.north)
(l0-1-3.south) edge (l12-1-2.north)
(l10-1-2.south) edge (l20-1-2.north)
(l10-1-3.south) edge (l21-1-2.north)
(l11-1-2.south) edge (l22-1-2.north)
(l12-1-2.south) edge (l23-1-2.north);
\end{tikzpicture}
\end{center}
\end{document}
答案1
您可以用 替换\draw
,\path
因为这就是创建箭头……没有路径,并且各种edge
命令也会创建带有箭头的路径,因此最终结果是一系列正确的路径,加上一个额外的箭头。
基本上,您的代码是这样的:
\draw [-{Latex[length=3mm]}]% a path without coordinates... so just the head!
(root.south) edge (l0-1-2.north) % oh another path
(l0-1-1.south) edge (l10-1-2.north) % ...and another path
(l0-1-2.south) edge (l11-1-2.north) % and so on...
(l0-1-3.south) edge (l12-1-2.north)
(l10-1-2.south) edge (l20-1-2.north)
(l10-1-3.south) edge (l21-1-2.north)
(l11-1-2.south) edge (l22-1-2.north)
(l12-1-2.south) edge (l23-1-2.north);% and the head goes here
您也可以删除它[-{Latex[length=3mm]}]
并将其放置在每个旁边edge
,但这不是很好的做法:输入太多,如果您更改一个,则必须更改其他 10 个,等等。
因此,无论使用哪种解决方案,结果都如下: