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}
Just a quick demonstration with Forest. The major advantages of Forest lie in its power, flexibility and concise syntax. Regularities in content and styling can be turned into automated configuration rules and trees themselves can be specified very concisely. Since Forest is based on TikZ, the power of the host package is also available.
For example,
\begin{forest}
bordered tree,
[
[x, border
[x1, acc, for descendants=border
[][][]
]
[x2, rej]
[x3, for children=border
[][][]
]
]
]
\end{forest}
specifies the target tree:
while the following partly explains the first and partly shows one or two additional tricks,
\begin{forest}
bordered tree,
[
[x, border, normal
[x1, acc, for descendants=border, label=left:\texttt{for descendants}
[][.,label=left:bordered children [][]][]
]
[x2, rej]
[x3, normal, for children=border, label=right:\texttt{for children}
[][.,label=right:unbordered children [][]][, for current and ancestors={edge+=blue}]
]
]
]
\end{forest}
which produces:
Complete code:
\documentclass[border=10pt]{standalone}
\usepackage{forest}
\forestset{
declare boolean={border}{0},
bordered tree/.style={
for tree={
minimum size=4mm,
inner sep=0.5mm,
edge+={semithick},
semithick,
},
before typesetting nodes={
where border={
edge+={dashed, draw},
}{},
where={isodd(n_children)}{
tempcounta/.process={
Ow+n {n children}{(##1+1)/2}
},
for n={
> R {tempcounta} % doesn't work to plug the above in directly ??'
}{calign with current edge},
}{},
where content={}{}{normal},
},
},
/tikz/.cd,
normal/.style={circle,draw},
invis/.style={draw=none},
acc/.style={circle,thick,draw=green!50,fill=green!2},
rej/.style={circle,thick,draw=red!50,fill=red!20},
}
\begin{document}
\begin{forest}
bordered tree,
[
[x, border
[x1, acc, for descendants=border
[][][]
]
[x2, rej]
[x3, for children=border
[][][]
]
]
]
\end{forest}
\begin{forest}
bordered tree,
[
[x, border, normal
[x1, acc, for descendants=border, label=left:\texttt{for descendants}
[][.,label=left:bordered children [][]][]
]
[x2, rej]
[x3, normal, for children=border, label=right:\texttt{for children}
[][.,label=right:unbordered children [][]][, for current and ancestors={edge+=blue}]
]
]
]
\end{forest}
\end{document}
Best Answer
I don't find the manual's explanation completely clear either. But the point is that
child
is a path operation and an optionxx
placed at the following pointapplies to all the
child
paths. Now some options to paths get inherited by nodes on those paths, others do not. For example a colourblue
in\draw[blue] (0,0) -- (1,0) node {x};
will apply both to the path and the node; whereas\draw[rectangle] (0,2) -- (1,2) node {x};
will not have any effect. Node styles can be passed viaevery node/.style
:Similarly in your example there is an
every child node/.style
that can be used.Notice how the
brect
style that contains a shape plus the colourblue
, when applied to a path just passes on the colour.