1

I am trying to draw a simple figure that looks like the following, but have been unable to get it. If I get the nodes not to have any spacing, the edge lengths come out wrong, if I get them right, then there is a spacing from the parent to the child edges. I would very much appreciate some assistance.

enter image description here

2
  • 1
    Could you please post a minimal working example? That way, we'll know what package you're using and why exactly the code doesn't produced the desired outcome.
    – Herr K.
    Commented Jul 25, 2014 at 17:35
  • I intentionally didn't do that because I tried using simply tikz with tikzlibrary{trees} and I also tried tikz-trees package. I was not able to get close to what I wanted. I thought if I posted it like this, someone more knowledgeable could provide a clean solution.
    – ozsu
    Commented Jul 25, 2014 at 17:58

1 Answer 1

6

The posted figure can be produced easily by either forest or tikz

MWE with forest

\documentclass[border=2pt]{standalone}
\usepackage{forest}

\begin{document}
\begin{forest}
  for tree={l+=1.5cm,}
  [,parent anchor=south,
    [\phantom{300000},parent anchor=north,child anchor=north,edge label={node[midway,left]{name}}
      [``Joe'',parent anchor=north,edge label={node[midway,left]{first}}]
      [``Blow'',ignore edge,edge label={node[midway,right]{last}}]
    ]
    [``UW'',edge label={node[near end]{institution}}]
    [300000,edge label={node[midway,right]{salary}}]
  ]
\end{forest}
\end{document}

MWE with tikz

\documentclass[border=2pt]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[level distance=2cm]
  \coordinate
    child{
      child{node{``Joe''} edge from parent node[left]{first}}
      child{node{``Blow''} edge from parent node[right]{last}}
      edge from parent node[left]{name}
    }
    child{node{``UW''} edge from parent node[near end]{institution}}
    child{node{300000} edge from parent node[right]{salary}}
  ;
\end{tikzpicture}
\end{document}

Output

enter image description here

1
  • Thank you very much; this is exactly what I needed. Much appreciated.
    – ozsu
    Commented Jul 25, 2014 at 18:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .