我想创建一个图表,可以在节点顶部写一些内容,另外将一些锚点加粗。我希望节点是我提供的自定义图像,而不是常规的圆圈。
我有这个代码:
\documentclass{article}
\usepackage{tikz}
\usepackage{graphicx}
\begin{document}
\begin{center}
\begin{tikzpicture}[sibling distance=10em]
\node[anchor=south] {\pgftext{\includegraphics{root}}}
child {node[anchor=north] {\pgftext{\includegraphics{left_child}}}}
child {node[anchor=north] {\pgftext{\includegraphics{final}}}}
child {node[anchor=north] {\pgftext{\includegraphics{right_child}}}};
\end{tikzpicture}
\end{document}
但是此代码的作用是,根节点显示在文档中的其他地方,left_child
和right_child
正确显示,但来自根的箭头一直延伸到图像中间,最后final
节点不显示为子节点left_child
,而是显示为根节点的子节点。您知道如何使用节点作为自定义图像来构建图形,并具有诸如能够在某些节点上书写或使某些箭头加粗之类的功能吗?
答案1
我不确定,如果我理解正确的话:
\documentclass{article}
\usepackage{tikz}
\usepackage{graphicx}
\begin{document}
\begin{center}
\begin{tikzpicture}[
every node/.style = {inner sep=0pt},
every label/.append style = {label distance=3pt, align = center},
level distance = 5em,
sibling distance = 10em,
level 1/.style = {anchor=north},
]
\node[anchor=south,
label=some text\\ above node\\ (in three lines)] {\includegraphics[width=22mm]{example-image-a}}
child {node[label=some text] {\includegraphics[width=22mm]{example-image-b}}
child {node[label=final\\ image] {\includegraphics[width=22mm]{example-image}}}
edge from parent[ultra thick, red]% <-- highlight edge from A to final
}
child {node{\includegraphics[width=22mm]{example-image-c}}}
;
\end{tikzpicture}
\end{center}
\end{document}