Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to get Rachel Brown all on one line, and below Rachel Brown - three branches that say Mary Brown, Laura Brown and Emma Brown. I am also trying to get ages to show below each name, for example directly below Hannah Brown it needs to say (Age: 23), etc. Many Thanks!

\documentclass{article}
\usepackage{tikz-qtree}

\begin{document}
\tikzset{edge from parent/.style=
{draw, edge from parent path={(\tikzparentnode.south)
-- +(0,-8pt)
-| (\tikzchildnode)}},
blank/.style={draw=none}}
\begin{tikzpicture}
\matrix
{
\node{\Tree 
 [.{Hannah Brown}
  [.Rachel Brown ]]};\\
};           
\end{tikzpicture}

\end{document}
share|improve this question
    
Did my answer solve your problem? If not, what is missing? –  Torbjørn T. Apr 15 at 18:02

1 Answer 1

To get Rachel Brown in one line, do as with Hannah, and add braces ({}). If you add every tree node/.style={align=center} you can use \\ to add linebreaks in a node, and then you can use Rachel Brown\\Age: 23 to place the age below the name. To get three branches you need to write something like [ .root [ .{first branch}] [ .{second branch} ] [ .{third branch} ] ]. Note that each branch is within the pair of brackets where the root is defined.

To properly align the middle branch, add minimum width=\widthof{Hannah Brown} to the every tree node style. You can also use a specific length (e.g. 3cm) instead of \widthof{the longest name in the family}.

enter image description here

\documentclass{article}
\usepackage{tikz-qtree}

\begin{document}
\tikzset{edge from parent/.style=
{draw, edge from parent path={(\tikzparentnode.south)
-- +(0,-8pt)
-| (\tikzchildnode)}},
blank/.style={draw=none},
level distance=45pt}
\begin{tikzpicture}[every tree node/.style={align=center,minimum width=\widthof{Hannah Brown}}]
\Tree 
 [ .{Hannah Brown}
   [ .{Rachel Brown\\Age: 23} 
     [ .{Mary Brown\\Age: 1} ]
     [ .{Laura Brown\\Age: 2} ]
     [ .{Emma Brown\\Age: 3} ] ] ]
\end{tikzpicture}

\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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