5

I read many examples in tikz-qtree, but I didn't find one which illustrates how to add text around/below a node using qtree. Anyone knows how to draw the following tree using tikz-qtree?

how to draw this

5

Here's one way to do this:

\documentclass{article}
\usepackage{tikz-qtree}
\tikzset{
every tree node/.style={align=center,anchor=north,draw,circle,inner sep=3pt},
sibling distance=2cm,
edge from parent/.style=
     {draw, edge from parent path={(\tikzparentnode) -- (\tikzchildnode)}},
myleaf/.style={label=below:{\strut#1}}}

\begin{document}
\begin{tikzpicture}
\Tree [.{}  \node[myleaf=A]{}; [.{} \node[myleaf=B]{};  \node[myleaf=C]{}; ]]
\end{tikzpicture}

\end{document}

output of code

| improve this answer | |
4

I know that the OP asked specifically for tikz-qtree but, just in case, here's one possibility showing the approach using the powerful forest package:

\documentclass{article}
\usepackage{forest}

\begin{document}
\begin{forest}
for tree={
  nodes={anchor=north,draw,circle,inner sep=3pt},
  myleaf/.style={label=below:{\strut#1}},
  s sep=2cm
}
[ [,myleaf={a}] [ [,myleaf={b}] [,myleaf={c}] ] ]
\end{forest}

\end{document}

enter image description here

| improve this answer | |

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.