Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Consider

\usetikzlibrary{calc,decorations.pathreplacing,shapes.symbols}
\begin{tikzpicture}
\node [shape=cloud,aspect=2,draw] {\strut}
  [level distance=6em,sibling distance=1.5em,grow=45]
  child {node[shape=circle,draw] (B) {}} 
  child {node[shape=circle] {}}
  child {node[shape=circle] {}}
  child {node[shape=circle] {}}
  child {node[shape=circle,draw] (A) {}}
  [grow=-45]
  child child child child 
;
\draw [line width=1.5mm,line cap=round,
             dash pattern={on 0pt off 3mm},dash phase=1.25mm]
    (A.south east) -- (B.north west) ;
\draw [decorate,decoration={brace,amplitude=2mm}]
($(A.north east)+(.5mm,.5mm)$) --
($(B.north east)+(.5mm,.5mm)$)
;
\node [anchor=south west] at ($(A.north east)!.5!(B.north east)+(2mm,2mm)$)
    {Cluster 1} ;
\end{tikzpicture}

The intent is to have two clusters of children of the cloud-shaped node, one above and to the right, the other below and to the right. What actually happens is that all the children after the [grow=-45] option are attached to the child node immediately above it, despite not being nested into that child.
enter image description here

What gives? How do I work around this?

(also, suggestions for less finicky ways to position the curly brace, the dotted line, and the "Cluster 1" label would be appreciated)

EDIT: In case this is a known bug:

Package: pgfrcs 2010/10/25 v2.10 (rcs-revision 1.24)
Package: pgf 2008/01/15 v2.10 (rcs-revision 1.12)
Package: pgfsys 2010/06/30 v2.10 (rcs-revision 1.37)
Package: pgfcore 2010/04/11 v2.10 (rcs-revision 1.7)
Package: pgfcomp-version-0-65 2007/07/03 v2.10 (rcs-revision 1.7)
Package: pgfcomp-version-1-18 2007/07/23 v2.10 (rcs-revision 1.1)
Package: pgffor 2010/03/23 v2.10 (rcs-revision 1.18)
Package: tikz 2010/10/13 v2.10 (rcs-revision 1.76)

... those seem a little old, hmm.

share|improve this question

1 Answer 1

One suggestion is to create a dummy level with one child for each cluster. An alternative could be using child[missing]. However, perhaps closest to your original picture is to draw a separate tree for each collection of children and place the cloud, filled white, on top as the last thing. Below is code for the last and then the first possibilities:

Sample with top node covering

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{calc,decorations.pathreplacing,shapes.symbols}
\begin{document}
\begin{tikzpicture}
\node {}
  [level distance=6em,sibling distance=1.5em,grow=-45]
  child {node[shape=circle,draw] (B) {}} 
  child {node[shape=circle] {}}
  child {node[shape=circle] {}}
  child {node[shape=circle] {}}
  child {node[shape=circle,draw] (A) {}};
\node {} [level distance=6em,sibling distance=1.5em,grow=45]
  child {node[shape=circle,draw] (C) {}} 
  child {node[shape=circle] {}}
  child {node[shape=circle] {}}
  child {node[shape=circle] {}}
  child {node[shape=circle,draw] (D) {}} ;
\node [shape=cloud,aspect=2,draw,fill=white] {\strut};

\draw [line width=1.5mm,line cap=round,
             dash pattern={on 0pt off 3mm},dash phase=1.5mm]
    (A.south west) -- (B.north east) ;
\draw [decorate,decoration={brace,amplitude=2mm}]
($(A.east)+(1mm,0mm)$) -- ($(B.east)+(-2mm,-3mm)$) ;
\node [anchor=south west] at ($(A.east)!.5!(B.east)+(1mm,-6mm)$)
    {Cluster 1} ;
\draw [line width=1.5mm,line cap=round,
             dash pattern={on 0pt off 3mm},dash phase=1.5mm]
    (D.south east) -- (C.north west) ;
\draw [decorate,decoration={brace,amplitude=2mm}]
($(D.east)+(-2mm,3mm)$) -- ($(C.east)+(1mm,0mm)$) ;
\node [anchor=south west] at ($(D.east)!.5!(C.east)+(1mm,1mm)$)
    {Cluster 2} ;
\end{tikzpicture}

\end{document}

Sample output

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{calc,decorations.pathreplacing,shapes.symbols}
\begin{document}
\begin{tikzpicture}
\node [shape=cloud,aspect=2,draw] {\strut}
  [level distance=2em,sibling distance=2em,grow=0]
  child{
  [level distance=6em,sibling distance=1.5em,grow=-45]
  child {node[shape=circle,draw] (B) {}} 
  child {node[shape=circle] {}}
  child {node[shape=circle] {}}
  child {node[shape=circle] {}}
  child {node[shape=circle,draw] (A) {}} }
 child{  [level distance=6em,sibling distance=1.5em,grow=45]
  child {node[shape=circle,draw] (C) {}} 
  child {node[shape=circle] {}}
  child {node[shape=circle] {}}
  child {node[shape=circle] {}}
  child {node[shape=circle,draw] (D) {}} }
;
\draw [line width=1.5mm,line cap=round,
             dash pattern={on 0pt off 3mm},dash phase=1.5mm]
    (A.south west) -- (B.north east) ;
\draw [decorate,decoration={brace,amplitude=2mm}]
($(A.east)+(1mm,0mm)$) -- ($(B.east)+(-2mm,-3mm)$) ;
\node [anchor=south west] at ($(A.east)!.5!(B.east)+(1mm,-6mm)$)
    {Cluster 1} ;
\draw [line width=1.5mm,line cap=round,
             dash pattern={on 0pt off 3mm},dash phase=1.5mm]
    (D.south east) -- (C.north west) ;
\draw [decorate,decoration={brace,amplitude=2mm}]
($(D.east)+(-2mm,3mm)$) -- ($(C.east)+(1mm,0mm)$) ;
\node [anchor=south west] at ($(D.east)!.5!(C.east)+(1mm,1mm)$)
    {Cluster 2} ;
\end{tikzpicture}

\end{document}

As you found isolated style changes such as your [grow=-45] are not allowed; styles can be placed immeadiately after child or after nodes and also just after the root node. See the diagram in section 18.4 "Specifying Options for Trees and Children" of the pgfmanual.

share|improve this answer
    
Just to add on to this last point, the bug is probably that this compiles at all, rather than failing with an error. The behavior in the question (inexplicable attachment to the most recent node following invalid option syntax) is actually independent of the option; I can replicate it with something like [red] in place of the [grow=-45]. –  kgr Jun 12 '13 at 21:19
    
@kgr Agreed. Providing any option [...] at such a point is a syntax error. –  Andrew Swann Jun 12 '13 at 21:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.