1

I want to create a graph where I will be able to write some stuff on top of the nodes, and additionally make some of the anchors bold. And I want the nodes to be custom images that I will provide, and not regular circles.

I had this code:

\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}

But what this code does is that the root node is displayed somewhere completely else in the document, the left_child and right_child are displayed correctly but the arrow that comes from root goes until the middle of the image, and lastly final node is not displayed as child of left_child but is displayed as child of root node. Any idea how build graphs with nodes as custom images and have the functionality such as to be able to write on top of some nodes or make some arrows bold?

  • Please, can you illustrate, what you like to obtain? From your code (slightly corrected, you have mismatch of curly braces) i got nice looking tree diagram as you described. Top of child nodes you have edges, which will cover text. – Zarko Oct 23 '16 at 12:25
2

I'm not sure, if I understand you correctly:

enter image description here

\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}
  • Exactly, that's what I'm looking for. Is it possible also to somehow make some of the connecting arrows bold? – typos Oct 23 '16 at 14:18
  • of course it is possible. just add edge from parent[very thick,red] before end of child scope. – Zarko Oct 23 '16 at 15:44
  • When I add it suddenly the graph structure gets mixed. Where exactly should I add it? For example can you highlight in your picture A->B->Image path? – typos Oct 24 '16 at 20:42
  • See edited answer. – Zarko Oct 24 '16 at 21:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.