Some marginal improvements can be achieved by setting the width of all the boxes, as I have done below. However, this particular choice of tree-structure (even for an organization chart is difficult to accomodate on an A3 or A4 paper). Imagine the grandchildren spaced horizontally and we are in trouble if we need to grow the tree one further level.
A better approach is to draw such charts as a directory tree. These type of grids are more economical in terms of horizontal spacing. Here is an example drawn using dirtree
.
Since the figure mostly consist of text, the using of boxing is extraneous in the example above, however the dirtree
can easily be extended to hold tikz nodes rather than text.
Another advantage of the above is that in the particular example I have shown in the illustration information was captured in a more intuitive and semantic way,
.6 \addCADMech{\hl{Dhanish Chandran}}.
.6 \addCADMech{\hl{Sogy George}}.
.6 \addCADMech{\hl{Jhonas Marquez}}.
.6 \addCADMech{\hl{Prasad Balakrishnan}}.
This also permitted automatic recalculation of totals and the production of a summary table. This is perhaps not a full answer, but you are asking to produce a layout which will break in most circumstances. The proper solution is to produce a dirtree
type solution either with dirtree
or with TikZ following such a pattern.
The MWE would produce the image above.
\documentclass{minimal}
\usepackage{xcolor}
\usepackage{tikz}
\usetikzlibrary{trees}
\def\name#1{\hbox to 50pt{#1\rule{10pt}{0pt}}}
\begin{document}
\begin{tikzpicture}[
man/.style={rectangle,draw,fill=gray!30},
woman/.style={rectangle,draw,fill=gray!10},
grandchild/.style={grow=down,xshift=1em,anchor=west,
edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.west)}},
first/.style={level distance=6ex},
second/.style={level distance=12ex},
third/.style={level distance=18ex},
level 1/.style={sibling distance=70pt}]
% Parents
\coordinate
child[grow=left] {node[man,anchor=east]{\name{Jim}}}
child[grow=right] {node[woman,anchor=west]{\name{Jane}}}
child[grow=down,level distance=0ex]
[edge from parent fork down]
% Children and grandchildren
child{node[man] {\name{Alfred}}
child[grandchild,first] {node[man]{\name{Joe}}}
child[grandchild,second] {node[woman]{\name{Heather}}}
child[grandchild,third] {node[woman] {\name{Barbara}}}}
child{node[woman] {\name{Berta}}
child[grandchild,first] {node[man]{\name{Howard}}}}
child {node[man] {\name{Charles}}
child[grandchild,first] {node[man]{\name{Howard}}}}
child {node[woman]{\name{Doris}}
child[grandchild,first] {node[man]{\name{Nick}}}
child[grandchild,second] {node[woman]{\name{Liz}}}};
\end{tikzpicture}
\end{document}
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}
Best Answer
Refer to Section 18.4 Specifying Options for Trees and Children of the pgfmanual. Using
sibling distance
, you can solve the problem (use the values that best suit your needs):