I don't really get the question so I hope this is what you wanted. If you include a full document (such that we copy paste and see the problem on our systems) things are much more easier.
Here, you can change the default setting within a scope but your block
style had a node distance
which was resetting every time it is issued. I've made it 2mm such that we can see the difference easier.
\documentclass[tikz]{standalone}
\usetikzlibrary{arrows,shapes.geometric,positioning}
\begin{document}
\begin{tikzpicture}[decision/.style={diamond, draw, text width=4.5em, text badly centered, node distance=3.5cm, inner sep=0pt},
block/.style ={rectangle, draw, text width=6em, text centered, rounded corners, minimum height=4em, minimum height=2em},
cloud/.style ={draw, ellipse, minimum height=2em},
line/.style ={draw,-latex'},
node distance = 1cm,
auto]
\node [block] (1st) {1st};
\node [block, right= of 1st] (2nd1) {2nd1};
\begin{scope}[node distance=2mm and 10mm]%Here we change it for everything inside this scope
\node [block, above= of 2nd1] (2nd2) {2nd2};
\node [block, below= of 2nd1] (2nd3) {2nd3};
\node [block, right= of 2nd1] (3rd1) {3rd1};
\node [block, above= of 3rd1] (3rd2) {3rd2};
\node [block, above= of 3rd2] (3rd3) {3rd3};
\end{scope}
\node [block, below= of 3rd1] (3rd4) {3rd4};
\node [block, below= of 3rd4] (3rd5) {3rd5};
\path [line] (1st) -- (2nd1);
\path [line] (2nd1) -- (2nd2);
\path [line] (2nd1) -- (2nd3);
\path [line] (2nd2) -- (3rd3);
\path [line] (2nd1) -- (3rd1);
\path [line] (1st) -- (2nd1);
\end{tikzpicture}
\end{document}
EDIT (Now with 3 solutions)
qtree
+ tikzmark
If you just need to draw arrows later, you can use tikzmark
with qtree
. At least, the following seems to work:
\documentclass{article}
\usepackage{qtree,tikz}
\usetikzlibrary{tikzmark,calc}
\begin{document}
\Tree [ [ [ {\tikzmark{a}$\sqrt{\textsc{Root}}$\tikzmark{b}} {\scshape Voice} ] [.{\scshape Asp} ] ] [.{\scshape {\tikzmark{c}Tns\tikzmark{d}}} ] ]
\begin{tikzpicture}[overlay, remember picture]
\draw [->, shorten >=5pt, shorten <=5pt] ($(pic cs:a)!1/2!(pic cs:b)$) .. controls +(1,-2) and +(-1,-2) .. ($(pic cs:c)!1/2!(pic cs:d)$);
\end{tikzpicture}
\end{document}
forest
I would also use Forest, but would definitely recommend the linguistics
library which provides nice empty nodes
and suitable edges out-of-the-box. To align the terminal nodes, you can add a phantom with zero width but appropriate height.
For example,
\documentclass{standalone}
\usepackage[linguistics]{forest}
\begin{document}
\begin{forest}
nice empty nodes,
for tree={
font=\scshape,
},
before typesetting nodes={
where n children=0{
+content=\makebox[0pt]{\phantom{$\sqrt{X}$}},
}{}
}
[
[
[
[$\sqrt{\textsc{Root}}$]
[Voice]
]
[Asp]
]
[Tns]
]
\end{forest}
\end{document}
tikz-qtree
If you prefer to stick with tikz-qtree
, you should wait to see what Alan Munn can come up with. I've only ever used qtree
and forest
, so the best I can do with tikz-qtree
is
\documentclass[border=10pt]{standalone}
\usepackage{tikz-qtree}
\begin{document}
\newlength\widesttreenodewidth
\settowidth{\widesttreenodewidth}{$\sqrt{\textsc{Root}}$}
\newlength\highesttreenodeht
\settoheight{\highesttreenodeht}{$\sqrt{\textsc{Root}}$}
\newlength\deepesttreenodedpth
\settodepth{\deepesttreenodedpth}{$\sqrt{\textsc{Root}}$}
\tikzset{
every tree node/.append style={text width=\widesttreenodewidth, text depth=\deepesttreenodedpth, text height=\highesttreenodeht, text centered},
execute at begin node=\makebox[0pt]{\phantom{$\sqrt{X}$}},
}
\Tree [ [ [ $\sqrt{\textsc{Root}}$ {\scshape Voice} ] [.{\scshape Asp} ] ] [.{\scshape Tns} ] ]
\end{document}
Note
Forest does take some time to learn and the syntax is a bit different, so it is not something to attempt at the end of a large project, deadline looming, for sure.
Best Answer
It's hard to replicate
qtree
spacing intikz-qtree
since the latter package uses a completely different method for node spacing; most of the time this leads to much better looking trees, especially for linguistics, which was its intended use. You can balance out particular node manually by enclosing their contents in an explicit\node
command and specifiying a width. The imbalance comes from having very different widths dominated by by the nodes at the first level. See How do I center this qtree? for a similar problem. For the node size problem, I've used egreg's\phantom
solution.A solution using the
forest
packageThe recent
forest
package provides the tools to do this fairly easily. Although its main raison d'ĂȘtre is to make more compact trees, it provides hooks to make less compact trees too. The input syntax is a bit different: there are no.
to mark node labels, and terminal nodes must be enclosed in[ ... ]
.