[Tex/LaTex] Vertical distance in tikz-qtree nodes

spacingtikz-qtreetikz-trees

I have put together a language tree using the following code (MWE):

\documentclass[b5paper,11pt,twoside,one column,openright,draft]{memoir}
\usepackage{rotating}
\usepackage{tikz-qtree}
\usepackage{tikz-qtree-compat}
\tikzset{every tree node/.style={align=center, anchor=north}} % to allow linebreaks
\begin{document}
\newlength{\egyptianlength}
\settowidth{\egyptianlength}{Egyptian}
\newlength{\msarabianlength}
\settowidth{\msarabianlength}{Modern South Arabian}
\newlength{\nwsemiticlength}
\settowidth{\nwsemiticlength}{Northwest Semitic}
\newlength{\canaanitelength}
\settowidth{\canaanitelength}{Canaanite}
\newlength{\pplength}
\settowidth{\pplength}{Phoenician/Punic}
\begin{figure}[p]
\begin{center}
\begin{turn}{90}
\begin{tikzpicture}
\tikzset{every tree node/.style={align=center,anchor=north,level distance=2\baselineskip}}
\tikzset{edge from parent/.style={draw,thick}}
\tikzset{level distance=2\baselineskip}
\Tree [.{Afro-Asiatic}
    [.{\makebox[\egyptianlength][c]{Berber}} ]
    [.{\makebox[\egyptianlength][c]{Chadic}} ]
    [.{\makebox[\egyptianlength][c]{Egyptian}} ]
    [.\node (Semitic) {\makebox[\egyptianlength][c]{Semitic}}; ]
    [.{\makebox[\egyptianlength][c]{Cushitic}} ]
    [.{\makebox[\egyptianlength][c]{Omotic}} ]
]
\node[below of=Semitic,yshift=-1.5em,xshift=-5.5em]{
    \Tree [
        [.{West Semitic}
            [.{\makebox[\msarabianlength][c]{Ethiopian}} ]
                            [.\node (CentralSemitic) {\makebox[\msarabianlength][c]{Central Semitic}}; ]
            [.{\makebox[\msarabianlength][c]{Modern South Arabian}} ]
        ]
                    [.{East Semitic}
            Eblaite
            Akkadian
        ]
    ]
};
\node[below of=CentralSemitic,yshift=-9.5em,xshift=-7.5em]{
    \Tree [                 
        [.{\makebox[\nwsemiticlength][c]{Old South Arabian}} ]
        [.\node (NWSemitic) {{\makebox[\nwsemiticlength][c]{Northwest Semitic}}}; ]
        [.{\makebox[\nwsemiticlength][c]{Arabic}} ]
    ]
};
\node[below of=NWSemitic,yshift=-13.75em,xshift=-8em]{
    \Tree [                 
        [.{\makebox[\canaanitelength][c]{Ugaritic}} ]
        [.{\makebox[\canaanitelength][c]{Aramaic}} ]
        [.\node (Canaanite) {{\makebox[\canaanitelength][c]{Canaanite}}}; ]
    ]
};
\node[below of=Canaanite,yshift=-17.75em,xshift=-3.1em]{
    \Tree [                 
        [.{\makebox[\pplength][c]{Phoenician/Punic}} ]
        [.{\makebox[\pplength][c]{Moabite}} ]
        [.{\makebox[\pplength][c]{Ammonite}} ]
        [.{\makebox[\pplength][c]{Edomite}} ]
        [.{\makebox[\pplength][c]{Hebrew}} ]
    ]
};
\end{tikzpicture}
\end{turn}
\end{center}
\caption{The Semitic languages in their Afro-Asiatic context}
\end{figure}
\end{document}

The fancy use of lengths and \makebox-es helps the tree not look so skewed. However, I have one problem, and one hope for 'a better way'…

Problem: the vertical distance between e.g. 'West Semitic' and 'Central Semitic' is much less (in terms of line length) than that between 'Central Semitic' and 'Northwest Semitic'.

Enhancement: it would be nice if the xshift and yshifts (which currently I determine by trial and error) could be made relative (i.e. drop down x from the baseline at the midpoint of the label text).

Any suggestions? I tried adjusting vertical distance based on info provided here but without success. Perhaps I'm not doing it properly….

Thanks!

Best Answer

This seems to be easier with standard tikz trees. In these node on a given level are evenly spaced and the vertical spacing is more uniform. You can adjust horizontal spacing in a sub-tree by setting sibling distance:

Sample output

\documentclass{article}

\usepackage{rotating}
\usepackage{tikz}

\begin{document}

\begin{figure}[p]
  \centering
  \begin{turn}{90}
  \begin{tikzpicture}
    \path[level distance=35pt,parent anchor=south,child
    anchor=north,text height=7pt,text depth=0pt,thick]
    node{Afro-Asiatic} [sibling distance=2cm]
    child {node{Berber}}
    child {node{Chadic}}
    child {node{Egyptian}}
    child {node{Semitic} [sibling distance=7cm] 
      child {node{West Semitic} [sibling distance=3.5cm] 
        child {node{Ethiopian}}
        child {node{Central Semitic} [sibling distance=3.2cm]
          child {node{Old South Arabian}}
          child {node{Northwest Semitic} [sibling distance=2cm]
            child {node{Ugartic}}
            child {node{Aramic}}
            child {node{Canaanite} [sibling distance=2.5cm]
              child {node{Phoenician/Punic}}
              child {node{Moabite}}
              child {node{Ammonite}}
              child {node{Edomite}}
              child {node{Hebrew}}}}
          child {node{Arabic}}}
        child {node{Modern South Arabian}}}
      child {node{East Semitic} [sibling distance=1.5cm] 
        child {node{Eblaite}}
        child {node{Akkadian}}}}
    child {node{Cushitic}}
    child {node{Omotic}}  ;
  \end{tikzpicture}
\end{turn}
\caption{The Semitic languages in their Afro-Asiatic context}
\end{figure}

\end{document}

The paths all descend from a given point on the parent node, as I have specified parent anchor=south, rather than the standard border.

I have specified text height and text depth to make sure nodes where the text has descenders are aligned with those where there are none.