# How to fix the overlapped nodes with long text, in TikZ. Concept maps

I'd like to get helping from you.
I want to have paragraphs in the nodes of the concept map with Tikz, I mean, texts with multiple lines.
I have a problem with texts, the nodes are overlapped.
Here's the code:

\documentclass{article}
\usepackage{tikz}
%
\usetikzlibrary{mindmap}
\usetikzlibrary{trees}

\begin{document}
\begin{center}
\begin{tikzpicture}[edge from parent fork down,edge from parent/.style={black,thick,draw},every node/.style={rectangle,draw,rounded corners}]
\node at (0,0) {
\begin{tabular}{m{30mm}}
Text very long Text very long Text very long Text very long Text very long Text very long Text very long Text very long Text very long\\
Text very long Text very long Text very long Text very long Text very long Text very long Text very long\\
\end{tabular}
}
child {node {text}}
child {node {text}
child {node {\begin{tabular}{m{30mm}}
Text very long Text very long Text very long Text very long Text very long Text very long Text very long Text very long Text very long\\
Text very long Text very long Text very long Text very long Text very long Text very long Text very long\\
\end{tabular}}}
child {node {\begin{tabular}{m{30mm}}
Text very long Text very long Text very long Text very long Text very long Text very long Text very long Text very long Text very long\\
Text very long Text very long Text very long Text very long Text very long Text very long Text very long\\
\end{tabular}}}
};
\end{tikzpicture}
\end{center}

\end{document}

-
Check subsection 16.4.3 “Text Parameters: Alignment and Width for Multi-Line Text” of the PGF manual, pp. 179ff.: tabular, align key (manual line-breaks), text width key (fixed-width an manual line-breaks). – Qrrbrbirlbel Dec 29 '12 at 4:57
@Qrrbrbirlbel Thanks a lot, but I have a problem, the nodes are superposed. I'm looking for some solution. – Isai Dec 29 '12 at 8:59

The placement of tree nodes depends on

• the level distance key,
• the sibling distance key (both default: 15mm),
• the growth parent anchor key, and
• the usual anchor key of the children.

The growth path depends on: - the placement of the nodes, - the parent anchor key, and - the child anchor key (both default: center).

The child anchor is not important because the last path operator of the chosen growth path is -|. It could be set to north.

The path is:

(\tikzparentnode\tikzparentanchor) -- +(0pt,-.5\tikzleveldistance)
-|  (\tikzchildnode\tikzchildanchor)


# Step 1: Changing the sibling distance.

In this example we could set the anchors to east and west but this would work only for two nodes and prevents us to do something we later need.

Therefore the sibling distance is set manually.

# Step 2 and 3: Changing growth parent anchor and setting all children nodes to anchor=north

The level distance is set between the growth parent anchor and the usual anchor of the children.

Setting growth parent anchor=south and anchor=north will set the level distance from border to border, not form center to center.

# Step 3: Changing parent anchor

The growth path starts at (<parent node>) and goes to a point that is half the level distance below (<parent node>) and then goes “horizontalvertically” (-|) to (<child node>).

For the calculation of that middle point the .center anchor of the <parent node> is used, but the actual line is connected to the border of <parent node> (which coincidentally is also the .south anchor)!
This is the reason that for big nodes (to be specific: nodes which half height is greater than half the level distance) the line goes inside of the node despite that a relative coordinate is used.

This is the reason the start node-anchor is set via the parent anchor key to south.

## Code

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{mindmap}

\begin{document}
\begin{tikzpicture}[
edge from parent fork down,
edge from parent/.style={black,thick,draw},
every node/.style={rectangle,draw,rounded corners},
every child node/.style={anchor=north}, % due to lack of a 'growth child anchor' style
% the .north anchor is selected manually
% this affects the placement
par node/.style={
text width=#1,
align=center,
},
par node/.default=30mm,
parent anchor=south,
growth parent anchor=south,
]

\node[par node] (p) at (0,0) {
Text very long Text very long Text very long Text very long Text very long Text very long Text very long Text very long Text very long\\
Text very long Text very long Text very long Text very long Text very long Text very long Text very long
}
child {node {text}}
child {node {text}
[sibling distance=40mm]
child {node[par node] {
Text very long Text very long Text very long Text very long Text very long Text very long Text very long Text very long Text very long\\
Text very long Text very long Text very long Text very long Text very long Text very long Text very long
}
}
child {node[par node] {
Text very long Text very long Text very long Text very long Text very long Text very long Text very long Text very long Text very long\\
Text very long Text very long Text very long Text very long Text very long Text very long Text very long
}
}
};
\end{tikzpicture}
\end{document}


-